當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Manager::model方法代碼示例

本文整理匯總了PHP中Manager::model方法的典型用法代碼示例。如果您正苦於以下問題:PHP Manager::model方法的具體用法?PHP Manager::model怎麽用?PHP Manager::model使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Manager的用法示例。


在下文中一共展示了Manager::model方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: authenticate

 /**
  * 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()
 {
     //在這個地方來校驗用戶名和密碼的真實性
     //首先來看看是否有此用戶名存在
     //find() 如果沒有查詢出來數據,則會返回null
     //findAll()  空數據會返回空數組
     //根據用戶名查詢是否有一個用戶信息
     $user_model = Manager::model()->find('username=:name', array(':name' => $this->username));
     //如果用戶名不存在
     if ($user_model === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
         return false;
     } else {
         if ($user_model->password !== $this->password) {
             //密碼判斷
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
             return false;
         } else {
             $this->errorCode = self::ERROR_NONE;
             return true;
         }
     }
     //		if(!isset($users[$this->username]))
     //			$this->errorCode=self::ERROR_USERNAME_INVALID;
     //		elseif($users[$this->username]!==$this->password)
     //			$this->errorCode=self::ERROR_PASSWORD_INVALID;
     //		else
     //			$this->errorCode=self::ERROR_NONE;
     //		return !$this->errorCode;
 }
開發者ID:Justes,項目名稱:learnyii,代碼行數:38,代碼來源:UserIdentity.php

示例2: getManager

 public function getManager($useCached = TRUE)
 {
     if ($useCached || is_null($this->manager)) {
         $this->manager = Manager::model()->findByPk($this->id);
     }
     return $this->manager;
 }
開發者ID:kinghinds,項目名稱:kingtest2,代碼行數:7,代碼來源:WebUser.php

示例3: actionView

 public function actionView($username = null)
 {
     if ($model = Manager::model()->find('username=:username', array(':username' => $username))) {
         $this->render('view', array('model' => $model));
     } else {
         throw new CHttpException(400, 'Такой страницы нет');
     }
 }
開發者ID:BGCX261,項目名稱:zoomtyre-svn-to-git,代碼行數:8,代碼來源:ManagersController.php

示例4: validatePassword

 public function validatePassword($attribute, $params)
 {
     if (!$this->hasErrors($attribute)) {
         $count = Manager::model()->countByAttributes(array('manager_id' => Yii::app()->user->id, 'login_password' => md5($this->{$attribute})));
         // if(!Yii::app()->db->createCommand('SELECT COUNT(*) FROM {{manager}} WHERE id=? AND login_password=?')->queryScalar(array(Yii::app()->user->id,md5($this->$attribute))))
         if ($count <= 0) {
             $this->addError($attribute, '原密碼錯誤');
         }
     }
 }
開發者ID:kinghinds,項目名稱:kingtest2,代碼行數:10,代碼來源:UpdatePasswordForm.php

示例5: authenticate

 public function authenticate()
 {
     $model = Manager::model()->findByAttributes(array('login_name' => $this->username));
     if (is_null($model)) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } elseif (!$this->_checkPassword($this->password, $model->login_password)) {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
     } elseif (!$model->is_allow_login) {
         $this->errorCode = self::ERROR_DENY_LOGIN;
     } else {
         $this->id = $model->primaryKey;
         $this->errorCode = self::ERROR_NONE;
     }
     return !$this->errorCode;
 }
開發者ID:kinghinds,項目名稱:kingtest2,代碼行數:15,代碼來源:ManagerIdentity.php

示例6: run

 public function run()
 {
     if (Yii::app()->request->isAjaxRequest && isset($_GET['q'])) {
         $tag = Yii::app()->request->getParam('q', '');
         $limit = Yii::app()->request->getParam('limit', 50);
         $limit = min($limit, 50);
         $criteria = new CDbCriteria();
         $criteria->condition = "username LIKE :sterm";
         $criteria->params = array(":sterm" => "%{$tag}%");
         $criteria->limit = $limit;
         $tagArray = Manager::model()->findAll($criteria);
         $returnVal = '';
         foreach ($tagArray as $tagValue) {
             $returnVal .= $tagValue->getAttribute('username') . '|' . $tagValue->getAttribute('username') . "\n";
         }
         echo $returnVal;
     }
 }
開發者ID:BGCX261,項目名稱:zoomtyre-svn-to-git,代碼行數:18,代碼來源:ajaxAutocompleteManagersAction.php

示例7: run

 public function run()
 {
     $category = array();
     $menus = array();
     $category['stat'] = '訪客統計';
     $menus['stat'][] = array('訪問統計', '/admin/stat/visit');
     $menus['stat'][] = array('三方統計', 'http://tongji.baidu.com/web/welcome/ico?s=17978066889cd84953900994ae849d62');
     $category['sys'] = '係統管理';
     $menus['sys'][] = array('用戶列表', '/admin/manager/index');
     $menus['sys'][] = array('係統設置', '/admin/system/setting');
     // current codes is check up the special privileges and remove it.
     $manager_sp = Manager::model()->sp();
     if (!empty($manager_sp)) {
         $self_sp_controllers = Yii::app()->user->getSp();
         $manager_sp_controller = array_keys($manager_sp);
         foreach ($menus as $one_level_key => $one_level_value) {
             foreach ($one_level_value as $two_level_key => $two_level_value) {
                 $tmp_controller = explode('/', $two_level_value[1]);
                 if (!empty($tmp_controller[2]) && in_array($tmp_controller[2], $manager_sp_controller) && !in_array($tmp_controller[2], $self_sp_controllers)) {
                     unset($menus[$one_level_key][$two_level_key]);
                 }
             }
         }
         foreach ($category as $key => $value) {
             if (empty($menus[$key])) {
                 unset($category[$key]);
             }
         }
     }
     // over
     $c = $this->controller->id;
     $a = $this->controller->action->id;
     $ac = '';
     $am = '';
     foreach ($menus as $ck => $ms) {
         foreach ($ms as $m) {
             if ('/admin/' . $c . '/' . $a == $m[1]) {
                 $ac = $ck;
                 $am = '/admin/' . $c . '/' . $a;
             }
         }
     }
     $this->render("NavList", compact('category', 'menus', 'c', 'a', 'ac', 'am'));
 }
開發者ID:zt123,項目名稱:Base-System,代碼行數:44,代碼來源:NavListWidget.php

示例8: visitCheck

 /**
  * 校驗訪問權限
  * @return [type] [description]
  */
 private function visitCheck()
 {
     $this->rule['guest'] = array('manager' => array('login', 'logout'), 'site' => array('verify'));
     if (Yii::app()->user->getIsGuest()) {
         if (empty($this->rule['guest'][$this->controller_id]) || !in_array($this->action_id, $this->rule['guest'][$this->controller_id])) {
             $this->showMessage('請先登陸', '/admin/manager/login');
         }
     } else {
         if (empty($this->rule['guest'][$this->controller_id]) || !in_array($this->action_id, $this->rule['guest'][$this->controller_id])) {
             $manager_sp = Manager::model()->sp();
             if (!empty($manager_sp)) {
                 $manager_sp_controllers = array_keys($manager_sp);
                 $self_sp_controllers = Yii::app()->user->getSp();
                 if (in_array($this->controller_id, $manager_sp_controllers) && !in_array($this->controller_id, $self_sp_controllers)) {
                     throw new CHtteException(404);
                 }
             }
         }
     }
 }
