DataObjects/Core_group.php
[Pman.Core] / DataObjects / Core_person.php
index 9801fdf..13b93c4 100644 (file)
@@ -50,7 +50,7 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject
     
     /* the code above is auto generated do not remove the tag below */
     ###END_AUTOCODE
-    
     function owner()
     {
         $p = DB_DataObject::Factory($this->tableName());
@@ -438,7 +438,10 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject
         }
                 
              
-        if (isset(   $_SESSION[get_class($this)][$sesPrefix .'-empty'] ) && $_SESSION[get_class($this)][$sesPrefix .'-empty']  < 1) {
+        if (
+            isset(   $_SESSION[get_class($this)][$sesPrefix .'-empty'] ) && 
+            $_SESSION[get_class($this)][$sesPrefix .'-empty']  < 1
+        ) {
             
             // fake person - open system..
             //$ce = DB_DataObject::factory('core_enum');
@@ -823,10 +826,7 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject
                 // list all staff who are not in a group.
                 $this->whereAdd("{$this->tableName()}.id NOT IN (
                     SELECT distinct(user_id) FROM $tn_gm LEFT JOIN
-                        $tn_g ON $tn_g.id = $tn_gm.group_id
-                        WHERE $tn_g.type = ".$q['query']['type']."
-                    )");
-                
+                        $tn_g ON $tn_g.id = $tn_gm.group_id)");
                 
             } else {
                 
@@ -1111,20 +1111,27 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject
         ));
 
         if ($p->count()) {
-           $roo->jerr();
+           $roo->jerr("Please remove this user from the Administrator group before deleting");
         }
  
          
         $p = DB_DataObject::Factory('core_group_member');
         $p->user_id = $this->id;
-        $mem = $p->fetchAll();
-
-        $e->logDeletedRecord($p);
-
+        $mem = $p->fetchAll();  // fetch all the rows and set the $mem variable to the rows data, just like mysqli_fetch_assoc
+        $e->logDeletedRecord($mem);
+                
         foreach($mem as $p) { 
             $p->delete();
         }  
         
+        $e = DB_DataObject::Factory('Events');        
+        $e->person_id = $this->id;
+        $eve = $e->fetchAll();  // fetch all the rows and set the $mem variable to the rows data, just like mysqli_fetch_assoc
+
+        $e->logDeletedRecord($eve);
+        foreach($eve as $e) { 
+            $e->delete();
+        }  
         
         
         // anything else?  
@@ -1217,6 +1224,7 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject
         }
         $c->find(true);
         $this->company_id = $c->id;
+        $this->email = trim($this->email);
         
     }
     
@@ -1378,13 +1386,8 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject
             
             $roo->jok($qrcode);
         }
-        // handle group_id here..
-        if(!empty($q['group_id'])){
-            
-            // insert data into core_person_member...
-            
-            
-        }
+        
+        $this->email = trim($this->email);
     }
     
     function generateOathKey()