/** * 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; }
/** * The singleton method * * @return Tracker_Hierarchy_HierarchicalTrackerFactory */ public static function instance() { if (!self::$instance) { self::$instance = new Tracker_Hierarchy_HierarchicalTrackerFactory(TrackerFactory::instance(), new Tracker_Hierarchy_Dao()); } return self::$instance; }
public function __construct(AgileDashboard_Kanban $kanban, PFUser $user, $user_is_kanban_admin, $language, $project_id) { $user_preferences = new AgileDashboard_KanbanUserPreferences(); $kanban_representation_builder = new Tuleap\AgileDashboard\REST\v1\Kanban\KanbanRepresentationBuilder($user_preferences, new AgileDashboard_KanbanColumnFactory(new AgileDashboard_KanbanColumnDao(), $user_preferences), TrackerFactory::instance(), Tracker_FormElementFactory::instance()); $this->kanban_representation = json_encode($kanban_representation_builder->build($kanban, $user)); $this->user_is_kanban_admin = (int) $user_is_kanban_admin; $this->language = $language; $this->project_id = $project_id; }
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; }
/** * The singleton method * * @return WorkflowFactory */ public static function instance() { if (!isset(self::$_instance)) { $formelement_factory = Tracker_FormElementFactory::instance(); $logger = new WorkflowBackendLogger(new BackendLogger()); $trigger_rules_manager = new Tracker_Workflow_Trigger_RulesManager(new Tracker_Workflow_Trigger_RulesDao(), $formelement_factory, new Tracker_Workflow_Trigger_RulesProcessor(UserManager::instance()->getUserById(Tracker_Workflow_WorkflowUser::ID), $logger), $logger); $c = __CLASS__; self::$_instance = new $c(TransitionFactory::instance(), TrackerFactory::instance(), $formelement_factory, $trigger_rules_manager, $logger); } return self::$_instance; }
public function getConfigFactory() { if (!$this->config_factory) { require_once 'OnTop/ConfigFactory.class.php'; require_once TRACKER_BASE_DIR . '/Tracker/TrackerFactory.class.php'; $tracker_factory = TrackerFactory::instance(); $element_factory = Tracker_FormElementFactory::instance(); $this->config_factory = new Cardwall_OnTop_ConfigFactory($tracker_factory, $element_factory); } return $this->config_factory; }
public function __construct(AgileDashboard_Kanban $kanban, PFUser $user, $user_is_kanban_admin, $language, $project_id) { $user_preferences = new AgileDashboard_KanbanUserPreferences(); $kanban_representation_builder = new Tuleap\AgileDashboard\REST\v1\Kanban\KanbanRepresentationBuilder($user_preferences, new AgileDashboard_KanbanColumnFactory(new AgileDashboard_KanbanColumnDao(), $user_preferences), new AgileDashboard_KanbanActionsChecker(TrackerFactory::instance(), new AgileDashboard_PermissionsManager(), Tracker_FormElementFactory::instance())); $this->kanban_representation = json_encode($kanban_representation_builder->build($kanban, $user)); $this->user_is_kanban_admin = (int) $user_is_kanban_admin; $this->language = $language; $this->project_id = $project_id; $this->user_id = $user->getId(); $this->view_mode = $user->getPreference('agiledashboard_kanban_item_view_mode_' . $kanban->getId()); $this->nodejs_server = ForgeConfig::get('nodejs_server'); }
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; }
/** * @return AgileDashboard_KanbanFactory */ private function getKanbanFactory() { return new AgileDashboard_KanbanFactory(TrackerFactory::instance(), new AgileDashboard_KanbanDao()); }
public function getTrackerFactory() { return TrackerFactory::instance(); }
/** * @return TrackerXmlImport */ public static function build() { $builder = new Tracker_Artifact_XMLImportBuilder(); $tracker_factory = TrackerFactory::instance(); return new TrackerXmlImport($tracker_factory, EventManager::instance(), new Tracker_Hierarchy_Dao(), Tracker_CannedResponseFactory::instance(), Tracker_FormElementFactory::instance(), Tracker_SemanticFactory::instance(), new Tracker_RuleFactory(new Tracker_RuleDao()), Tracker_ReportFactory::instance(), WorkflowFactory::instance(), new XML_RNGValidator(), $tracker_factory->getTriggerRulesManager(), $builder->build()); }
function service_public_areas($params) { require_once 'Tracker/TrackerFactory.class.php'; if ($params['project']->usesService('plugin_tracker')) { $tf = TrackerFactory::instance(); // Get the artfact type list $trackers = $tf->getTrackersByGroupId($params['project']->getGroupId()); if ($trackers) { $entries = array(); foreach ($trackers as $t) { if ($t->userCanView()) { $entries[] = '<a href="' . TRACKER_BASE_URL . '/?tracker=' . $t->id . '">' . $t->name . '</a>'; } } if ($entries) { $area = ''; $area .= '<a href="' . TRACKER_BASE_URL . '/?group_id=' . $params['project']->getGroupId() . '">'; $area .= $GLOBALS['HTML']->getImage('ic/clipboard-list.png'); $area .= ' ' . $GLOBALS['Language']->getText('plugin_tracker', 'service_lbl_key'); $area .= '</a>'; $area .= '<ul><li>' . implode('</li><li>', $entries) . '</li></ul>'; $params['areas'][] = $area; } } } }
public function get_projectid_from_url($params) { $url = $params['url']; if (strpos($url, '/plugins/tracker/') === 0) { if (!$params['request']->get('tracker')) { return; } $tracker = TrackerFactory::instance()->getTrackerById($params['request']->get('tracker')); if ($tracker) { $params['project_id'] = $tracker->getGroupId(); } } }
* the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Tuleap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Tuleap. If not, see <http://www.gnu.org/licenses/>. */ require_once 'pre.php'; try { $user_manager = UserManager::instance(); $user_manager->forceLogin($argv[1]); $tracker = TrackerFactory::instance()->getTrackerById($argv[2]); if ($tracker) { $xml_import_builder = new Tracker_Artifact_XMLImportBuilder(); $xml_import = $xml_import_builder->build(new XMLImportHelper($user_manager)); $zip = new ZipArchive(); if ($zip->open($argv[3]) !== true) { echo 'Impossible to open archive ' . $argv[3] . PHP_EOL; exit(1); } $archive = new Tracker_Artifact_XMLImport_XMLImportZipArchive($tracker, $zip, ForgeConfig::get('tmp_dir')); $xml_import->importFromArchive($tracker, $archive); } } catch (XML_ParseException $exception) { echo $exception->getMessage() . PHP_EOL; echo $exception->getIndentedXml() . PHP_EOL; echo implode(PHP_EOL, $exception->getErrors()) . PHP_EOL;
/** * Returns the tracker this artifact belongs to * * @return Tracker The tracker this artifact belongs to */ public function getTracker() { return TrackerFactory::instance()->getTrackerByid($this->tracker_id); }
if (empty($name)) { echo 'Fetching name from XML' . PHP_EOL; $name = $oxml->name; } if (empty($description)) { echo 'Fetching description from XML' . PHP_EOL; $description = $oxml->description; } if (empty($item_name)) { echo 'Fetching item name from XML' . PHP_EOL; $item_name = $oxml->item_name; } #FILE PROCESSING $output = ''; ob_start(); $tf = TrackerFactory::instance(); $tracker = $tf->createFromXML($xmlFile, $group_id, $name, $description, $item_name, null); $output = ob_get_contents(); ob_end_flush(); #WARN AND ERRORS PARSING $matches = array(); if (preg_match_all('/.*\\s+error\\:\\s+.*/', $output, $matches)) { echo 'Invalid XML format' . PHP_EOL; exit(1); } if ($GLOBALS['Response']->feedbackHasErrors()) { echo $GLOBALS['Response']->getRawFeedback(); exit(1); } if ($GLOBALS['Response']->feedbackHasWarningsOrErrors()) { echo $GLOBALS['Response']->getRawFeedback();
/** * @return TrackerFactory */ protected function getTrackerFactory() { return TrackerFactory::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()); }
protected function buildController(Codendi_Request $request) { return new AgileDashboard_Controller($request, $this->planning_factory, $this->kanban_manager, $this->kanban_factory, $this->config_manager, TrackerFactory::instance(), new AgileDashboard_PermissionsManager()); }
/** * Duplicate a formElement * @param int $from_tracker_id * @param int $to_tracker_id * @param array $ugroup_mapping * @return array the mapping between old formElements and new ones */ public function duplicate($from_tracker_id, $to_tracker_id, $ugroup_mapping) { $mapping = array(); foreach ($this->getDao()->searchByTrackerId($from_tracker_id) as $from_row) { $has_workflow = false; if (in_array($from_row['formElement_type'], array('sb', 'rb'))) { $field = $this->getFieldById($from_row['id']); if ($field->fieldHasDefineWorkflow()) { $has_workflow = true; } } //First duplicate formElement info if ($id = $this->getDao()->duplicate($from_row['id'], $to_tracker_id)) { $created_form_element = $this->getFormElementById($id); if ($created_form_element) { $created_values = $created_form_element->duplicate($from_row['id'], $id); if ($has_workflow) { $workflow = $this->getFormElementById($from_row['id'])->getWorkflow(); } $mapping[] = array('from' => $from_row['id'], 'to' => $id, 'values' => $created_values, 'workflow' => $has_workflow); $type = $this->getType($created_form_element); } $tracker = TrackerFactory::instance()->getTrackerByid($to_tracker_id); } } $this->getDao()->mapNewParentsAfterDuplication($to_tracker_id, $mapping); return $mapping; }
/** * Builds a new PlanningFactory instance. * * TODO: * - Use Planning_MilestoneFactory instead. * * @return PlanningFactory */ protected function getPlanningFactory() { return new PlanningFactory(new PlanningDao(), TrackerFactory::instance()); }
private function anArtifactLinkInfo($artifact_id, $tracker_id) { $artifact_link_info = mock('Tracker_ArtifactLinkInfo'); stub($artifact_link_info)->getArtifactId()->returns($artifact_id); stub($artifact_link_info)->getTracker()->returns(TrackerFactory::instance()->getTrackerById($tracker_id)); return $artifact_link_info; }
/** * Returns the "open" artifacts * - assigned to user $user_id OR * - submitted by user $user_id OR * - submitted by or assigned to user $user_id. * regarding the callback method (respectively * - searchOpenAssignedToUserId, * - searchOpenSubmittedByUserId * - searchOpenSubmittedByOrAssignedToUserId) * * in an array of the form: * array( * $tracker_id => array( * 'tracker' => $tracker (Tracker), * 'artifacts' => array( * 'artifact' => $artifact (Tracker_Artifact), * 'title' => $title (string) * ) * ) * ) * * @param int $user_id the id of the user * @param string $callback the callback method * * @return array Complex array of artifacts group by trackers (see above) */ protected function getUserOpenArtifacts($user_id, $callback) { $tf = TrackerFactory::instance(); $artifacts = array(); foreach ($this->getDao()->{$callback}($user_id) as $row) { if (!isset($artifacts[$row['tracker_id']])) { $tracker = $tf->getTrackerById($row['tracker_id']); $with_title = false; if ($title_field = Tracker_Semantic_Title::load($tracker)->getField()) { if ($title_field->userCanRead()) { $with_title = true; } } $artifacts[$row['tracker_id']] = array('tracker' => $tracker, 'with_title' => $with_title, 'artifacts' => array()); } if (!isset($artifacts[$row['tracker_id']]['artifacts'][$row['id']])) { $artifact = $this->getInstanceFromRow($row); if ($artifact->userCanView()) { $artifacts[$row['tracker_id']]['artifacts'][$row['id']] = array('artifact' => $artifact, 'title' => $artifacts[$row['tracker_id']]['with_title'] ? $row['title'] : ''); } } } return $artifacts; }
public function setUp() { parent::setUp(); $tracker_factory = TrackerFactory::instance(); $hierarchy_dao = mock('Tracker_Hierarchy_Dao'); $hierarchy_factory = new Tracker_HierarchyFactory($hierarchy_dao, $tracker_factory, mock('Tracker_ArtifactFactory')); $tracker_factory->setHierarchyFactory($hierarchy_factory); $this->setUpTrackers($tracker_factory, $hierarchy_dao); $this->setUpPlannings($tracker_factory); }
/** * @return PlanningFactory */ public static function build() { return new PlanningFactory(new PlanningDao(), TrackerFactory::instance(), Tracker_FormElementFactory::instance(), new PlanningPermissionsManager()); }
/** * @return AgileDashboard_KanbanManager */ private function getKanbanManager() { return new AgileDashboard_KanbanManager(new AgileDashboard_KanbanDao(), TrackerFactory::instance()); }
/** * Returns the tracker this artifact belongs to * * @return Tracker The tracker this artifact belongs to */ public function getTracker() { if (!isset($this->tracker)) { $this->tracker = TrackerFactory::instance()->getTrackerByid($this->tracker_id); } return $this->tracker; }
private function getSemanticStatus(AgileDashboard_Kanban $kanban) { $tracker = TrackerFactory::instance()->getTrackerById($kanban->getTrackerId()); if (!$tracker) { return; } $semantic = Tracker_Semantic_Status::forceLoad($tracker); if (!$semantic->getFieldId()) { return; } return $semantic; }
/** * @return PlanningFactory */ public static function build() { return new PlanningFactory(new PlanningDao(), TrackerFactory::instance()); }
protected function editOptions($request) { $project = ProjectManager::instance()->getProject($this->group_id); $old_item_name = $this->getItemName(); $old_name = $this->getName(); $this->name = trim($request->getValidated('name', 'string', '')); $this->description = trim($request->getValidated('description', 'text', '')); $this->item_name = trim($request->getValidated('item_name', 'string', '')); $this->allow_copy = $request->getValidated('allow_copy') ? 1 : 0; $this->submit_instructions = $request->getValidated('submit_instructions', 'text', ''); $this->browse_instructions = $request->getValidated('browse_instructions', 'text', ''); $this->instantiate_for_new_projects = $request->getValidated('instantiate_for_new_projects') ? 1 : 0; if (!$this->name || !$this->description || !$this->item_name) { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_tracker_common_type', 'name_requ')); } else { if ($old_name != $this->name) { if (TrackerFactory::instance()->isNameExists($this->name, $this->group_id)) { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_tracker_common_type', 'name_already_exists', $this->name)); return false; } } if ($old_item_name != $this->item_name) { if (!$this->itemNameIsValid($this->item_name)) { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_tracker_common_type', 'invalid_shortname', $this->item_name, CODENDI_PURIFIER_CONVERT_HTML)); return false; } if (TrackerFactory::instance()->isShortNameExists($this->item_name, $this->group_id)) { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_tracker_common_type', 'shortname_already_exists', $this->item_name)); return false; } $reference_manager = ReferenceManager::instance(); if (!$reference_manager->checkKeyword($this->item_name)) { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_tracker_common_type', 'invalid_shortname', $this->item_name, CODENDI_PURIFIER_CONVERT_HTML)); return false; } if ($reference_manager->_isKeywordExists($this->item_name, $this->group_id)) { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_tracker_common_type', 'shortname_already_exists', $this->item_name, CODENDI_PURIFIER_CONVERT_HTML)); return false; } //Update reference and cross references //WARNING this replace existing reference(s) so that all old_item_name reference won't be extracted anymore $reference_manager->updateProjectReferenceShortName($this->group_id, $old_item_name, $this->item_name); } $dao = new TrackerDao(); if ($dao->save($this)) { $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_tracker_admin', 'successfully_updated')); } else { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('global', 'error')); } } }