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


PHP Roles::assign_tasks_to_role方法代码示例

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


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

示例1: restoreRoleSettings

 private function restoreRoleSettings($restore_roles, $_msg = null)
 {
     try {
         if (count($restore_roles) > 0) {
             $roles = new Roles();
             $roles_info = $roles->get_multiple(null);
             foreach ($roles_info as $_role) {
                 $role = $roles->get($_role->id);
                 if (is_object($role)) {
                     if (!$role->read_only) {
                         $roles->delete((int) $_role->id);
                     }
                 }
             }
             foreach ($restore_roles as $role) {
                 $_role = Roles::getRoleInfoByID($role['id'], $fetch_mode = DB_FETCHMODE_ASSOC);
                 if (isset($_role['id'])) {
                     // existing role, need to update only
                     $new_role = new Roles();
                     $new_role->id = $role['id'];
                     $new_role->description = $role['description'];
                     $new_role->name = $role['name'];
                     $new_role->type = $role['type'];
                     $new_role->update();
                     Roles::delete_role_tasks($new_role->id);
                     if (!empty($role['tasks'])) {
                         $tasks = array();
                         foreach ($role['tasks'] as $task) {
                             $tasks[] = $task['id'];
                         }
                         Roles::assign_tasks_to_role($tasks, $new_role->id);
                     }
                 } else {
                     $new_role = new Roles();
                     $new_role->description = $role['description'];
                     $new_role->name = $role['name'];
                     $role_id = $new_role->create();
                     if ($role_id && !empty($role['tasks'])) {
                         $tasks = array();
                         foreach ($role['tasks'] as $task) {
                             $tasks[] = $task['id'];
                         }
                         Roles::assign_tasks_to_role($tasks, $role_id);
                     }
                 }
             }
             $error_msg = $_msg ? $_msg : __('Default Roles settings sucessfully restored.');
         } else {
             $error_msg = __('There is no Roles data in default XML settings file.');
         }
     } catch (Exception $e) {
         $error = TRUE;
         $error_msg = $e->getMessage();
     }
     return $error_msg;
 }
开发者ID:Cyberspace-Networks,项目名称:CoreSystem,代码行数:56,代码来源:CNRoleManageModule.php

示例2: testAssign_tasks_to_role_empty_role

 /**
  * @todo Implement testAssign_tasks_to_role().
  */
 public function testAssign_tasks_to_role_empty_role()
 {
     //check for single tasks
     $tasks = 1;
     $role = NULL;
     $code = NULL;
     try {
         Roles::assign_tasks_to_role($tasks, $role);
     } catch (PAException $e) {
         $error = $e->message;
         $code = $e->code;
     }
     //this id should be equal to newly created id
     $this->assertEquals($code, REQUIRED_PARAMETERS_MISSING);
 }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:18,代码来源:RolesTest.php

示例3: Roles

if (@$_GET['msg']) {
    $msg = $_GET['msg'];
}
//echo '<pre>';print_r($_POST);exit;
if (@$_POST['save']) {
    $count_role = (int) $_POST['totalcount'];
    for ($i = 1; $i <= $count_role; $i++) {
        $role_id = $_POST['link_id' . $i];
        $role = new Roles();
        $task_count = (int) $_POST['taskcount'];
        for ($j = 1; $j <= $task_count; $j++) {
            $task_id = $_POST['taskid' . $j];
            $chk = $role_id . '~' . $task_id;
            if ($_POST[$chk]) {
                try {
                    $role->assign_tasks_to_role($task_id, $role_id);
                } catch (PAException $e) {
                    $msg = "{$e->message}";
                    $error = TRUE;
                }
            } else {
                $task_exist = Roles::is_roletask_exist($role_id, $task_id);
                if ($task_exist) {
                    Roles::delete_taskrole($role_id, $task_id);
                }
            }
        }
    }
    header("Location:assign_tasks.php?msg=9015");
    exit;
}
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:31,代码来源:assign_tasks.php


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