3 * Table Definition for ProjectDirectory
5 require_once 'DB/DataObject.php';
7 class Pman_Core_DataObjects_ProjectDirectory extends DB_DataObject
10 /* the code below is auto generated do not remove the above tag */
12 public $__table = 'ProjectDirectory'; // table name
13 public $id; // int(11) not_null primary_key auto_increment
14 public $project_id; // int(11) not_null
15 public $person_id; // int(11) not_null
16 public $ispm; // int(11) not_null
17 public $role; // string(16) not_null
20 /* the code above is auto generated do not remove the tag below */
26 $p = DB_DataObject::factory('Person');
27 $p->get($this->person_id);
31 function toEventString() {
33 // this is weird... company is in the person.. - effieciency??
35 $c = DB_DataObject::factory('Companies');
36 $c->get($this->company_id);
37 $pr = DB_DataObject::factory('Projects');
38 $pr->get($this->project_id);
40 return $pr->code . ' '. $p->name . '('. $c->name .')';
43 function personMemberOf($pe, $pr) {
44 $this->person_id = $pe->id;
45 $this->project_id = $pr->id;
47 if ($this->find(true)) {
53 function ensureProjectMember($pr, $pe) // used where?
55 if ($this->personMemberOf($pe, $pr)) {
58 $this->company_id = $pe->company_id;
59 $this->office_id = $pe->office_id;
60 $this->role = $pe->role;
65 * project id's for a user.
66 * @param DB_DataObject_Core_Person|array - who, or list of people.
67 * @return array id's of the project they are a member of..
69 function projects($au)
72 $p = DB_DataObject::Factory('Projects');
73 $p->get('code', '*PUBLIC');
80 $c->whereAddIn('person_id', $au, 'int');
82 $c->person_id = $au->id;
85 // people may have multiple roles for a project..
86 $c->selectAdd("distinct({$this->tableName()}.project_id) as project_id");
87 return $c->fetchAll('project_id');
90 * project id's for a user.
91 * @param DB_DataObject_Core_Person - who
92 * @return array id's of the project they are a member of..
97 //echo '<PRE>';print_R($this);exit;
100 $c->whereAddIn("{$this->tableName()}.project_id", $pr, 'int');
102 $c->project_id = $pr->id;
105 $c->selectAdd("{$this->tableName()}.person_id as person_id");
106 return $c->fetchAll('person_id');
112 function checkPerm($lvl, $au)
114 return $au->hasPerm('Documents.Project_Directory', $lvl);
116 function setFromRoo($ar,$roo)
121 ($this->project_id == $roo->old->project_id) &&
122 ($this->person_id == $roo->old->person_id) &&
123 ($this->company_id == $roo->old->company_id) )
128 $xx = DB_Dataobject::factory('ProjectDirectory');
130 'project_id' => $this->project_id,
131 'person_id' => $this->person_id,
132 'company_id' => $this->company_id,
136 return "Duplicate entry found Project Directory entry";
141 function applyFilters($q, $au)
143 //DB_DAtaObject::debugLevel(1); var_dump($q);
145 // otherwise only the project they are involved with..
147 // can see - their projects + their personal mail...
148 if (!empty($q['project_id_ar'])) {
149 // can filter projects!
150 $this->whereAddIn('ProjectDirectory.project_id', explode(',',$q['project_id_ar']), 'int');
154 if (!empty($q['query']['company_ids'])) {
155 $this->whereAddIn('ProjectDirectory.company_id', explode(',',$q['query']['company_ids']), 'int');
158 // whos should they see as far as personal contacts.!?!?
159 // their projects... and their mail or.. just their mail if no projects..
162 /// ------------ PERMISSION FILTERERIN!!!!!!
164 if ($au->hasPerm('Core.Projects_All', 'S')) {
165 return; // can see it all!!!
169 $pr = DB_DataObject::factory('Projects');
170 $pr->whereAdd("Projects.type IN ('N','X')");
171 $prjs = $pr->fetchAll('id');
174 $pd = DB_DataObject::factory('ProjectDirectory');
175 $pd->joinAdd(DB_DataObject::factory('Projects'), 'LEFT');
176 $pd->whereAdd("Projects.type NOT IN ('N','X')");
177 $pd->person_id = $au->id;
179 $prjs = array_merge($prjs, $pd->fetchAll('project_id'));
182 (ProjectDirectory.project_id IN (".implode(',', $prjs)."))
187 $this->whereAdd("1=0"); // can see nothing!!!