示例#1
0
 /**
  * Returns an instance of Tracker_HierarchyFactory (creating it when needed).
  *
  * We should usually prefer dependency injection over static methods, but
  * there are some cases in Tuleap legacy code where injection would require
  * a lot of refactoring (e.g. Tracker/FormElement).
  *
  * @return Tracker_HierarchyFactory
  */
 public static function instance()
 {
     if (!self::$_instance) {
         self::$_instance = new Tracker_HierarchyFactory(new Tracker_Hierarchy_Dao(), TrackerFactory::instance(), Tracker_ArtifactFactory::instance());
     }
     return self::$_instance;
 }
示例#2
0
 public function build(User $user, Project $project, Tracker_CrossSearch_Query $cross_search_query, array $already_planned_artifact_ids, $backlog_tracker_id, Planning $planning, $planning_redirect_parameter)
 {
     $report = $this->getReport($user);
     $criteria = $this->getCriteria($user, $project, $report, $cross_search_query);
     $tracker_ids = $this->hierarchy_factory->getHierarchy(array($backlog_tracker_id))->flatten();
     $artifacts = $this->getHierarchicallySortedArtifacts($user, $project, $tracker_ids, $cross_search_query, $already_planned_artifact_ids);
     $visitor = new Planning_BacklogItemFilterVisitor($backlog_tracker_id, $this->hierarchy_factory, $already_planned_artifact_ids);
     $artifacts = $artifacts->accept($visitor);
     return new Planning_SearchContentView($report, $criteria, $artifacts, Tracker_ArtifactFactory::instance(), $this->form_element_factory, $user, $planning, $planning_redirect_parameter);
 }
示例#3
0
 public function activatePlugins()
 {
     $this->activatePlugin('tracker');
     $this->activatePlugin('agiledashboard');
     $this->activatePlugin('cardwall');
     PluginManager::instance()->loadPlugins();
     $this->tracker_artifact_factory = Tracker_ArtifactFactory::instance();
     $this->tracker_formelement_factory = Tracker_FormElementFactory::instance();
     $this->tracker_factory = TrackerFactory::instance();
     return $this;
 }
 /**
  * @return Tracker_CrossSearch_SearchView 
  */
 public function build(User $user, Project $project, Tracker_CrossSearch_Query $cross_search_query)
 {
     $report = $this->getReport($user);
     $service = $this->getService($project);
     $criteria = $this->getCriteria($user, $project, $report, $cross_search_query);
     $trackers = $this->tracker_factory->getTrackersByGroupIdUserCanView($project->getGroupId(), $user);
     $tracker_ids = $this->getTrackersIds($trackers);
     $artifacts = $this->getHierarchicallySortedArtifacts($user, $project, $tracker_ids, $cross_search_query);
     $content_view = new Tracker_CrossSearch_SearchContentView($report, $criteria, $artifacts, Tracker_ArtifactFactory::instance(), $this->form_element_factory, $user);
     return new Tracker_CrossSearch_SearchView($project, $service, $criteria, $trackers, $content_view);
 }
示例#5
0
 public function __construct(Cardwall_PaneInfo $info, Planning_Milestone $milestone, Cardwall_OnTop_Config $config, PFUser $user, Planning_MilestoneFactory $milestone_factory)
 {
     $this->info = $info;
     $this->milestone = $milestone;
     $this->config = $config;
     $this->user = $user;
     $this->milestone_factory = $milestone_factory;
     $this->artifact_factory = Tracker_ArtifactFactory::instance();
     $this->tracker_form_element_factory = Tracker_FormElementFactory::instance();
     $this->user_manager = UserManager::instance();
     $this->planning_factory = PlanningFactory::build();
 }
 /**
  * @return Tracker_Artifact_XMLImport
  */
 public function build(User\XML\Import\IFindUserFromXMLReference $user_finder)
 {
     $artifact_factory = Tracker_ArtifactFactory::instance();
     $formelement_factory = Tracker_FormElementFactory::instance();
     $fields_validator = new Tracker_Artifact_Changeset_AtGivenDateFieldsValidator($formelement_factory);
     $changeset_dao = new Tracker_Artifact_ChangesetDao();
     $changeset_comment_dao = new Tracker_Artifact_Changeset_CommentDao();
     $logger = new Log_ConsoleLogger();
     $send_notifications = false;
     $artifact_creator = new Tracker_ArtifactCreator($artifact_factory, $fields_validator, new Tracker_Artifact_Changeset_InitialChangesetAtGivenDateCreator($fields_validator, $formelement_factory, $changeset_dao, $artifact_factory, EventManager::instance()));
     $new_changeset_creator = new Tracker_Artifact_Changeset_NewChangesetAtGivenDateCreator($fields_validator, $formelement_factory, $changeset_dao, $changeset_comment_dao, $artifact_factory, EventManager::instance(), ReferenceManager::instance());
     return new Tracker_Artifact_XMLImport(new XML_RNGValidator(), $artifact_creator, $new_changeset_creator, Tracker_FormElementFactory::instance(), $user_finder, new Tracker_FormElement_Field_List_Bind_Static_ValueDao(), $logger, $send_notifications);
 }
