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


PHP Roles::delete方法代码示例

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


在下文中一共展示了Roles::delete方法的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: deleteAction

 function deleteAction()
 {
     $request = new Bolts_Request($this->getRequest());
     $roles_table = new Roles();
     if ($request->has('id')) {
         $id = $request->id;
         $role = $roles_table->fetchRow("id = " . $id);
         if (is_null($role)) {
             $this->_redirect('/bolts/role');
         }
     } else {
         $this->_redirect('/bolts/role');
     }
     if ($this->getRequest()->isPost() and $request->has("delete")) {
         $errors = array();
         // can't be last admin
         if ((bool) $role->isadmin and $roles_table->getCountByWhereClause("isadmin = 1") == 1) {
             $errors[] = $this->_T("This is the only admin role. It cannot be deleted.");
         }
         // can't be guest
         if ((bool) $role->isguest) {
             $errors[] = $this->_T("This is the guest role. It cannot be deleted.");
         }
         // can't be default
         if ((bool) $role->isdefault) {
             $errors[] = $this->_T("This is the default role. It cannot be deleted.");
         }
         // can't have any users
         $userwhereclause = "role_id = " . $role->id;
         $users_table = new UsersRoles();
         if ($users_table->getCountByWhereClause($userwhereclause) > 0) {
             $errors[] = $this->_T("This role cannot be deleted because there are users assigned to it.");
         }
         // can't have children
         $inherited_by = $roles_table->fetchImmediateChildren($role->id);
         if (count($inherited_by) > 0) {
             $error = $this->_T("This role is inherited by role(s) ");
             $firstpass = true;
             foreach ($inherited_by as $role_i) {
                 if ($firstpass) {
                     $firstpass = false;
                 } else {
                     $error .= ", ";
                 }
                 $error .= $role_i->shortname;
             }
             $error .= $this->_T(". It cannot be deleted.");
             $errors[] = $error;
         }
         if ($request->delete == "Yes") {
             if (count($errors) > 0) {
                 $this->view->errors = $errors;
             } else {
                 $roles_table->delete("id = " . $id);
                 $this->view->success = $this->_T("Role deleted.");
             }
         } else {
             $this->_redirect("/bolts/role");
         }
     }
     $this->view->role = $role->toArray();
 }
开发者ID:jaybill,项目名称:Bolts,代码行数:62,代码来源:RoleController.php

示例3: dirname

<?php

/** !
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* [filename] is a part of PeopleAggregator.
* [description including history]
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* @author [creator, or "Original Author"]
* @license http://bit.ly/aVWqRV PayAsYouGo License
* @copyright Copyright (c) 2010 Broadband Mechanics
* @package PeopleAggregator
*/
$login_required = TRUE;
require_once dirname(__FILE__) . '/../../config.inc';
include_once "web/includes/page.php";
require_once "api/Roles/Roles.php";
if ($_POST['id']) {
    $msg = __("Role can't be deleted.");
    $role = new Roles();
    if ($role->delete((int) $_POST['id'])) {
        $msg = __("Successfully deleted.");
    }
}
echo $msg;
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:24,代码来源:deleterole.php


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