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


PHP auth_admin类代码示例

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


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

示例1: install

 function install()
 {
     global $phpbb_root_path, $phpEx, $db, $user;
     // Setup $auth_admin class so we can add permission options
     include $phpbb_root_path . 'includes/acp/auth.' . $phpEx;
     $auth_admin = new auth_admin();
     // Add permission for manage cvsdb
     $auth_admin->acl_add_option(array('local' => array(), 'global' => array('a_add_board')));
     $module_data = $this->module();
     $module_basename = substr(strstr($module_data['filename'], '_'), 1);
     $result = $db->sql_query('SELECT module_id FROM ' . MODULES_TABLE . " WHERE module_basename = '{$module_basename}'");
     $module_id = $db->sql_fetchfield('module_id');
     $db->sql_freeresult($result);
     $sql = 'UPDATE ' . MODULES_TABLE . " SET module_auth = 'acl_a_add_board' WHERE module_id = {$module_id}";
     $db->sql_query($sql);
     $config->set('add_user_version', $module_data['version'], false);
     trigger_error(sprintf($user->lang['ADD_USER_MOD_UPDATED'], $module_data['version']));
 }
开发者ID:phryneas,项目名称:hjw_calendar_phpbb31,代码行数:18,代码来源:main_info.php

示例2: preg_replace

