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


PHP Rights::getAssignedRoles方法代码示例

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


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

示例1: beforeSave

 public function beforeSave()
 {
     $roles = Rights::getAssignedRoles(Yii::app()->user->Id);
     // check for single role
     foreach ($roles as $role) {
         if ($role->name == 'Editor' or $role->name == 'Administrator' or $role->name == 'Superadmin') {
             $this->post_editor = Yii::app()->user->id;
         } else {
             $this->post_author = Yii::app()->user->id;
         }
     }
     if ($this->isNewRecord) {
         // jika record baru jalankan
         $this->post_created = date('Y-m-d H:i:s');
     }
     if ($this->post_name == '') {
         $this->post_name = 'No Title';
     }
     if ($this->post_link == '') {
         $this->post_link = $this->post_name;
     }
     if ($this->post_title == '') {
         $this->post_title = $this->post_name;
     }
     $this->post_type = $this->_type;
     $this->post_image = str_replace(Helper::rootImg('content'), '', $this->post_image);
     return parent::beforeSave();
 }
开发者ID:beckblurry,项目名称:Yii1-Base-Core-V.Alpha.1,代码行数:28,代码来源:Video.php

示例2: beforeControllerAction

 public function beforeControllerAction($controller, $action)
 {
     $roles = Rights::getAssignedRoles(Yii::app()->user->Id);
     // check for single role
     foreach ($roles as $role) {
         if (sizeof($roles) == 1 and $role->name == 'parent') {
             $controller->layout = 'none';
         }
         if (sizeof($roles) == 1 and $role->name == 'student') {
             $controller->layout = 'studentmain';
         }
     }
     if (Yii::app()->user->isGuest) {
         if (Yii::app()->user->loginUrl) {
             $controller->redirect($controller->createUrl(reset(Yii::app()->user->loginUrl)));
         } else {
             $controller->redirect($controller->createUrl('/'));
         }
     } else {
         if (parent::beforeControllerAction($controller, $action)) {
             // this method is called before any module controller action is performed
             // you may place customized code here
             return true;
         } else {
             return false;
         }
     }
 }
开发者ID:SoftScape,项目名称:open-school-CE,代码行数:28,代码来源:MessageModule.php

示例3: isRole

 public function isRole($roleParam)
 {
     $allroles = Rights::getAssignedRoles($this->id);
     foreach ($allroles as $ii) {
         if ($ii->name == $roleParam) {
             return true;
         }
     }
     return false;
 }
开发者ID:beckblurry,项目名称:Yii1-Base-Core-V.Alpha.1,代码行数:10,代码来源:RWebUser.php

示例4: actionIndex

 public function actionIndex()
 {
     $criteria = new CDbCriteria();
     $criteria->condition = '`file`<>:null';
     $criteria->params = array(':null' => '');
     $roles = Rights::getAssignedRoles(Yii::app()->user->id);
     // check for single role
     $user_roles = array();
     foreach ($roles as $role) {
         $user_roles[] = '"' . $role->name . '"';
     }
     $teacher = Employees::model()->findByAttributes(array('uid' => Yii::app()->user->id));
     $batches = Batches::model()->findAllByAttributes(array('employee_id' => $teacher->id));
     foreach ($batches as $classteacher) {
         $batch[] = $classteacher->id;
     }
     $timetable = TimetableEntries::model()->findAllByAttributes(array('employee_id' => $teacher->id));
     foreach ($timetable as $period) {
         $batch[] = $period->batch_id;
     }
     $unique_batch = array_unique($batch);
     if (count($unique_batch) > 0) {
         $criteria->condition .= ' AND (`placeholder`=:null OR `created_by`=:user_id OR (`placeholder` IN (' . implode(',', $user_roles) . ')) AND (`batch` IS NULL OR `batch` IN (' . implode(',', $unique_batch) . '))) ';
     } else {
         $criteria->condition .= ' AND (`placeholder`=:null OR `created_by`=:user_id) OR (`placeholder` IN (' . implode(',', $user_roles) . '))';
     }
     $criteria->params[':user_id'] = Yii::app()->user->id;
     $criteria->order = '`created_at` DESC';
     $files = FileUploads::model()->findAll($criteria);
     if (isset($_POST['Downfiles'])) {
         $selected_files = $_POST['Downfiles'];
         $slfiles = array();
         foreach ($selected_files as $s_file) {
             $model = FileUploads::model()->findByPk($s_file);
             if ($model != NULL) {
                 $slfiles[] = 'uploads/shared/' . $model->id . '/' . $model->file;
             }
         }
         $zip = Yii::app()->zip;
         $fName = $this->generateRandomString(rand(10, 20)) . '.zip';
         $zipFile = 'compressed/' . $fName;
         if ($zip->makeZip($slfiles, $zipFile)) {
             $fcon = file_get_contents($zipFile);
             header('Content-type:text/plain');
             header('Content-disposition:attachment; filename=' . $fName);
             header('Pragma:no-cache');
             echo $fcon;
             unlink($zipFile);
         } else {
             Yii::app()->user->setFlash('success', 'Can\'t download');
         }
     }
     $this->render('/fileUploads/index', array('files' => $files));
 }
