The followings are the available columns in table 'p2_adminuser':
Inheritance: extends ActiveRecord
Esempio n. 1
1
 public function actionLogout()
 {
     alog(at("User logged out."));
     AdminUser::model()->deleteAll('userid=:id', array(':id' => Yii::app()->user->id));
     Yii::app()->user->logout();
     fok(at('Thank You! You are now logged out.'));
     $this->redirect(array('/login'));
 }
    public function up()
    {
        $this->execute('CREATE TABLE `admin_user` (
			`id` int(11) NOT NULL AUTO_INCREMENT,
			`username` varchar(45) DEFAULT NULL,
			`password` varchar(255) DEFAULT NULL,
			`salt` varchar(255) DEFAULT NULL,
			`password_strategy` varchar(50) DEFAULT NULL,
			`requires_new_password` tinyint(1) DEFAULT NULL,
			`email` varchar(255) DEFAULT NULL,
			`login_attempts` int(11) DEFAULT NULL,
			`login_time` int(11) DEFAULT NULL,
			`login_ip` varchar(32) DEFAULT NULL,
			`validation_key` varchar(255) DEFAULT NULL,
			`create_id` int(11) DEFAULT NULL,
			`create_time` int(11) DEFAULT NULL,
			`update_id` int(11) DEFAULT NULL,
			`update_time` int(11) DEFAULT NULL,
			PRIMARY KEY (`id`),
			UNIQUE KEY `username` (`username`),
			UNIQUE KEY `email` (`email`)
		) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8');
        /* add demo users */
        $demoUser = new AdminUser();
        $demoUser->username = "******";
        $demoUser->email = "*****@*****.**";
        $demoUser->password = "******";
        $demoUser->save();
        $adminUser = new AdminUser();
        $adminUser->username = "******";
        $adminUser->email = "*****@*****.**";
        $adminUser->password = "******";
        $adminUser->save();
    }
Esempio n. 3
0
 /**
  * 退出登录
  *
  */
 public function dologout()
 {
     importModule("AdminUser.AdminUser");
     $adminuser = new AdminUser();
     $adminuser->Loginout();
     $this->app->redirect('index.php');
 }
 public function getUser()
 {
     if ($this->user != null) {
         return $this->user;
     }
     // for test
     $this->user = new GuestUser();
     try {
         if (isset($_COOKIE["ut"])) {
             if (isset($_COOKIE["uh"]) && isset($_COOKIE["ud"])) {
                 if ($_COOKIE["ut"] == UserGroups::$CARWASH) {
                     $user = new CarwashUser($_COOKIE["ud"]);
                 } else {
                     if ($_COOKIE["ut"] == UserGroups::$ADMIN) {
                         $user = new AdminUser($_COOKIE["ud"]);
                     }
                 }
             }
         }
         if (isset($user) && $user->validate($_COOKIE["uh"])) {
             $this->user = $user;
         }
         if ($this->user && $this->user->getLevel() != UserGroups::$GUEST) {
             $hash = $_COOKIE["uh"];
             $this->user->setUniqueId($hash, false);
         }
     } catch (InvalidUserException $ex) {
     }
     return $this->user;
 }
Esempio n. 5
0
 public function do_login()
 {
     $admin = new AdminUser();
     $admin->setArray($_POST);
     if ($admin->autenticate()) {
         Session::start($admin);
         header("Location: ?ID=packs");
     } else {
         header("Location: ?ID=login");
     }
 }
Esempio n. 6
0
 public function service()
 {
     $login = strtolower($this->secure($_REQUEST['login']));
     $password = $this->secure($_REQUEST['password']);
     $adminManager = new AdminManager($this->config, $this->args);
     $adminDto = $adminManager->getAdminByEmailAndPassword($login, $password);
     if (isset($adminDto)) {
         $user = new AdminUser($adminDto->getId());
         $user->setUniqueId($adminDto->getHash());
         $this->sessionManager->setUser($user, true, true);
     }
     $this->redirect('admin');
 }
 /**
  * @param AdminUser $admin
  * @return AdminUser
  */
 public function getToLogin(AdminUser $admin)
 {
     $statement = "SELECT id, name, username FROM user\r\n            WHERE username = :username AND password = :password LIMIT 1";
     $query = $this->session->prepare($statement);
     $query->bindParam(':username', $admin->username());
     $query->bindParam(':password', $admin->password());
     $query->execute();
     if ($query->rowCount() > 0) {
         $response = $query->fetch(PDO::FETCH_ASSOC);
         return new AdminUser($response['username'], $response['name'], null, $response['id']);
     }
     return null;
 }