$remove_remarks = $available_dbms[$dbms]['COMMENTS'];
$delimiter = $available_dbms[$dbms]['DELIM'];
$sql_query = preg_replace('#phpbb_#i', $table_prefix, $table);
$remove_remarks($sql_query);
$sql_query = split_sql_file($sql_query, $delimiter);
foreach ($sql_query as $sql) {
    $db->sql_query($sql);
}
unset($sql_query);
foreach ($config_items as $name => $value) {
    set_config($name, $value);
}
foreach ($config_items_dyn as $name => $value) {
    set_config($name, $value, true);
}
$acl = new auth_admin();
$acl->acl_add_option($permissions);
$error = array();
install_module('acp', 'acp_shoutbox', $error, 'ACP_CAT_DOT_MODS');
add_log('admin', 'LOG_AS_INSTALLED', VERSION);
trigger_error('MOD_INSTALLED');
function generate_sql(&$lineg, $dbms)
{
    global $phpbb_root_path, $phpEx;
    $dbms_type_map = array('mysql_41' => array('INT:' => 'int(%d)', 'BINT' => 'bigint(20)', 'UINT' => 'mediumint(8) UNSIGNED', 'UINT:' => 'int(%d) UNSIGNED', 'TINT:' => 'tinyint(%d)', 'USINT' => 'smallint(4) UNSIGNED', 'BOOL' => 'tinyint(1) UNSIGNED', 'VCHAR' => 'varchar(255)', 'VCHAR:' => 'varchar(%d)', 'CHAR:' => 'char(%d)', 'XSTEXT' => 'text', 'XSTEXT_UNI' => 'varchar(100)', 'STEXT' => 'text', 'STEXT_UNI' => 'varchar(255)', 'TEXT' => 'text', 'TEXT_UNI' => 'text', 'MTEXT' => 'mediumtext', 'MTEXT_UNI' => 'mediumtext', 'TIMESTAMP' => 'int(11) UNSIGNED', 'DECIMAL' => 'decimal(5,2)', 'DECIMAL:' => 'decimal(%d,2)', 'PDECIMAL' => 'decimal(6,3)', 'PDECIMAL:' => 'decimal(%d,3)', 'VCHAR_UNI' => 'varchar(255)', 'VCHAR_UNI:' => 'varchar(%d)', 'VCHAR_CI' => 'varchar(255)', 'VARBINARY' => 'varbinary(255)'), 'mysql_40' => array('INT:' => 'int(%d)', 'BINT' => 'bigint(20)', 'UINT' => 'mediumint(8) UNSIGNED', 'UINT:' => 'int(%d) UNSIGNED', 'TINT:' => 'tinyint(%d)', 'USINT' => 'smallint(4) UNSIGNED', 'BOOL' => 'tinyint(1) UNSIGNED', 'VCHAR' => 'varbinary(255)', 'VCHAR:' => 'varbinary(%d)', 'CHAR:' => 'binary(%d)', 'XSTEXT' => 'blob', 'XSTEXT_UNI' => 'blob', 'STEXT' => 'blob', 'STEXT_UNI' => 'blob', 'TEXT' => 'blob', 'TEXT_UNI' => 'blob', 'MTEXT' => 'mediumblob', 'MTEXT_UNI' => 'mediumblob', 'TIMESTAMP' => 'int(11) UNSIGNED', 'DECIMAL' => 'decimal(5,2)', 'DECIMAL:' => 'decimal(%d,2)', 'PDECIMAL' => 'decimal(6,3)', 'PDECIMAL:' => 'decimal(%d,3)', 'VCHAR_UNI' => 'blob', 'VCHAR_UNI:' => array('varbinary(%d)', 'limit' => array('mult', 3, 255, 'blob')), 'VCHAR_CI' => 'blob', 'VARBINARY' => 'varbinary(255)'), 'firebird' => array('INT:' => 'INTEGER', 'BINT' => 'DOUBLE PRECISION', 'UINT' => 'INTEGER', 'UINT:' => 'INTEGER', 'TINT:' => 'INTEGER', 'USINT' => 'INTEGER', 'BOOL' => 'INTEGER', 'VCHAR' => 'VARCHAR(255) CHARACTER SET NONE', 'VCHAR:' => 'VARCHAR(%d) CHARACTER SET NONE', 'CHAR:' => 'CHAR(%d) CHARACTER SET NONE', 'XSTEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', 'STEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', 'TEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', 'MTEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', 'XSTEXT_UNI' => 'VARCHAR(100) CHARACTER SET UTF8', 'STEXT_UNI' => 'VARCHAR(255) CHARACTER SET UTF8', 'TEXT_UNI' => 'BLOB SUB_TYPE TEXT CHARACTER SET UTF8', 'MTEXT_UNI' => 'BLOB SUB_TYPE TEXT CHARACTER SET UTF8', 'TIMESTAMP' => 'INTEGER', 'DECIMAL' => 'DOUBLE PRECISION', 'DECIMAL:' => 'DOUBLE PRECISION', 'PDECIMAL' => 'DOUBLE PRECISION', 'PDECIMAL:' => 'DOUBLE PRECISION', 'VCHAR_UNI' => 'VARCHAR(255) CHARACTER SET UTF8', 'VCHAR_UNI:' => 'VARCHAR(%d) CHARACTER SET UTF8', 'VCHAR_CI' => 'VARCHAR(255) CHARACTER SET UTF8', 'VARBINARY' => 'CHAR(255) CHARACTER SET NONE'), 'mssql' => array('INT:' => '[int]', 'BINT' => '[float]', 'UINT' => '[int]', 'UINT:' => '[int]', 'TINT:' => '[int]', 'USINT' => '[int]', 'BOOL' => '[int]', 'VCHAR' => '[varchar] (255)', 'VCHAR:' => '[varchar] (%d)', 'CHAR:' => '[char] (%d)', 'XSTEXT' => '[varchar] (1000)', 'STEXT' => '[varchar] (3000)', 'TEXT' => '[varchar] (8000)', 'MTEXT' => '[text]', 'XSTEXT_UNI' => '[varchar] (100)', 'STEXT_UNI' => '[varchar] (255)', 'TEXT_UNI' => '[varchar] (4000)', 'MTEXT_UNI' => '[text]', 'TIMESTAMP' => '[int]', 'DECIMAL' => '[float]', 'DECIMAL:' => '[float]', 'PDECIMAL' => '[float]', 'PDECIMAL:' => '[float]', 'VCHAR_UNI' => '[varchar] (255)', 'VCHAR_UNI:' => '[varchar] (%d)', 'VCHAR_CI' => '[varchar] (255)', 'VARBINARY' => '[varchar] (255)'), 'oracle' => array('INT:' => 'number(%d)', 'BINT' => 'number(20)', 'UINT' => 'number(8)', 'UINT:' => 'number(%d)', 'TINT:' => 'number(%d)', 'USINT' => 'number(4)', 'BOOL' => 'number(1)', 'VCHAR' => 'varchar2(255)', 'VCHAR:' => 'varchar2(%d)', 'CHAR:' => 'char(%d)', 'XSTEXT' => 'varchar2(1000)', 'STEXT' => 'varchar2(3000)', 'TEXT' => 'clob', 'MTEXT' => 'clob', 'XSTEXT_UNI' => 'varchar2(300)', 'STEXT_UNI' => 'varchar2(765)', 'TEXT_UNI' => 'clob', 'MTEXT_UNI' => 'clob', 'TIMESTAMP' => 'number(11)', 'DECIMAL' => 'number(5, 2)', 'DECIMAL:' => 'number(%d, 2)', 'PDECIMAL' => 'number(6, 3)', 'PDECIMAL:' => 'number(%d, 3)', 'VCHAR_UNI' => 'varchar2(765)', 'VCHAR_UNI:' => array('varchar2(%d)', 'limit' => array('mult', 3, 765, 'clob')), 'VCHAR_CI' => 'varchar2(255)', 'VARBINARY' => 'raw(255)'), 'sqlite' => array('INT:' => 'int(%d)', 'BINT' => 'bigint(20)', 'UINT' => 'INTEGER UNSIGNED', 'UINT:' => 'INTEGER UNSIGNED', 'TINT:' => 'tinyint(%d)', 'USINT' => 'INTEGER UNSIGNED', 'BOOL' => 'INTEGER UNSIGNED', 'VCHAR' => 'varchar(255)', 'VCHAR:' => 'varchar(%d)', 'CHAR:' => 'char(%d)', 'XSTEXT' => 'text(65535)', 'STEXT' => 'text(65535)', 'TEXT' => 'text(65535)', 'MTEXT' => 'mediumtext(16777215)', 'XSTEXT_UNI' => 'text(65535)', 'STEXT_UNI' => 'text(65535)', 'TEXT_UNI' => 'text(65535)', 'MTEXT_UNI' => 'mediumtext(16777215)', 'TIMESTAMP' => 'INTEGER UNSIGNED', 'DECIMAL' => 'decimal(5,2)', 'DECIMAL:' => 'decimal(%d,2)', 'PDECIMAL' => 'decimal(6,3)', 'PDECIMAL:' => 'decimal(%d,3)', 'VCHAR_UNI' => 'varchar(255)', 'VCHAR_UNI:' => 'varchar(%d)', 'VCHAR_CI' => 'varchar(255)', 'VARBINARY' => 'blob'), 'postgres' => array('INT:' => 'INT4', 'BINT' => 'INT8', 'UINT' => 'INT4', 'UINT:' => 'INT4', 'USINT' => 'INT2', 'BOOL' => 'INT2', 'TINT:' => 'INT2', 'VCHAR' => 'varchar(255)', 'VCHAR:' => 'varchar(%d)', 'CHAR:' => 'char(%d)', 'XSTEXT' => 'varchar(1000)', 'STEXT' => 'varchar(3000)', 'TEXT' => 'varchar(8000)', 'MTEXT' => 'TEXT', 'XSTEXT_UNI' => 'varchar(100)', 'STEXT_UNI' => 'varchar(255)', 'TEXT_UNI' => 'varchar(4000)', 'MTEXT_UNI' => 'TEXT', 'TIMESTAMP' => 'INT4', 'DECIMAL' => 'decimal(5,2)', 'DECIMAL:' => 'decimal(%d,2)', 'PDECIMAL' => 'decimal(6,3)', 'PDECIMAL:' => 'decimal(%d,3)', 'VCHAR_UNI' => 'varchar(255)', 'VCHAR_UNI:' => 'varchar(%d)', 'VCHAR_CI' => 'varchar_ci', 'VARBINARY' => 'bytea'));
    // A list of types being unsigned for better reference in some db's
    $unsigned_types = array('UINT', 'UINT:', 'USINT', 'BOOL', 'TIMESTAMP');
    $supported_dbms = array('firebird', 'mssql', 'mysql_40', 'mysql_41', 'oracle', 'postgres', 'sqlite');
    $schema_data = get_schema();
    if ($dbms == 'mysqli' || $dbms == 'mysql4') {
        $dbms = 'mysql_41';
开发者ID:paul999,项目名称:ajax-shoutbox,代码行数:31,代码来源:index.php

示例3: add_permissions

/**
 * simplification of auth_admin::acl_add()
 *
 * @param array $local_perms
 * @param array $global_perms
 */
function add_permissions($local_perms = array(), $global_perms = array())
{
    static $auth_admin = false;
    if (!$auth_admin) {
        // if it's not set, include auth_admin and create an object
        if (!class_exists('auth_admin')) {
            global $phpbb_root_path, $phpEx;
            include $phpbb_root_path . 'includes/acp/auth.' . $phpEx;
        }
        $auth_admin = new auth_admin();
    }
    // now let's add 'em
    $auth_admin->acl_add_option(array('local' => !empty($local_perms) && is_array($local_perms) ? $local_perms : array(), 'global' => !empty($global_perms) && is_array($global_perms) ? $global_perms : array()));
}
开发者ID:phpbbmodders-30x-mods,项目名称:modders-libs,代码行数:20,代码来源:functions_install.php

示例4: redirect

        }
        redirect(append_sid("{$phpbb_root_path}index.{$phpEx}"));
        break;
    case 'switch_perm':
        $user_id = request_var('u', 0);
        $sql = 'SELECT *
			FROM ' . USERS_TABLE . '
			WHERE user_id = ' . (int) $user_id;
        $result = $db->sql_query($sql);
        $user_row = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
        if (!$auth->acl_get('a_switchperm') || !$user_row || $user_id == $user->data['user_id'] || !check_link_hash(request_var('hash', ''), 'switchperm')) {
            redirect(append_sid("{$phpbb_root_path}index.{$phpEx}"));
        }
        include $phpbb_root_path . 'includes/acp/auth.' . $phpEx;
        $auth_admin = new auth_admin();
        if (!$auth_admin->ghost_permissions($user_id, $user->data['user_id'])) {
            redirect(append_sid("{$phpbb_root_path}index.{$phpEx}"));
        }
        add_log('admin', 'LOG_ACL_TRANSFER_PERMISSIONS', $user_row['username']);
        $message = sprintf($user->lang['PERMISSIONS_TRANSFERRED'], $user_row['username']) . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.{$phpEx}") . '">', '</a>');
        trigger_error($message);
        break;
    case 'restore_perm':
        if (!$user->data['user_perm_from'] || !$auth->acl_get('a_switchperm')) {
            redirect(append_sid("{$phpbb_root_path}index.{$phpEx}"));
        }
        $auth->acl_cache($user->data);
        $sql = 'SELECT username
			FROM ' . USERS_TABLE . '
			WHERE user_id = ' . $user->data['user_perm_from'];
开发者ID:puring0815,项目名称:OpenKore,代码行数:31,代码来源:ucp.php

示例5: change_database_data

function change_database_data(&$no_updates, $version)
{
	global $db, $errored, $error_ary, $config, $phpbb_root_path, $phpEx;

	switch ($version)
	{
		case '3.0.0':

			$sql = 'UPDATE ' . TOPICS_TABLE . "
				SET topic_last_view_time = topic_last_post_time
				WHERE topic_last_view_time = 0";
			_sql($sql, $errored, $error_ary);

			// Update smiley sizes
			$smileys = array('icon_e_surprised.gif', 'icon_eek.gif', 'icon_cool.gif', 'icon_lol.gif', 'icon_mad.gif', 'icon_razz.gif', 'icon_redface.gif', 'icon_cry.gif', 'icon_evil.gif', 'icon_twisted.gif', 'icon_rolleyes.gif', 'icon_exclaim.gif', 'icon_question.gif', 'icon_idea.gif', 'icon_arrow.gif', 'icon_neutral.gif', 'icon_mrgreen.gif', 'icon_e_ugeek.gif');

			foreach ($smileys as $smiley)
			{
				if (file_exists($phpbb_root_path . 'images/smilies/' . $smiley))
				{
					list($width, $height) = getimagesize($phpbb_root_path . 'images/smilies/' . $smiley);

					$sql = 'UPDATE ' . SMILIES_TABLE . '
						SET smiley_width = ' . $width . ', smiley_height = ' . $height . "
						WHERE smiley_url = '" . $db->sql_escape($smiley) . "'";

					_sql($sql, $errored, $error_ary);
				}
			}

			$no_updates = false;
		break;

		// No changes from 3.0.1-RC1 to 3.0.1
		case '3.0.1-RC1':
		break;

		// changes from 3.0.1 to 3.0.2-RC1
		case '3.0.1':

			set_config('referer_validation', '1');
			set_config('check_attachment_content', '1');
			set_config('mime_triggers', 'body|head|html|img|plaintext|a href|pre|script|table|title');

			$no_updates = false;
		break;

		// No changes from 3.0.2-RC1 to 3.0.2-RC2
		case '3.0.2-RC1':
		break;

		// No changes from 3.0.2-RC2 to 3.0.2
		case '3.0.2-RC2':
		break;

		// Changes from 3.0.2 to 3.0.3-RC1
		case '3.0.2':
			set_config('enable_queue_trigger', '0');
			set_config('queue_trigger_posts', '3');

			set_config('pm_max_recipients', '0');

			// Set maximum number of recipients for the registered users, bots, guests group
			$sql = 'UPDATE ' . GROUPS_TABLE . ' SET group_max_recipients = 5
				WHERE ' . $db->sql_in_set('group_name', array('GUESTS', 'REGISTERED', 'REGISTERED_COPPA', 'BOTS'));
			_sql($sql, $errored, $error_ary);

			// Not prefilling yet
			set_config('dbms_version', '');

			// Add new permission u_masspm_group and duplicate settings from u_masspm
			include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx);
			$auth_admin = new auth_admin();

			// Only add the new permission if it does not already exist
			if (empty($auth_admin->acl_options['id']['u_masspm_group']))
			{
				$auth_admin->acl_add_option(array('global' => array('u_masspm_group')));

				// Now the tricky part, filling the permission
				$old_id = $auth_admin->acl_options['id']['u_masspm'];
				$new_id = $auth_admin->acl_options['id']['u_masspm_group'];

				$tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE);

				foreach ($tables as $table)
				{
					$sql = 'SELECT *
						FROM ' . $table . '
						WHERE auth_option_id = ' . $old_id;
					$result = _sql($sql, $errored, $error_ary);

					$sql_ary = array();
					while ($row = $db->sql_fetchrow($result))
					{
						$row['auth_option_id'] = $new_id;
						$sql_ary[] = $row;
					}
					$db->sql_freeresult($result);

//.........这里部分代码省略.........
开发者ID:kellanved,项目名称:phpbb3,代码行数:101,代码来源:database_update.php

示例6: main


//.........这里部分代码省略.........
							'GROUP_TYPE'			=> $user->lang['USER_GROUP_' . strtoupper($group_type)])
						);
					}

					foreach ($data_ary as $data)
					{
						$template->assign_block_vars('group', array(
							'U_EDIT_GROUP'		=> append_sid("{$phpbb_admin_path}index.$phpEx", "i=groups&amp;mode=manage&amp;action=edit&amp;u=$user_id&amp;g={$data['group_id']}&amp;back_link=acp_users_groups"),
							'U_DEFAULT'			=> $this->u_action . "&amp;action=default&amp;u=$user_id&amp;g=" . $data['group_id'],
							'U_DEMOTE_PROMOTE'	=> $this->u_action . '&amp;action=' . (($data['group_leader']) ? 'demote' : 'promote') . "&amp;u=$user_id&amp;g=" . $data['group_id'],
							'U_DELETE'			=> $this->u_action . "&amp;action=delete&amp;u=$user_id&amp;g=" . $data['group_id'],

							'GROUP_NAME'		=> ($group_type == 'special') ? $user->lang['G_' . $data['group_name']] : $data['group_name'],
							'L_DEMOTE_PROMOTE'	=> ($data['group_leader']) ? $user->lang['GROUP_DEMOTE'] : $user->lang['GROUP_PROMOTE'],

							'S_NO_DEFAULT'		=> ($user_row['group_id'] != $data['group_id']) ? true : false,
							'S_SPECIAL_GROUP'	=> ($group_type == 'special') ? true : false,
							)
						);
					}
				}

				$template->assign_vars(array(
					'S_GROUPS'			=> true,
					'S_GROUP_OPTIONS'	=> $s_group_options)
				);

			break;

			case 'perm':

				include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx);

				$auth_admin = new auth_admin();

				$user->add_lang('acp/permissions');
				add_permission_language();

				$forum_id = request_var('f', 0);

				// Global Permissions
				if (!$forum_id)
				{
					// Select auth options
					$sql = 'SELECT auth_option, is_local, is_global
						FROM ' . ACL_OPTIONS_TABLE . '
						WHERE auth_option ' . $db->sql_like_expression($db->any_char . '_') . '
							AND is_global = 1
						ORDER BY auth_option';
					$result = $db->sql_query($sql);

					$hold_ary = array();
					
					while ($row = $db->sql_fetchrow($result))
					{
						$hold_ary = $auth_admin->get_mask('view', $user_id, false, false, $row['auth_option'], 'global', ACL_NEVER);
						$auth_admin->display_mask('view', $row['auth_option'], $hold_ary, 'user', false, false);
					}
					$db->sql_freeresult($result);

					unset($hold_ary);
				}
				else
				{
					$sql = 'SELECT auth_option, is_local, is_global
						FROM ' . ACL_OPTIONS_TABLE . "
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:67,代码来源:acp_users.php

示例7: change_database_data

function change_database_data(&$no_updates, $version)
{
    global $db, $db_tools, $errored, $error_ary, $config, $table_prefix, $phpbb_root_path, $phpEx;
    switch ($version) {
        case '3.0.0':
            $sql = 'UPDATE ' . TOPICS_TABLE . "\n\t\t\t\tSET topic_last_view_time = topic_last_post_time\n\t\t\t\tWHERE topic_last_view_time = 0";
            _sql($sql, $errored, $error_ary);
            // Update smiley sizes
            $smileys = array('icon_e_surprised.gif', 'icon_eek.gif', 'icon_cool.gif', 'icon_lol.gif', 'icon_mad.gif', 'icon_razz.gif', 'icon_redface.gif', 'icon_cry.gif', 'icon_evil.gif', 'icon_twisted.gif', 'icon_rolleyes.gif', 'icon_exclaim.gif', 'icon_question.gif', 'icon_idea.gif', 'icon_arrow.gif', 'icon_neutral.gif', 'icon_mrgreen.gif', 'icon_e_ugeek.gif');
            foreach ($smileys as $smiley) {
                if (file_exists($phpbb_root_path . 'images/smilies/' . $smiley)) {
                    list($width, $height) = getimagesize($phpbb_root_path . 'images/smilies/' . $smiley);
                    $sql = 'UPDATE ' . SMILIES_TABLE . '
						SET smiley_width = ' . $width . ', smiley_height = ' . $height . "\n\t\t\t\t\t\tWHERE smiley_url = '" . $db->sql_escape($smiley) . "'";
                    _sql($sql, $errored, $error_ary);
                }
            }
            $no_updates = false;
            break;
            // No changes from 3.0.1-RC1 to 3.0.1
        // No changes from 3.0.1-RC1 to 3.0.1
        case '3.0.1-RC1':
            break;
            // changes from 3.0.1 to 3.0.2-RC1
        // changes from 3.0.1 to 3.0.2-RC1
        case '3.0.1':
            set_config('referer_validation', '1');
            set_config('check_attachment_content', '1');
            set_config('mime_triggers', 'body|head|html|img|plaintext|a href|pre|script|table|title');
            $no_updates = false;
            break;
            // No changes from 3.0.2-RC1 to 3.0.2-RC2
        // No changes from 3.0.2-RC1 to 3.0.2-RC2
        case '3.0.2-RC1':
            break;
            // No changes from 3.0.2-RC2 to 3.0.2
        // No changes from 3.0.2-RC2 to 3.0.2
        case '3.0.2-RC2':
            break;
            // Changes from 3.0.2 to 3.0.3-RC1
        // Changes from 3.0.2 to 3.0.3-RC1
        case '3.0.2':
            set_config('enable_queue_trigger', '0');
            set_config('queue_trigger_posts', '3');
            set_config('pm_max_recipients', '0');
            // Set maximum number of recipients for the registered users, bots, guests group
            $sql = 'UPDATE ' . GROUPS_TABLE . ' SET group_max_recipients = 5
				WHERE ' . $db->sql_in_set('group_name', array('GUESTS', 'REGISTERED', 'REGISTERED_COPPA', 'BOTS'));
            _sql($sql, $errored, $error_ary);
            // Not prefilling yet
            set_config('dbms_version', '');
            // Add new permission u_masspm_group and duplicate settings from u_masspm
            include_once $phpbb_root_path . 'includes/acp/auth.' . $phpEx;
            $auth_admin = new auth_admin();
            // Only add the new permission if it does not already exist
            if (empty($auth_admin->acl_options['id']['u_masspm_group'])) {
                $auth_admin->acl_add_option(array('global' => array('u_masspm_group')));
                // Now the tricky part, filling the permission
                $old_id = $auth_admin->acl_options['id']['u_masspm'];
                $new_id = $auth_admin->acl_options['id']['u_masspm_group'];
                $tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE);
                foreach ($tables as $table) {
                    $sql = 'SELECT *
						FROM ' . $table . '
						WHERE auth_option_id = ' . $old_id;
                    $result = _sql($sql, $errored, $error_ary);
                    $sql_ary = array();
                    while ($row = $db->sql_fetchrow($result)) {
                        $row['auth_option_id'] = $new_id;
                        $sql_ary[] = $row;
                    }
                    $db->sql_freeresult($result);
                    if (sizeof($sql_ary)) {
                        $db->sql_multi_insert($table, $sql_ary);
                    }
                }
                // Remove any old permission entries
                $auth_admin->acl_clear_prefetch();
            }
            /**
            * Do not resync post counts here. An admin may do this later from the ACP
            $start = 0;
            $step = ($config['num_posts']) ? (max((int) ($config['num_posts'] / 5), 20000)) : 20000;
            
            $sql = 'UPDATE ' . USERS_TABLE . ' SET user_posts = 0';
            _sql($sql, $errored, $error_ary);
            
            do
            {
            	$sql = 'SELECT COUNT(post_id) AS num_posts, poster_id
            		FROM ' . POSTS_TABLE . '
            		WHERE post_id BETWEEN ' . ($start + 1) . ' AND ' . ($start + $step) . '
            			AND post_postcount = 1 AND post_approved = 1
            		GROUP BY poster_id';
            	$result = _sql($sql, $errored, $error_ary);
            
            	if ($row = $db->sql_fetchrow($result))
            	{
            		do
            		{
//.........这里部分代码省略.........
开发者ID:PetsFundation,项目名称:Pets,代码行数:101,代码来源:database_update.php

示例8: add_permissions

	/**
	* Add permissions groups
	*/
	function add_permissions($mode, $sub)
	{
		global $phpbb_root_path, $phpEx, $db, $errored, $error_ary;

		// Reset permissions
		$sql = 'UPDATE ' . USERS_TABLE . "
			SET user_permissions = '',
				user_perm_from = 0";
		$db->sql_query($sql);

		// Add new permissions u_karma_can, u_karma_view, f_karma_can and f_karma_view
		// and duplicate settings from u_viewprofile
		include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx);
		$auth_admin = new auth_admin();

		// Add u_karma_can permission, only if it doesn not already exist
		if (!isset($auth_admin->acl_options['id']['u_karma_can']))
		{
			$auth_admin->acl_add_option(array('global' => array('u_karma_can')));

			// Now the tricky part, filling the permission
			$old_id = $auth_admin->acl_options['id']['u_viewprofile'];
			$new_id = $auth_admin->acl_options['id']['u_karma_can'];

			$tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE);

			foreach ($tables as $table)
			{
				$sql = 'SELECT *
					FROM ' . $table . '
					WHERE auth_option_id = ' . $old_id;
				$result = $db->sql_query($sql);

				$sql_ary = array();
				while ($row = $db->sql_fetchrow($result))
				{
					$row['auth_option_id'] = $new_id;
					$sql_ary[] = $row;
				}
				$db->sql_freeresult($result);

				if (sizeof($sql_ary))
				{
					$db->sql_multi_insert($table, $sql_ary);
				}
			}

			// Remove any old permission entries
			$auth_admin->acl_clear_prefetch();
		}

		// Add u_karma_view permission, only if it doesn not already exist
		if (!isset($auth_admin->acl_options['id']['u_karma_view']))
		{
			$auth_admin->acl_add_option(array('global' => array('u_karma_view')));

			// Now the tricky part, filling the permission
			$old_id = $auth_admin->acl_options['id']['u_viewprofile'];
			$new_id = $auth_admin->acl_options['id']['u_karma_view'];

			$tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE);

			foreach ($tables as $table)
			{
				$sql = 'SELECT *
					FROM ' . $table . '
					WHERE auth_option_id = ' . $old_id;
				$result = $db->sql_query($sql);

				$sql_ary = array();
				while ($row = $db->sql_fetchrow($result))
				{
					$row['auth_option_id'] = $new_id;
					$sql_ary[] = $row;
				}
				$db->sql_freeresult($result);

				if (sizeof($sql_ary))
				{
					$db->sql_multi_insert($table, $sql_ary);
				}
			}

			// Remove any old permission entries
			$auth_admin->acl_clear_prefetch();
		}

		// Add f_karma_can permission, only if it doesn not already exist
		if (!isset($auth_admin->acl_options['id']['f_karma_can']))
		{
			$auth_admin->acl_add_option(array('local' => array('f_karma_can')));

			// Now the tricky part, filling the permission
			$old_id = $auth_admin->acl_options['id']['f_reply'];
			$new_id = $auth_admin->acl_options['id']['f_karma_can'];

			$tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE);
