}
- 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 {
$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($p);
-
+ $e->logDeletedRecord($mem);
+
foreach($mem as $p) {
$p->delete();
}
- $e = DB_DataObject::Factory('events');
+ $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);
}
- $pid = $q['id'];
+
$x = PDO_DataObject::factory('core_group_member');
$x->select('group_id');
- $x->user_id = $pid;
-
+ $x->user_id = $q['id'];
$ar = $x->fetchAll('group_id');
// check if id needs to be deleted
if(!empty($result_del)){
- foreach($result_del as $rdid){
+ /*
+ $x = PDO_DataObject::factory('core_group_member');
+ $x->user_id = $q['id'];
+ $x->whereAddIn('group_id', $result_del, 'int');
+ foreach($x->fetchAll() as $cgm) {
+ $cgm->delete();
+ }
+
+
+ */
+ foreach($result_del as $group_id){
$x = PDO_DataObject::factory('core_group_member');
- $x->get($rdid);
+ $x->user_id = $q['id'];
+ $x->group_id = $group_id;
+ $x->find(true);
$x->delete();
}
}
//PDO_DataObject::Factory('coremytable_group_member')->set([ 'group_id' => 'test', 'user_id' => "{$this->tableName()}.id"])->insert();
if(!empty($result_add)){
foreach($result_add as $gid){
- PDO_DataObject::Factory('core_group_member')->set([ 'group_id'=> $gid, 'user_id' => $pid])->insert();
+ PDO_DataObject::Factory('core_group_member')->set(array(
+ 'group_id'=> $gid,
+ 'user_id' => $q['id']
+ ))->insert();
}
}
}
+ $this->email = trim($this->email);
}
function generateOathKey()