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


PHP UserRole::model方法代码示例

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


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

示例1: selectAllByUserId

 public function selectAllByUserId($id)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = 'user_id=:id';
     $criteria->params = array(':id' => $id);
     return UserRole::model()->findAll($criteria);
 }
开发者ID:vasia-ostapchuk,项目名称:source,代码行数:7,代码来源:UserRole.php

示例2: itemAlias

 public static function itemAlias($type, $code = NULL)
 {
     $_items = array('UserStatus' => array(self::STATUS_NOACTIVE => UserModule::t('Not active'), self::STATUS_ACTIVE => UserModule::t('Active'), self::STATUS_BANNED => UserModule::t('Banned')), 'AdminStatus' => array('0' => UserModule::t('No'), '1' => UserModule::t('Yes')), 'UserRoleStatus' => [CHtml::listData(UserRole::model()->findAll(array('select' => 'id, user_role', 'order' => 'user_role')), 'id', 'user_role')]);
     if (isset($code)) {
         return isset($_items[$type][$code]) ? $_items[$type][$code] : false;
     } else {
         return isset($_items[$type]) ? $_items[$type] : false;
     }
 }
开发者ID:artmart,项目名称:verare,代码行数:9,代码来源:User.php

示例3: testUserSavesRolesOnSave

 public function testUserSavesRolesOnSave()
 {
     $model = $this->getModel();
     $model->use_username = self::USERNAME;
     $model->roles = $roles = UserRole::model()->findAll();
     $model->save(false);
     /** @var $model User */
     $model = User::model()->findByPk($model->use_id);
     $this->assertTrue(is_array($model->roles));
     $this->assertEquals(count($roles), count($model->roles));
 }
开发者ID:jankichaudhari,项目名称:yii-site,代码行数:11,代码来源:UserTest.php

示例4: loggedIn

 public function loggedIn($record)
 {
     ## set id and role
     $this->id = $record->id;
     ## set role
     $role = UserRole::model()->findByAttributes(['user_id' => $this->id, 'is_default_role' => 'Yes']);
     $this->setState('fullRole', $role->role['role_name']);
     $rootRole = Helper::explodeFirst(".", $role->role['role_name']);
     $this->setState('role', $rootRole);
     $this->setState('roleId', $role->id);
     ## reset error code
     $this->errorCode = self::ERROR_NONE;
 }
开发者ID:reggi49,项目名称:plansys,代码行数:13,代码来源:UserIdentity.php

示例5: accessRules

 /**
  * Правила доступа к backend
  */
 public function accessRules()
 {
     $rolesAdm = array('admin');
     //по умолчанию
     //Получаем админов
     $model_adm = UserRole::model()->findAll('access_level=10');
     if ($model_adm) {
         foreach ($model_adm as $adm_key) {
             $rolesAdm[] = $adm_key->name;
         }
     }
     return array(array('allow', 'roles' => $rolesAdm), array('allow', 'actions' => array('login', 'logout', 'access', 'error', 'recover'), 'users' => array('*')), array('deny', 'users' => array('*')));
 }
开发者ID:Diakonrus,项目名称:fastweb-yii,代码行数:16,代码来源:Controller.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 user record by email address (username)
     $UserLogin = UserLogin::model()->findByAttributes(array('LoginEmail' => $this->username, 'IsActive' => 1));
     if ($UserLogin === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($UserLogin->UserPassword !== md5($this->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->errorCode = self::ERROR_NONE;
             // set user login ID
             $this->userLoginID = $UserLogin->UserLoginID;
             // assign user role in auth manager
             $userRole = UserRole::model()->findByPk($UserLogin->UserRoleID)->RoleType;
             $currentRoles = Yii::app()->authManager->getRoles($this->userLoginID);
             if (!array_key_exists($userRole, $currentRoles)) {
                 // remove old role if role changes
                 if (!empty($currentRoles)) {
                     AuthAssignment::model()->deleteAll('userid = :userid', array('userid' => $this->userLoginID));
                 }
                 Yii::app()->authManager->assign($userRole, $this->userLoginID);
                 Yii::app()->authManager->save();
             }
             // UserProfile
             //$UserProfile = UserProfile::model()->findByAttributes(array('UserLoginID'=>$UserLogin->UserLoginID));
             $UserProfile = UserProfile::model()->with('companies')->findByAttributes(array('UserLoginID' => $UserLogin->UserLoginID));
             //            echo '<pre>';
             //            print_r($UserProfile);
             //            die();
             // create session variables
             $this->setState('fullName', sprintf('%s %s', $UserProfile->FirstName, $UserProfile->LastName));
             // full user name
             $this->setState('companyID', $UserProfile->CompanyID);
             // user email
             $this->setState('userProfileID', $UserProfile->UserProfileID);
             // user email
             $this->setState('email', $UserLogin->LoginEmail);
             // user email
             $this->setState('companyName', $UserProfile->companies->CompanyName);
             // user email
             $this->setState('agreeToTerms', $UserProfile->AgreeToTerms);
             // user email
             $this->setState('isFacilitator', $UserProfile->IsFacilitator);
             // user email
             $this->setState('UserRoleID', $UserLogin->UserRoleID);
             // user email
         }
     }
     return !$this->errorCode;
 }
