Exemple #1
0
 public function __construct()
 {
     parent::__construct();
     if ($this->isPostBack()) {
         $this->post->type->addValidation(new ValidateInputNotNullOrEmpty());
         $this->post->name->addValidation(new ValidateInputNotNullOrEmpty());
         $this->post->subdomain->addValidation(new ValidateInputNotNullOrEmpty());
         $this->post->base_url->addValidation([new ValidateInputNotNullOrEmpty(), new ValidateInputUri()]);
         if (!$this->hasErrors()) {
             $source = new SourceWebFolder();
             $source->name = $this->input('name');
             $source->type = $this->input('type');
             $source->setSubdomain($this->input('subdomain'));
             $source->require_ssl = $this->input('require_ssl');
             $source->default_parameters = $this->input('default_parameters');
             $source->error_image_url = $this->input('error_image_url');
             $source->error_image_parameters = $this->input('error_image_parameters');
             $source->missing_image_url = $this->input('missing_image_url');
             $source->missing_image_parameters = $this->input('missing_image_parameters');
             $source->organisation_id = $this->currentUser->getActiveOrganisation();
             $source->setBaseUrl($this->input('base_url'));
             $this->save($source);
         }
     }
 }
Exemple #2
0
 public function __construct($sourceId)
 {
     parent::__construct();
     $this->source = SourceWebFolder::createType(Source::getById($sourceId));
     if (!$this->source->hasRow()) {
         redirect(url('controlpanel.source'));
     }
     if ($this->isPostBack()) {
         $this->post->type->addValidation(new ValidateInputNotNullOrEmpty());
         $this->post->name->addValidation(new ValidateInputNotNullOrEmpty());
         $this->post->subdomain->addValidation(new ValidateInputNotNullOrEmpty());
         $this->post->base_url->addValidation([new ValidateInputNotNullOrEmpty(), new ValidateInputUri()]);
         if (!$this->hasErrors()) {
             $updateDns = false;
             // Update DNS if the subdomain has changed
             if ($this->source->subdomain != trim(strtolower($this->input('subdomain')))) {
                 $updateDns = true;
             }
             $this->subdomain = $this->source->subdomain;
             $this->source->name = $this->input('name');
             $this->source->type = $this->input('type');
             $this->source->setSubdomain($this->input('subdomain'));
             $this->source->require_ssl = $this->input('require_ssl');
             $this->source->default_parameters = $this->input('default_parameters');
             $this->source->error_image_url = $this->input('error_image_url');
             $this->source->error_image_parameters = $this->input('error_image_parameters');
             $this->source->missing_image_url = $this->input('missing_image_url');
             $this->source->missing_image_parameters = $this->input('missing_image_parameters');
             $this->source->organisation_id = $this->currentUser->getActiveOrganisation();
             $this->source->setBaseUrl($this->input('base_url'));
             $this->edit($updateDns);
         }
     }
 }