开发者ID:akilraj1255,项目名称:rajeshwari,代码行数:54,代码来源:TeachersController.php

示例5: actions

 public function actions()
 {
     $disabled = array();
     $roles = Rights::getAssignedRoles(Yii::app()->user->Id);
     // check for single role
     foreach ($roles as $role) {
         if ($role->name != 'Editor' and $role->name != 'Administrator' and $role->name != 'Superadmin') {
             $disabled = array('copy', 'paste', 'archive', 'extract', 'mkdir', 'mkfile', 'rm', 'duplicate', 'resize', 'rename', 'edit');
         }
     }
     return array('connector' => array('class' => 'ElFinderConnectorAction', 'settings' => array('root' => ROOT_DIR . '/uploads/content/', 'URL' => rootUrl . 'uploads/content/', 'rootAlias' => 'Home', 'mimeDetect' => 'internal', 'tmbDir' => '.tmb', 'debug' => '', 'uploadAllow' => array('image'), 'uploadDeny' => array('all'), 'uploadOrder' => 'deny,allow', 'perms' => array('/\\.(txt|html|php|py|pl|sh|xml)$/i' => array('read' => true, 'write' => false, 'rm' => true)), 'disabled' => $disabled)));
 }
开发者ID:beckblurry,项目名称:Yii1-Base-Core-V.Alpha.1,代码行数:12,代码来源:ElfinderController.php

示例6: actionLogin

 /**
  * Displays the login page
  */
 public function actionLogin()
 {
     if (Yii::app()->user->isGuest) {
         $model = new UserLogin();
         // collect user input data
         if (isset($_POST['UserLogin'])) {
             $model->attributes = $_POST['UserLogin'];
             // validate user input and redirect to previous page if valid
             if ($model->validate()) {
                 $this->lastViset();
                 //Yii::import('application.controllers.ActivityFeedController');
                 //SmsSettings::model()->sendSms($to,$from,$message); To call an action written on a controller
                 //Adding activity to feed via saveFeed($initiator_id,$activity_type,$goal_id,$goal_name,$field_name,$initial_field_value,$new_field_value)
                 ActivityFeed::model()->saveFeed(Yii::app()->user->Id, '1', NULL, NULL, NULL, NULL, NULL);
                 $roles = Rights::getAssignedRoles(Yii::app()->user->Id);
                 // check for single role
                 foreach ($roles as $role) {
                     if (sizeof($roles) == 1 and $role->name == 'Company') {
                         $this->redirect(array('/students'));
                     }
                 }
                 if (sizeof($roles) == 1 and $role->name == 'Trainee') {
                     $this->redirect(array('/students'));
                 }
                 if (sizeof($roles) == 1 and $role->name == 'Employee') {
                     $this->redirect(array('/students'));
                 }
                 if (Yii::app()->user->checkAccess('admin')) {
                     if (Yii::app()->user->returnUrl == '/index.php') {
                         $this->redirect(Yii::app()->controller->module->returnUrl);
                     } else {
                         $this->redirect(Yii::app()->user->returnUrl);
                     }
                 } else {
                     $this->redirect(array('/students'));
                 }
             }
         }
         // display the login form
         $this->render('/user/login', array('model' => $model));
     } else {
         $this->redirect(Yii::app()->controller->module->returnUrl);
     }
 }
开发者ID:akilraj1255,项目名称:rajeshwari,代码行数:47,代码来源:LoginController.php

