/** * 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")); }