开发者ID:elephanthead,项目名称:itr,代码行数:59,代码来源:UserIdentity.php

示例7: init

 public function init()
 {
     if (Yii::app()->user->isGuest) {
         $this->redirect('/');
     }
     $modleRole = UserRole::model()->find('name LIKE "' . Yii::app()->user->role . '"')->id;
     $modelSiteModel = SiteModule::model()->find('templates LIKE "' . $this->module_template_name . '"');
     if ($modleRole && $modelSiteModel) {
         $modelRule = UserGroupRule::model()->find('user_role_id = ' . $modleRole . ' AND module_id=' . $modelSiteModel->id);
         if ($modelRule) {
             $this->rule = $modelRule->access_type;
         }
     }
 }
开发者ID:Diakonrus,项目名称:fastweb-yii,代码行数:14,代码来源:controller.php

示例8: testUserCreate

 public function testUserCreate()
 {
     $this->deleteUser();
     $this->login();
     $this->url('admin4/user/create');
     $this->assertRegExp('/admin v4 - create user/i', $this->title());
     $this->byId('User_use_username')->value(self::USERNAME);
     $this->byId('User_use_password')->value(self::PASSWORD);
     $this->byId('User_use_fname')->value(self::SURNAME);
     $this->byId('User_use_sname')->value(self::EMAIL);
     $this->byId('User_use_email')->value(self::EMAIL);
     /** @var $roles UserRole[] */
     $roles = UserRole::model()->findAll();
     foreach ($roles as $role) {
         $this->byId('User_role_' . $role->rol_id)->click();
     }
     $this->byId('user-form')->submit();
     $this->assertRegExp('/admin4\\/user\\/update/i', $this->url());
     $this->getBrowser();
     //		$this->assertRegExp('/succesfully created/i', $this->source());
 }
开发者ID:jankichaudhari,项目名称:yii-site,代码行数:21,代码来源:UserControllerTest.php

示例9: afterLogin

 public function afterLogin($fromCookie)
 {
     if ($fromCookie) {
         Yii::app()->user =& $this;
     }
     $oUser = User::model()->findByPk($this->id);
     $this->roleid = $oUser->roleid;
     $this->rolename = $oUser->Role->name;
     $this->roletype = $oUser->Role->type;
     $this->realname = $oUser->realname;
     $this->status = $oUser->status;
     $this->lang = $oUser->lang;
     $this->view_all = $oUser->view_all;
     $model = UserRole::model()->findByPk($this->roleid);
     if ($oUser->Role->purview == 'admin') {
         $this->perm = Module::getUserPerm('admin');
     } else {
         $this->perm = Module::getUserPerm(json_decode($model->purview, true));
     }
     $this->publishers = UserResource::getUserPublisher();
 }
开发者ID:wheatma,项目名称:react_study,代码行数:21,代码来源:WebUser.php