示例#7
0
 public function activatePlugins()
 {
     $this->activatePlugin('tracker');
     $this->activatePlugin('agiledashboard');
     $this->activatePlugin('cardwall');
     PluginManager::instance()->invalidateCache();
     PluginManager::instance()->loadPlugins();
     $this->tracker_artifact_factory = Tracker_ArtifactFactory::instance();
     $this->tracker_formelement_factory = Tracker_FormElementFactory::instance();
     $this->tracker_factory = TrackerFactory::instance();
     $this->hierarchy_checker = new AgileDashboard_HierarchyChecker(PlanningFactory::build(), new AgileDashboard_KanbanFactory($this->tracker_factory, new AgileDashboard_KanbanDao()), $this->tracker_factory);
     return $this;
 }
 /**
  * build bar chart data
  *
  * @param Gantt_Engine object
  * @return array data array
  */
 function buildData($engine)
 {
     $engine->data = array();
     $ff = Tracker_FormElementFactory::instance();
     $field_start = $this->chart->getField_start() ? $ff->getFormElementById($this->chart->getField_start()) : null;
     $field_due = $this->chart->getField_due() ? $ff->getFormElementById($this->chart->getField_due()) : null;
     $field_finish = $this->chart->getField_finish() ? $ff->getFormElementById($this->chart->getField_finish()) : null;
     $field_percentage = $this->chart->getField_percentage() ? $ff->getFormElementById($this->chart->getField_percentage()) : null;
     $field_righttext = $this->chart->getField_righttext() ? $ff->getFormElementById($this->chart->getField_righttext()) : null;
     $field_summary = $this->chart->getSummary() ? $ff->getFormElementById($this->chart->getSummary()) : null;
     $af = Tracker_ArtifactFactory::instance();
     $changesets = explode(',', $this->artifacts['last_changeset_id']);
     foreach (explode(',', $this->artifacts['id']) as $i => $aid) {
         if ($artifact = $af->getArtifactByid($aid)) {
             if ($changeset = $artifact->getChangeset($changesets[$i])) {
                 $data = array('id' => $aid, 'summary' => '#' . $aid, 'start' => 0, 'due' => 0, 'finish' => 0, 'progress' => 0, 'right' => '', 'hint' => '#' . $aid, 'links' => TRACKER_BASE_URL . '/?aid=' . $aid);
                 if ($field_start) {
                     $data['start'] = $field_start->fetchRawValueFromChangeset($changeset);
                 }
                 if ($field_due) {
                     $data['due'] = $field_due->fetchRawValueFromChangeset($changeset);
                 }
                 if ($field_finish) {
                     $data['finish'] = $field_finish->fetchRawValueFromChangeset($changeset);
                 }
                 if ($field_percentage) {
                     $data['progress'] = $field_percentage->fetchRawValueFromChangeset($changeset);
                 }
                 if ($field_righttext) {
                     $data['right'] = $field_righttext->fetchRawValueFromChangeset($changeset);
                 }
                 if ($field_summary) {
                     $data['hint'] = $data['summary'] = $field_summary->fetchRawValueFromChangeset($changeset);
                 }
                 if ($data['progress'] < 0) {
                     $data['progress'] = 0;
                 } else {
                     if ($data['progress'] > 100) {
                         $data['progress'] = 1;
                     } else {
                         $data['progress'] = $data['progress'] / 100;
                     }
                 }
                 $engine->data[] = $data;
             }
         }
     }
     usort($engine->data, array($this, 'sortByDate'));
     return $engine->data;
 }
