Пример #1
0
 /**
  * create new cron item for remote acl or return already available one
  * @return array status action
  */
 public function fetchRBCronAction()
 {
     $result = array("result" => "failed");
     if ($this->request->isPost()) {
         $mdlProxy = new Proxy();
         if ((string) $mdlProxy->forward->acl->remoteACLs->UpdateCron == "") {
             $mdlCron = new Cron();
             // update cron relation (if this doesn't break consistency)
             $uuid = $mdlCron->newDailyJob("Proxy", "proxy fetchacls", "fetch proxy acls", "1");
             $mdlProxy->forward->acl->remoteACLs->UpdateCron = $uuid;
             if ($mdlCron->performValidation()->count() == 0) {
                 $mdlCron->serializeToConfig();
                 // save data to config, do not validate because the current in memory model doesn't know about the
                 // cron item just created.
                 $mdlProxy->serializeToConfig($validateFullModel = false, $disable_validation = true);
                 Config::getInstance()->save();
                 $result['result'] = "new";
                 $result['uuid'] = $uuid;
             } else {
                 $result['result'] = "unable to add cron";
             }
         } else {
             $result['result'] = "existing";
             $result['uuid'] = (string) $mdlProxy->forward->acl->remoteACLs->UpdateCron;
         }
     }
     return $result;
 }
Пример #2
0
 /**
  *
  * @return array
  * @throws \Phalcon\Validation\Exception
  */
 public function setAction()
 {
     $result = array("result" => "failed");
     if ($this->request->hasPost("proxy")) {
         // load model and update with provided data
         $mdlProxy = new Proxy();
         $mdlProxy->setNodes($this->request->getPost("proxy"));
         // perform validation
         $valMsgs = $mdlProxy->performValidation();
         foreach ($valMsgs as $field => $msg) {
             if (!array_key_exists("validations", $result)) {
                 $result["validations"] = array();
             }
             $result["validations"]["proxy." . $msg->getField()] = $msg->getMessage();
         }
         // serialize model to config and save
         if ($valMsgs->count() == 0) {
             $mdlProxy->serializeToConfig();
             $cnf = Config::getInstance();
             $cnf->save();
             $result["result"] = "saved";
         }
     }
     return $result;
 }