開發者ID:zt123,項目名稱:Base-System,代碼行數:24,代碼來源:BController.php

示例9: authenticate

 public function authenticate()
 {
     $manager = Manager::model()->getArrByAttributes(array('name' => $this->name));
     if (empty($manager)) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($manager['status'] != Manager::MAN_STATUS_NORMAL) {
             $this->errorCode = self::ERROR_USERNAME_INVALID;
         } else {
             if (McryptComponent::decryption($manager['passwd']) != $this->password) {
                 $this->errorCode = self::ERROR_PASSWORD_INVALID;
             } else {
                 $this->errorCode = self::ERROR_NONE;
                 $this->id = $manager['id'];
                 $this->sp = $manager['sp'];
             }
         }
     }
     return !$this->errorCode;
 }
開發者ID:zt123,項目名稱:Base-System,代碼行數:20,代碼來源:ManagerIdentity.php

示例10: actionLogin

 public function actionLogin()
 {
     session_start();
     //獲得表單提交的數據
     $userName = $_POST["userName"];
     $password = $_POST["password"];
     $checkCode = $_POST["checkCode"];
     $trueCode = $_SESSION["trueCode"];
     //登陸驗證
     if ($checkCode != $trueCode) {
         $this->redirect(__APP__ . "/success/index/act/login/rst/0");
     } else {
         $userInfo = Manager::model()->find("userName='{$userName}' and password='{$password}'");
         if ($userInfo == NULL) {
             $this->redirect(__APP__ . "/success/index/act/login/rst/1");
         } else {
             $_SESSION["userMsg"] = $userInfo;
             $this->redirect(__APP__ . "/success/index/act/login/rst/2");
         }
     }
 }