示例#9
0
 public function build(User $user, Project $project, Tracker_CrossSearch_Query $cross_search_query, array $already_planned_artifact_ids, array $backlog_tracker_ids, Planning $planning, Planning_BacklogActionsPresenter $backlog_actions_presenter, $planning_redirect_parameter)
 {
     $report = $this->getReport($user);
     $criteria = $this->getCriteria($user, $project, $report, $cross_search_query);
     $artifacts = $this->getHierarchicallySortedArtifacts($user, $project, $backlog_tracker_ids, $cross_search_query, $already_planned_artifact_ids);
     // The following lines allows to tailor/rebuild the result before display
     // As of today (aug-12), we decided to display everything and to wait for
     // user feedback to see if we need to enable one of them.
     //$visitor     = new Planning_BacklogItemFilterVisitor($backlog_tracker_id, $this->hierarchy_factory, $already_planned_artifact_ids);
     //$artifacts   = $artifacts->accept($visitor);
     //$visitor     = new Planning_GroupByParentsVisitor($user);
     //$artifacts->accept($visitor);
     return new Planning_SearchContentView($report, $criteria, $artifacts, Tracker_ArtifactFactory::instance(), $this->form_element_factory, $user, $backlog_actions_presenter, $planning, $planning_redirect_parameter);
 }
 /**
  * Display the field for CSV export
  * Used in CSV data export
  *
  * @param int $artifact_id the corresponding artifact id
  * @param int $changeset_id the corresponding changeset
  * @param mixed $value the value of the field
  *
  * @return string
  */
 public function fetchCSVChangesetValue($artifact_id, $changeset_id, $value, $report)
 {
     $values = array();
     $artifact = Tracker_ArtifactFactory::instance()->getArtifactById($artifact_id);
     if ($artifact->useArtifactPermissions()) {
         $dao = new Tracker_Artifact_Changeset_ValueDao();
         $row = $dao->searchByFieldId($changeset_id, $this->id)->getRow();
         $changeset_value_id = $row['id'];
         foreach ($this->getValueDao()->searchByChangesetValueId($changeset_value_id) as $value) {
             $name = $this->getUGroupDao()->searchByUGroupId($value['ugroup_id'])->getRow();
             $values[] = util_translate_name_ugroup($name['name']);
         }
         return implode(',', $values);
     }
     return '';
 }
示例#11
0
 public function ajax_reference_tooltip($params)
 {
     require_once 'Tracker/Artifact/Tracker_ArtifactFactory.class.php';
     if ($params['reference']->getServiceShortName() == 'plugin_tracker') {
         if ($params['reference']->getNature() == Tracker_Artifact::REFERENCE_NATURE) {
             $user = UserManager::instance()->getCurrentUser();
             $aid = $params['val'];
             require_once 'Tracker/Artifact/Tracker_ArtifactFactory.class.php';
             if ($artifact = Tracker_ArtifactFactory::instance()->getArtifactByid($aid)) {
                 if ($artifact && $artifact->getTracker()->isActive()) {
                     echo $artifact->fetchTooltip($user);
                 } else {
                     echo $GLOBALS['Language']->getText('plugin_tracker_common_type', 'artifact_not_exist');
                 }
             }
         }
     }
 }
 private function indexAllArtifacts(Tracker $tracker)
 {
     $tracker_id = $tracker->getId();
     $tracker_artifact_factory = Tracker_ArtifactFactory::instance();
     $tracker_artifact_iterator = new Tracker_Artifact_BatchIterator($tracker_artifact_factory, $tracker_id);
     $this->logger->debug('[Tracker] ElasticSearch: indexing all artifacts of tracker #' . $tracker_id);
     $tracker_artifact_iterator->rewind();
     while ($batch = $tracker_artifact_iterator->next()) {
         foreach ($batch as $artifact) {
             $this->indexArtifactUpdate($artifact);
         }
     }
 }
 public function getArtifactFactory()
 {
     return Tracker_ArtifactFactory::instance();
 }
 /**
  * Allows clear factory instance for test. DO NOT USE IT IN PRODUCTION!
  * 
  * @param Tracker_ArtifactFactory $factory 
  */
 public static function clearInstance()
 {
     self::$instance = null;
 }
 public function fetchChangesetValue($artifact_id, $changeset_id, $value, $report = null, $from_aid = null)
 {
     $current_user = UserManager::instance()->getCurrentUser();
     $artifact = Tracker_ArtifactFactory::instance()->getArtifactById($artifact_id);
     return $this->getComputedValue($current_user, $artifact);
 }
