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


PHP Roles::getErrors方法代码示例

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


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

示例1: actionManageRoles

 /**
  * A catch all page for roles.
  *
  * This action renders a page with forms for the creation, editing, and deletion
  * of roles.  It also displays a grid with all user created roles (default
  * roles are not included and cannot be edited this way).
  */
 public function actionManageRoles()
 {
     $dataProvider = new CActiveDataProvider('Roles');
     $roles = Yii::app()->db->createCommand()->select('id, name')->from('x2_roles')->queryAll();
     $model = new Roles();
     $model->timeout = 60;
     $roleInput = FilterUtil::filterArrayInput($_POST, 'Roles');
     if (!empty($roleInput)) {
         $model->attributes = $roleInput;
         $model->users = '';
         $viewPermissions = FilterUtil::filterArrayInput($_POST, 'viewPermissions');
         $editPermissions = FilterUtil::filterArrayInput($_POST, 'editPermissions');
         $users = FilterUtil::filterArrayInput($roleInput, 'users');
         $model->timeout *= 60;
         if ($model->timeout === 0) {
             $model->timeout = null;
         }
         $model->setUsers($users);
         $model->setViewPermissions($viewPermissions);
         $model->setEditPermissions($editPermissions);
         if ($model->save()) {
         } else {
             foreach ($model->getErrors() as $err) {
                 $errors = $err;
             }
             $errors = implode(',', $errors);
             Yii::app()->user->setFlash('error', Yii::t('admin', "Unable to save role: {errors}", array('{errors}' => $errors)));
         }
         $this->redirect('manageRoles');
     }
     $this->render('manageRoles', array('dataProvider' => $dataProvider, 'model' => $model, 'roles' => $roles));
 }
开发者ID:xl602,项目名称:X2CRM,代码行数:39,代码来源:AdminController.php

示例2: actionManageRoles

 /**
  * A catch all page for roles.
  *
  * This action renders a page with forms for the creation, editing, and deletion
  * of roles.  It also displays a grid with all user created roles (default
  * roles are not included and cannot be edited this way).
  */
 public function actionManageRoles()
 {
     $dataProvider = new CActiveDataProvider('Roles');
     $roles = $dataProvider->getData();
     $arr = array();
     foreach ($roles as $role) {
         $arr[$role->name] = $role->name;
     }
     $temp = Workflow::model()->findAll();
     $workflows = array();
     foreach ($temp as $workflow) {
         $workflows[$workflow->id] = $workflow->name;
     }
     $model = new Roles();
     $model->timeout = 60;
     if (isset($_POST['Roles'])) {
         $model->attributes = $_POST['Roles'];
         if (!isset($_POST['viewPermissions'])) {
             $viewPermissions = array();
         } else {
             $viewPermissions = $_POST['viewPermissions'];
         }
         if (!isset($_POST['editPermissions'])) {
             $editPermissions = array();
         } else {
             $editPermissions = $_POST['editPermissions'];
         }
         if (isset($_POST['Roles']['users'])) {
             $users = $model->users;
         } else {
             $users = array();
         }
         $model->users = "";
         $model->timeout *= 60;
         if ($model->save()) {
             foreach ($users as $user) {
                 $role = new RoleToUser();
                 $role->roleId = $model->id;
                 if (!is_numeric($user)) {
                     $userRecord = User::model()->findByAttributes(array('username' => $user));
                     $role->userId = $userRecord->id;
                     $role->type = 'user';
                 } else {
                     $role->userId = $user;
                     $role->type = 'group';
                 }
                 /* end x2temp */
                 $role->save();
             }
             $fields = Fields::model()->findAll();
             $temp = array();
             foreach ($fields as $field) {
                 $temp[] = $field->id;
             }
             $both = array_intersect($viewPermissions, $editPermissions);
             $view = array_diff($viewPermissions, $editPermissions);
             $neither = array_diff($temp, $viewPermissions);
             foreach ($both as $field) {
                 $rolePerm = new RoleToPermission();
                 $rolePerm->roleId = $model->id;
                 $rolePerm->fieldId = $field;
                 $rolePerm->permission = 2;
                 $rolePerm->save();
             }
             foreach ($view as $field) {
                 $rolePerm = new RoleToPermission();
                 $rolePerm->roleId = $model->id;
                 $rolePerm->fieldId = $field;
                 $rolePerm->permission = 1;
                 $rolePerm->save();
             }
             foreach ($neither as $field) {
                 $rolePerm = new RoleToPermission();
                 $rolePerm->roleId = $model->id;
                 $rolePerm->fieldId = $field;
                 $rolePerm->permission = 0;
                 $rolePerm->save();
             }
         } else {
             foreach ($model->getErrors() as $err) {
                 $errors = $err;
             }
             $errors = implode(',', $errors);
             Yii::app()->user->setFlash('error', Yii::t('admin', "Unable to save role: {errors}", array('{errors}' => $errors)));
         }
         $this->redirect('manageRoles');
     }
     $this->render('manageRoles', array('dataProvider' => $dataProvider, 'model' => $model, 'roles' => $arr, 'workflows' => $workflows));
 }
开发者ID:keyeMyria,项目名称:CRM,代码行数:96,代码来源:AdminController.php


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