<?php
/**
* Table Definition for Groups
+ *
+ *group types
+ *
+ * 0 = permission group..
+ * 1 = team
+ * 2 = contact group
+ *
+ *
*/
require_once 'DB/DataObject.php';
function beforeDelete()
{
$x = DB_DataObject::factory('Groups');
- $x->query("DELETE FROM Group_Rights WHERE group_id = {$this->id}");
- $x->query("DELETE FROM Group_Members 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}");
}
/**
* check who is trying to access this. false == access denied..
$pi = DB_DataObject::factory(empty($ff->Pman['authTable']) ? 'Person' : $ff->Pman['authTable']);
$pi->get($this->leader);
- $p = DB_DataObject::factory('Group_Members');
+ $p = DB_DataObject::factory('group_members');
$p->group_id = $this->id;
$p->user_id = $this->leader;
//$p->type = 1; //???????
$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);
}
+
+ function lookup($k,$v = false) {
+ if ($v === false) {
+ $v = $k;
+ $k = 'id';
+ }
+ $this->get($k,$v);
+
+ return $this;
+ }
+
function postListFilter($ar, $au, $req)
{
//$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();
+
+ }
+
+ function initDatabase($roo, $data)
+ {
+ $this->initGroups();
+ foreach($data as $gi) {
+ $g = DB_DataObject::factory('Groups');
+ $g->setFrom($gi);
+ if ($g->count()) {
+ continue;
+ }
+ $g->insert();
+
+
+ }
+ }
}