當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。