示例7: actionIndex

 /**
  * Specifies the access control rules.
  * This method is used by the 'accessControl' filter.
  * @return array access control rules
  */
 public function actionIndex()
 {
     $criteria = new CDbCriteria();
     $criteria->condition = '';
     $roles = Rights::getAssignedRoles(Yii::app()->user->id);
     // check for single role
     $user_roles = array();
     foreach ($roles as $role) {
         $user_roles[] = '"' . $role->name . '"';
     }
     $student = Students::model()->findByAttributes(array('uid' => Yii::app()->user->id));
     $batch = Batches::model()->findByAttributes(array('id' => $student->batch_id));
     $criteria->condition .= '`file`<>:null AND (`placeholder`=:null OR `placeholder` IN (' . implode(',', $user_roles) . ')) AND ((`course` IS NULL) OR (`course`=:course) OR (`course`=0)) AND ((`batch` IS NULL) OR (`batch`=:batch) OR (`batch`=0))';
     $criteria->params = array(':null' => '', ':course' => $batch->course_id, ':batch' => $batch->id);
     $criteria->order = '`created_at` DESC';
     //print_r($criteria); exit;
     $files = FileUploads::model()->findAll($criteria);
     if (isset($_POST['Downfiles'])) {
         $selected_files = $_POST['Downfiles'];
         $slfiles = array();
         foreach ($selected_files as $s_file) {
             $model = FileUploads::model()->findByPk($s_file);
             if ($model != NULL) {
                 $slfiles[] = 'uploads/shared/' . $model->id . '/' . $model->file;
             }
         }
         $zip = Yii::app()->zip;
         $fName = $this->generateRandomString(rand(10, 20)) . '.zip';
         $zipFile = 'compressed/' . $fName;
         if ($zip->makeZip($slfiles, $zipFile)) {
             $fcon = file_get_contents($zipFile);
             header('Content-type:text/plain');
             header('Content-disposition:attachment; filename=' . $fName);
             header('Pragma:no-cache');
             echo $fcon;
             unlink($zipFile);
         } else {
             Yii::app()->user->setFlash('success', 'Can\'t download');
         }
     }
     $this->render('/fileUploads/index', array('files' => $files));
 }
开发者ID:akilraj1255,项目名称:rajeshwari,代码行数:47,代码来源:StudentsController.php

示例8: actionLogin

 /**
  * Displays the login page
  */
 public function actionLogin()
 {
     if (Yii::app()->user->isGuest) {
         $model = new UserLogin();
         // collect user input data
         if (isset($_POST['UserLogin'])) {
             $model->attributes = $_POST['UserLogin'];
             // validate user input and redirect to previous page if valid
             if ($model->validate()) {
                 $this->lastViset();
                 $roles = Rights::getAssignedRoles(Yii::app()->user->Id);
                 // check for single role
                 foreach ($roles as $role) {
                     if (sizeof($roles) == 1 and $role->name == 'parent') {
                         $this->redirect(array('/portal'));
                     }
                 }
                 if (sizeof($roles) == 1 and $role->name == 'student') {
                     $this->redirect(array('/portal'));
                 }
                 if (sizeof($roles) == 1 and $role->name == 'teacher') {
                     $this->redirect(array('/portal'));
                 }
                 if (Yii::app()->user->checkAccess('admin')) {
                     if (Yii::app()->user->returnUrl == '/index.php') {
                         $this->redirect(Yii::app()->controller->module->returnUrl);
                     } else {
                         $this->redirect(Yii::app()->user->returnUrl);
                     }
                 } else {
                     $this->redirect(array('/mailbox'));
                 }
             }
         }
         // display the login form
         $this->render('/user/login', array('model' => $model));
     } else {
         $this->redirect(Yii::app()->controller->module->returnUrl);
     }
 }
开发者ID:SoftScape,项目名称:open-school-CE,代码行数:43,代码来源:LoginController.php