示例#16
0
 public function getSearchResults(array $result)
 {
     $results = array();
     $validator = new ElasticSearch_1_2_ResultValidator();
     if (!isset($result['hits']['hits'])) {
         return $results;
     }
     $user = $this->user_manager->getCurrentUser();
     foreach ($result['hits']['hits'] as $hit) {
         $project = $this->project_manager->getProject($this->extractGroupIdFromHit($hit));
         $index = $this->extractIndexFromHit($hit);
         if ($project->isError()) {
             continue;
         }
         try {
             $this->url_verification->userCanAccessProject($user, $project);
         } catch (Project_AccessPrivateException $exception) {
             continue;
         }
         switch ($index) {
             case fulltextsearchPlugin::SEARCH_DOCMAN_TYPE:
                 if (!$validator->isDocmanResultValid($hit)) {
                     continue;
                 }
                 $results[] = new ElasticSearch_SearchResultDocman($hit, $project);
                 break;
             case fulltextsearchPlugin::SEARCH_WIKI_TYPE:
                 if (!$validator->isWikiResultValid($hit)) {
                     continue;
                 }
                 $wiki = new Wiki($project->getID());
                 if ($wiki->isAutorized($user->getId())) {
                     $results[] = new ElasticSearch_SearchResultWiki($hit, $project);
                 }
                 break;
             case fulltextsearchPlugin::SEARCH_TRACKER_TYPE:
                 if (!$validator->isArtifactResultValid($hit)) {
                     continue;
                 }
                 $artifact = Tracker_ArtifactFactory::instance()->getArtifactById($hit['fields']['id'][0]);
                 if ($artifact->userCanView($user)) {
                     $results[] = new ElasticSearch_SearchResultTracker($hit, $project, $artifact);
                 }
                 break;
             default:
         }
     }
     return $results;
 }
 private function getPriorityManager()
 {
     return new Tracker_Artifact_PriorityManager(new Tracker_Artifact_PriorityDao(), new Tracker_Artifact_PriorityHistoryDao(), UserManager::instance(), Tracker_ArtifactFactory::instance());
 }
 /**
  * @return Cardwall_RendererPresenter
  */
 private function getPresenter(array $artifact_ids, PFUser $user, $form = null)
 {
     $redirect_parameter = 'cardwall[renderer][' . $this->report->id . ']=' . $this->id;
     $field = $this->getField();
     if (!$field) {
         $board = new Cardwall_Board(array(), new Cardwall_OnTop_Config_ColumnCollection(), new Cardwall_MappingCollection());
     } else {
         $field_provider = new Cardwall_FieldProviders_CustomFieldRetriever($field);
         $column_preferences = new Cardwall_UserPreferences_Autostack_AutostackRenderer($user, $this->report);
         $columns = $this->config->getRendererColumns($field, $column_preferences);
         $column_autostack = new Cardwall_UserPreferences_UserPreferencesAutostackFactory();
         $column_autostack->setAutostack($columns, $column_preferences);
         $display_preferences = new Cardwall_UserPreferences_UserPreferencesDisplayUser(Cardwall_UserPreferences_UserPreferencesDisplayUser::DISPLAY_AVATARS);
         $mapping_collection = $this->config->getCardwallMappings(array($field->getId() => $field), $columns);
         $presenter_builder = new Cardwall_CardInCellPresenterBuilder(new Cardwall_CardInCellPresenterFactory($field_provider, $mapping_collection), new Cardwall_CardFields(UserManager::instance(), Tracker_FormElementFactory::instance()), $display_preferences, $user);
         $swimline_factory = new Cardwall_SwimlineFactory($this->config, $field_provider);
         $board_builder = new Cardwall_RendererBoardBuilder($presenter_builder, Tracker_ArtifactFactory::instance(), $swimline_factory);
         $board = $board_builder->getBoard($artifact_ids, $columns, $mapping_collection);
     }
     return new Cardwall_RendererPresenter($board, $this->getQrCode(), $redirect_parameter, $field, $form);
 }
 /**
  * Get artifacts that responds to some criteria
  *
  * @param date    $date      The date criteria
  * @param Integer $trackerId The Tracker Id
  *
  * @return Array
  */
 public function getArtifactsByCriterias($date, $trackerId = null)
 {
     $artifacts = array();
     $dao = new Tracker_Artifact_ChangesetDao();
     $dar = $dao->getArtifactsByFieldAndLastUpdateDate($trackerId, $date);
     if ($dar && !$dar->isError()) {
         $artifactFactory = Tracker_ArtifactFactory::instance();
         foreach ($dar as $row) {
             $artifacts[] = $artifactFactory->getArtifactById($row['artifact_id']);
         }
     }
     return $artifacts;
 }