Esempio n. 8
0
 public function authenticate()
 {
     if ($this->userType == 'Front') {
         $record = User::model()->findByAttributes(array('username' => $this->username));
         if ($record === null) {
             $this->errorCode = self::ERROR_USERNAME_INVALID;
         } else {
             if ($record->password !== $this->password) {
                 $this->errorCode = self::ERROR_PASSWORD_INVALID;
             } else {
                 $this->_id = $record->userId;
                 $this->setState('name', $record->firstName . ' ' . $record->lastName);
                 $this->errorCode = self::ERROR_NONE;
             }
         }
         return !$this->errorCode;
     }
     if ($this->userType == 'Back') {
         $record = AdminUser::model()->findByAttributes(array('email' => $this->username));
         if ($record === null) {
             $this->errorCode = self::ERROR_USERNAME_INVALID;
         } else {
             if ($record->password !== base64_encode($this->password)) {
                 $this->errorCode = self::ERROR_PASSWORD_INVALID;
             } else {
                 $this->setState('isAdmin', 1);
                 $this->_id = $record->userId;
                 $this->setState('name', $record->name);
                 $this->errorCode = self::ERROR_NONE;
             }
         }
         return !$this->errorCode;
     }
 }
Esempio n. 9
0
 public function authenticate()
 {
     $email = $_SERVER['PHP_AUTH_USER'];
     $password = $_SERVER['PHP_AUTH_PW'];
     if ($email == "" && $password == "") {
         list($email, $password) = explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
     }
     //Check if username or password aren't empty
     if ($email == "" || $password == "") {
         throw new Shineisp_Api_Exceptions(403001);
         exit;
     }
     // login the user by ACL
     $result = AdminUser::fastlogin($email, $password, 0);
     switch ($result->getCode()) {
         case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND:
             throw new Shineisp_Api_Exceptions(401001);
             break;
         case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID:
             /** do stuff for invalid credential **/
             throw new Shineisp_Api_Exceptions(401002);
             break;
         case Zend_Auth_Result::SUCCESS:
             return true;
         case Zend_Auth_Result::FAILURE:
         default:
             /** do stuff for other failure **/
             throw new Shineisp_Api_Exceptions(401001);
             break;
     }
     die;
 }
Esempio n. 10
0
 public function service()
 {
     $login = $this->secure($_REQUEST['login']);
     $password = $this->secure($_REQUEST['password']);
     $adminsManager = AdminsManager::getInstance();
     $adminDto = $adminsManager->getByLoginPassword($login, $password);
     if ($adminDto) {
         $adminUser = new AdminUser($adminDto->getId());
         $adminUser->setUniqueId($adminDto->getHash());
         $this->sessionManager->setUser($adminUser, true, true);
     } else {
         $_SESSION['error_message'] = 'Wrong Login/Password!';
         $this->redirect('admin/login');
     }
     $this->redirect('admin');
 }
Esempio n. 11
0
 /**
  * Save the permission
  * @param $id
  */
 public static function SaveAll($data, $id = null)
 {
     if (!empty($data) && is_array($data)) {
         if (is_numeric($id)) {
             $role = Doctrine::getTable('AdminRoles')->find($id);
         } else {
             $role = new AdminRoles();
         }
         // Save the role label
         if (!empty($data['name'])) {
             $role['name'] = Shineisp_Commons_UrlRewrites::format($data['name']);
             $role->save();
         }
         // Set the new Role ID to the users selected
         if (!empty($data['users'])) {
             foreach ($data['users'] as $user) {
                 AdminUser::setUserRoleID($user, $id);
             }
         }
         // Clear old permissions
         AdminPermissions::clearPermissionByRoleID($id);
         if (!empty($data['resources'])) {
             // Explode the string into an array
             $resources = explode("/", $data['resources']);
             // Add the new permissions
             foreach ($resources as $resource) {
                 list($module, $controller) = explode(':', $resource);
                 AdminPermissions::addPermission($id, $module, $controller);
             }
         }
         return $role;
     }
     return false;
 }
