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


PHP auth_admin::acl_set_role方法代码示例

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


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

示例1: main


//.........这里部分代码省略.........
                    }
                    if (utf8_strlen($role_description) > 4000) {
                        trigger_error($user->lang['ROLE_DESCRIPTION_LONG'] . page_back_link($this->u_action), E_USER_WARNING);
                    }
                    // if we add/edit a role we check the name to be unique among the settings...
                    $sql = 'SELECT role_id
						FROM ' . ACL_ROLES_TABLE . "\n\t\t\t\t\t\tWHERE role_type = '" . $db->sql_escape($permission_type) . "'\n\t\t\t\t\t\t\tAND role_name = '" . $db->sql_escape($role_name) . "'";
                    $result = $db->sql_query($sql);
                    $row = $db->sql_fetchrow($result);
                    $db->sql_freeresult($result);
                    // Make sure we only print out the error if we add the role or change it's name
                    if ($row && ($mode == 'add' || $mode == 'edit' && $role_row['role_name'] != $role_name)) {
                        trigger_error(sprintf($user->lang['ROLE_NAME_ALREADY_EXIST'], $role_name) . page_back_link($this->u_action), E_USER_WARNING);
                    }
                    $sql_ary = array('role_name' => (string) $role_name, 'role_description' => (string) $role_description, 'role_type' => (string) $permission_type);
                    if ($action == 'edit') {
                        $sql = 'UPDATE ' . ACL_ROLES_TABLE . '
							SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
							WHERE role_id = ' . $role_id;
                        $db->sql_query($sql);
                    } else {
                        // Get maximum role order for inserting a new role...
                        $sql = 'SELECT MAX(role_order) as max_order
							FROM ' . ACL_ROLES_TABLE . "\n\t\t\t\t\t\t\tWHERE role_type = '" . $db->sql_escape($permission_type) . "'";
                        $result = $db->sql_query($sql);
                        $max_order = (int) $db->sql_fetchfield('max_order');
                        $db->sql_freeresult($result);
                        $sql_ary['role_order'] = $max_order + 1;
                        $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
                        $db->sql_query($sql);
                        $role_id = $db->sql_nextid();
                    }
                    // Now add the auth settings
                    $auth_admin->acl_set_role($role_id, $auth_settings);
                    $role_name = !empty($user->lang[$role_name]) ? $user->lang[$role_name] : $role_name;
                    add_log('admin', 'LOG_' . strtoupper($permission_type) . 'ROLE_' . strtoupper($action), $role_name);
                    trigger_error($user->lang['ROLE_' . strtoupper($action) . '_SUCCESS'] . page_back_link($this->u_action));
                    break;
            }
        }
        // Display screens
        switch ($action) {
            case 'add':
                $options_from = request_var('options_from', 0);
                $role_row = array('role_name' => utf8_normalize_nfc(request_var('role_name', '', true)), 'role_description' => utf8_normalize_nfc(request_var('role_description', '', true)), 'role_type' => $permission_type);
                if ($options_from) {
                    $sql = 'SELECT p.auth_option_id, p.auth_setting, o.auth_option
						FROM ' . ACL_ROLES_DATA_TABLE . ' p, ' . ACL_OPTIONS_TABLE . ' o
						WHERE o.auth_option_id = p.auth_option_id
							AND p.role_id = ' . $options_from . '
						ORDER BY p.auth_option_id';
                    $result = $db->sql_query($sql);
                    $auth_options = array();
                    while ($row = $db->sql_fetchrow($result)) {
                        $auth_options[$row['auth_option']] = $row['auth_setting'];
                    }
                    $db->sql_freeresult($result);
                } else {
                    $sql = 'SELECT auth_option_id, auth_option
						FROM ' . ACL_OPTIONS_TABLE . "\n\t\t\t\t\t\tWHERE auth_option " . $db->sql_like_expression($permission_type . $db->any_char) . "\n\t\t\t\t\t\t\tAND auth_option <> '{$permission_type}'\n\t\t\t\t\t\tORDER BY auth_option_id";
                    $result = $db->sql_query($sql);
                    $auth_options = array();
                    while ($row = $db->sql_fetchrow($result)) {
                        $auth_options[$row['auth_option']] = ACL_NO;
                    }
                    $db->sql_freeresult($result);
开发者ID:ALTUN69,项目名称:icy_phoenix,代码行数:67,代码来源:class_cms_permissions_roles.php


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