//.........这里部分代码省略.........
开发者ID:esacinc,项目名称:forum-sitplatform-org-website,代码行数:101,代码来源:install_install.php

示例9: wpu_do_upgrade

function wpu_do_upgrade($action)
{
    global $phpbbForum, $wpUnited, $debug, $db, $wpuDebug, $phpbb_root_path, $phpEx;
    switch ($action) {
        /**
         *	UPGRADING <0.9.2.0 TO 0.9.2.0
         *	-----------------------------
         * in this version, we move the cross-posting column from POSTS_TABLE to TOPICS_TABLE
         */
        case 'from <0.9.2.0':
            $wpuDebug->add("Upgrading WP-United {$action}");
            $fStateChanged = $phpbbForum->foreground();
            $db->sql_return_on_error(true);
            $sql = 'ALTER TABLE ' . TOPICS_TABLE . ' 
				ADD topic_wpu_xpost VARCHAR(10) NULL DEFAULT NULL';
            @$db->sql_query($sql);
            //Now copy across data from posts column to topics column
            $sql = 'SELECT post_wpu_xpost, topic_id FROM ' . POSTS_TABLE . ' 
					WHERE post_wpu_xpost > 0';
            if ($result = $db->sql_query($sql)) {
                while ($row = $db->sql_fetchrow($result)) {
                    $sql = 'UPDATE ' . TOPICS_TABLE . ' 
						SET topic_wpu_xpost = ' . (int) $row['post_wpu_xpost'] . '
						WHERE topic_id = ' . (int) $row['topic_id'];
                    @$db->sql_query($sql);
                }
            }
            $db->sql_freeresult($result);
            // Now delete the posts column
            $sql = 'ALTER TABLE ' . POSTS_TABLE . ' DROP COLUMN post_wpu_xpost';
            @$db->sql_query($sql);
            $db->sql_return_on_error(false);
            $phpbbForum->restore_state($fStateChanged);
            // no break!
        // no break!
        case 'from 0.9.2.0-r0':
            $wpuDebug->add("Upgrading WP-United {$action}");
            $fStateChanged = $phpbbForum->foreground();
            $db->sql_return_on_error(true);
            // Add new x-posting columns
            $sql = 'ALTER TABLE ' . POSTS_TABLE . ' 
				ADD post_wpu_xpost_parent VARCHAR(10) NULL DEFAULT NULL, 
				ADD post_wpu_xpost_meta1 VARCHAR(255) NULL DEFAULT NULL, 
				ADD post_wpu_xpost_meta2 VARCHAR(255) NULL DEFAULT NULL';
            @$db->sql_query($sql);
            $db->sql_return_on_error(false);
            $phpbbForum->restore_state($fStateChanged);
            // no break!
        // no break!
        case 'from 0.9.2.0-r1':
            $wpuDebug->add("Upgrading WP-United {$action}");
            $fStateChanged = $phpbbForum->foreground();
            // Setup $auth_admin class so we can add permission options
            include_once $phpbb_root_path . 'includes/acp/auth.' . $phpEx;
            $auth_admin = new auth_admin();
            // Add permissions
            $auth_admin->acl_add_option(array('local' => array('f_wpu_xpost', 'f_wpu_xpost_comment'), 'global' => array('u_wpu_subscriber', 'u_wpu_contributor', 'u_wpu_author', 'm_wpu_editor', 'a_wpu_administrator')));
            $phpbbForum->restore_state($fStateChanged);
        default:
            break;
    }
}
开发者ID:snitchashor,项目名称:wp-united,代码行数:62,代码来源:upgrade.php