Esempio n. 12
0
 /**
  * Execute a manual cron process  
  */
 public function executeAction()
 {
     $resources = Shineisp_Commons_Layout::getData("system", null);
     $class_called = $this->getRequest()->getParam('class');
     $method_called = $this->getRequest()->getParam('method');
     $email = $this->getRequest()->getParam('email');
     $password = $this->getRequest()->getParam('password');
     if (empty($email) || empty($password)) {
         Shineisp_Commons_Utilities::log("Manual Start needs the administrator authentication", 'cron.log');
     }
     $result = AdminUser::fastlogin($email, $password, false);
     if (Zend_Auth_Result::SUCCESS == $result->getCode()) {
         $identity = $result->getIdentity();
         // Get the cron default configuration
         $xmlobject = $resources->xpath("cron/execute");
         if (count($xmlobject)) {
             foreach ($xmlobject as $cron) {
                 foreach ($cron as $code) {
                     $class = (string) $code['class'];
                     $method = (string) $code['method'];
                     $params = json_decode((string) $code['params']);
                     $log = (string) $code;
                     if ($class == $class_called && $method == $method_called) {
                         $this->execScript($class, $method, $params);
                         Shineisp_Commons_Utilities::log("Manual Start: {$log} by " . $identity['lastname'], 'cron.log');
                     }
                 }
             }
         }
     }
 }
Esempio n. 13
0
 /**
  * Logout action
  */
 public function actionLogout()
 {
     // Log Message
     alog(at("User logged out."));
     // Delete records for this users from admin logged in
     AdminUser::model()->deleteAll('userid=:id', array(':id' => Yii::app()->user->id));
     Yii::app()->user->logout();
     fok(at('Thank You! You are now logged out.'));
     $this->redirect(array('/admin/login'));
 }
Esempio n. 14
0
 public function init()
 {
     // Set the custom decorator
     $this->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator');
     $translate = Shineisp_Registry::get('Zend_Translate');
     $this->addElement('text', 'name', array('filters' => array('StringTrim'), 'decorators' => array('Bootstrap'), 'required' => true, 'label' => $translate->_('Role Name'), 'description' => $translate->_('Write here the name of the role in lowercase'), 'class' => 'form-control'));
     $this->addElement('multiselect', 'users', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Users'), 'title' => $translate->_('Select ...'), 'data-container' => 'body', 'data-selected-text-format' => 'count > 2', 'data-size' => 'auto', 'data-live-search' => 'true', 'class' => 'multiselect show-tick col-md-4'));
     $this->getElement('users')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(AdminUser::getList());
     $this->addElement('hidden', 'role_id');
 }
 /**
  * 取用户被授权的所有动作
  * @param type $userId
  */
 public function getAuthAssignments($userId)
 {
     if (empty($userId)) {
         return false;
     }
     $admin = AdminUser::model()->findByPk($userId);
     $actions = $admin->role->actions;
     if ($actions == '*') {
         return '*';
     }
     return explode(',', $actions);
 }
Esempio n. 16
0
 public function init()
 {
     $translate = Shineisp_Registry::get('Zend_Translate');
     $company = $this->addElement('text', 'company', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Company')));
     $firstname = $this->addElement('text', 'firstname', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Firstname')));
     $lastname = $this->addElement('text', 'lastname', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Lastname')));
     $contact = $this->addElement('select', 'type_id', array('label' => $translate->_('Contact')));
     $contact = $this->getElement('type_id')->setAllowEmpty(false)->setMultiOptions(AdminUser::getList())->setRequired(true);
     $email = $this->addElement('text', 'email', array('filters' => array('StringTrim', 'StringToLower'), 'validators' => array('EmailAddress'), 'required' => true, 'label' => $translate->_('Your email')));
     $password = $this->addElement('password', 'password', array('filters' => array('StringTrim'), 'validators' => array(array('regex', false, '/^[a-zA-Z0-9\\-\\_\\.\\%\\!\\$]{6,20}$/')), 'required' => true, 'label' => $translate->_('Password')));
     $id = $this->addElement('hidden', 'user_id');
     $this->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'dl', 'class' => 'user_form')), array('Description', array('placement' => 'prepend')), 'Form'));
 }
Esempio n. 17
0
 /**
  * @return Zend_Auth_Result
  */
 public function authenticate()
 {
     $result = AdminUser::checkCredencials($this->_identity, $this->_credential);
     if (is_array($result)) {
         return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $result);
     } elseif ($result === false) {
         return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, null);
     } elseif (is_null($result)) {
         return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND, null);
     } else {
         return new Zend_Auth_Result(Zend_Auth_Result::FAILURE, null);
     }
 }
