/** @return Tracker */ private function importTrackerStructure() { try { return $this->xml_import->createFromXMLFile($this->project->getID(), $this->template_path); } catch (Exception $exception) { $logger = new BackendLogger(); $logger->error('Unable to create first kanban for ' . $this->project->getId() . ': ' . $exception->getMessage()); return; } }
/** * * @param array $params * @see Event::IMPORT_XML_PROJECT */ public function import_xml_project($params) { TrackerXmlImport::build()->import($params['project']->getId(), $params['xml_content'], $params['extraction_path']); }
public function doCreateTracker(Project $project, Codendi_Request $request) { $is_error = false; $new_tracker = null; $name = trim($request->get('name')); $description = trim($request->get('description')); $itemname = trim($request->get('itemname')); $atid_template = $request->getValidated('atid_template', 'uint', 0); // First try XML if ($request->existAndNonEmpty('create_mode') && $request->get('create_mode') == 'xml') { $vFile = new Valid_File('tracker_new_xml_file'); $vFile->required(); if ($request->validFile($vFile)) { try { $user_finder = new XMLImportHelper(UserManager::instance()); $new_tracker = TrackerXmlImport::build($user_finder)->createFromXMLFileWithInfo($project->getID(), $_FILES["tracker_new_xml_file"]["tmp_name"], $name, $description, $itemname); } catch (XML_ParseException $exception) { $this->displayCreateTrackerFromXMLErrors($project, $exception->getErrors(), $exception->getFileLines()); } catch (TrackerFromXmlException $exception) { $GLOBALS['Response']->addFeedback(Feedback::ERROR, $exception->getMessage()); } } } else { if ($request->existAndNonEmpty('create_mode') && $request->get('create_mode') == 'tv3') { $atid = $request->get('tracker_new_tv3'); $user = UserManager::instance()->getCurrentUser(); $new_tracker = $this->getTrackerFactory()->createFromTV3($user, $atid, $project, $name, $description, $itemname); } else { if ($request->existAndNonEmpty('create_mode') && $request->get('create_mode') == 'migrate_from_tv3') { $tracker_id = $request->get('tracker_new_tv3'); if ($this->getTV3MigrationManager()->askForMigration($project, $tracker_id, $name, $description, $itemname)) { $GLOBALS['Response']->redirect(TRACKER_BASE_URL . '/?group_id=' . $project->group_id); } } else { // Otherwise tries duplicate $duplicate = $this->getTrackerFactory()->create($project->getId(), -1, $atid_template, $name, $description, $itemname); $new_tracker = $duplicate['tracker']; } } } if ($new_tracker) { $GLOBALS['Response']->redirect(TRACKER_BASE_URL . '/?group_id=' . $project->group_id . '&tracker=' . $new_tracker->id); } else { $tracker_template = $this->getTrackerFactory()->getTrackerById($atid_template); $this->displayCreateTracker($project, $request, $name, $description, $itemname, $tracker_template); } }
public function buildTrackersHierarchy(array $hierarchy, SimpleXMLElement $xml_tracker, array $mapper) { return parent::buildTrackersHierarchy($hierarchy, $xml_tracker, $mapper); }
public function updateConfiguration() { $token = new CSRFSynchronizerToken('/plugins/agiledashboard/?action=admin'); $token->check(); if (!$this->request->getCurrentUser()->isAdmin($this->group_id)) { $GLOBALS['Response']->addFeedback(Feedback::ERROR, $GLOBALS['Language']->getText('global', 'perm_denied')); return; } $response = new AgileDashboardConfigurationResponse($this->request->getProject(), $this->request->exist('home-ease-onboarding')); if ($this->request->exist('activate-kanban')) { $updater = new AgileDashboardKanbanConfigurationUpdater($this->request, $this->config_manager, $response, new AgileDashboard_FirstKanbanCreator($this->request->getProject(), $this->kanban_manager, $this->tracker_factory, TrackerXmlImport::build())); } else { $updater = new AgileDashboardScrumConfigurationUpdater($this->request, $this->config_manager, $response, new AgileDashboard_FirstScrumCreator($this->request->getProject(), $this->planning_factory, $this->tracker_factory, new ProjectXMLImporter(EventManager::instance(), ProjectManager::instance(), new XML_RNGValidator(), new UGroupManager(), UserManager::instance(), new XMLImportHelper(), new ProjectXMLImporterLogger()))); } return $updater->updateConfiguration(); }
$posix_user = posix_getpwuid(posix_geteuid()); $sys_user = $posix_user['name']; if ($sys_user !== 'root' && $sys_user !== 'codendiadm') { die('Unsufficient privileges for user ' . $sys_user . PHP_EOL); } // ARGS RETRIEVAL $xmlFile = !empty($argv[1]) ? $argv[1] : ''; $group_id = !empty($argv[2]) ? $argv[2] : 100; $GLOBALS['Response'] = new Response(); $user = UserManager::instance()->forceLogin('admin'); if (!is_readable($xmlFile)) { die('Unable to read xml file' . PHP_EOL); } // FILE PROCESSING try { TrackerXmlImport::build(new XMLImportHelper(UserManager::instance()))->createFromXMLFile($group_id, $xmlFile); if ($GLOBALS['Response']->feedbackHasErrors()) { echo $GLOBALS['Response']->getRawFeedback(); exit(1); } if ($GLOBALS['Response']->feedbackHasWarningsOrErrors()) { echo $GLOBALS['Response']->getRawFeedback(); exit(2); } echo 'Import succeeded' . PHP_EOL; exit(0); } catch (XML_ParseException $exception) { foreach ($exception->getErrors() as $parse_error) { fwrite(STDERR, $parse_error . PHP_EOL); } echo 'Invalid XML format' . PHP_EOL;
$posix_user = posix_getpwuid(posix_geteuid()); $sys_user = $posix_user['name']; if ($sys_user !== 'root' && $sys_user !== 'codendiadm') { die('Unsufficient privileges for user ' . $sys_user . PHP_EOL); } // ARGS RETRIEVAL $xmlFile = !empty($argv[1]) ? $argv[1] : ''; $group_id = !empty($argv[2]) ? $argv[2] : 100; $GLOBALS['Response'] = new Response(); $user = UserManager::instance()->forceLogin('admin'); if (!is_readable($xmlFile)) { die('Unable to read xml file' . PHP_EOL); } // FILE PROCESSING try { TrackerXmlImport::build()->createFromXMLFile($group_id, $xmlFile); if ($GLOBALS['Response']->feedbackHasErrors()) { echo $GLOBALS['Response']->getRawFeedback(); exit(1); } if ($GLOBALS['Response']->feedbackHasWarningsOrErrors()) { echo $GLOBALS['Response']->getRawFeedback(); exit(2); } echo 'Import succeeded' . PHP_EOL; exit(0); } catch (XML_ParseException $exception) { foreach ($exception->getErrors() as $parse_error) { fwrite(STDERR, $parse_error . PHP_EOL); } echo 'Invalid XML format' . PHP_EOL;