示例10: auth_admin

<?php

include 'sso.php';
$auth_options = ["u_mission_list", "u_mission_admin", "u_member_page", "u_member_admin", "u_front_page_admin"];
$global = true;
if (!class_exists('auth_admin')) {
    global $phpbb_root_path, $phpEx;
    include $phpbb_root_path . 'includes/acp/auth.' . $phpEx;
}
$auth_admin = new auth_admin();
$auth_admin->acl_add_option(array('global' => $auth_options));
开发者ID:BourbonWarfare,项目名称:BWWebApplication,代码行数:11,代码来源:add_perms.php

示例11: implode

if (!isset($forum_id[$which_mode])) {
    $forum_id[$which_mode][] = 0;
}
$sql_forum_id = implode(', ', array_map('intval', $forum_id[$which_mode]));
// Generate list of forum id's
$s_forum_id = '';
foreach ($forum_id as $forum_submode => $forum_submode_ids) {
    foreach ($forum_submode_ids as $submode_forum_id) {
        $s_forum_id .= '<input type="hidden" name="f[' . $forum_submode . '][]" value="' . $submode_forum_id . '" />';
    }
}
unset($forum_submode_ids);
unset($forum_submode);
unset($submode_forum_id);
// Instantiate a new auth admin object in readiness
$auth_admin = new auth_admin();
// Are we setting deps? If we are we need to re-run the mode match above for the
// relevant 'new' mode
if (!empty($submode)) {
    switch ($submode) {
        case 'forum':
            $l_title_explain = $_CLASS['core_user']->lang['PERMISSIONS_EXPLAIN'];
            $which_acl = 'a_auth';
            $sql_option_mode = 'f';
            break;
        case 'mod':
            $l_title_explain = $_CLASS['core_user']->lang['MODERATORS_EXPLAIN'];
            $which_acl = 'a_authmods';
            $sql_option_mode = 'm';
            break;
        case 'supermod':
开发者ID:BackupTheBerlios,项目名称:viperals-svn,代码行数:31,代码来源:admin_permissions.php

示例12: request_var

include $phpbb_root_path . 'common.' . $phpEx;
/**
* Setup user session, authorisation & language 
*/
$user->session_begin();
$auth->acl($user->data);
$user->setup('mods/garage');
//Get Mode Required For Page
$mode = request_var('mode', '');
$page_title = 'Manage Garage Permissions';
// Output the page
page_header($page_title);
$template->set_filenames(array('body' => 'message_body.html'));
//Setup $auth_admin class so we can add permission options
include $phpbb_root_path . '/includes/acp/auth.' . $phpEx;
$auth_admin = new auth_admin();
//Decide What Mode The User Is Doing
switch ($mode) {
    case 'add':
        //Lets Add The Required New Permissions
        $phpbbgarage_permissions = array('local' => array(), 'global' => array('u_garage_browse', 'u_garage_search', 'u_garage_add_vehicle', 'u_garage_delete_vehicle', 'u_garage_add_modification', 'u_garage_delete_modification', 'u_garage_add_quartermile', 'u_garage_delete_quartermile', 'u_garage_add_lap', 'u_garage_delete_lap', 'u_garage_add_track', 'u_garage_delete_track', 'u_garage_add_dynorun', 'u_garage_delete_dynorun', 'u_garage_add_insurance', 'u_garage_delete_insurance', 'u_garage_add_service', 'u_garage_delete_service', 'u_garage_add_blog', 'u_garage_delete_blog', 'u_garage_add_business', 'u_garage_add_make_model', 'u_garage_add_product', 'u_garage_rate', 'u_garage_comment', 'u_garage_upload_image', 'u_garage_remote_image', 'u_garage_delete_image', 'u_garage_deny', 'm_garage_edit', 'm_garage_delete', 'm_garage_rating', 'm_garage_approve_vehicle', 'm_garage_approve_make', 'm_garage_approve_model', 'm_garage_approve_business', 'm_garage_approve_quartermile', 'm_garage_approve_dynorun', 'm_garage_approve_guestbook', 'm_garage_approve_lap', 'm_garage_approve_track', 'm_garage_approve_product', 'a_garage_setting', 'a_garage_business', 'a_garage_category', 'a_garage_field', 'a_garage_model', 'a_garage_product', 'a_garage_quota', 'a_garage_tool', 'a_garage_track'));
        $auth_admin->acl_add_option($phpbbgarage_permissions);
        //Standard Admin Role
        $role = get_role_by_name('ROLE_ADMIN_STANDARD');
        if ($role) {
            acl_update_role($role['role_id'], array('a_garage_setting', 'a_garage_business', 'a_garage_category', 'a_garage_field', 'a_garage_model', 'a_garage_product', 'a_garage_quota', 'a_garage_tool', 'a_garage_track'));
        }
        //Full Admin Role
        $role = get_role_by_name('ROLE_ADMIN_FULL');
        if ($role) {
            acl_update_role($role['role_id'], array('a_garage_setting', 'a_garage_business', 'a_garage_category', 'a_garage_field', 'a_garage_model', 'a_garage_product', 'a_garage_quota', 'a_garage_tool', 'a_garage_track'));
开发者ID:Phatboy82,项目名称:phpbbgarage,代码行数:31,代码来源:manage_garage_permissions.php

示例13: synchronise_settings

    /**
     * transmits new settings from the WP settings panel to phpBB
     */
    public function synchronise_settings($dataToStore)
    {
        global $wpUnited, $cache, $user, $auth, $config, $db, $phpbb_root_path, $phpEx;
        if (empty($dataToStore)) {
            echo "No settings to process";
            return false;
        }
        $fStateChanged = $this->foreground();
        $adminLog = array();
        $adminLog[] = __('Receiving settings from WP-United...', 'wp-united');
        /**
         * MySQL will not allow duplicate column names, so we can suppress errors (we still check anyway)
         */
        $db->sql_return_on_error(true);
        if (!array_key_exists('user_wpuint_id', $user->data)) {
            $sql = 'ALTER TABLE ' . USERS_TABLE . ' 
				  ADD user_wpuint_id VARCHAR(10) NULL DEFAULT NULL';
            @$db->sql_query($sql);
            $adminLog[] = __('Modified USERS Table (Integration ID)', 'wp-united');
        }
        if (!array_key_exists('user_wpublog_id', $user->data)) {
            $sql = 'ALTER TABLE ' . USERS_TABLE . ' 
				ADD user_wpublog_id VARCHAR(10) NULL DEFAULT NULL';
            @$db->sql_query($sql);
            $adminLog[] = __('Modified USERS Table (Blog ID)', 'wp-united');
        }
        //Add an x-posting column to topics
        $sql = 'SELECT * FROM ' . TOPICS_TABLE;
        $result = $db->sql_query_limit($sql, 1);
        $row = (array) $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
        if (!array_key_exists('topic_wpu_xpost', $row)) {
            $sql = 'ALTER TABLE ' . TOPICS_TABLE . ' 
				ADD topic_wpu_xpost VARCHAR(10) NULL DEFAULT NULL';
            @$db->sql_query($sql);
            // Add new columns
            $sql = 'ALTER TABLE ' . POSTS_TABLE . ' 
				ADD post_wpu_xpost_parent VARCHAR(10) NULL DEFAULT NULL, 
				ADD post_wpu_xpost_meta1 VARCHAR(255) NULL DEFAULT NULL, 
				ADD post_wpu_xpost_meta2 VARCHAR(255) NULL DEFAULT NULL';
            @$db->sql_query($sql);
            $adminLog[] = __('Modified TOPICS and POSTS Tables (Cross-Posting ability)', 'wp-united');
        }
        $db->sql_return_on_error(false);
        $adminLog[] = __('Adding WP-United Permissions', 'wp-united');
        // Setup $auth_admin class so we can add permission options
        include_once $phpbb_root_path . 'includes/acp/auth.' . $phpEx;
        $auth_admin = new auth_admin();
        // Add permissions
        $auth_admin->acl_add_option(array('local' => array('f_wpu_xpost', 'f_wpu_xpost_comment'), 'global' => array('u_wpu_subscriber', 'u_wpu_contributor', 'u_wpu_author', 'm_wpu_editor', 'a_wpu_administrator')));
        $adminLog[] = __('Storing the new WP-United settings', 'wp-united');
        // this stores the passed-in settings object, which is a bit brittle
        // TODO: ask $wpUnited->settings to store/reload itself, without making it public
        $this->clear_settings();
        $sql = array();
        $sql[] = array('config_name' => 'wpu_location', 'config_value' => $wpUnited->get_plugin_path());
        $dataIn = base64_encode(gzcompress(serialize($dataToStore)));
        $currPtr = 1;
        $chunkStart = 0;
        while ($chunkStart < strlen($dataIn)) {
            $sql[] = array('config_name' => "wpu_settings_{$currPtr}", 'config_value' => substr($dataIn, $chunkStart, 255));
            $chunkStart = $chunkStart + 255;
            $currPtr++;
        }
        $db->sql_multi_insert(CONFIG_TABLE, $sql);
        $cache->destroy('config');
        if ($wpUnited->get_setting('integrateLogin') && $wpUnited->get_setting('avatarsync')) {
            if (!$config['allow_avatar'] || !$config['allow_avatar_remote']) {
                $adminLog[] = __('Updating avatar settings', 'wp-united');
                $sql = 'UPDATE ' . CONFIG_TABLE . ' 
					SET config_value = 1
					WHERE ' . $db->sql_in_set('config_name', array('allow_avatar', 'allow_avatar_remote'));
                $db->sql_query($sql);
                $cache->destroy('config');
            }
        }
        // clear out the WP-United cache on settings change
        $adminLog[] = __('Purging the WP-United cache', 'wp-united');
        $wpuCache = WPU_Cache::getInstance();
        $wpuCache->purge();
        $adminLog[] = __('Completed successfully', 'wp-united');
        // Save the admin log in a nice dropdown in phpBB admin log.
        // Requires a bit of template hacking using JS since we don't want to have to do a mod edit for new script
        // generate unique ID for details ID
        $randSeed = rand(0, 99999);
        $bodyContent = '<div style="display: none; border: 1px solid #cccccc; background-color: #ccccff; padding: 3px;" id="wpulogdets' . $randSeed . '">';
        $bodyContent .= implode("<br />\n\n", $adminLog) . '</div>';
        $ln = "*}<span class='wpulog'><script type=\"text/javascript\">// <![CDATA[\n\t\tvar d = document;\n\t\tfunction wputgl{$randSeed}() {\n\t\t\tvar l = d.getElementById('wpulogdets{$randSeed}');\n\t\t\tvar p = d.getElementById('wpulogexp{$randSeed}'); var n = p.firstChild.nodeValue;\n\t\t\tl.style.display = (n == '-') ? 'none' : 'block';\n\t\t\tp.firstChild.nodeValue = (n == '-') ? '+' : '-';\n\t\t\treturn false;\n\t\t}\n\t\tif(typeof wpual == 'undefined') {\n\t\t\tvar wpual = window.onload;\n\t\t\twindow.onload = function() {\n\t\t\t\tif (typeof wpual == 'function') wpual();\n\t\t\t\ttry {\n\t\t\t\t\tvar hs = d.getElementsByClassName('wpulog');\n\t\t\t\t\tfor(h in hs) {var p = hs[h].parentNode; p.firstChild.nodeValue = ''; p.lastChild.nodeValue = '';}\n\t\t\t\t} catch(e) {}\t  \n\t\t\t};\n\t\t}\n\t\t// ]]>\n\t\t</script>";
        $ln .= '<strong><a href="#" onclick="return wputgl' . $randSeed . '();" title="click to see details">' . __('Changed WP-United Settings (click for details)', 'wp-united') . '<span id="wpulogexp' . $randSeed . '">+</span></a></strong>' . $bodyContent . '</span>{*';
        add_log('admin', $ln);
        $cache->purge();
        $this->restore_state($fStateChanged);
        return true;
    }
开发者ID:snitchashor,项目名称:wp-united,代码行数:97,代码来源:phpbb.php

示例14: set_ideas_forum_options

    /**
     * Set ideas forum options
     *
     * @return void
     * @access public
     */
    public function set_ideas_forum_options()
    {
        // Check if Ideas forum is selected and apply relevant settings if it is
        // But display the confirm box first
        if (confirm_box(true)) {
            if (empty($this->config['ideas_forum_id'])) {
                trigger_error($this->language->lang('ACP_IDEAS_NO_FORUM') . adm_back_link($this->u_action), E_USER_WARNING);
            }
            if (!class_exists('auth_admin')) {
                include $this->phpbb_root_path . 'includes/acp/auth.' . $this->php_ext;
            }
            $auth_admin = new \auth_admin();
            $forum_id = (int) $this->config['ideas_forum_id'];
            // Get the REGISTERED usergroup ID
            $sql = 'SELECT group_id
				FROM ' . GROUPS_TABLE . "\n\t\t\t\tWHERE group_name = '" . $this->db->sql_escape('REGISTERED') . "'";
            $this->db->sql_query($sql);
            $group_id = (int) $this->db->sql_fetchfield('group_id');
            // Get 'f_' local REGISTERED users group permissions array for the ideas forum
            // Default undefined permissions to ACL_NO
            $hold_ary = $auth_admin->get_mask('set', false, $group_id, $forum_id, 'f_', 'local', ACL_NO);
            $auth_settings = $hold_ary[$group_id][$forum_id];
            // Set 'Can start new topics' permissions to 'Never' for the ideas forum
            $auth_settings['f_post'] = ACL_NEVER;
            // Update the registered usergroup permissions for selected Ideas forum...
            $auth_admin->acl_set('group', $forum_id, $group_id, $auth_settings);
            // Disable auto-pruning for ideas forum
            $sql = 'UPDATE ' . FORUMS_TABLE . '
				SET ' . $this->db->sql_build_array('UPDATE', array('enable_prune' => false)) . '
				WHERE forum_id = ' . $forum_id;
            $this->db->sql_query($sql);
            $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'ACP_PHPBB_IDEAS_FORUM_SETUP_LOG');
            trigger_error($this->language->lang('ACP_IDEAS_FORUM_SETUP_UPDATED') . adm_back_link($this->u_action));
        } else {
            confirm_box(false, $this->language->lang('ACP_IDEAS_FORUM_SETUP_CONFIRM'), build_hidden_fields(array('ideas_forum_setup' => $this->request->is_set_post('ideas_forum_setup'))));
        }
    }
开发者ID:VSEphpbb,项目名称:phpbb-ideas,代码行数:43,代码来源:admin_controller.php

示例15: add

    /**
     * Permission Add
     *
     * Add a permission (auth) option
     *
     * @param string $auth_option The name of the permission (auth) option
     * @param bool $global True for checking a global permission setting,
     * 	False for a local permission setting
     * @param int|false $copy_from If set, contains the id of the permission from which to copy the new one.
     * @return null
     */
    public function add($auth_option, $global = true, $copy_from = false)
    {
        if ($this->exists($auth_option, $global)) {
            return;
        }
        // We've added permissions, so set to true to notify the user.
        $this->permissions_added = true;
        if (!class_exists('auth_admin')) {
            include $this->phpbb_root_path . 'includes/acp/auth.' . $this->php_ext;
        }
        $auth_admin = new \auth_admin();
        // We have to add a check to see if the !$global (if global, local, and if local, global) permission already exists.  If it does, acl_add_option currently has a bug which would break the ACL system, so we are having a work-around here.
        if ($this->exists($auth_option, !$global)) {
            $sql_ary = array('is_global' => 1, 'is_local' => 1);
            $sql = 'UPDATE ' . ACL_OPTIONS_TABLE . '
				SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\tWHERE auth_option = '" . $this->db->sql_escape($auth_option) . "'";
            $this->db->sql_query($sql);
        } else {
            if ($global) {
                $auth_admin->acl_add_option(array('global' => array($auth_option)));
            } else {
                $auth_admin->acl_add_option(array('local' => array($auth_option)));
            }
        }
        // The permission has been added, now we can copy it if needed
        if ($copy_from && isset($auth_admin->acl_options['id'][$copy_from])) {
            $old_id = $auth_admin->acl_options['id'][$copy_from];
            $new_id = $auth_admin->acl_options['id'][$auth_option];
            $tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE);
            foreach ($tables as $table) {
                $sql = 'SELECT *
					FROM ' . $table . '
					WHERE auth_option_id = ' . $old_id;
                $result = $this->db->sql_query($sql);
                $sql_ary = array();
                while ($row = $this->db->sql_fetchrow($result)) {
                    $row['auth_option_id'] = $new_id;
                    $sql_ary[] = $row;
                }
                $this->db->sql_freeresult($result);
                if (!empty($sql_ary)) {
                    $this->db->sql_multi_insert($table, $sql_ary);
                }
            }
            $auth_admin->acl_clear_prefetch();
        }
    }
开发者ID:phpbb,项目名称:phpbb-core,代码行数:58,代码来源:permission.php


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