DataObjects/core.sql
[Pman.Core] / DataObjects / Groups.php
index cdf29b4..cd60ebd 100755 (executable)
@@ -28,7 +28,7 @@ class Pman_Core_DataObjects_Groups extends DB_DataObject
     function beforeDelete()
     {
         $x = DB_DataObject::factory('Groups');
-        $x->query("DELETE FROM Group_Rights WHERE group_id = {$this->id}");
+        $x->query("DELETE FROM group_rights WHERE group_id = {$this->id}");
         $x->query("DELETE FROM group_members WHERE group_id = {$this->id}");
     }
     /**
@@ -88,19 +88,28 @@ class Pman_Core_DataObjects_Groups extends DB_DataObject
             $gm->insert();
         }
     }
+    /**
+     *
+     *  grab a list of members - default is the array of person objects..
+     *  @param $what  = set to 'email' to get a list of email addresses.
+     *
+     *
+     */
     
-    function members()
+    function members($what = false)
     {
-        
-        
         $ids = $this->memberIds();
         if (!$ids) {
             return array();
         }
-        $p = DB_Dataobject::factory(empty($ff->Pman['authTable']) ? 'Person' : $ff->Pman['authTable']);
+        //$p = DB_Dataobject::factory(empty($ff->Pman['authTable']) ? 'Person' : $ff->Pman['authTable']);
+        // groups databse is hard coded to person.. so this should not be used for other tables.????
+        $p = DB_Dataobject::factory( 'Person' );
+        
         $p->whereAdd('id IN ('. implode(',', $ids) .')');
         $p->active = 1;
-        return $p->fetchAll();
+        return $p->fetchAll($what);
+    
      
         
         
@@ -114,7 +123,23 @@ class Pman_Core_DataObjects_Groups extends DB_DataObject
             //$ret[] = array( 'id' => 999999, 'name' => 'ADMINISTRATORS');
 
     }
+    
+    function initGroups()
+    {
+        
+        $g = DB_DataObject::factory('Groups');
+        $g->type = 0;
+        $g->name = 'Administrators';
+        if ($g->count()) {
+            return;
+        }
+        $g->insert();
+        $gr = DB_DataObject::factory('group_rights');
+        $gr->genDefault();
+    
         
+    }
+    
      
     
 }