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('core_project');
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('core_group_right');
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('core_group_right');
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('core_group');
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 $pr->orderBY('role DESC');
79 $ar = $pr->fetchAll();
83 $pd->person = $pd->person();
84 $pd->person->perms = $pd->person->getPerms();
86 $g = DB_DataObject::factory('core_group_member');
87 $pd->person->groups = $g->listGroupMembership($pd->person);
91 $this->people[] = $pd;
100 function checkGroupPerson($p,$g)
103 $str = '<input class="mtrack-perm" type="checkbox" name="'. $p->id . '_'. $g->id. '" value="1"';
105 if (in_array($g->id, $p->groups)) {
106 $str .= ' checked="checked"';
113 * Things that can change...
114 * - permission updates
119 if (empty($_POST['action'])) {
120 $this->jerr("invalid action");
124 switch ($_POST['action']) {
127 //DB_DataObject::debugLevel(1);
128 if ($this->authUser->company()->comptype != 'OWNER') {
129 $this->jerr("Owner company only");
131 if (!$this->hasPerm('Core.Groups', 'E')) {
132 $this->jerr("permission denied");
135 $p = DB_DataObject::factory('core_person');
136 if (empty($_POST['uid']) || !$p->get($_POST['uid'])) {
137 $this->jerr("invalid user");
139 $g = DB_DataObject::factory('core_group');
140 if (empty($_POST['gid']) || !$g->get($_POST['gid'])) {
141 $this->jerr("invalid group");
143 // verify group is a MTrack only??
146 $state = empty($_POST['value']) ? 0 : 1;
147 $gm = DB_DataObject::factory('core_group_member');
148 $gm->change($p, $g, $state);
149 $this->jok("updated");
152 //DB_DataObject::debugLevel(1);
153 if ($this->authUser->company()->comptype != 'OWNER') {
154 $this->jerr("Owner company only");
156 // which role ... this is not really correct.
157 if (!$this->hasPerm('Core.Groups', 'E')) {
158 $this->jerr("permission denied");
161 $pd = DB_DataObject::factory('ProjectDirectory');
162 if (empty($_POST['pdid']) || !$pd->get($_POST['pdid'])) {
163 $this->jerr("invalid line");
165 $pd->role = $_POST['value'];
173 $this->jerr("invalid action");