⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 acp_permission_roles.php

📁 这些都是我以前学习是用到的源码
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php/** ** @package acp* @version $Id: acp_permission_roles.php,v 1.17 2006/10/30 19:51:56 acydburn Exp $* @copyright (c) 2005 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License **//*** @package acp*/class acp_permission_roles{	var $u_action;	function main($id, $mode)	{		global $db, $user, $auth, $template, $cache;		global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;		include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx);		include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx);		$auth_admin = new auth_admin();		$user->add_lang('acp/permissions');		add_permission_language();		$this->tpl_name = 'acp_permission_roles';		$submit = (isset($_POST['submit'])) ? true : false;		$role_id = request_var('role_id', 0);		$action = request_var('action', '');		$action = (isset($_POST['add'])) ? 'add' : $action;		switch ($mode)		{			case 'admin_roles':				$permission_type = 'a_';				$this->page_title = 'ACP_ADMIN_ROLES';			break;			case 'user_roles':				$permission_type = 'u_';				$this->page_title = 'ACP_USER_ROLES';			break;			case 'mod_roles':				$permission_type = 'm_';				$this->page_title = 'ACP_MOD_ROLES';			break;			case 'forum_roles':				$permission_type = 'f_';				$this->page_title = 'ACP_FORUM_ROLES';			break;			default:				trigger_error('NO_MODE', E_USER_ERROR);			break;		}		$template->assign_vars(array(			'L_TITLE'		=> $user->lang[$this->page_title],			'L_EXPLAIN'		=> $user->lang[$this->page_title . '_EXPLAIN'])		);		// Take action... admin submitted something		if ($submit || $action == 'remove')		{			switch ($action)			{				case 'remove':					if (!$role_id)					{						trigger_error($user->lang['NO_ROLE_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING);					}					$sql = 'SELECT *						FROM ' . ACL_ROLES_TABLE . '						WHERE role_id = ' . $role_id;					$result = $db->sql_query($sql);					$role_row = $db->sql_fetchrow($result);					$db->sql_freeresult($result);					if (!$role_row)					{						trigger_error($user->lang['NO_ROLE_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING);					}					if (confirm_box(true))					{						$this->remove_role($role_id, $permission_type);						add_log('admin', 'LOG_' . strtoupper($permission_type) . 'ROLE_REMOVED', $role_row['role_name']);						trigger_error($user->lang['ROLE_DELETED'] . adm_back_link($this->u_action));					}					else					{						confirm_box(false, 'DELETE_ROLE', build_hidden_fields(array(							'i'			=> $id,							'mode'		=> $mode,							'role_id'	=> $role_id,							'action'	=> $action,						)));					}				break;				case 'edit':					if (!$role_id)					{						trigger_error($user->lang['NO_ROLE_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING);					}					// Get role we edit					$sql = 'SELECT *						FROM ' . ACL_ROLES_TABLE . '						WHERE role_id = ' . $role_id;					$result = $db->sql_query($sql);					$role_row = $db->sql_fetchrow($result);					$db->sql_freeresult($result);					if (!$role_row)					{						trigger_error($user->lang['NO_ROLE_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING);					}				// no break;				case 'add':					$role_name = request_var('role_name', '', true);					$role_description = request_var('role_description', '', true);					$auth_settings = request_var('setting', array('' => 0));					if (!$role_name)					{						trigger_error($user->lang['NO_ROLE_NAME_SPECIFIED'] . adm_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 . "						WHERE role_type = '" . $db->sql_escape($permission_type) . "'							AND 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) . adm_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 . "							WHERE 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);					add_log('admin', 'LOG_' . strtoupper($permission_type) . 'ROLE_' . strtoupper($action), $role_name);					trigger_error($user->lang['ROLE_' . strtoupper($action) . '_SUCCESS'] . adm_back_link($this->u_action));				break;			}		}		// Display screens		switch ($action)		{			case 'add':				$options_from = request_var('options_from', 0);				$role_row = array(					'role_name'			=> request_var('role_name', '', true),					'role_description'	=> 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 . "						WHERE auth_option LIKE '{$permission_type}%'							AND auth_option <> '{$permission_type}'						ORDER 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);				}			// no break;			case 'edit':				if ($action == 'edit')				{					if (!$role_id)					{						trigger_error($user->lang['NO_ROLE_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING);					}										$sql = 'SELECT *						FROM ' . ACL_ROLES_TABLE . '						WHERE role_id = ' . $role_id;					$result = $db->sql_query($sql);					$role_row = $db->sql_fetchrow($result);					$db->sql_freeresult($result);					$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 = ' . $role_id . '						ORDER BY p.auth_option_id';					$result = $db->sql_query($sql);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -