/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
-
+
function owner()
{
$p = DB_DataObject::Factory($this->tableName());
}
- 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');
// 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 {
// if they are a member of admin group do not delete anything.
$default_admin = false;
+ $e = DB_DataObject::Factory('Events');
+ $e->whereAdd('person_id = ' . $this->id);
+ $g = DB_DataObject::Factory('core_group');
+ $g->get('name', 'Administrators'); // select * from core_group where name = 'Administrators'
+ $p = DB_DataObject::Factory('core_group_member');
+ $p->setFrom(array(
+ 'user_id' => $this->id,
+ 'group_id' => $g->id
+ ));
+
+ if ($p->count()) {
+ $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(); // 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?
}
$c->find(true);
$this->company_id = $c->id;
+ $this->email = trim($this->email);
}
$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()