示例#20
0
 /**
  * @return Tracker_HierarchyFactory 
  */
 public function getHierarchyFactory()
 {
     return new Tracker_HierarchyFactory(new Tracker_Hierarchy_Dao(), $this, Tracker_ArtifactFactory::instance());
 }
 private function getTrackerSystemEventManager()
 {
     $form_element_factory = Tracker_FormElementFactory::instance();
     $permissions_serializer = new Tracker_Permission_PermissionsSerializer(new Tracker_Permission_PermissionRetrieveAssignee(UserManager::instance()));
     $artifact_properties_extractor = new ElasticSearch_1_2_ArtifactPropertiesExtractor($form_element_factory, $permissions_serializer);
     return new FullTextSearch_TrackerSystemEventManager(SystemEventManager::instance(), new FullTextSearchTrackerActions($this->getIndexClient(self::SEARCH_TRACKER_TYPE), new ElasticSearch_1_2_RequestTrackerDataFactory($artifact_properties_extractor), $this->getFullTextSearchSystemEventQueue()->getLogger()), Tracker_ArtifactFactory::instance(), TrackerFactory::instance(), $this, $this->getFullTextSearchSystemEventQueue()->getLogger());
 }
示例#22
0
 /**
  * Builds a new Planning_MilestoneFactory instance.
  * @return Planning_MilestoneFactory 
  */
 protected function getMilestoneFactory()
 {
     return new Planning_MilestoneFactory($this->getPlanningFactory(), Tracker_ArtifactFactory::instance(), Tracker_FormElementFactory::instance());
 }
示例#23
0
 /**
  * On create, the artifact was linked to it's immediate parent.
  * In agiledashoard, to remain consistent, it means that we need to link to all
  * parents
  *
  * @param array $params
  */
 private function updateBacklogs(array $params)
 {
     require_once 'Planning/ArtifactLinker.class.php';
     $artifact_linker = new Planning_ArtifactLinker(Tracker_ArtifactFactory::instance());
     $artifact_linker->linkWithParents($params['request'], $params['artifact']);
 }
 private function inconsistentArtifactsIdsAreValid(array $artifact_ids)
 {
     $validator = new Valid_UInt();
     $validator->required();
     $artifact_factory = Tracker_ArtifactFactory::instance();
     foreach ($artifact_ids as $artifact_id) {
         if (!($validator->validate($artifact_id) && $artifact_factory->getArtifactById($artifact_id))) {
             return false;
         }
     }
     return true;
 }
 /**
  * Returns a Tracker_ArtifactFactory instance
  *
  * @return Tracker_ArtifactFactory
  */
 protected function getArtifactFactory()
 {
     if ($this->artifact_factory) {
         return $this->artifact_factory;
     }
     return Tracker_ArtifactFactory::instance();
 }
 protected function getTrackerReferenceManager()
 {
     return new Tracker_ReferenceManager(ReferenceManager::instance(), Tracker_ArtifactFactory::instance());
 }
 /**
  * Returns true is the current user can see the artifact
  *
  * @return boolean
  */
 public function userCanView(PFUser $user)
 {
     $af = Tracker_ArtifactFactory::instance();
     $a = $af->getArtifactById($this->artifact_id);
     return $a->userCanView($user);
 }
 /**
  * @return Tracker_ArtifactFactory
  */
 public function getArtifactFactory()
 {
     if (!$this->artifact_factory) {
         $this->artifact_factory = Tracker_ArtifactFactory::instance();
     }
     return $this->artifact_factory;
 }
示例#29
0
 protected function getArtifactFactory()
 {
     return Tracker_ArtifactFactory::instance();
 }
 public function getFullRESTValue(PFUser $user)
 {
     $values = array();
     $tracker_artifact_factory = Tracker_ArtifactFactory::instance();
     foreach ($this->getArtifactIdsUserCanSee($user) as $id) {
         $classname_with_namespace = 'Tuleap\\Tracker\\REST\\Artifact\\ArtifactReference';
         $artifact_reference = new $classname_with_namespace();
         $artifact_reference->build($tracker_artifact_factory->getArtifactById($id));
         $values[] = $artifact_reference;
     }
     $classname_with_namespace = 'Tuleap\\Tracker\\REST\\Artifact\\ArtifactFieldValueArtifactLinksFullRepresentation';
     $artifact_links_representation = new $classname_with_namespace();
     $artifact_links_representation->build($this->field->getId(), Tracker_FormElementFactory::instance()->getType($this->field), $this->field->getLabel(), $values);
     return $artifact_links_representation;
 }