開發者ID:denson7,項目名稱:phpstudy,代碼行數:21,代碼來源:IndexController.php

示例11: actionDelete

 public function actionDelete()
 {
     if (Yii::app()->user->getIsSuperUser() == false && Yii::app()->user->checkAccess('deleteManager') == false) {
         throw new CHttpException(403);
     }
     $id = Yii::app()->request->getQuery('id');
     $manager = Manager::model()->findByPk($id);
     if (is_null($manager)) {
         throw new CHttpException(403);
     }
     if ($manager->is_admin) {
         throw new CHttpException(403, strtr('管理員{name}為默認係統管理員, 不允許被刪除.', array('{name}' => $manager->login_name)));
     }
     $flag = $manager->delete();
     ManagerLog::logCurrentUserAction($flag, '刪除管理員', $manager->login_name);
 }
開發者ID:kinghinds,項目名稱:kingtest2,代碼行數:16,代碼來源:ManagerController.php

示例12: actionPassword

 public function actionPassword()
 {
     $model = new UpdatePasswordForm();
     if (isset($_POST['UpdatePasswordForm'])) {
         $model->attributes = Yii::app()->request->getPost('UpdatePasswordForm');
         if ($model->validate()) {
             Manager::model()->updateByPk(Yii::app()->user->id, array('login_password' => md5($model->new_password)));
             $this->setFlashMessage('您的密碼已更新, 新密碼已生效');
             $this->redirect($this->getReturnUrl());
         }
     }
     $this->breadcrumbs = array('修改密碼');
     $this->render('password', array('model' => $model, 'returnUrl' => $this->getReturnUrl()));
 }
開發者ID:kinghinds,項目名稱:kingtest2,代碼行數:14,代碼來源:SiteController.php

示例13: actionDelete

 public function actionDelete()
 {
     $id = Yii::app()->request->getQuery('id');
     print_r($id);
     print_r(Yii::app()->session['manager_id']);
     if ($id == Yii::app()->session['manager_id']) {
         $this->showError('不能對自己進行該操作');
     } else {
         $status = Manager::model()->deleteById($id);
         if ($status) {
             $this->showSuccess('刪除操作成功');
         } else {
             $this->showError('刪除操作失敗');
         }
     }
     $this->redirect('/admin/manager/index');
 }
開發者ID:zt123,項目名稱:Base-System,代碼行數:17,代碼來源:ManagerController.php

示例14: loadModel

 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Manager::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'Запрашиваемая страница не существует.');
     }
     return $model;
 }
開發者ID:BGCX261,項目名稱:zoomtyre-svn-to-git,代碼行數:13,代碼來源:ManagersController.php


注:本文中的Manager::model方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。