本文整理汇总了PHP中auth_admin::acl_clear_prefetch方法的典型用法代码示例。如果您正苦于以下问题:PHP auth_admin::acl_clear_prefetch方法的具体用法?PHP auth_admin::acl_clear_prefetch怎么用?PHP auth_admin::acl_clear_prefetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类auth_admin
的用法示例。
在下文中一共展示了auth_admin::acl_clear_prefetch方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: change_database_data
//.........这里部分代码省略.........
// 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
{
$sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = user_posts + {$row['num_posts']} WHERE user_id = {$row['poster_id']}";
_sql($sql, $errored, $error_ary);
}
while ($row = $db->sql_fetchrow($result));
$start += $step;
}
else
{
示例2: change_database_data
//.........这里部分代码省略.........
// 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
{
$sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = user_posts + {$row['num_posts']} WHERE user_id = {$row['poster_id']}";
_sql($sql, $errored, $error_ary);
}
while ($row = $db->sql_fetchrow($result));
$start += $step;
}
else
{
示例3: 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
{
//.........这里部分代码省略.........
示例4: 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();
}
}
示例5: foreach
/**
* Delete ALL phpBB Garage Data
*/
function delete_garage_data($mode, $sub)
{
global $cache, $db, $phpbb_root_path, $phpEx, $table_prefix, $lang, $template;
$this->page_title = $lang['STAGE_OPTIONAL'];
//Setup $auth_admin class so we can remove permission options
include $phpbb_root_path . '/includes/acp/auth.' . $phpEx;
include $phpbb_root_path . '/includes/acp/acp_modules.' . $phpEx;
$auth_admin = new auth_admin();
$module_admin = new acp_modules();
// lets get rid of phpBB Garage internal data first
foreach ($this->garage_tables as $table) {
$db->sql_query('DROP TABLE ' . $table_prefix . $table);
}
// lets get rid of phpBB Garage internal data first
if ($db->sql_layer == 'postgres') {
foreach ($this->garage_postgres_sequences as $sequence) {
$db->sql_query('DROP SEQUENCE ' . $table_prefix . $sequence);
}
}
// next for the chop is permisions we added
foreach ($this->garage_permissions as $permission) {
// get auth option id so we can remove it from any user, group or role
$sql = $db->sql_build_query('SELECT', array('SELECT' => 'acl.auth_option_id', 'FROM' => array(ACL_OPTIONS_TABLE => 'acl'), 'WHERE' => "acl.auth_option = '{$permission}'"));
$result = $db->sql_query($sql);
$auth_option_id = (int) $db->sql_fetchfield('auth_option_id');
$db->sql_freeresult($result);
// remove option from user
$db->sql_query('DELETE FROM ' . ACL_USERS_TABLE . " WHERE auth_option_id = " . $auth_option_id);
// remove option from group
$db->sql_query('DELETE FROM ' . ACL_GROUPS_TABLE . " WHERE auth_option_id = " . $auth_option_id);
// remove option from role
$db->sql_query('DELETE FROM ' . ACL_ROLES_DATA_TABLE . " WHERE auth_option_id = " . $auth_option_id);
// remove option itself now
$db->sql_query('DELETE FROM ' . ACL_OPTIONS_TABLE . " WHERE auth_option_id = " . $auth_option_id);
}
// next for the chop is imageset data we added
foreach ($this->garage_imageset as $image_name) {
$db->sql_query('DELETE FROM ' . STYLES_IMAGESET_DATA_TABLE . " WHERE image_name = '" . $image_name . "'");
}
// clear permissions cache now we have handled them all
$cache->destroy('_acl_options');
$auth_admin->acl_clear_prefetch();
// next into the slaughter house is modules we added
foreach ($this->garage_modules as $module_name => $module_class) {
// get module id so we can remove it
$sql = $db->sql_build_query('SELECT', array('SELECT' => 'm.*', 'FROM' => array(MODULES_TABLE => 'm'), 'WHERE' => "m.module_langname = '{$module_name}'\n\t\t\t\t\t\t\tAND m.module_class = '{$module_class}'"));
// module may have been installed in multiple places per class ... delete them all
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$module_id = (int) $row['module_id'];
$branch = $module_admin->get_module_branch($module_id, 'children', 'descending', false);
if (sizeof($branch)) {
return array($user->lang['CANNOT_REMOVE_MODULE']);
}
// If not move
$diff = 2;
$sql = 'DELETE FROM ' . MODULES_TABLE . "\n\t\t\t\t\tWHERE module_class = '" . $module_class . "'\n\t\t\t\t\t\tAND module_id = {$module_id}";
$db->sql_query($sql);
$row['right_id'] = (int) $row['right_id'];
$row['left_id'] = (int) $row['left_id'];
// Resync tree
$sql = 'UPDATE ' . MODULES_TABLE . "\n\t\t\t\t\tSET right_id = right_id - {$diff}\n\t\t\t\t\tWHERE module_class = '" . $module_class . "'\n\t\t\t\t\t\tAND left_id < {$row['right_id']} AND right_id > {$row['right_id']}";
$db->sql_query($sql);
$sql = 'UPDATE ' . MODULES_TABLE . "\n\t\t\t\t\tSET left_id = left_id - {$diff}, right_id = right_id - {$diff}\n\t\t\t\t\tWHERE module_class = '" . $module_class . "'\n\t\t\t\t\t\tAND left_id > {$row['right_id']}";
$db->sql_query($sql);
}
$db->sql_freeresult($result);
}
// module categories ... be no more
foreach ($this->garage_module_categories as $module_category => $module_class) {
// get module id so we can remove it
$sql = $db->sql_build_query('SELECT', array('SELECT' => 'm.*', 'FROM' => array(MODULES_TABLE => 'm'), 'WHERE' => "m.module_langname = '{$module_category}'\n\t\t\t\t\t\t\tAND m.module_class = '{$module_class}'"));
// we can only delete the categories we created...
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$module_id = (int) $row['module_id'];
$branch = $module_admin->get_module_branch($module_id, 'children', 'descending', false);
if (sizeof($branch)) {
return array($user->lang['CANNOT_REMOVE_MODULE']);
}
// If not move
$diff = 2;
$sql = 'DELETE FROM ' . MODULES_TABLE . "\n\t\t\t\tWHERE module_class = '" . $module_class . "'\n\t\t\t\t\tAND module_id = {$module_id}";
$db->sql_query($sql);
$row['right_id'] = (int) $row['right_id'];
$row['left_id'] = (int) $row['left_id'];
// Resync tree
$sql = 'UPDATE ' . MODULES_TABLE . "\n\t\t\t\tSET right_id = right_id - {$diff}\n\t\t\t\tWHERE module_class = '" . $module_class . "'\n\t\t\t\t\tAND left_id < {$row['right_id']} AND right_id > {$row['right_id']}";
$db->sql_query($sql);
$sql = 'UPDATE ' . MODULES_TABLE . "\n\t\t\t\tSET left_id = left_id - {$diff}, right_id = right_id - {$diff}\n\t\t\t\tWHERE module_class = '" . $module_class . "'\n\t\t\t\t\tAND left_id > {$row['right_id']}";
$db->sql_query($sql);
}
// clear module cache now we have handled them all
$module_admin->remove_cache_file();
// and finally step forward data in $config
foreach ($this->config_data as $config_data) {
//.........这里部分代码省略.........
示例6: array
/**
* Remove role
*/
function remove_role($role_id, $permission_type)
{
global $db;
$auth_admin = new auth_admin();
// Get complete auth array
$sql = 'SELECT auth_option, auth_option_id
FROM ' . ACL_OPTIONS_TABLE . "\n\t\t\tWHERE auth_option " . $db->sql_like_expression($permission_type . $db->any_char);
$result = $db->sql_query($sql);
$auth_settings = array();
while ($row = $db->sql_fetchrow($result)) {
$auth_settings[$row['auth_option']] = ACL_NO;
}
$db->sql_freeresult($result);
// Get the role auth settings we need to re-set...
$sql = 'SELECT o.auth_option, r.auth_setting
FROM ' . ACL_ROLES_DATA_TABLE . ' r, ' . ACL_OPTIONS_TABLE . ' o
WHERE o.auth_option_id = r.auth_option_id
AND r.role_id = ' . $role_id;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$auth_settings[$row['auth_option']] = $row['auth_setting'];
}
$db->sql_freeresult($result);
// Get role assignments
$hold_ary = $auth_admin->get_role_mask($role_id);
// Re-assign permissions
foreach ($hold_ary as $forum_id => $forum_ary) {
if (isset($forum_ary['users'])) {
$auth_admin->acl_set('user', $forum_id, $forum_ary['users'], $auth_settings, 0, false);
}
if (isset($forum_ary['groups'])) {
$auth_admin->acl_set('group', $forum_id, $forum_ary['groups'], $auth_settings, 0, false);
}
}
// Remove role from users and groups just to be sure (happens through acl_set)
$sql = 'DELETE FROM ' . ACL_USERS_TABLE . '
WHERE auth_role_id = ' . $role_id;
$db->sql_query($sql);
$sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . '
WHERE auth_role_id = ' . $role_id;
$db->sql_query($sql);
// Remove role data and role
$sql = 'DELETE FROM ' . ACL_ROLES_DATA_TABLE . '
WHERE role_id = ' . $role_id;
$db->sql_query($sql);
$sql = 'DELETE FROM ' . ACL_ROLES_TABLE . '
WHERE role_id = ' . $role_id;
$db->sql_query($sql);
$auth_admin->acl_clear_prefetch();
}
示例7: array
/**
* 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);
//.........这里部分代码省略.........