/**
  * Create a tracker v5 from a tracker v3
  *
  * @param PFUser         $user           the user who requested the creation
  * @param int            $atid           the id of the tracker v3
  * @param Project        $project        the Id of the project to create the tracker
  * @param string         $name           the name of the tracker (label)
  * @param string         $description    the description of the tracker
  * @param string         $itemname       the short name of the tracker
  *
  * @throws Tracker_Exception_Migration_GetTv3Exception
  *
  * @return Tracker
  */
 public function createFromTV3(PFUser $user, $atid, Project $project, $name, $description, $itemname)
 {
     require_once 'common/tracker/ArtifactType.class.php';
     $tv3 = new ArtifactType($project, $atid);
     if ($tv3->isError()) {
         throw new Tracker_Exception_Migration_GetTv3Exception($tv3->getErrorMessage());
     }
     // Check if this tracker is valid (not deleted)
     if (!$tv3->isValid()) {
         throw new Tracker_Exception_Migration_GetTv3Exception($GLOBALS['Language']->getText('tracker_add', 'invalid'));
     }
     //Check if the user can view the artifact
     if (!$tv3->userCanView($user->getId())) {
         throw new Tracker_Exception_Migration_GetTv3Exception($GLOBALS['Language']->getText('include_exit', 'no_perm'));
     }
     $tracker = null;
     if ($this->validMandatoryInfoOnCreate($name, $description, $itemname, $project->getId())) {
         $migration_v3 = new Tracker_Migration_V3($this);
         $tracker = $migration_v3->createTV5FromTV3($project, $name, $description, $itemname, $tv3);
         $this->postCreateActions($tracker);
     }
     return $tracker;
 }
示例#2
0
 protected function convertTaskTracker()
 {
     $res = db_query('SELECT * FROM artifact_group_list WHERE item_name = "task" AND group_id = 100');
     $row = db_fetch_array($res);
     $trackerv3_id = $row['group_artifact_id'];
     $v3_migration = new Tracker_Migration_V3(TrackerFactory::instance());
     $project = ProjectManager::instance()->getProject(100);
     $name = 'Tasks';
     $description = "tasks tracker";
     $itemname = "tsk";
     $tv3 = new ArtifactType($project, $trackerv3_id);
     $task_tracker = $v3_migration->createTV5FromTV3($project, $name, $description, $itemname, $tv3);
     self::$task_tracker_id = $task_tracker->getId();
 }