Exemple #1
0
 /**
  * @return Reference
  */
 public function __construct(Tracker $tracker, $keyword)
 {
     $base_id = 0;
     $visibility = 'P';
     $is_used = 1;
     parent::__construct($base_id, $keyword, $GLOBALS['Language']->getText('project_reference', 'reference_art_desc_key') . ' - ' . $tracker->getName(), TRACKER_BASE_URL . '/?aid=$1&group_id=$group_id', $visibility, trackerPlugin::SERVICE_SHORTNAME, Tracker_Artifact::REFERENCE_NATURE, $is_used, $tracker->getGroupId());
 }
 public function __construct(Tracker $tracker, array $stored_ugroups_permissions, PermissionsManager $permissions_manager)
 {
     $this->group_id = $tracker->getGroupId();
     $this->atid = $tracker->getId();
     $this->tracker = $tracker;
     $this->stored_ugroups_permissions = $stored_ugroups_permissions;
     $this->permissions_manager = $permissions_manager;
 }
 private function getUGroupList(Tracker $tracker)
 {
     $ugroup_list = array();
     $ugroups_permissions = plugin_tracker_permission_get_tracker_ugroups_permissions($tracker->getGroupId(), $tracker->getId());
     ksort($ugroups_permissions);
     reset($ugroups_permissions);
     foreach ($ugroups_permissions as $ugroup_permissions) {
         $ugroup = $ugroup_permissions['ugroup'];
         $permissions = $ugroup_permissions['permissions'];
         if ($ugroup['id'] != ProjectUGroup::PROJECT_ADMIN) {
             $ugroup_list[] = new Tracker_Permission_PermissionUgroupPresenter($ugroup['id'], $ugroup['name'], isset($ugroup['link']) ? $ugroup['link'] : '', $this->getPermissionTypeList($ugroup['id'], $permissions));
         }
     }
     return $ugroup_list;
 }
 public function queueTrackerReindexation(Tracker $tracker)
 {
     $project_id = $tracker->getGroupId();
     if ($this->plugin->isAllowed($project_id)) {
         $this->system_event_manager->createEvent(SystemEvent_FULLTEXTSEARCH_TRACKER_REINDEX::NAME, $this->implodeParams(array($tracker->getId())), SystemEvent::PRIORITY_LOW, SystemEvent::OWNER_APP);
     }
 }
 /**
  * @return array of Tracker
  */
 public function getTrackers(Tracker $tracker)
 {
     $trackers = $this->tracker_factory->getTrackersByGroupId($tracker->getGroupId());
     return array_diff($trackers, array($tracker));
 }
 /**
  * Do all stuff which have to be done after a tracker creation, like reference creation for example
  *
  * @param Tracker $tracker The tracker
  *
  * @return void
  */
 protected function postCreateActions(Tracker $tracker)
 {
     // Create corresponding reference
     $ref = new Reference(0, strtolower($tracker->getItemName()), $GLOBALS['Language']->getText('project_reference', 'reference_art_desc_key') . ' - ' . $tracker->getName(), TRACKER_BASE_URL . '/?aid=$1&group_id=$group_id', 'P', 'plugin_tracker', Tracker_Artifact::REFERENCE_NATURE, '1', $tracker->getGroupId());
     // Force reference creation because default trackers use reserved keywords
     $this->getReferenceManager()->createReference($ref, true);
 }
 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;
 }
 private function addTopBacklogPlanningEntry($selected_milestone_id, Tracker $backlog_tracker, PFUser $user)
 {
     $top_planning = $this->planning_factory->getVirtualTopPlanning($user, $backlog_tracker->getGroupId());
     $backlog_trackers_ids = $top_planning->getBacklogTrackersIds();
     if (in_array($backlog_tracker->getId(), $backlog_trackers_ids)) {
         return $this->getOptionForSelectBox($selected_milestone_id, self::TOP_BACKLOG_IDENTIFIER, self::TOP_BACKLOG_OPTION_ENTRY);
     }
     return;
 }
 private function getPermissionSetter()
 {
     return new Tracker_Permission_PermissionSetter($this->tracker, plugin_tracker_permission_get_tracker_ugroups_permissions($this->tracker->getGroupId(), $this->tracker->getId()), PermissionsManager::instance());
 }
 /**
  * @param Tracker $tracker
  *
  * @return Children trackers of the given tracker.
  */
 public function getPossibleChildren($tracker)
 {
     $project_id = $tracker->getGroupId();
     $trackers = $this->getTrackersByGroupId($project_id);
     unset($trackers[$tracker->getId()]);
     return $trackers;
 }
 /**
  * @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;
 }
 protected function getMatchingIdsInDb(DataAccessObject $dao, PermissionsManager $permissionManager, Tracker $tracker, PFUser $user, array $criteria)
 {
     $dump_criteria = array();
     foreach ($criteria as $c) {
         $dump_criteria[$c->field->getName()] = $c->field->getCriteriaValue($c);
     }
     $dao->logStart(__METHOD__, json_encode(array('user' => $user->getUserName(), 'project' => $tracker->getGroupId(), 'query' => $dump_criteria, 'trackers' => array($tracker->getId()))));
     $matching_ids = array();
     $group_id = $tracker->getGroupId();
     $permissions = $permissionManager->getPermissionsAndUgroupsByObjectid($tracker->getId());
     $contributor_field = $tracker->getContributorField();
     $contributor_field_id = $contributor_field ? $contributor_field->getId() : null;
     $additional_from = array();
     $additional_where = array();
     foreach ($criteria as $c) {
         if ($f = $c->getFrom()) {
             $additional_from[] = $f;
         }
         if ($w = $c->getWhere()) {
             $additional_where[] = $w;
         }
     }
     $matching_ids['id'] = '';
     $matching_ids['last_changeset_id'] = '';
     $matching_ids_result = $dao->searchMatchingIds($group_id, $tracker->getId(), $additional_from, $additional_where, $user, $permissions, $contributor_field_id);
     if ($matching_ids_result) {
         $matching_ids = $matching_ids_result->getRow();
         if ($matching_ids) {
             if (substr($matching_ids['id'], -1) === ',') {
                 $matching_ids['id'] = substr($matching_ids['id'], 0, -1);
             }
             if (substr($matching_ids['last_changeset_id'], -1) === ',') {
                 $matching_ids['last_changeset_id'] = substr($matching_ids['last_changeset_id'], 0, -1);
             }
         }
     }
     $nb_matching = $matching_ids['id'] ? substr_count($matching_ids['id'], ',') + 1 : 0;
     $dao->logEnd(__METHOD__, $nb_matching);
     return $matching_ids;
 }