Пример #1
0
 /**
  * Construct the deployment form
  *
  * @return Form
  */
 public function getDeployForm($request = null)
 {
     // Performs canView permission check by limiting visible projects
     $project = $this->getCurrentProject();
     if (!$project) {
         return $this->project404Response();
     }
     // Performs canView permission check by limiting visible projects
     $environment = $this->getCurrentEnvironment($project);
     if (!$environment) {
         return $this->environment404Response();
     }
     if (!$environment->canDeploy()) {
         return new SS_HTTPResponse("Not allowed to deploy", 401);
     }
     // Generate the form
     $form = new DeployForm($this, 'DeployForm', $environment, $project);
     // If this is an ajax request we don't want to submit the form - we just want to retrieve the markup.
     if ($request && !$request->requestVar('action_showDeploySummary') && $this->getRequest()->isAjax() && $this->getRequest()->isGET()) {
         // We can just use the URL we're accessing
         $form->setFormAction($this->getRequest()->getURL());
         $body = json_encode(array('Content' => $form->forAjaxTemplate()->forTemplate()));
         $this->getResponse()->addHeader('Content-Type', 'application/json');
         $this->getResponse()->setBody($body);
         return $body;
     }
     $form->setFormAction($this->getRequest()->getURL() . '/DeployForm');
     return $form;
 }
Пример #2
0
 /**
  * Construct the deployment form
  *
  * @param SS_HTTPRequest $request
  * @return Form
  */
 public function getDeployForm(SS_HTTPRequest $request)
 {
     // Performs canView permission check by limiting visible projects
     $project = $this->getCurrentProject();
     if (!$project) {
         return new SS_HTTPResponse("Project '" . Convert::raw2xml($request->latestParam('Project')) . "' not found.", 404);
     }
     // Performs canView permission check by limiting visible projects
     $environment = $this->getCurrentEnvironment($project);
     if (!$environment) {
         return new SS_HTTPResponse("Environment '" . Convert::raw2xml($request->latestParam('Environment')) . "' not found.", 404);
     }
     if (!$environment->canDeploy()) {
         return new SS_HTTPResponse("Not allowed to deploy", 401);
     }
     if (!$project->repoExists()) {
         $literalField = new LiteralField('noRepoWarning', '<strong>The GIT repository is for the time being not available.</strong>');
         return Form::create($this, 'DeployForm', new FieldList($literalField), new FieldList());
     }
     // Generate the form
     $form = new DeployForm($this, 'DeployForm', $environment, $project);
     // Tweak the action so it plays well with our fake URL structure.
     $form->setFormAction($request->getURL() . '/DeployForm');
     return $form;
 }