/** * @return ProjectUGroup[] */ public function getListOfInvolvedStaticUgroups(Tracker $template_tracker) { $project = $template_tracker->getProject(); $ugroups = array(); foreach ($this->permissions_dao->getAuthorizedStaticUgroupIds($template_tracker->getId()) as $id) { $ugroups[] = $this->ugroup_manager->getUGroup($project, $id); } return $ugroups; }
/** * @return Tracker_UgroupPermissionsConsistencyMessage */ public function checkConsistency(Tracker $template_tracker, Project $target_project) { if ($template_tracker->getProject() == $target_project) { $this->messenger->allIsWell(); return; } $ugroups = $this->permissions_retriever->getListOfInvolvedStaticUgroups($template_tracker); if (!$ugroups) { $this->messenger->allIsWell(); return; } $template_ugroups_names = array_map(array($this, 'extractUGroupName'), $ugroups); $target_ugroups = $this->ugroup_manager->getStaticUGroups($target_project); $target_ugroups_names = array_map(array($this, 'extractUGroupName'), $target_ugroups); $diff = array_diff($template_ugroups_names, $target_ugroups_names); if ($diff) { $this->messenger->ugroupsMissing($diff); } else { $this->messenger->ugroupsAreTheSame($template_ugroups_names); } }
/** * @throws SoapFault if user can't view the tracker */ private function checkUserCanViewTracker(Tracker $tracker, PFUser $user) { if (!$tracker->userCanView($user)) { throw new Exception('Permission Denied: You are not granted sufficient permission to perform this operation.', (string) get_tracker_factory_fault); } $this->checkUserCanAccessProject($user, $tracker->getProject()); }
public function fetchTrackerSwitcher(PFUser $user, $separator, Project $include_project = null, Tracker $current_tracker = null) { $hp = Codendi_HTMLPurifier::instance(); $html = ''; //Projects/trackers $projects = $user->getProjects(true); if ($include_project) { $found = false; foreach ($projects as $data) { if ($data['group_id'] == $include_project->getGroupId()) { $found = true; break; } } if (!$found) { $projects[] = array('group_id' => $include_project->getGroupId(), 'group_name' => $include_project->getPublicName()); } } $html .= '<strong>'; if ($current_tracker) { $html .= $hp->purify($current_tracker->getProject()->getPublicName(), CODENDI_PURIFIER_CONVERT_HTML); } else { $html .= $GLOBALS['Language']->getText('plugin_tracker', 'tracker_switcher'); } $html .= '</strong>' . $separator; $html .= '<select id="tracker_select_tracker">'; if (!$current_tracker) { $html .= '<option selected="selected">--</option>'; } $factory = TrackerFactory::instance(); foreach ($projects as $data) { if ($trackers = $factory->getTrackersByGroupId($data['group_id'])) { foreach ($trackers as $key => $v) { if (!$v->userCanView($user)) { unset($trackers[$key]); } } if ($trackers) { $html .= '<optgroup label="' . $hp->purify($data['group_name'], CODENDI_PURIFIER_CONVERT_HTML) . '">'; foreach ($trackers as $t) { $selected = $current_tracker && $t->getId() == $current_tracker->getId() ? 'selected="selected"' : ''; $html .= '<option ' . $selected . ' value="' . $t->getId() . '">'; $html .= $hp->purify($t->getName(), CODENDI_PURIFIER_CONVERT_HTML); $html .= '</option>'; } $html .= '</optgroup>'; } } } $html .= '</select>'; return $html; }
public function userCanViewTracker(PFUser $user, Tracker $tracker) { if ($user->isSuperUser()) { return true; } if ($tracker->userIsAdmin($user)) { return true; } $project = $tracker->getProject(); if ($this->userIsRestrictedAndNotMemberOfProject($user, $project) || $this->userIsNotMemberOfPrivateProject($user, $project)) { return false; } foreach ($tracker->getPermissionsByUgroupId() as $ugroup_id => $permission_types) { if ($user->isMemberOfUGroup($ugroup_id, $tracker->getGroupId())) { return true; } } return false; }
public function getProject() { return $this->unhierarchizedTracker->getProject(); }
public function isKanbanHierarchy(Tracker $tracker) { $project = $tracker->getProject(); $hierarchy = $tracker->getHierarchy(); return $this->checkHierarchyContainsGivenTrackerIds($hierarchy, $this->getKanbanTrackerIds($project)); }
/** * @return TreeNode */ public function getHierarchy(Tracker $tracker) { $project_trackers = $this->getProjectTrackers($tracker->getProject()); $parent_child_dar = $this->dao->searchParentChildAssociations($tracker->getGroupId()); $children_map = $this->getChildrenMapFromDar($parent_child_dar, $project_trackers); $root = new TreeNode(); $root->setId('root'); $this->buildHierarchyChildrenOf($root, $children_map, $project_trackers, $tracker); return $root; }