/**
  * Проверяет данные перед регистрацией.
  * Ассигнирует шаблону данные для отображения ошибок
  * @return Boolean Всё ок?
  */
 protected function _verifyInputData($item = null)
 {
     $messages = array();
     $req = $this->getAllRequest();
     foreach ($req as $key => $value) {
         if (is_string($value)) {
             $req[$key] = stripslashes($value);
         }
     }
     if (!$item) {
         $item = new struct_core_users($req);
     } else {
         $item->MergeArrayToStruct($req);
     }
     $item->u_email = strip_tags($item->u_email);
     $item->u_fio = trim(strip_tags($item->u_fio));
     $item->u_login = trim(strip_tags($item->u_login));
     $this->setVar('u_pass1', trim(filter_var($this->request('u_pass1'), FILTER_SANITIZE_STRING)));
     $this->setVar('u_pass2', trim(filter_var($this->request('u_pass2'), FILTER_SANITIZE_STRING)));
     if (!php_mail_check($item->u_email)) {
         $messages[] = $this->lang('entervalidemail.session.error');
     } elseif (rad_instances::get('model_core_users')->emailExists($item->u_email)) {
         $messages[] = $this->lang('mailexsists.session.message');
     }
     if (empty($item->u_fio)) {
         $messages[] = $this->lang('emptyfio.session.error');
     }
     if (empty($item->u_login)) {
         $messages[] = $this->lang('emptylogin.session.error');
     } elseif (rad_instances::get('model_core_users')->loginExists($item->u_login)) {
         $messages[] = $this->lang('loginexists.session.error');
     }
     if (empty($item->u_pass) and $this->request('u_pass1')) {
         $item->u_pass = trim($this->request('u_pass1'));
     }
     if ($this->request('u_pass1') != $this->request('u_pass2')) {
         $messages[] = $this->lang('passwordsnotmatch.session.message');
     } elseif (mb_strlen($this->request('u_pass1')) < 6) {
         $messages[] = $this->lang('passwordishort.session.message');
     }
     if (count($messages)) {
         $this->setVar('message', implode('<br />', $messages));
         $this->setVar('action');
         return false;
     } else {
         return $item;
     }
 }
Beispiel #2
0
 function deleteItem(struct_core_users $struct = NULL)
 {
     if ($struct->getPrimaryKey()) {
         return $this->delete_struct($struct, RAD . 'users');
     }
     return 0;
 }
Beispiel #3
0
 /**
  * Save the user from request from AJAX form
  * @return JavaScript code
  */
 function saveUser()
 {
     if ($this->request('hash') == $this->hash()) {
         $u_id = (int) $this->request('u_id');
         if ($u_id) {
             $user = new struct_core_users($this->getAllRequest());
             $user->u_id = $u_id;
             if ($user->u_access < $this->getCurrentUser()->u_access) {
                 echo 'alert("can\'t edit user with rules more then yours");';
                 die;
             }
             $user->addFieldToIgnoresList('u_pass');
             $rows = rad_instances::get('model_core_users')->updateItem($user);
             if ($rows) {
                 echo 'RADUsers.message("' . addslashes($this->lang('updatedrows.sustem.message')) . ': ' . $rows . '");';
                 echo 'RADUsersTree.listUsers(RADUsersTree.getSID());';
             } else {
                 $this->badRequest();
             }
             echo 'RADUsers.cancelClick();';
         } else {
             $this->securityHoleAlert(__FILE__, __LINE__, $this->getClassName());
         }
     } else {
         $this->securityHoleAlert(__FILE__, __LINE__, $this->getClassName());
     }
 }