Esempio n. 1
0
 /**
  * Add a build (AJAX call)
  * 
  * @param TBGRequest $request The request object
  */
 public function runAddBuild(TBGRequest $request)
 {
     $i18n = TBGContext::getI18n();
     if ($this->access_level == TBGSettings::ACCESS_FULL) {
         try {
             $p_id = $request->getParameter('project_id');
             if ($project = TBGContext::factory()->TBGProject($p_id)) {
                 if (TBGContext::getUser()->canManageProjectReleases($project)) {
                     if (($b_name = $request->getParameter('build_name')) && trim($b_name) != '') {
                         if (in_array($b_name, $project->getBuilds())) {
                             throw new Exception($i18n->__('This release already exists for this project'));
                         }
                         if (($e_id = $request->getParameter('edition_id')) && ($edition = TBGContext::factory()->TBGEdition($e_id))) {
                             if (in_array($b_name, $edition->getBuilds())) {
                                 throw new Exception($i18n->__('This release already exists for this edition'));
                             }
                         }
                         $build = new TBGBuild();
                         $build->setName($b_name);
                         $build->setVersion($request->getParameter('ver_mj', 0), $request->getParameter('ver_mn', 0), $request->getParameter('ver_rev', 0));
                         if (isset($edition)) {
                             $build->setEdition($edition);
                         } else {
                             $build->setProject($project);
                         }
                         $build->save();
                         return $this->renderJSON(array('html' => "<span id=\"build_list_{$build->getID()}\">" . $this->getTemplateHTML('buildbox', array('build' => $build, 'access_level' => $this->access_level)) . '</span>'));
                     } else {
                         throw new Exception($i18n->__('You need to specify a name for the new release'));
                     }
                 } else {
                     throw new Exception($i18n->__('You do not have access to this project'));
                 }
             } else {
                 throw new Exception($i18n->__('You need to specify a project id'));
             }
         } catch (Exception $e) {
             return $this->renderJSON(array('failed' => true, "error" => $i18n->__('The release could not be added') . ", " . $e->getMessage()));
         }
     }
     return $this->renderJSON(array('failed' => true, "error" => $i18n->__("You don't have access to add releases")));
 }
Esempio n. 2
0
 /**
  * Add a build (AJAX call)
  *
  * @param TBGRequest $request The request object
  */
 public function runProjectBuild(TBGRequest $request)
 {
     $i18n = TBGContext::getI18n();
     if ($this->getUser()->canManageProjectReleases($this->selected_project)) {
         try {
             if (TBGContext::getUser()->canManageProjectReleases($this->selected_project)) {
                 if (($b_name = $request['build_name']) && trim($b_name) != '') {
                     $build = new TBGBuild($request['build_id']);
                     $build->setName($b_name);
                     $build->setVersion($request->getParameter('ver_mj', 0), $request->getParameter('ver_mn', 0), $request->getParameter('ver_rev', 0));
                     $build->setReleased((bool) $request['isreleased']);
                     $build->setLocked((bool) $request['locked']);
                     if ($request['milestone'] && ($milestone = TBGContext::factory()->TBGMilestone($request['milestone']))) {
                         $build->setMilestone($milestone);
                     } else {
                         $build->clearMilestone();
                     }
                     if ($request['edition'] && ($edition = TBGContext::factory()->TBGEdition($request['edition']))) {
                         $build->setEdition($edition);
                     } else {
                         $build->clearEdition();
                     }
                     $release_date = null;
                     if ($request['has_release_date']) {
                         $release_date = mktime($request['release_hour'], $request['release_minute'], 1, $request['release_month'], $request['release_day'], $request['release_year']);
                     }
                     $build->setReleaseDate($release_date);
                     switch ($request->getParameter('download', 'leave_file')) {
                         case '0':
                             $build->clearFile();
                             $build->setFileURL('');
                             break;
                         case 'upload_file':
                             if ($build->hasFile()) {
                                 $build->getFile()->delete();
                                 $build->clearFile();
                             }
                             $file = TBGContext::getRequest()->handleUpload('upload_file');
                             $build->setFile($file);
                             $build->setFileURL('');
                             break;
                         case 'url':
                             $build->clearFile();
                             $build->setFileURL($request['file_url']);
                             break;
                     }
                     if ($request['edition_id']) {
                         $build->setEdition($edition);
                     }
                     if (!$build->getID()) {
                         $build->setProject($this->selected_project);
                     }
                     $build->save();
                 } else {
                     throw new Exception($i18n->__('You need to specify a name for the release'));
                 }
             } else {
                 throw new Exception($i18n->__('You do not have access to this project'));
             }
         } catch (Exception $e) {
             TBGContext::setMessage('build_error', $e->getMessage());
         }
         $this->forward(TBGContext::getRouting()->generate('project_release_center', array('project_key' => $this->selected_project->getKey())));
     }
     return $this->forward403($i18n->__("You don't have access to add releases"));
 }
Esempio n. 3
0
 /**
  * Set status for affected build
  * 
  * @see setAffectedItemStatus()
  * @see setAffectedEditionStatus()
  * @see setAffectedComponentStatus()
  * 
  * @param TBGBuild $item The build to set status for
  * @param TBGDatatype $status The status to set
  * 
  * @return boolean
  */
 public function setAffectedBuildStatus($item, $status)
 {
     if (TBGIssueAffectsBuildTable::getTable()->setStatusByIssueIDandBuildID($this->getID(), $item->getID(), $status->getID())) {
         $this->addLogEntry(TBGLogTable::LOG_AFF_DELETE, TBGContext::getI18n()->__("'%item_name' -> '%status_name", array('%item_name' => $item->getName(), '%status_name' => $status->getName())));
         return true;
     }
     return false;
 }
Esempio n. 4
0
 /**
  * @covers TBGBuild::getID
  * @depends testConstruct
  */
 public function testGetID(TBGBuild $build)
 {
     $this->assertEquals(1, $build->getID());
 }
 /**
  * Set status for affected build
  * 
  * @see setAffectedItemStatus()
  * @see setAffectedEditionStatus()
  * @see setAffectedComponentStatus()
  * 
  * @param TBGBuild $item The build to set status for
  * @param TBGDatatype $status The status to set
  * 
  * @return boolean
  */
 public function setAffectedBuildStatus($item, $status)
 {
     if (B2DB::getTable('TBGIssueAffectsBuildTable')->setStatusByIssueIDandBuildID($this->getID(), $item->getID(), $status->getID())) {
         $this->addLogEntry(TBGLogTable::LOG_AFF_DELETE, TBGContext::getI18n()->__("'%item_name%' -> '%status_name%", array('%item_name%' => $item->getName(), '%status_name%' => $status->getName())));
         $this->addSystemComment(TBGContext::getI18n()->__('Affected build updated'), TBGContext::getI18n()->__('Build \'\'\'%build%\'\'\' is now %status%', array('%build%' => $item->getName(), '%status%' => $status->getName())), TBGContext::getUser()->getID());
         return true;
     }
     return false;
 }