示例10: returnDiscount

 /**
  * Возращает скидку на товар.
  * Входные параметры: $count - количество заказаного товара, $model - модель скидки (таблица tbl_catalog_elements_discount)
  * Выходные параметры - возращает размер скидки (ИЗ ЦЕНЫ СКИДКА НЕ ВЫЧИТАЕТСЯ)
  */
 public function returnDiscount($price, $count, $model)
 {
     $discount = 0;
     //Проверяем права на получение скитки
     if (($model->user_role_id == 0 || UserRole::model()->returnUserRule(Yii::app()->user->id) == $model->user_role_id) && $count >= $model->count) {
         switch ($model->type) {
             case 1:
                 //Фиксированая
                 $discount = $model->values;
                 break;
             case 2:
                 //В процентах
                 $discount = $price * ($model->values / 100);
                 break;
         }
     }
     return $discount;
 }
开发者ID:Diakonrus,项目名称:fastweb-yii,代码行数:23,代码来源:CatalogElementsDiscount.php

示例11: actionSaveuserrole

 public function actionSaveuserrole()
 {
     $organid = $this->Getorganid();
     $roleids = $_POST['roleids'];
     $employeeID = $_POST['userid'];
     $findmodel = UserRole::model()->findAll("EmployeeID=:userid", array(':userid' => $employeeID));
     if (!empty($employeeID)) {
         if (!empty($roleids)) {
             $roleids = substr($roleids, 0, strlen($roleids) - 1);
             $roleids = explode(',', $roleids);
             if (count($findmodel) == 0) {
                 $i = 0;
                 foreach ($roleids as $roleid) {
                     $model = new UserRole();
                     $model->RoleID = $roleid;
                     $model->EmployeeID = $employeeID;
                     $model->OrganID = $organid['OrganID'];
                     $model->UserID = $organid['id'];
                     $model->CreateTime = time();
                     $result = $model->save();
                     if ($result) {
                         $i++;
                     }
                 }
                 if ($i == count($roleids)) {
                     $message = "保存成功";
                 } else {
                     $message = "保存失败";
                 }
             } else {
                 foreach ($findmodel as $key => $val) {
                     if (!in_array($val->RoleID, $roleids)) {
                         $delcount = UserRole::model()->deleteByPk($val->ID);
                     }
                 }
                 foreach ($roleids as $roleid) {
                     $findmodel = UserRole::model()->findAll("RoleID=:roleid and EmployeeID=:urid", array(':roleid' => $roleid, ':urid' => $employeeID));
                     if (empty($findmodel)) {
                         $model = new UserRole();
                         $model->RoleID = $roleid;
                         $model->EmployeeID = $employeeID;
                         $model->OrganID = $organid['OrganID'];
                         $model->UserID = $organid['id'];
                         $model->CreateTime = time();
                         $result = $model->save();
                     }
                 }
                 $findmodel = UserRole::model()->findAll("EmployeeID=:userid", array(':userid' => $employeeID));
                 if (count($roleids) == count($findmodel)) {
                     $message = "保存成功";
                 } else {
                     $message = "保存失败";
                 }
             }
         } else {
             $result = UserRole::model()->deleteAll("EmployeeID=:userid", array(":userid" => $employeeID));
             if ($result > 0) {
                 $message = "保存成功";
             } else {
                 $message = "保存失败";
             }
         }
     } else {
         $message = "保存失败";
     }
     echo json_encode($message);
 }
开发者ID:zwq,项目名称:unpei,代码行数:67,代码来源:JurisdictionController.php

示例12: array

    ?>
                                <h4 class='alert alert-success centered hide-on-click'>
                                        <?php 
    echo Yii::t("UserAdminModule.admin", "Saved");
    ?>
                                </h4>
                        <?php 
}
?>

                        <?php 
$roleForm = $this->beginWidget('CActiveForm');
?>
                        
                                <?php 
echo $roleForm->checkBoxList($model, 'roleIds', CHtml::listData(UserRole::model()->findAll(), 'code', 'name'), array('template' => "<label class='checkbox'>{input} {label}</label>", 'separator' => ''));
?>
                        
                                <br>
                                <?php 
echo CHtml::htmlButton('<i class="icon-ok icon-white"></i> ' . Yii::t("UserAdminModule.admin", "Save"), array('class' => 'btn btn-info', 'type' => 'submit'));
?>
                        
                        <?php 
$this->endWidget();
?>
                </td>

                <td style='padding:0 10px;'>
                        <?php 
