2 require_once 'MTrackWeb.php';
4 class MTrackWeb_Project extends MTrackWeb
7 //function getAuth-- inherit
9 function get($code='') {
11 if (isset($_REQUEST['active_project_id'])) {
12 $this->currentProject($_REQUEST['active_project_id']);
13 return $this->jok($this->currentProject());
16 if (!isset($_REQUEST['ajax_body'])) {
19 $this->masterTemplate = 'project.html';
21 $p = DB_DataObject::factory('Projects');
22 $p->get( $this->currentProject());
27 $this->milestones = $this->project->milestones();
35 if (!$this->authUser) {
38 ///DB_DataObject::debugLevel(1);
40 $gr = DB_DataObject::factory('Group_Rights');
41 $ar = $gr->defaultPermData();
42 //echo '<PRE>';print_r($ar);
44 foreach($ar as $nm=>$data) {
45 if (!preg_match('/^MTrack\./', $nm)) {
51 $gr = DB_DataObject::factory('Group_Rights');
52 $gr->whereAddIn('rightname', $perms, 'string');
55 $gr->selectAdd('distinct(group_id) as group_id');
56 $gr->whereAdd("AccessMask != ''");
57 $gids = $gr->fetchAll('group_id');
60 $g = DB_DataObject::Factory('groups');
61 $g->whereAddIn('id',$gids, 'int');
62 $this->groups = $g->fetchAll( );
65 // find out which groups are using those perms... so that we can offer membership to people..
70 // members... (might be large one day)
71 $pr = DB_DataObject::Factory('ProjectDirectory');
72 $pr->project_id = $this->currentProject();
75 if ($this->authUser->company()->comptype !='OWNER') {
76 $pr->whereAdd("role=''");
78 $ar = $pr->fetchAll();
82 $pd->person = $pd->person();
83 $pd->person->perms = $pd->person->getPerms();
85 $g = DB_DataObject::Factory('Group_Members');
86 $pd->person->groups = $g->listGroupMembership($pd->person);
90 $this->people[] = $pd;
99 function checkGroupPerson($p,$g)
102 $str = '<input class="mtrack-perm" type="checkbox" name="'. $p->id . '_'. $g->id. '" value="1"';
104 if (in_array($g->id, $p->groups)) {
105 $str .= ' checked="checked"';
112 * Things that can change...
113 * - permission updates
118 if (empty($_POST['action'])) {
119 $this->jerr("invalid action");
123 switch ($_POST['action']) {
126 //DB_DataObject::debugLevel(1);
127 if ($this->authUser->company()->comptype != 'OWNER') {
128 $this->jerr("Owner company only");
130 if (!$this->hasPerm('Core.Groups', 'E')) {
131 $this->jerr("permission denied");
134 $p = DB_DataObject::factory('Person');
135 if (empty($_POST['uid']) || !$p->get($_POST['uid'])) {
136 $this->jerr("invalid user");
138 $g = DB_DataObject::factory('Groups');
139 if (empty($_POST['gid']) || !$g->get($_POST['gid'])) {
140 $this->jerr("invalid group");
142 // verify group is a MTrack only??
145 $state = empty($_POST['value']) ? 0 : 1;
146 $gm = DB_DataObject::factory('Group_Members');
147 $gm->change($p, $g, $state);
148 $this->jok("updated");
151 //DB_DataObject::debugLevel(1);
152 if ($this->authUser->company()->comptype != 'OWNER') {
153 $this->jerr("Owner company only");
155 // which role ... this is not really correct.
156 if (!$this->hasPerm('Core.Groups', 'E')) {
157 $this->jerr("permission denied");
160 $pd = DB_DataObject::factory('ProjectDirectory');
161 if (empty($_POST['pdid']) || !$pd->get($_POST['pdid'])) {
162 $this->jerr("invalid line");
164 $pd->role = $_POST['value'];
172 $this->jerr("invalid action");