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)) { $new_tracker = $this->importTracker($project, $name, $description, $itemname, $_FILES["tracker_new_xml_file"]["tmp_name"]); } } 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 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 importForm() { $this->redirectNonAdmin(); $template_file = new Valid_File('template_file'); $template_file->required(); if ($this->request->validFile($template_file)) { $this->importConfiguration(); } $presenter = new Planning_ImportTemplateFormPresenter($this->group_id); return $this->renderToString('import', $presenter); }