当前位置: 首页>>代码示例>>PHP>>正文


PHP Account::model方法代码示例

本文整理汇总了PHP中Account::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Account::model方法的具体用法?PHP Account::model怎么用?PHP Account::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Account的用法示例。


在下文中一共展示了Account::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: authenticate

 public function authenticate()
 {
     $record = Account::model()->findByAttributes(array('Username' => $this->username));
     if ($record === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($record->Pass !== $this->password) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->_id = $record->Id;
             $this->setState('role', $record->Role);
             $this->setState('fullname', $record->Fullname);
             $this->setState('my_infrastructureid', '');
             $this->setState('my_infrastructurename', '');
             $record->LastLogin = new CDbExpression('NOW()');
             $record->save();
             /*
             foreach ($record->mikrotiks as $mikrotik){
                 $my_mikrotik[$mikrotik->m_id] = $mikrotik->m_name;
                 if($record->m_id==0){
                     $record->m_id = $mikrotik->m_id;
                     $record->save(); 
                 }
             }
             $this->setState('my_mikrotik',$my_mikrotik);
             $this->setState('my_mikrotikid', $record->m_id);
             */
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return !$this->errorCode;
 }
开发者ID:phainamikaze,项目名称:miza,代码行数:32,代码来源:UserIdentity.php

示例2: getModel

 private function getModel()
 {
     if (!$this->isGuest && $this->_model === null) {
         $this->_model = Account::model()->findByAttributes($this->memb___id, array('select' => 'status'));
     }
     return $this->_model;
 }
开发者ID:smokeelow,项目名称:faicore,代码行数:7,代码来源:WebUser.php

示例3: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     if (isset($_POST['Message'])) {
         $toUsers = explode(',', $_POST['toUsers']);
         $arrUserIds = array();
         foreach ($toUsers as $toUser) {
             $username = trim(strtok(trim($toUser), '-'));
             $user = Account::model()->findByAttributes(array('username' => $username));
             if ($user && $user->getPrimaryKey() != $this->viewer->getPrimaryKey()) {
                 $arrUserIds = array_merge($arrUserIds, array($user->getPrimaryKey()));
             }
         }
         if (!empty($arrUserIds)) {
             foreach ($arrUserIds as $userId) {
                 $model = new Message();
                 $model->subject = $_POST['Message']['subject'];
                 $model->message = $_POST['Message']['message'];
                 $model->id_from = $this->viewer->getPrimaryKey();
                 $model->id_user = $userId;
                 $model->save();
             }
         }
         Yii::app()->user->setFlash('message', Yii::t('flexiblearn', 'Your message is sent successfully !!!'));
         $this->redirect(array('manage'));
     }
     Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/js/jquery.autocomplete-min.js');
     Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl . '/stylesheet/autocomplete.css');
     $this->render('create', array('model' => new Message()));
 }
开发者ID:laiello,项目名称:flexiblearning,代码行数:33,代码来源:MessageController.php

示例4: actionIndex

 function actionIndex()
 {
     $account = Account::model()->findByPk(Yii::app()->user->id);
     $restrict_arr = unserialize($account['Restrict']);
     $munu_list = MenuList::getMenuListByMenuNumStr($restrict_arr);
     $this->renderPartial('home', array('menu_list' => $munu_list));
 }
开发者ID:lovecheng,项目名称:brs-demo2,代码行数:7,代码来源:HomeController.php

示例5: actionMylist

 public function actionMylist()
 {
     if (false) {
         $this->redirect(Yii::app()->baseUrl . '/login');
     }
     $msgInfo = "none";
     $msgError = "none";
     if (!empty($_POST) && $_POST['action'] == "create") {
         //if(AccountInfrastructure::model()->findByAttributes(array(''=>$_REQUEST['infraname']))
         $newinfra = new Infrastructure();
         $newinfra->Name = $_POST['infraname'];
         $newinfra->Device = 1;
         if ($newinfra->save()) {
             $newAcctInfra = new AccountInfrastructure();
             $newAcctInfra->Account_Id = Yii::app()->user->getId();
             $newAcctInfra->Infrastructure_Id = $newinfra->Id;
             $newAcctInfra->IsOnwer = 1;
             if ($newAcctInfra->save()) {
                 $msgInfo = "Create the Infrastructure Successfully";
             } else {
                 print_r($newAcctInfra->errors);
             }
         } else {
             print_r($newinfra->errors);
         }
     }
     $myaccount = Account::model()->findByPk(Yii::app()->user->getId());
     $this->renderPartial('mylist', array('msgError' => $msgError, 'msgInfo' => $msgInfo, 'infralist' => $myaccount));
 }
开发者ID:phainamikaze,项目名称:miza,代码行数:29,代码来源:InfrastructureController.php

示例6: 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 = Account::model()->find('UserName=:name', array(':name' => $this->username));
     //如果用户名不存在
     if ($user_model === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
         return false;
     } else {
         if ($user_model->Valid == 0 || $user_model->PassWord !== md5($this->password)) {
             //密码判断
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
             return false;
         } else {
             $this->_id = $user_model->ID;
             $this->_name = $user_model->RealName;
             $this->errorCode = self::ERROR_NONE;
             return true;
         }
     }
 }
开发者ID:lovecheng,项目名称:brs-demo2,代码行数:33,代码来源:UserIdentity.php

示例7: 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()
 {
     //        $users=array(
     //                // username => password
     //                'demo'=>'demo',
     //                'admin'=>'admin',
     //        );
     //        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;
     $account = Account::model()->find('Username=:Username', array('Username' => $this->username));
     if ($account === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if (isset($account->Password) && $account->Password != $this->password) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->errorCode = self::ERROR_NONE;
             Yii::app()->user->setState('idAccount', $account->ID);
             $user = Users::model()->find('ID_Account=:id', array('id' => $account->ID));
             Yii::app()->user->setState('idUser', $user->ID);
         }
     }
     return !$this->errorCode;
 }
开发者ID:vuvankhai,项目名称:itplus,代码行数:37,代码来源:UserIdentity.php

示例8: actionIndex

 public function actionIndex()
 {
     $db = Account::model()->getDbConnection();
     $total = $db->createCommand("SELECT SUM(amount) FROM account")->queryScalar();
     $criteria = new CDbCriteria();
     $criteria->order = "id DESC";
     $criteria->limit = 5;
     $articles = Article::model()->findAll($criteria);
     $this->render('index', array('total' => $total, 'articles' => $articles));
 }
开发者ID:moohwaan,项目名称:yii-application-cookbook-2nd-edition-code,代码行数:10,代码来源:DashboardController.php

示例9: getModel

 public function getModel()
 {
     if (!isset($this->id)) {
         $this->model = new Account();
     }
     if ($this->model === null) {
         $this->model = Account::model()->findByPk($this->id);
     }
     return $this->model;
 }
开发者ID:Lucerin,项目名称:Yii-projects,代码行数:10,代码来源:WebUser.php

示例10: init

 public function init()
 {
     $eventHandler = array($this, 'deletePersonsOrAccountsItems');
     Contact::model()->attachEventHandler('onAfterDelete', $eventHandler);
     $this->attachedEventHandlersIndexedByModelClassName['Contact'] = array('onAfterDelete', $eventHandler);
     User::model()->attachEventHandler('onAfterDelete', $eventHandler);
     $this->attachedEventHandlersIndexedByModelClassName['User'] = array('onAfterDelete', $eventHandler);
     Account::model()->attachEventHandler('onAfterDelete', $eventHandler);
     $this->attachedEventHandlersIndexedByModelClassName['Account'] = array('onAfterDelete', $eventHandler);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:10,代码来源:EmailMessagesObserver.php

示例11: actionValidEmail

 public function actionValidEmail()
 {
     $record = Account::model()->findByAttributes(array('Email' => $_REQUEST['email']));
     $count = count($record);
     if ($count === 0) {
         $output = true;
     } else {
         $output = false;
     }
     echo json_encode($output);
 }
开发者ID:phainamikaze,项目名称:miza,代码行数:11,代码来源:UserController.php

示例12: authenticate

 public function authenticate()
 {
     if (!($user = Account::model()->findByAttributes(['email' => $this->username]))) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } elseif (!$user->checkPass($this->password)) {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
     } else {
         $this->_id = $user->id;
         $this->setState('timezone', $user->getAttribute('timezone'));
         $this->errorCode = self::ERROR_NONE;
     }
     return !$this->errorCode;
 }
开发者ID:Allgood07,项目名称:diplom,代码行数:13,代码来源:UserIdentity.php

示例13: init

 public function init()
 {
     // register class paths for extension captcha extended
     Yii::$classMap = array_merge(Yii::$classMap, array('CaptchaExtendedAction' => Yii::getPathOfAlias('ext.captchaExtended') . DIRECTORY_SEPARATOR . 'CaptchaExtendedAction.php', 'CaptchaExtendedValidator' => Yii::getPathOfAlias('ext.captchaExtended') . DIRECTORY_SEPARATOR . 'CaptchaExtendedValidator.php'));
     $this->unreadReceivedMessagesCount = Yii::app()->db->createCommand()->select('count(*)')->from('message')->where(array('and', 'id_user = :id', 'is_read = 0'), array('id' => Yii::app()->user->getId()))->queryScalar();
     $this->viewer = null;
     if (!Yii::app()->user->getIsGuest()) {
         $this->viewer = Account::model()->findByPk(Yii::app()->user->getId());
     }
     $params = $this->getActionParams();
     if (!empty($params) && array_key_exists('code', $params) && $params['code']) {
         Yii::app()->setLanguage($params['code']);
     }
 }
开发者ID:laiello,项目名称:flexiblearning,代码行数:14,代码来源:Controller.php

示例14: actionIndex

 function actionIndex()
 {
     $login_model = new LoginForm();
     if (isset($_POST['LoginForm'])) {
         $login_model->attributes = $_POST['LoginForm'];
         //用户名和密码(包括真实性)判断validate,持久化session信息login
         if ($login_model->validate() && $login_model->login()) {
             Account::model()->updateByPk(Yii::app()->user->id, array('LastLoginTime' => date('Y-m-d H:i:s', time()), 'LastLoginIp' => Yii::app()->request->userHostAddress));
             // 更新最后登录时间与IP
             $this->redirect(Yii::app()->createUrl('Home/Index'));
         }
     }
     //调用模板
     $this->renderPartial('index', array('login_model' => $login_model));
 }
开发者ID:lovecheng,项目名称:brs-demo2,代码行数:15,代码来源:IndexController.php

示例15: login

 /**
  * Logs in the user using the given username and password in the model.
  * @return boolean whether login is successful
  */
 public function login()
 {
     if ($this->_identity === null) {
         $this->_identity = new UserIdentity($this->username, $this->password);
         $this->_identity->authenticate();
     }
     if ($this->_identity->errorCode === UserIdentity::ERROR_NONE) {
         $duration = $this->rememberMe ? 3600 * 24 * 30 : 0;
         // 30 days
         Yii::app()->user->login($this->_identity, $duration);
         Account::model()->updateByPk($this->_identity->id, array('last_login' => new CDbExpression('NOW()'), 'ip_add' => Yii::app()->getRequest()->getUserHostAddress()));
         return true;
     } else {
         return false;
     }
 }
开发者ID:laiello,项目名称:flexiblearning,代码行数:20,代码来源:LoginForm.php


注:本文中的Account::model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。