当前位置: 首页>>代码示例>>PHP>>正文


PHP Operator::newRecord方法代码示例

本文整理汇总了PHP中Operator::newRecord方法的典型用法代码示例。如果您正苦于以下问题:PHP Operator::newRecord方法的具体用法?PHP Operator::newRecord怎么用?PHP Operator::newRecord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Operator的用法示例。

在下文中一共展示了Operator::newRecord方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: execute

 public function execute()
 {
     global $gvMinPasswordLength, $gvPath;
     $op_password = gfPostVar('op_password', '');
     $op_password_repete = gfPostVar('op_password_repete', '');
     // Trim data
     $this->op_code = trim($this->op_code);
     $this->op_name = trim($this->op_name);
     $this->op_surname = trim($this->op_surname);
     // Data validation
     if ($this->op_code === '' || $this->op_name === '' || $this->op_surname === '') {
         $this->message = "Errore: tutti i campi sono obbligatori.";
         return true;
     }
     if ($this->op_id === 0 && $op_password === '') {
         $this->message = "Errore: il campo password è obbligatorio.";
         return true;
     }
     if ($op_password && strlen($op_password) < $gvMinPasswordLength) {
         $this->message = "Errore: la password deve contenere almeno " . "{$gvMinPasswordLength} caratteri.";
         return true;
     }
     if ($op_password !== $op_password_repete) {
         $this->message = "Errore: le password non coincidono.";
         return true;
     }
     // Allow only letters and digits in op_code
     if (preg_match('/^[0-9a-z]+$/i', $this->op_code) !== 1) {
         $this->message = "Errore: il codice operatore non è valido.";
         return true;
     }
     // Check name
     if (preg_match('/^[a-z \'àèéìòù]+$/i', $this->op_name) !== 1) {
         $this->message = "Errore: il nome contiene caratteri non validi.";
         return true;
     }
     // Check surname
     if (preg_match('/^[a-z \'àèéìòù]+$/i', $this->op_surname) !== 1) {
         $this->message = "Errore: il cognome contiene caratteri non validi.";
         return true;
     }
     // Check if code is taken for new operator
     $op = Operator::fromDatabaseByCode($this->op_code);
     if ($op && ($this->op_id === 0 || $this->op_id !== (int) $op->getId())) {
         $this->message = "Errore: il codice operatore non è disponibile.";
         return true;
     }
     unset($op);
     // Check operator is offline (only when edit)
     if ($this->op_id !== 0) {
         $operator = Operator::fromDatabaseById($this->op_id);
         if (!$operator) {
             $this->message = "Errore interno: il record non è presente.";
             return true;
         }
         if ($operator->isOnline()) {
             $this->message = "L'operatore è online, impossibile modificarlo.";
             return true;
         }
     }
     if ($this->op_id === 0) {
         $op = Operator::newRecord();
         $op->setCode($this->op_code);
         $op->setName($this->op_name);
         $op->setSurname($this->op_surname);
         $op->setPassword($op_password);
     } else {
         $op = Operator::fromDatabaseById($this->op_id);
         $op->setCode($this->op_code);
         $op->setName($this->op_name);
         $op->setSurname($this->op_surname);
         if ($op_password) {
             $op->setPassword($op_password);
         }
     }
     if ($op->save()) {
         gfSetDelayedMsg('Operazione effettuata correttamente', 'Ok');
         $redirect = new RedirectOutput("{$gvPath}/application/adminOperatorList");
         return $redirect;
     } else {
         $this->message = "Impossibile salvare le modifiche. Ritentare in seguito.";
         return true;
     }
 }
开发者ID:adntec,项目名称:queueManage,代码行数:84,代码来源:AdminOperatorEdit.php



注:本文中的Operator::newRecord方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。