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 $office_id; // int(11)
18 public $company_id; // int(11)
19 public $role; // string(16) not_null
22 /* the code above is auto generated do not remove the tag below */
28 $p = DB_DataObject::factory('Person');
29 $p->get($this->person_id);
33 function toEventString() {
35 // this is weird... company is in the person.. - effieciency??
36 $c = DB_DataObject::factory('Companies');
37 $c->get($this->company_id);
38 $pr = DB_DataObject::factory('Projects');
39 $pr->get($this->project_id);
41 return $pr->code . ' '. $p->name . '('. $c->name .')';
44 function personMemberOf($pe, $pr) {
45 $this->person_id = $pe->id;
46 $this->project_id = $pr->id;
48 if ($this->find(true)) {
54 function ensureProjectMember($pr, $pe) // used where?
56 if ($this->personMemberOf($pe, $pr)) {
59 $this->company_id = $pe->company_id;
60 $this->office_id = $pe->office_id;
61 $this->role = $pe->role;
67 function checkPerm($lvl, $au)
69 return $au->hasPerm('Documents.Project_Directory', $lvl);
71 function setFromRoo($ar,$roo)
76 ($this->project_id == $roo->old->project_id) &&
77 ($this->person_id == $roo->old->person_id) &&
78 ($this->company_id == $roo->old->company_id) )
83 $xx = DB_Dataobject::factory('ProjectDirectory');
85 'project_id' => $this->project_id,
86 'person_id' => $this->person_id,
87 'company_id' => $this->company_id,
91 return "Duplicate entry found Project Directory entry";
96 function applyFilters($q, $au)
98 //DB_DAtaObject::debugLevel(1); var_dump($q);
100 // otherwise only the project they are involved with..
102 // can see - their projects + their personal mail...
103 if (!empty($q['project_id_ar'])) {
104 // can filter projects!
105 $this->whereAddIn('ProjectDirectory.project_id', explode(',',$q['project_id_ar']), 'int');
109 if (!empty($q['query']['company_ids'])) {
110 $this->whereAddIn('ProjectDirectory.company_id', explode(',',$q['query']['company_ids']), 'int');
113 // whos should they see as far as personal contacts.!?!?
114 // their projects... and their mail or.. just their mail if no projects..
117 /// ------------ PERMISSION FILTERERIN!!!!!!
119 if ($au->hasPerm('Core.Projects_All', 'S')) {
120 return; // can see it all!!!
124 $pr = DB_DataObject::factory('Projects');
125 $pr->whereAdd("Projects.type IN ('N','X')");
126 $prjs = $pr->fetchAll('id');
129 $pd = DB_DataObject::factory('ProjectDirectory');
130 $pd->joinAdd(DB_DataObject::factory('Projects'), 'LEFT');
131 $pd->whereAdd("Projects.type NOT IN ('N','X')");
132 $pd->person_id = $au->id;
134 $prjs = array_merge($prjs, $pd->fetchAll('project_id'));
137 (ProjectDirectory.project_id IN (".implode(',', $prjs)."))
142 $this->whereAdd("1=0"); // can see nothing!!!