if (Yii::app()->user->getFlash('taskSaved')) {
开发者ID:shakyapranin,项目名称:IMS,代码行数:31,代码来源:view.php

示例13: actionEdit

 public function actionEdit()
 {
     // check permissions
     if (!Yii::app()->user->checkAccess('manageUser')) {
         Helper::authException();
     }
     // make sure a user login id is defined
     $userLoginId = Helper::verifyId($_GET['id'], 'UserLogin');
     // models
     $UserLogin = UserLogin::model()->findByPk($userLoginId);
     $UserProfile = UserProfile::model()->findByAttributes(array('UserLoginID' => $userLoginId));
     // role array for select
     $userRoles = UserRole::model()->findAll();
     $rolesArray = array();
     foreach ($userRoles as $UserRole) {
         if ($UserRole->RoleType != 'godAdministrator') {
             $rolesArray[$UserRole->UserRoleID] = $UserRole->RoleDesc;
         } elseif (Helper::hasRole('godAdministrator') || $UserLogin->UserRoleID == $UserRole->UserRoleID) {
             $rolesArray[$UserRole->UserRoleID] = $UserRole->RoleDesc;
         }
     }
     // add default (empty value) to front of array
     $rolesArray = array('' => '') + $rolesArray;
     // make sure associated rows were found in our models
     if ($UserLogin == null || $UserProfile == null) {
         throw new CHttpException(404, 'A User with the specified ID could not be found.');
     }
     // form processing
     if (isset($_POST['UserLogin'], $_POST['UserProfile'])) {
         // redirect to the dashboard if 'Cancel' button clicked
         if (isset($_POST['button-cancel'])) {
             $this->redirect($this->createUrl('user/dashboard'));
         }
         // set UserLogin attributes and scenario
         $UserLogin->attributes = $_POST['UserLogin'];
         $UserLogin->scenario = 'edit';
         // set UserProfile attributes
         $UserProfile->attributes = $_POST['UserProfile'];
         // validate form submission
         $valid = $UserLogin->validate();
         $valid = $UserProfile->validate() && $valid;
         if ($valid) {
             // save UserLogin
             if (!$UserLogin->save(false)) {
                 throw new CHttpException(400, 'Error when trying to save user changes.');
             }
             // save UserProfile
             if (!$UserProfile->save(false)) {
                 throw new CHttpException(400, 'Error when trying to save user changes.');
             }
             // set success message for user
             Yii::app()->user->setFlash('success', 'User successfully updated.');
             // redirect to user dashboard
             $this->redirect($this->createUrl('user/dashboard'));
         }
     }
     // clear password
     $UserLogin->UserPassword = null;
     // render view
     $this->render('create', array('UserLogin' => $UserLogin, 'UserProfile' => $UserProfile, 'rolesArray' => $rolesArray, 'isEdit' => true));
 }
开发者ID:elephanthead,项目名称:itr,代码行数:61,代码来源:UserController.old.php

示例14: array

		<?php 
//echo $form->error($model,'superuser');
?>
        </div>
	</div>
 -->   
    <div class="row form-group">
        <div class="col-md-3 control-label">
		<?php 
echo $form->labelEx($model, 'user_role');
?>
        </div>
        <div class="col-md-4">
		<?php 
//echo $form->dropDownList($model,'user_role',User::itemAlias('AdminStatus'));
echo $form->dropDownList($model, 'user_role', CHtml::listData(UserRole::model()->findAll(array('select' => 'id, user_role', 'order' => 'user_role')), 'id', 'user_role'), array('empty' => '- Select -', 'class' => 'form-control input-md'));
?>
		<?php 
echo $form->error($model, 'user_role');
?>
        </div>
	</div>

	<div class="row form-group">
        <div class="col-md-3 control-label">
		<?php 
echo $form->labelEx($model, 'status');
?>
        </div>
        <div class="col-md-4">
		<?php 
开发者ID:artmart,项目名称:verare,代码行数:31,代码来源:_form.php

示例15: 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 $id the ID of the model to be loaded
  * @return UserRole the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = UserRole::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
开发者ID:artmart,项目名称:verare,代码行数:15,代码来源:UserRoleController.php


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