Esempio n. 1
0
 public function onsubmit($sender)
 {
     $this->setError('');
     if ($this->_login == '') {
         $this->setError('Введите логин');
     } else {
         if ($this->_password == '') {
             $this->setError('Введите пароль');
         } else {
             if ($this->_confirm == '') {
                 $this->setError('Подтвердите пароль');
             } else {
                 if ($this->_confirm != $this->_password) {
                     $this->setError('Неверное подтверждение');
                 } else {
                     if ($user = Helper::login($this->_login) != false) {
                         $this->setError('Логин уже существует');
                     }
                 }
             }
         }
     }
     if (!$this->isError()) {
         $user = new User();
         $user->userlogin = $this->_login;
         $user->userpass = \password_hash($this->_password, PASSWORD_DEFAULT);
         $user->Save();
         App::Redirect('\\ZippyERP\\System\\Pages\\UserInfo', $user->user_id);
     }
     $this->_confirm = '';
     $this->_password = '';
 }
Esempio n. 2
0
 public function __construct($id)
 {
     parent::__construct($id);
     $form = new \Zippy\Html\Panel('welcomform');
     $form->add(new Label('username'));
     $form->add(new ClickLink('logout', $this, 'LogoutClick'));
     $this->add($form);
     $form->add(new Label('adminmenu', ''));
     if ($_COOKIE['remember'] && System::getUser()->user_id == 0) {
         $arr = explode('_', $_COOKIE['remember']);
         $_config = parse_ini_file(_ROOT . 'config/config.ini', true);
         if ($arr[0] > 0 && $arr[1] === md5($arr[0] . $_config['common']['salt'])) {
             $user = User::load($arr[0]);
         }
         if ($user instanceof User) {
             System::setUser($user);
             $_SESSION['user_id'] = $user->user_id;
             //для  использования  вне  Application
             $_SESSION['userlogin'] = $user->userlogin;
             //для  использования  вне  Application
             //   @mkdir(_ROOT . UPLOAD_USERS .$user->user_id) ;
             //  \ZippyERP\System\Util::removeDirRec(_ROOT . UPLOAD_USERS .$user->user_id.'/tmp') ;
             //   @mkdir(_ROOT .UPLOAD_USERS .$user->user_id .'/tmp') ;
         }
     }
 }
Esempio n. 3
0
 public function __construct($user_id)
 {
     parent::__construct();
     $this->user = \ZippyERP\System\User::load($user_id);
     $this->add(new Label('login', $this->user->userlogin));
     $this->add(new Label('createdate', date('Y-m-d', $this->user->registration_date)));
     $this->add(new Label('userroles', 'Зарегистрировнный пользователь'));
     $this->add(new \Zippy\Html\Form\Form('roleform'))->setVisible(System::getUser()->userlogin == 'admin');
     $this->roleform->add(new \Zippy\Html\DataList\DataView("rolerow", new \ZCL\DB\EntityDataSource('\\ZippyERP\\System\\Role'), $this, 'OnAddRoleRow'))->Reload();
     $this->roleform->setSubmitHandler($this, 'OnSubmit');
 }
Esempio n. 4
0
 public function saveOnClick($sender)
 {
     $this->_employee->contact_id = $this->employeedetail->editcontact->getKey();
     if ($this->_employee->contact_id == 0) {
         $this->setError("Выберите контакт");
         return;
     }
     $this->_employee->position_id = $this->employeedetail->editposition->getValue();
     $this->_employee->department_id = $this->employeedetail->editdepartment->getValue();
     $login = trim($this->employeedetail->editlogin->getText());
     if (strlen($login) > 0) {
         if ($login == "admin") {
             $this->setError('Недопустимое значение логина');
             return;
         }
         $_emp = Employee::getFirst("login = '******'");
         if ($_emp != null && $_emp->employee_id != $this->_employee->employee_id) {
             $this->setError('Логин  занят сотрудником ' . $_emp->getInitName());
             return;
         }
         $user = \ZippyERP\System\User::getByLogin($login);
         if ($user == null) {
             $this->setError('Несуществующий логин');
             return;
         }
     }
     $this->_employee->login = $login;
     $this->_employee->Save();
     $this->employeedetail->setVisible(false);
     $this->employeetable->setVisible(true);
     $this->employeetable->employeelist->Reload();
     $this->contactdetail->setVisible(false);
     $this->contactview->setVisible(false);
 }
Esempio n. 5
0
 /**
  * Возвращает  пользователя   по  хешу
  * 
  * @param mixed $md5hash
  */
 public static function getByHash($md5hash)
 {
     $conn = \ZCL\DB\DB::getConnect();
     $arr = User::find('md5hash=' . Entity::qstr($md5hash));
     if (count($arr) == 0) {
         return null;
     }
     $arr = array_values($arr);
     return $arr[0];
 }
Esempio n. 6
0
 public function getItem($id)
 {
     return User::load($id);
 }
Esempio n. 7
0
 /**
  * Проверка  существования логина
  * 
  * @param mixed $login
  */
 public static function existsLogin($login)
 {
     $list = \ZippyERP\System\User::find("  userlogin='******' ");
     return count($list) > 0;
 }