示例9: authenticate

 /**
  * Authenticates a user.
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $username = strtolower($this->username);
     $user = User::model()->find('LOWER(email)=?', array($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->email;
             $this->setState('name', $user->name);
             $this->setState('dashboardurl', '/dashboard');
             $this->errorCode = self::ERROR_NONE;
             $this->setSessionParams($user->publisher);
             $roles = Rights::getAssignedRoles($user->id, true);
             $this->setState('isAdmin', array_key_exists("Admin", $roles) ? 1 : 0);
         }
     }
     return $this->errorCode == self::ERROR_NONE;
 }
开发者ID:sundgaarden,项目名称:dashboard,代码行数:26,代码来源:UserIdentity.php

示例10: role

 public function role()
 {
     foreach (Rights::getAssignedRoles($this->id) as $role) {
         echo $role->description . ', ';
     }
 }
开发者ID:buildshop,项目名称:bs-common,代码行数:6,代码来源:User.php

示例11: checkTransferTo

 public static function checkTransferTo($params = null, $data = null, $perm)
 {
     $roles = Rights::getAssignedRoles(user()->id, true);
     $arr_result = array();
     $to_user_roles = Rights::getAssignedRoles($params['to_user_id'], true);
     foreach ($roles as $role) {
         if (array_key_exists(trim($role->name), $perm)) {
             foreach ($to_user_roles as $to_role) {
                 if (array_key_exists($to_role->name, $perm[trim($role->name)]['allowedTransferto'])) {
                     $arr_result[] = GxcContentPermission::execBizRules($perm[trim($role->name)]['allowedTransferto'][$to_role->name]['condition'], $params, $data);
                 } else {
                     $arr_result[] = false;
                 }
             }
         }
     }
     if (in_array(true, $arr_result)) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:pramana08,项目名称:GXC-CMS-2,代码行数:22,代码来源:GxcContentPermission.php

示例12: checkUserRole

 public function checkUserRole($user_id)
 {
     foreach (Rights::getAssignedRoles($user_id) as $role) {
         echo $role->name . '<br/>';
     }
 }
开发者ID:buildshop,项目名称:bs-common,代码行数:6,代码来源:CManagerAccess.php

示例13: doSearch

    /**
     * Do Search Object based on its status
     * @param type $type
     * @return CActiveDataProvider 
     */
    public function doSearch($type = 0)
    {
        $criteria = new CDbCriteria();
        $sort = new CSort();
        $sort->attributes = array('object_id');
        $sort->defaultOrder = 'object_id DESC';
        switch ($type) {
            //If looking for DRAFT Content
            case ConstantDefine::OBJECT_STATUS_DRAFT:
                $criteria->condition = 'object_status = :status and object_author = :uid';
                $criteria->params = array(':status' => ConstantDefine::OBJECT_STATUS_DRAFT, ':uid' => user()->id);
                break;
                //If looking for Pending Content
            //If looking for Pending Content
            case ConstantDefine::OBJECT_STATUS_PENDING:
                $criteria->select = " t.*";
                $criteria->distinct = true;
                $current_user_roles = Rights::getAssignedRoles(user()->id, true);
                foreach ($current_user_roles as $r) {
                    $user_roles_allow[] = $r->name;
                }
                $criteria->join = "JOIN gxc_transfer as tr ON t.object_id = tr.object_id\n\t\t\tLEFT OUTER JOIN gxc_transfer tr2 ON (t.object_id = tr2.object_id AND \n\t\t\t(tr.time < tr2.time OR tr.time = tr2.time AND tr.transfer_id < tr2.transfer_id))";
                $criteria->condition = 'object_status = :status and tr2.transfer_id IS NULL and
			(( tr.type= :type_person and tr.to_user_id = :toperson ) or (
			   tr.type= :type_role and tr.note in ( "' . implode(",", $user_roles_allow) . '" )
			) )
			';
                $criteria->params = array(':status' => ConstantDefine::OBJECT_STATUS_PENDING, ':toperson' => user()->id, ':type_person' => ConstantDefine::TRANS_PERSON, ':type_role' => ConstantDefine::TRANS_ROLE);
                break;
                //If looking for Published Content
            //If looking for Published Content
            case ConstantDefine::OBJECT_STATUS_PUBLISHED:
                //Do nothing;
                $criteria->condition = 'object_status = :status';
                $criteria->params = array(':status' => ConstantDefine::OBJECT_STATUS_PUBLISHED);
                break;
        }
        $criteria->compare('object_id', $this->object_id, true);
        $criteria->compare('object_author', $this->object_author, true);
        $criteria->compare('object_date', $this->object_date);
        $criteria->compare('object_content', $this->object_content, true);
        $criteria->compare('object_title', $this->object_title, true);
        $criteria->compare('object_name', $this->object_name, true);
        return new CActiveDataProvider(get_class($this), array('criteria' => $criteria, 'sort' => $sort));
    }
开发者ID:pramana08,项目名称:GXC-CMS-2,代码行数:50,代码来源:Object.php

示例14: foreach

<?php

if (Yii::app()->user->isSuperuser && $data->id != Yii::app()->user->id) {
    $roles = Rights::getAssignedRoles($data->id);
    $su = 0;
    foreach ($roles as $role) {
        if ($role->name == 'Admin') {
            $su = 1;
            break;
        }
    }
    if ($su) {
        $group = Yii::t('site', 'Admin');
    } else {
        $group = Yii::t('site', 'User');
    }
    ?>
<a  data-title="<?php 
    echo Yii::t('site', 'Change status');
    ?>
"  data-value="<?php 
    echo $su;
    ?>
" data-pk="<?php 
    echo $data->id;
    ?>
"   id="group<?php 
    echo $data->id;
    ?>
" href="#" class="status editable editable-click" data-original-title="" title="" style=""><?php 
    echo $group;
开发者ID:Aplay,项目名称:anetika_site,代码行数:31,代码来源:_grid_status.php

示例15: getType

 public function getType($alias = false)
 {
     $roles = Rights::getAssignedRoles($this->id);
     foreach ($roles as $role) {
         if ($alias == true) {
             return $role->name;
         }
         return $role->getNameText();
     }
 }
开发者ID:phiphi1992,项目名称:fpthue,代码行数:10,代码来源:User.php


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