Esempio n. 18
0
 public function init()
 {
     // Login required
     if (Yii::app()->getController()->id != 'login') {
         $returnUrl = Yii::app()->request->getUrl();
         if (strpos($returnUrl, '/admin') === false) {
             $returnUrl = array('/admin');
         }
         Yii::app()->user->setReturnUrl($returnUrl);
     }
     // Make sure we have access
     if (!Yii::app()->user->id || !checkAccess('admin')) {
         // Do we need to login
         if (!Yii::app()->user->id && Yii::app()->getController()->id != 'login') {
             $this->redirect(array('/admin/login'));
         }
         // Make sure we are not in login page
         if (Yii::app()->getController()->id != 'login') {
             throw new CHttpException(at('Sorry, You are not allowed to enter this section.'));
         }
     }
     // Make sure we have a valid admin user record
     if (Yii::app()->getController()->id != 'login' && Yii::app()->user->id && !AdminUser::model()->exists('userid=:id', array(':id' => Yii::app()->user->id))) {
         Yii::app()->user->logout();
         ferror(at('Your session expired. Please login.'));
         $this->redirect(array('/admin/login'));
     }
     // Check if we haven't clicked more then X amount of time
     $maxIdleTime = 60 * 60 * getParam('admin_logged_in_time', 5);
     // 5 hour default
     // Were we using an old session
     if (Yii::app()->getController()->id != 'login' && time() - $maxIdleTime > Yii::app()->session['admin_clicked']) {
         // Loguser out and redirect to login
         AdminUser::model()->deleteAll('userid=:id', array(':id' => Yii::app()->user->id));
         Yii::app()->user->logout();
         ferror(at('Your session expired. Please login.'));
         $this->redirect(array('/admin/login'));
     }
     // Delete old records
     AdminUser::model()->deleteAll('lastclick_time < :time', array(':time' => time() - $maxIdleTime));
     // Update only if this is not an ajax request
     if (!request()->isAjaxRequest) {
         // Update record info
         Yii::app()->session['admin_clicked'] = time();
         AdminUser::model()->updateAll(array('lastclick_time' => time(), 'location' => Yii::app()->getController()->id), 'userid=:id', array(':id' => Yii::app()->user->id));
     }
     // Add Breadcrumb
     $this->addBreadCrumb(at('Dashboard'), array('index/index'));
     parent::init();
 }
Esempio n. 19
0
 public static function checkLogin($username = '', $password = '')
 {
     $res = AdminUser::getItemByUsername($username);
     if (count($res)) {
         $res = $res[0];
         if (md5($password) == $res['passwd']) {
             $_SESSION['info'] = $res;
             return array('code' => 0, 'msg' => '成功');
         } else {
             return array('code' => 1, 'msg' => '密码错误');
         }
     } else {
         return array('code' => 0, 'msg' => '没有这个用户');
     }
 }
Esempio n. 20
0
 /**
  * Authenticates a user.
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $user = AdminUser::model()->find('LOWER(username)=?', array(strtolower($this->username)));
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if (!$user->validatePassword($this->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->_id = $user->id;
             $this->username = $user->username;
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return $this->errorCode == self::ERROR_NONE;
 }
Esempio n. 21
0
 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $user = AdminUser::model()->find(array('condition' => 'login = :l', 'params' => array(':l' => $this->username)));
     if (!$user) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($this->isPasswordValid($user)) {
             $this->user = $user;
             $this->errorCode = self::ERROR_NONE;
         } else {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         }
     }
     //		$this->errorCode = self::ERROR_NONE;
     return !$this->errorCode;
 }
Esempio n. 22
0
 public function actionDelete(array $ids)
 {
     foreach ($ids as $id) {
         $model = AdminUserGroup::model()->findByPk($id);
         if (is_null($model)) {
             errorHandler()->log(Yii::t('AdminUserGroup.Api', 'Admin User Group not found.'));
             continue;
         }
         if (AdminUser::model()->count('user_group_id=:groupId', array(':groupId' => $model->id)) > 0) {
             errorHandler()->log(Yii::t('AdminUserGroup.Api', 'This group has user. Cannot delete.'));
             continue;
         }
         $model->delete();
     }
     return $this->result;
 }
 /**
  * 锁屏
  */
 public function actionLock()
 {
     $user = Yii::app()->user;
     $userInfo = $user->getState('userInfo');
     if ($_POST) {
         $inputpwd = $_POST['passwd'];
         $n = $user->getState("userInfo");
         if (AdminUser::model()->encrypt($inputpwd) == $n['password']) {
             $user->setState('lock', false);
             $this->redirect(Yii::app()->createUrl('adminis/default/index'));
         }
     }
     $user->setState('lock', true);
     //   var_dump($_SESSION);
     $this->renderpartial("lock", array('userInfo' => $userInfo));
 }
