mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
Merge pull request #6564 from marc1706/ticket/13162
[ticket/13162] Add truncate table functionality to database tools
This commit is contained in:
@@ -27,7 +27,7 @@ class acp_forums
|
||||
function main($id, $mode)
|
||||
{
|
||||
global $db, $user, $auth, $template, $cache, $request, $phpbb_dispatcher;
|
||||
global $phpbb_admin_path, $phpbb_root_path, $phpEx, $phpbb_log;
|
||||
global $phpbb_admin_path, $phpbb_container, $phpbb_root_path, $phpEx, $phpbb_log;
|
||||
|
||||
$user->add_lang('acp/forums');
|
||||
$this->tpl_name = 'acp_forums';
|
||||
@@ -210,7 +210,7 @@ class acp_forums
|
||||
($action != 'edit' || empty($forum_id) || ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth'))))
|
||||
{
|
||||
copy_forum_permissions($forum_perm_from, $forum_data['forum_id'], ($action == 'edit') ? true : false);
|
||||
phpbb_cache_moderators($db, $cache, $auth);
|
||||
phpbb_cache_moderators($db, $phpbb_container->get('dbal.tools'), $cache, $auth);
|
||||
$copied_permissions = true;
|
||||
}
|
||||
/* Commented out because of questionable UI workflow - re-visit for 3.0.7
|
||||
@@ -789,7 +789,7 @@ class acp_forums
|
||||
if (!empty($forum_perm_from) && $forum_perm_from != $forum_id)
|
||||
{
|
||||
copy_forum_permissions($forum_perm_from, $forum_id, true);
|
||||
phpbb_cache_moderators($db, $cache, $auth);
|
||||
phpbb_cache_moderators($db, $phpbb_container->get('dbal.tools'), $cache, $auth);
|
||||
$auth->acl_clear_prefetch();
|
||||
$cache->destroy('sql', FORUMS_TABLE);
|
||||
|
||||
|
@@ -574,16 +574,8 @@ class acp_icons
|
||||
// The user has already selected a smilies_pak file
|
||||
if ($current == 'delete')
|
||||
{
|
||||
switch ($db->get_sql_layer())
|
||||
{
|
||||
case 'sqlite3':
|
||||
$db->sql_query('DELETE FROM ' . $table);
|
||||
break;
|
||||
|
||||
default:
|
||||
$db->sql_query('TRUNCATE TABLE ' . $table);
|
||||
break;
|
||||
}
|
||||
$db_tools = $phpbb_container->get('dbal.tools');
|
||||
$db_tools->sql_truncate_table($table);
|
||||
|
||||
switch ($mode)
|
||||
{
|
||||
|
@@ -281,16 +281,8 @@ class acp_main
|
||||
break;
|
||||
|
||||
case 'db_track':
|
||||
switch ($db->get_sql_layer())
|
||||
{
|
||||
case 'sqlite3':
|
||||
$db->sql_query('DELETE FROM ' . TOPICS_POSTED_TABLE);
|
||||
break;
|
||||
|
||||
default:
|
||||
$db->sql_query('TRUNCATE TABLE ' . TOPICS_POSTED_TABLE);
|
||||
break;
|
||||
}
|
||||
$db_tools = $phpbb_container->get('dbal.tools');
|
||||
$db_tools->sql_truncate_table(TOPICS_POSTED_TABLE);
|
||||
|
||||
// This can get really nasty... therefore we only do the last six months
|
||||
$get_from_time = time() - (6 * 4 * 7 * 24 * 60 * 60);
|
||||
@@ -370,7 +362,7 @@ class acp_main
|
||||
|
||||
// Clear permissions
|
||||
$auth->acl_clear_prefetch();
|
||||
phpbb_cache_moderators($db, $cache, $auth);
|
||||
phpbb_cache_moderators($db, $phpbb_container->get('dbal.tools'), $cache, $auth);
|
||||
|
||||
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_PURGE_CACHE');
|
||||
|
||||
@@ -388,19 +380,11 @@ class acp_main
|
||||
}
|
||||
|
||||
$tables = array(CONFIRM_TABLE, SESSIONS_TABLE);
|
||||
$db_tools = $phpbb_container->get('dbal.tools');
|
||||
|
||||
foreach ($tables as $table)
|
||||
{
|
||||
switch ($db->get_sql_layer())
|
||||
{
|
||||
case 'sqlite3':
|
||||
$db->sql_query("DELETE FROM $table");
|
||||
break;
|
||||
|
||||
default:
|
||||
$db->sql_query("TRUNCATE TABLE $table");
|
||||
break;
|
||||
}
|
||||
$db_tools->sql_truncate_table($table);
|
||||
}
|
||||
|
||||
// let's restore the admin session
|
||||
|
@@ -679,7 +679,7 @@ class acp_permissions
|
||||
function set_permissions($mode, $permission_type, $auth_admin, &$user_id, &$group_id)
|
||||
{
|
||||
global $db, $cache, $user, $auth;
|
||||
global $request;
|
||||
global $request, $phpbb_container;
|
||||
|
||||
$psubmit = $request->variable('psubmit', array(0 => array(0 => 0)));
|
||||
|
||||
@@ -747,7 +747,7 @@ class acp_permissions
|
||||
// Do we need to recache the moderator lists?
|
||||
if ($permission_type == 'm_')
|
||||
{
|
||||
phpbb_cache_moderators($db, $cache, $auth);
|
||||
phpbb_cache_moderators($db, $phpbb_container->get('dbal.tools'), $cache, $auth);
|
||||
}
|
||||
|
||||
// Remove users who are now moderators or admins from everyones foes list
|
||||
@@ -768,7 +768,7 @@ class acp_permissions
|
||||
function set_all_permissions($mode, $permission_type, $auth_admin, &$user_id, &$group_id)
|
||||
{
|
||||
global $db, $cache, $user, $auth;
|
||||
global $request;
|
||||
global $request, $phpbb_container;
|
||||
|
||||
// User or group to be set?
|
||||
$ug_type = (count($user_id)) ? 'user' : 'group';
|
||||
@@ -817,7 +817,7 @@ class acp_permissions
|
||||
// Do we need to recache the moderator lists?
|
||||
if ($permission_type == 'm_')
|
||||
{
|
||||
phpbb_cache_moderators($db, $cache, $auth);
|
||||
phpbb_cache_moderators($db, $phpbb_container->get('dbal.tools'), $cache, $auth);
|
||||
}
|
||||
|
||||
// Remove users who are now moderators or admins from everyones foes list
|
||||
@@ -883,7 +883,7 @@ class acp_permissions
|
||||
*/
|
||||
function remove_permissions($mode, $permission_type, $auth_admin, &$user_id, &$group_id, &$forum_id)
|
||||
{
|
||||
global $user, $db, $cache, $auth;
|
||||
global $user, $db, $cache, $auth, $phpbb_container;
|
||||
|
||||
// User or group to be set?
|
||||
$ug_type = (count($user_id)) ? 'user' : 'group';
|
||||
@@ -900,7 +900,7 @@ class acp_permissions
|
||||
// Do we need to recache the moderator lists?
|
||||
if ($permission_type == 'm_')
|
||||
{
|
||||
phpbb_cache_moderators($db, $cache, $auth);
|
||||
phpbb_cache_moderators($db, $phpbb_container->get('dbal.tools'), $cache, $auth);
|
||||
}
|
||||
|
||||
$this->log_action($mode, 'del', $permission_type, $ug_type, (($ug_type == 'user') ? $user_id : $group_id), (count($forum_id) ? $forum_id : array(0 => 0)));
|
||||
@@ -1202,7 +1202,7 @@ class acp_permissions
|
||||
*/
|
||||
function copy_forum_permissions()
|
||||
{
|
||||
global $db, $auth, $cache, $template, $user, $request;
|
||||
global $db, $auth, $cache, $phpbb_container, $template, $user, $request;
|
||||
|
||||
$user->add_lang('acp/forums');
|
||||
|
||||
@@ -1217,7 +1217,7 @@ class acp_permissions
|
||||
{
|
||||
if (copy_forum_permissions($src, $dest))
|
||||
{
|
||||
phpbb_cache_moderators($db, $cache, $auth);
|
||||
phpbb_cache_moderators($db, $phpbb_container->get('dbal.tools'), $cache, $auth);
|
||||
|
||||
$auth->acl_clear_prefetch();
|
||||
$cache->destroy('sql', FORUMS_TABLE);
|
||||
|
@@ -2490,26 +2490,17 @@ function auto_prune($forum_id, $prune_mode, $prune_flags, $prune_days, $prune_fr
|
||||
* must be carried through for the moderators table.
|
||||
*
|
||||
* @param \phpbb\db\driver\driver_interface $db Database connection
|
||||
* @param \phpbb\db\tools\tools_interface $db_tools Database tools
|
||||
* @param \phpbb\cache\driver\driver_interface $cache Cache driver
|
||||
* @param \phpbb\auth\auth $auth Authentication object
|
||||
* @return void
|
||||
*/
|
||||
function phpbb_cache_moderators($db, $cache, $auth)
|
||||
function phpbb_cache_moderators($db, $db_tools, $cache, $auth)
|
||||
{
|
||||
// Remove cached sql results
|
||||
$cache->destroy('sql', MODERATOR_CACHE_TABLE);
|
||||
|
||||
// Clear table
|
||||
switch ($db->get_sql_layer())
|
||||
{
|
||||
case 'sqlite3':
|
||||
$db->sql_query('DELETE FROM ' . MODERATOR_CACHE_TABLE);
|
||||
break;
|
||||
|
||||
default:
|
||||
$db->sql_query('TRUNCATE TABLE ' . MODERATOR_CACHE_TABLE);
|
||||
break;
|
||||
}
|
||||
$db_tools->sql_truncate_table(MODERATOR_CACHE_TABLE);
|
||||
|
||||
// We add moderators who have forum moderator permissions without an explicit ACL_NEVER setting
|
||||
$sql_ary = array();
|
||||
|
@@ -126,8 +126,8 @@ function tz_select($default = '', $truncate = false)
|
||||
*/
|
||||
function cache_moderators()
|
||||
{
|
||||
global $db, $cache, $auth;
|
||||
phpbb_cache_moderators($db, $cache, $auth);
|
||||
global $db, $cache, $auth, $phpbb_container;
|
||||
phpbb_cache_moderators($db, $phpbb_container->get('dbal.tools'), $cache, $auth);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1873,18 +1873,11 @@ function update_dynamic_config()
|
||||
*/
|
||||
function update_topics_posted()
|
||||
{
|
||||
global $db;
|
||||
global $db, $phpbb_container;
|
||||
|
||||
switch ($db->get_sql_layer())
|
||||
{
|
||||
case 'sqlite3':
|
||||
$db->sql_query('DELETE FROM ' . TOPICS_POSTED_TABLE);
|
||||
break;
|
||||
|
||||
default:
|
||||
$db->sql_query('TRUNCATE TABLE ' . TOPICS_POSTED_TABLE);
|
||||
break;
|
||||
}
|
||||
/** @var \phpbb\db\tools\tools_interface $db_tools */
|
||||
$db_tools = $phpbb_container->get('dbal.tools');
|
||||
$db_tools->sql_truncate_table(TOPICS_POSTED_TABLE);
|
||||
|
||||
// This can get really nasty... therefore we only do the last six months
|
||||
$get_from_time = time() - (6 * 4 * 7 * 24 * 60 * 60);
|
||||
|
@@ -2255,7 +2255,7 @@ function group_delete($group_id, $group_name = false)
|
||||
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
|
||||
}
|
||||
|
||||
phpbb_cache_moderators($db, $cache, $auth);
|
||||
phpbb_cache_moderators($db, $phpbb_container->get('dbal.tools'), $cache, $auth);
|
||||
|
||||
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_GROUP_DELETE', false, array($group_name));
|
||||
|
||||
@@ -3167,7 +3167,10 @@ function group_update_listings($group_id)
|
||||
global $phpbb_root_path, $phpEx;
|
||||
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
|
||||
}
|
||||
phpbb_cache_moderators($db, $cache, $auth);
|
||||
|
||||
global $phpbb_container;
|
||||
|
||||
phpbb_cache_moderators($db, $phpbb_container->get('dbal.tools'), $cache, $auth);
|
||||
}
|
||||
|
||||
if ($mod_permissions || $admin_permissions)
|
||||
|
Reference in New Issue
Block a user