Esempio n. 24
0
 /**
  * @param string $type [isp, operator] 
  * @return Zend_Auth_Result
  */
 public function authenticate($type = "isp")
 {
     if ($this->_type == "operator") {
         $result = AdminUser::checkOperatorCredencialsBySecretKey($this->_identity);
     } else {
         $result = AdminUser::checkIspCredencialsBySecretKey($this->_identity);
     }
     if (is_array($result)) {
         return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $result);
     } elseif ($result === false) {
         return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, null);
     } elseif (is_null($result)) {
         return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND, null);
     } else {
         return new Zend_Auth_Result(Zend_Auth_Result::FAILURE, null);
     }
 }
Esempio n. 25
0
 public function authenticate()
 {
     $username = strtolower($this->username);
     $adminUser = AdminUser::model()->find('username = :username and password = :password', array(':username' => $username, ':password' => AdminUser::model()->encrypt($this->password)));
     if ($username === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } elseif (!$adminUser) {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
     } elseif ($adminUser->attributes['disable'] == 1) {
         //用户账户
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
     } else {
         $this->_id = $adminUser->id;
         $this->username = $adminUser->username;
         $this->errorCode = self::ERROR_NONE;
     }
     return $this->errorCode === self::ERROR_NONE;
 }
 /**
  * Authenticates a user.
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     // 获取用户信息
     $user = AdminUser::getUserInfoByName($this->username);
     if ($user === false) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } elseif (!$user->validatePassword($this->password)) {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
     } else {
         $this->user_id = $user->id;
         $this->user_name = $user->username;
         Yii::app()->user->setState('user_id', $this->user_id);
         Yii::app()->user->setState('user_name', $this->user_name);
         // 更新用户最后登陆时间
         AdminUser::model()->updateByPk($user->id, array('last_time' => time(), 'last_ip' => Yii::app()->request->userHostAddress));
     }
     return $this->errorCode = self::ERROR_NONE;
 }
 public function authenticate()
 {
     if ($this->userType == 'Front') {
         // check if login details exists in database
         $userType = Yii::app()->user->getState("user_type");
         $user = User::model()->findByAttributes(array('email_id' => CHtml::encode($this->username), 'user_type' => $userType));
         Yii::app()->user->setState("user_type", null);
         if ($user === null) {
             $this->errorCode = self::ERROR_USERNAME_INVALID;
         } else {
             if ($user->password !== md5($this->password)) {
                 $this->errorCode = self::ERROR_PASSWORD_INVALID;
             } else {
                 $this->setState('user_id', $user->user_id);
                 //$this->setState('name', $user->first_name.' '.$user->last_name);
                 //$this->setState('userType', $user->user_type);
                 $this->errorCode = self::ERROR_NONE;
                 $this->setUser($user);
             }
         }
         unset($user);
         return !$this->errorCode;
     }
     if ($this->userType == 'admin') {
         // check if login details exists in database
         $record = AdminUser::model()->findByAttributes(array('email' => $this->username));
         // here I use Email as user name which comes from database
         if ($record === null) {
             $this->errorCode = self::ERROR_USERNAME_INVALID;
         } else {
             if ($record->password !== $this->password) {
                 $this->errorCode = self::ERROR_PASSWORD_INVALID;
             } else {
                 $this->setState('isAdmin', 1);
                 $this->setState('userId', $record->userId);
                 $this->setState('name', $record->firstName . ' ' . $record->lastName);
                 $this->setUser($record);
                 $this->errorCode = self::ERROR_NONE;
             }
         }
         unset($record);
         return !$this->errorCode;
     }
 }
Esempio n. 28
0
 public function init()
 {
     // Set the custom decorator
     $this->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator');
     $translate = Shineisp_Registry::get('Zend_Translate');
     $this->addElement('text', 'subject', array('filters' => array('StringTrim'), 'required' => false, 'decorators' => array('Bootstrap'), 'label' => $translate->_('Subject'), 'class' => 'form-control'));
     $this->addElement('text', 'datetime', array('filters' => array('StringTrim'), 'label' => $translate->_('Date'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->addElement('textarea', 'note', array('filters' => array('StringTrim'), 'class' => 'col-lg-12 form-control wysiwyg'));
     $this->addElement('select', 'sendemail', array('label' => $translate->_('Send Email'), 'description' => $translate->_('Send an email to the customer.'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'multioptions' => array('1' => $translate->_('Yes'), '0' => $translate->_('No'))));
     $this->addElement('select', 'category_id', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Category'), 'class' => 'form-control'));
     $this->getElement('category_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(TicketsCategories::getList());
     $this->addElement('select', 'customer_id', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Customer'), 'class' => 'form-control'));
     $this->getElement('customer_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(Customers::getList());
     $this->addElement('select', 'category', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Category'), 'class' => 'form-control'));
     $this->getElement('category')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(TicketsCategories::getList());
     $this->addElement('select', 'order_id', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Order reference'), 'class' => 'form-control'));
     $this->getElement('order_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(Orders::getList(true));
     $this->addElement('select', 'sibling_id', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Relationships'), 'class' => 'form-control'));
     $this->getElement('sibling_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false);
     $this->addElement('select', 'user_id', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Operator'), 'class' => 'form-control'));
     $this->getElement('user_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(AdminUser::getList());
     #->setMultiOptions(AdminUser::getUserbyRoleID(AdminRoles::getIdRoleByName('operator')));
     $this->addElement('select', 'status_id', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Status'), 'class' => 'form-control'));
     $this->getElement('status_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(Statuses::getList('tickets'));
     // If the browser client is an Apple client hide the file upload html object
     if (false == Shineisp_Commons_Utilities::isAppleClient()) {
         $MBlimit = Settings::findbyParam('adminuploadlimit');
         $Types = Settings::findbyParam('adminuploadfiletypes', 'Admin');
         if (empty($MBlimit)) {
             $MBlimit = 1;
         }
         if (empty($Types)) {
             $Types = "zip,jpg";
         }
         $Byteslimit = Shineisp_Commons_Utilities::MB2Bytes($MBlimit);
         $file = $this->createElement('file', 'attachments', array('label' => $translate->_('Attachment'), 'decorators' => array('File', array('ViewScript', array('viewScript' => 'partials/file.phtml', 'placement' => false))), 'description' => $translate->_('Select the document to upload. Files allowed are (%s) - Max %s', $Types, Shineisp_Commons_Utilities::formatSizeUnits($Byteslimit)), 'data-classButton' => 'btn btn-primary', 'data-input' => 'false', 'class' => 'filestyle'));
         $file->addValidator('Extension', false, $Types)->addValidator('Size', false, $Byteslimit)->addValidator('Count', false, 1);
         $this->addElement($file);
     } else {
         $this->addElement('hidden', 'attachments');
     }
     $this->addElement('hidden', 'ticket_id');
 }
Esempio n. 29
0
 public function login($params = [])
 {
     Session::$error = FALSE;
     $email = isset($_POST['email']) ? $_POST['email'] : '';
     $password = isset($_POST['password']) ? $_POST['password'] : '';
     $user = AdminUser::read_one($params['email']);
     if (!isset($user['username'])) {
         header('Location: https://www.winwrap.com/web/basic/support/login.asp?A=' . urlencode($email) . '&P=' . urlencode($password));
     } else {
         if (isset($_POST['email'])) {
             Session::$error = Session::authorize_admin($email, $password);
         }
         if (Session::$error) {
             Render::php(HTML . 'login.php');
         } else {
             header('Location: ' . SUBDIR . '/md/doc-editor');
         }
     }
 }
Esempio n. 30
0
 /**
  * Authenticates username and password
  * @return boolean CUserIdentity::ERROR_NONE if successful authentication
  */
 public function authenticate()
 {
     $attribute = strpos($this->username, '@') ? 'email' : 'username';
     $user = AdminUser::model()->find(array('condition' => $attribute . '=:loginname', 'params' => array(':loginname' => $this->username)));
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if (!$user->verifyPassword($this->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $user->regenerateValidationKey();
             $this->_id = $user->id;
             $this->username = $user->username;
             $this->setState('vkey', $user->validation_key);
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return !$this->errorCode;
 }