diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2009-01-16 17:41:04 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2009-01-16 17:41:04 +0000 |
commit | 57aea7e62f7df2424ffbd1adc90941bff482d7ea (patch) | |
tree | 5b6e3c5c11c66509a9f600ce448a82d7fbd7b346 /phpBB/modules/acp | |
parent | 0df7a9b3e38773207441fac64c5e5c6323e59d6f (diff) | |
download | forums-57aea7e62f7df2424ffbd1adc90941bff482d7ea.tar forums-57aea7e62f7df2424ffbd1adc90941bff482d7ea.tar.gz forums-57aea7e62f7df2424ffbd1adc90941bff482d7ea.tar.bz2 forums-57aea7e62f7df2424ffbd1adc90941bff482d7ea.tar.xz forums-57aea7e62f7df2424ffbd1adc90941bff482d7ea.zip |
modified some files to get the admin index page working, as well as index page in logged in state and not logged in state
additionally prepare for a working installation
git-svn-id: file:///svn/phpbb/trunk@9272 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/modules/acp')
-rw-r--r-- | phpBB/modules/acp/acp_groups.php | 11 | ||||
-rw-r--r-- | phpBB/modules/acp/acp_main.php | 172 | ||||
-rw-r--r-- | phpBB/modules/acp/acp_modules.php | 260 | ||||
-rw-r--r-- | phpBB/modules/acp/acp_permissions.php | 4 | ||||
-rw-r--r-- | phpBB/modules/acp/acp_styles.php | 12 | ||||
-rw-r--r-- | phpBB/modules/acp/acp_users.php | 12 |
6 files changed, 224 insertions, 247 deletions
diff --git a/phpBB/modules/acp/acp_groups.php b/phpBB/modules/acp/acp_groups.php index 408b0b33f7..7ded95e228 100644 --- a/phpBB/modules/acp/acp_groups.php +++ b/phpBB/modules/acp/acp_groups.php @@ -67,7 +67,7 @@ class acp_groups } // Check if the user is allowed to manage this group if set to founder only. - if ($user->data['user_type'] != phpbb::USER_FOUNDER && $group_row['group_founder_manage']) + if (!phpbb::$user->is_founder && $group_row['group_founder_manage']) { trigger_error($user->lang['NOT_ALLOWED_MANAGE_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING); } @@ -310,7 +310,7 @@ class acp_groups 'founder_manage' => 0, ); - if ($user->data['user_type'] == phpbb::USER_FOUNDER) + if (phpbb::$user->is_founder) { $submit_ary['founder_manage'] = phpbb_request::is_set('group_founder_manage') ? 1 : 0; } @@ -426,8 +426,9 @@ class acp_groups $db->sql_freeresult($result); // Check the group if non-founder - if ($check_row && ($user->data['user_type'] == phpbb::USER_FOUNDER || $check_row['group_founder_manage'] == 0)) + if ($check_row && (phpbb::$user->is_founder || $check_row['group_founder_manage'] == 0)) { + // @todo CHANGE - do we support < 4.0.14? // From the mysql documentation: // Prior to MySQL 4.0.14, the target table of the INSERT statement cannot appear in the FROM clause of the SELECT part of the query. This limitation is lifted in 4.0.14. // Due to this we stay on the safe side if we do the insertion "the manual way" @@ -549,7 +550,7 @@ class acp_groups 'S_SPECIAL_GROUP' => ($group_type == GROUP_SPECIAL) ? true : false, 'S_DISPLAY_GALLERY' => (phpbb::$config['allow_avatar_local'] && !$display_gallery) ? true : false, 'S_IN_GALLERY' => (phpbb::$config['allow_avatar_local'] && $display_gallery) ? true : false, - 'S_USER_FOUNDER' => ($user->data['user_type'] == phpbb::USER_FOUNDER) ? true : false, + 'S_USER_FOUNDER' => phpbb::$user->is_founder, 'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '', 'GROUP_NAME' => ($group_type == GROUP_SPECIAL) ? $user->lang['G_' . $group_name] : $group_name, @@ -568,7 +569,7 @@ class acp_groups 'S_DESC_SMILIES_CHECKED'=> $group_desc_data['allow_smilies'], 'S_RANK_OPTIONS' => $rank_options, - 'S_GROUP_OPTIONS' => group_select_options(false, false, (($user->data['user_type'] == phpbb::USER_FOUNDER) ? false : 0)), + 'S_GROUP_OPTIONS' => group_select_options(false, false, ((phpbb::$user->is_founder) ? false : 0)), 'AVATAR' => $avatar_img, 'AVATAR_IMAGE' => $avatar_img, 'AVATAR_MAX_FILESIZE' => phpbb::$config['avatar_filesize'], diff --git a/phpBB/modules/acp/acp_main.php b/phpBB/modules/acp/acp_main.php index ee96eab767..91918166cf 100644 --- a/phpBB/modules/acp/acp_main.php +++ b/phpBB/modules/acp/acp_main.php @@ -25,32 +25,30 @@ class acp_main function main($id, $mode) { - global $db, $user, $auth, $template; - // Show restore permissions notice - if ($user->data['user_perm_from'] && $auth->acl_get('a_switchperm')) + if (phpbb::$user->data['user_perm_from'] && phpbb::$acl->acl_get('a_switchperm')) { $this->tpl_name = 'acp_main'; $this->page_title = 'ACP_MAIN'; $sql = 'SELECT user_id, username, user_colour FROM ' . USERS_TABLE . ' - WHERE user_id = ' . $user->data['user_perm_from']; - $result = $db->sql_query($sql); - $user_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); + WHERE user_id = ' . phpbb::$user->data['user_perm_from']; + $result = phpbb::$db->sql_query($sql); + $user_row = phpbb::$db->sql_fetchrow($result); + phpbb::$db->sql_freeresult($result); $perm_from = '<strong' . (($user_row['user_colour']) ? ' style="color: #' . $user_row['user_colour'] . '">' : '>'); - $perm_from .= ($user_row['user_id'] != ANONYMOUS) ? '<a href="' . append_sid('memberlist', 'mode=viewprofile&u=' . $user_row['user_id']) . '">' : ''; + $perm_from .= ($user_row['user_id'] != ANONYMOUS) ? '<a href="' . phpbb::$url->append_sid('memberlist', 'mode=viewprofile&u=' . $user_row['user_id']) . '">' : ''; $perm_from .= $user_row['username']; $perm_from .= ($user_row['user_id'] != ANONYMOUS) ? '</a>' : ''; $perm_from .= '</strong>'; - $template->assign_vars(array( + phpbb::$template->assign_vars(array( 'S_RESTORE_PERMISSIONS' => true, - 'U_RESTORE_PERMISSIONS' => append_sid('ucp', 'mode=restore_perm'), + 'U_RESTORE_PERMISSIONS' => phpbb::$url->append_sid('ucp', 'mode=restore_perm'), 'PERM_FROM' => $perm_from, - 'L_PERMISSIONS_TRANSFERRED_EXPLAIN' => sprintf($user->lang['PERMISSIONS_TRANSFERRED_EXPLAIN'], $perm_from, append_sid('ucp', 'mode=restore_perm')), + 'L_PERMISSIONS_TRANSFERRED_EXPLAIN' => sprintf(phpbb::$user->lang['PERMISSIONS_TRANSFERRED_EXPLAIN'], $perm_from, phpbb::$url->append_sid('ucp', 'mode=restore_perm')), )); return; @@ -62,10 +60,10 @@ class acp_main { if ($action === 'admlogout') { - $user->unset_admin(); - $redirect_url = append_sid(PHPBB_ROOT_PATH . 'index.' . PHP_EXT); + phpbb::$user->unset_admin(); + $redirect_url = phpbb::$url->append_sid(PHPBB_ROOT_PATH . 'index.' . PHP_EXT); meta_refresh(3, $redirect_url); - trigger_error($user->lang['ADM_LOGGED_OUT'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect_url . '">', '</a>')); + trigger_error(phpbb::$user->lang['ADM_LOGGED_OUT'] . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_INDEX'], '<a href="' . $redirect_url . '">', '</a>')); } if (!confirm_box(true)) @@ -104,7 +102,7 @@ class acp_main if ($confirm) { - confirm_box(false, $user->lang[$confirm_lang], build_hidden_fields(array( + confirm_box(false, phpbb::$user->lang[$confirm_lang], build_hidden_fields(array( 'i' => $id, 'mode' => $mode, 'action' => $action, @@ -117,9 +115,9 @@ class acp_main { case 'online': - if (!$auth->acl_get('a_board')) + if (!phpbb::$acl->acl_get('a_board')) { - trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); + trigger_error(phpbb::$user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); } set_config('record_online_users', 1, true); @@ -128,45 +126,45 @@ class acp_main break; case 'stats': - if (!$auth->acl_get('a_board')) + if (!phpbb::$acl->acl_get('a_board')) { - trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); + trigger_error(phpbb::$user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); } $sql = 'SELECT COUNT(post_id) AS stat FROM ' . POSTS_TABLE . ' WHERE post_approved = 1'; - $result = $db->sql_query($sql); - set_config('num_posts', (int) $db->sql_fetchfield('stat'), true); - $db->sql_freeresult($result); + $result = phpbb::$db->sql_query($sql); + set_config('num_posts', (int) phpbb::$db->sql_fetchfield('stat'), true); + phpbb::$db->sql_freeresult($result); $sql = 'SELECT COUNT(topic_id) AS stat FROM ' . TOPICS_TABLE . ' WHERE topic_approved = 1'; - $result = $db->sql_query($sql); - set_config('num_topics', (int) $db->sql_fetchfield('stat'), true); - $db->sql_freeresult($result); + $result = phpbb::$db->sql_query($sql); + set_config('num_topics', (int) phpbb::$db->sql_fetchfield('stat'), true); + phpbb::$db->sql_freeresult($result); $sql = 'SELECT COUNT(user_id) AS stat FROM ' . USERS_TABLE . ' WHERE user_type IN (' . phpbb::USER_NORMAL . ',' . phpbb::USER_FOUNDER . ')'; - $result = $db->sql_query($sql); - set_config('num_users', (int) $db->sql_fetchfield('stat'), true); - $db->sql_freeresult($result); + $result = phpbb::$db->sql_query($sql); + set_config('num_users', (int) phpbb::$db->sql_fetchfield('stat'), true); + phpbb::$db->sql_freeresult($result); $sql = 'SELECT COUNT(attach_id) as stat FROM ' . ATTACHMENTS_TABLE . ' WHERE is_orphan = 0'; - $result = $db->sql_query($sql); - set_config('num_files', (int) $db->sql_fetchfield('stat'), true); - $db->sql_freeresult($result); + $result = phpbb::$db->sql_query($sql); + set_config('num_files', (int) phpbb::$db->sql_fetchfield('stat'), true); + phpbb::$db->sql_freeresult($result); $sql = 'SELECT SUM(filesize) as stat FROM ' . ATTACHMENTS_TABLE . ' WHERE is_orphan = 0'; - $result = $db->sql_query($sql); - set_config('upload_dir_size', (float) $db->sql_fetchfield('stat'), true); - $db->sql_freeresult($result); + $result = phpbb::$db->sql_query($sql); + set_config('upload_dir_size', (float) phpbb::$db->sql_fetchfield('stat'), true); + phpbb::$db->sql_freeresult($result); if (!function_exists('update_last_username')) { @@ -178,9 +176,9 @@ class acp_main break; case 'user': - if (!$auth->acl_get('a_board')) + if (!phpbb::$acl->acl_get('a_board')) { - trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); + trigger_error(phpbb::$user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); } // Resync post counts @@ -189,18 +187,18 @@ class acp_main // Find the maximum post ID, we can only stop the cycle when we've reached it $sql = 'SELECT MAX(forum_last_post_id) as max_post_id FROM ' . FORUMS_TABLE; - $result = $db->sql_query($sql); - $max_post_id = (int) $db->sql_fetchfield('max_post_id'); - $db->sql_freeresult($result); + $result = phpbb::$db->sql_query($sql); + $max_post_id = (int) phpbb::$db->sql_fetchfield('max_post_id'); + phpbb::$db->sql_freeresult($result); // No maximum post id? :o if (!$max_post_id) { $sql = 'SELECT MAX(post_id) FROM ' . POSTS_TABLE; - $result = $db->sql_query($sql); - $max_post_id = (int) $db->sql_fetchfield('max_post_id'); - $db->sql_freeresult($result); + $result = phpbb::$db->sql_query($sql); + $max_post_id = (int) phpbb::$db->sql_fetchfield('max_post_id'); + phpbb::$db->sql_freeresult($result); } // Still no maximum post id? Then we are finished @@ -211,7 +209,7 @@ class acp_main } $step = (phpbb::$config['num_posts']) ? (max((int) (phpbb::$config['num_posts'] / 5), 20000)) : 20000; - $db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_posts = 0'); + phpbb::$db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_posts = 0'); while ($start < $max_post_id) { @@ -220,18 +218,18 @@ class acp_main WHERE post_id BETWEEN ' . ($start + 1) . ' AND ' . ($start + $step) . ' AND post_postcount = 1 AND post_approved = 1 GROUP BY poster_id'; - $result = $db->sql_query($sql); + $result = phpbb::$db->sql_query($sql); - if ($row = $db->sql_fetchrow($result)) + if ($row = phpbb::$db->sql_fetchrow($result)) { do { $sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = user_posts + {$row['num_posts']} WHERE user_id = {$row['poster_id']}"; - $db->sql_query($sql); + phpbb::$db->sql_query($sql); } - while ($row = $db->sql_fetchrow($result)); + while ($row = phpbb::$db->sql_fetchrow($result)); } - $db->sql_freeresult($result); + phpbb::$db->sql_freeresult($result); $start += $step; } @@ -241,9 +239,9 @@ class acp_main break; case 'date': - if (!$auth->acl_get('a_board')) + if (!phpbb::$acl->acl_get('a_board')) { - trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); + trigger_error(phpbb::$user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); } set_config('board_startdate', time() - 1); @@ -251,13 +249,13 @@ class acp_main break; case 'db_track': - if ($db->truncate) + if (phpbb::$db->features['truncate']) { - $db->sql_query('TRUNCATE TABLE ' . TOPICS_POSTED_TABLE); + phpbb::$db->sql_query('TRUNCATE TABLE ' . TOPICS_POSTED_TABLE); } else { - $db->sql_query('DELETE FROM ' . TOPICS_POSTED_TABLE); + phpbb::$db->sql_query('DELETE FROM ' . TOPICS_POSTED_TABLE); } // This can get really nasty... therefore we only do the last six months @@ -267,14 +265,14 @@ class acp_main $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . ' WHERE forum_type <> ' . FORUM_CAT; - $result = $db->sql_query($sql); + $result = phpbb::$db->sql_query($sql); $forum_ids = array(); - while ($row = $db->sql_fetchrow($result)) + while ($row = phpbb::$db->sql_fetchrow($result)) { $forum_ids[] = $row['forum_id']; } - $db->sql_freeresult($result); + phpbb::$db->sql_freeresult($result); // Any global announcements? ;) $forum_ids[] = 0; @@ -290,14 +288,14 @@ class acp_main AND t.topic_id = p.topic_id AND p.poster_id <> ' . ANONYMOUS . ' GROUP BY p.poster_id, p.topic_id'; - $result = $db->sql_query($sql); + $result = phpbb::$db->sql_query($sql); $posted = array(); - while ($row = $db->sql_fetchrow($result)) + while ($row = phpbb::$db->sql_fetchrow($result)) { $posted[$row['poster_id']][] = $row['topic_id']; } - $db->sql_freeresult($result); + phpbb::$db->sql_freeresult($result); $sql_ary = array(); foreach ($posted as $user_id => $topic_row) @@ -315,7 +313,7 @@ class acp_main if (sizeof($sql_ary)) { - $db->sql_multi_insert(TOPICS_POSTED_TABLE, $sql_ary); + phpbb::$db->sql_multi_insert(TOPICS_POSTED_TABLE, $sql_ary); } } @@ -323,15 +321,15 @@ class acp_main break; case 'purge_cache': - if ((int) $user->data['user_type'] !== phpbb::USER_FOUNDER) + if (!phpbb::$user->is_founder) { - trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); + trigger_error(phpbb::$user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); } phpbb::$acm->purge(); // Clear permissions - $auth->acl_clear_prefetch(); + phpbb::$acl->acl_clear_prefetch(); cache_moderators(); add_log('admin', 'LOG_PURGE_CACHE'); @@ -346,7 +344,7 @@ class acp_main $total_users = phpbb::$config['num_users']; $total_files = phpbb::$config['num_files']; - $start_date = $user->format_date(phpbb::$config['board_startdate']); + $start_date = phpbb::$user->format_date(phpbb::$config['board_startdate']); $boarddays = (time() - phpbb::$config['board_startdate']) / 86400; @@ -375,7 +373,7 @@ class acp_main else { // Couldn't open Avatar dir. - $avatar_dir_size = $user->lang['NOT_AVAILABLE']; + $avatar_dir_size = phpbb::$user->lang['NOT_AVAILABLE']; } if ($posts_per_day > $total_posts) @@ -404,9 +402,9 @@ class acp_main FROM ' . ATTACHMENTS_TABLE . ' WHERE is_orphan = 1 AND filetime < ' . (time() - 3*60*60); - $result = $db->sql_query($sql); - $total_orphan = (int) $db->sql_fetchfield('total_orphan'); - $db->sql_freeresult($result); + $result = phpbb::$db->sql_query($sql); + $total_orphan = (int) phpbb::$db->sql_fetchfield('total_orphan'); + phpbb::$db->sql_freeresult($result); } else { @@ -415,7 +413,7 @@ class acp_main $dbsize = get_database_size(); - $template->assign_vars(array( + phpbb::$template->assign_vars(array( 'TOTAL_POSTS' => $total_posts, 'POSTS_PER_DAY' => $posts_per_day, 'TOTAL_TOPICS' => $total_topics, @@ -430,38 +428,38 @@ class acp_main 'UPLOAD_DIR_SIZE' => $upload_dir_size, 'TOTAL_ORPHAN' => $total_orphan, 'S_TOTAL_ORPHAN' => ($total_orphan === false) ? false : true, - 'GZIP_COMPRESSION' => (phpbb::$config['gzip_compress']) ? $user->lang['ON'] : $user->lang['OFF'], - 'DATABASE_INFO' => $db->sql_server_info(), + 'GZIP_COMPRESSION' => (phpbb::$config['gzip_compress']) ? phpbb::$user->lang['ON'] : phpbb::$user->lang['OFF'], + 'DATABASE_INFO' => phpbb::$db->sql_server_info(), 'BOARD_VERSION' => phpbb::$config['version'], 'U_ACTION' => $this->u_action, - 'U_ADMIN_LOG' => append_sid(PHPBB_ADMIN_PATH . 'index.' . PHP_EXT, 'i=logs&mode=admin'), - 'U_INACTIVE_USERS' => append_sid(PHPBB_ADMIN_PATH . 'index.' . PHP_EXT, 'i=inactive&mode=list'), + 'U_ADMIN_LOG' => phpbb::$url->append_sid(PHPBB_ADMIN_PATH . 'index.' . PHP_EXT, 'i=logs&mode=admin'), + 'U_INACTIVE_USERS' => phpbb::$url->append_sid(PHPBB_ADMIN_PATH . 'index.' . PHP_EXT, 'i=inactive&mode=list'), - 'S_ACTION_OPTIONS' => ($auth->acl_get('a_board')) ? true : false, - 'S_FOUNDER' => ($user->data['user_type'] == phpbb::USER_FOUNDER) ? true : false, + 'S_ACTION_OPTIONS' => (phpbb::$acl->acl_get('a_board')) ? true : false, + 'S_FOUNDER' => phpbb::$user->is_founder, ) ); $log_data = array(); $log_count = 0; - if ($auth->acl_get('a_viewlogs')) + if (phpbb::$acl->acl_get('a_viewlogs')) { view_log('admin', $log_data, $log_count, 5); foreach ($log_data as $row) { - $template->assign_block_vars('log', array( + phpbb::$template->assign_block_vars('log', array( 'USERNAME' => $row['username_full'], 'IP' => $row['ip'], - 'DATE' => $user->format_date($row['time']), + 'DATE' => phpbb::$user->format_date($row['time']), 'ACTION' => $row['action']) ); } } - if ($auth->acl_get('a_user')) + if (phpbb::$acl->acl_get('a_user')) { $inactive = array(); $inactive_count = 0; @@ -470,14 +468,14 @@ class acp_main foreach ($inactive as $row) { - $template->assign_block_vars('inactive', array( - 'INACTIVE_DATE' => $user->format_date($row['user_inactive_time']), - 'JOINED' => $user->format_date($row['user_regdate']), - 'LAST_VISIT' => (!$row['user_lastvisit']) ? ' - ' : $user->format_date($row['user_lastvisit']), + phpbb::$template->assign_block_vars('inactive', array( + 'INACTIVE_DATE' => phpbb::$user->format_date($row['user_inactive_time']), + 'JOINED' => phpbb::$user->format_date($row['user_regdate']), + 'LAST_VISIT' => (!$row['user_lastvisit']) ? ' - ' : phpbb::$user->format_date($row['user_lastvisit']), 'REASON' => $row['inactive_reason'], 'USER_ID' => $row['user_id'], 'USERNAME' => $row['username'], - 'U_USER_ADMIN' => append_sid(PHPBB_ADMIN_PATH . 'index.' . PHP_EXT, "i=users&mode=overview&u={$row['user_id']}")) + 'U_USER_ADMIN' => phpbb::$url->append_sid(PHPBB_ADMIN_PATH . 'index.' . PHP_EXT, "i=users&mode=overview&u={$row['user_id']}")) ); } @@ -487,7 +485,7 @@ class acp_main $option_ary += array('remind' => 'REMIND'); } - $template->assign_vars(array( + phpbb::$template->assign_vars(array( 'S_INACTIVE_USERS' => true, 'S_INACTIVE_OPTIONS' => build_select($option_ary)) ); @@ -496,13 +494,13 @@ class acp_main // Warn if install is still present if (file_exists(PHPBB_ROOT_PATH . 'install')) { - $template->assign_var('S_REMOVE_INSTALL', true); + phpbb::$template->assign_var('S_REMOVE_INSTALL', true); } if (!defined('PHPBB_DISABLE_CONFIG_CHECK') && file_exists(PHPBB_ROOT_PATH . 'config.' . PHP_EXT) && is_writable(PHPBB_ROOT_PATH . 'config.' . PHP_EXT)) { // World-Writable? (000x) - $template->assign_var('S_WRITABLE_CONFIG', (bool) (@fileperms(PHPBB_ROOT_PATH . 'config.' . PHP_EXT) & 0x0002)); + phpbb::$template->assign_var('S_WRITABLE_CONFIG', (bool) (@fileperms(PHPBB_ROOT_PATH . 'config.' . PHP_EXT) & 0x0002)); } $this->tpl_name = 'acp_main'; diff --git a/phpBB/modules/acp/acp_modules.php b/phpBB/modules/acp/acp_modules.php index bf5f17449b..977a47a2e4 100644 --- a/phpBB/modules/acp/acp_modules.php +++ b/phpBB/modules/acp/acp_modules.php @@ -43,12 +43,12 @@ class acp_modules function main($id, $mode) { - global $db, $user, $auth, $template, $module; + global $auth, $template, $module; // Set a global define for modules we might include (the author is able to prevent execution of code by checking this constant) define('MODULE_INCLUDE', true); - $user->add_lang('acp/modules'); + phpbb::$user->add_lang('acp/modules'); $this->tpl_name = 'acp_modules'; // module class @@ -56,11 +56,11 @@ class acp_modules if ($this->module_class == 'ucp') { - $user->add_lang('ucp'); + phpbb::$user->add_lang('ucp'); } else if ($this->module_class == 'mcp') { - $user->add_lang('mcp'); + phpbb::$user->add_lang('mcp'); } if ($module->p_class != $this->module_class) @@ -80,7 +80,7 @@ class acp_modules case 'delete': if (!$module_id) { - trigger_error($user->lang['NO_MODULE_ID'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); + trigger_error(phpbb::$user->lang['NO_MODULE_ID'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } if (confirm_box(true)) @@ -91,9 +91,9 @@ class acp_modules $sql = 'SELECT parent_id FROM ' . MODULES_TABLE . ' WHERE module_id = ' . $module_id; - $result = $db->sql_query($sql); - $this->parent_id = (int) $db->sql_fetchfield('parent_id'); - $db->sql_freeresult($result); + $result = phpbb::$db->sql_query($sql); + $this->parent_id = (int) phpbb::$db->sql_fetchfield('parent_id'); + phpbb::$db->sql_freeresult($result); } $errors = $this->delete_module($module_id); @@ -101,7 +101,7 @@ class acp_modules if (!sizeof($errors)) { $this->remove_cache_file(); - trigger_error($user->lang['MODULE_DELETED'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); + trigger_error(phpbb::$user->lang['MODULE_DELETED'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); } } else @@ -121,29 +121,29 @@ class acp_modules case 'disable': if (!$module_id) { - trigger_error($user->lang['NO_MODULE_ID'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); + trigger_error(phpbb::$user->lang['NO_MODULE_ID'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } $sql = 'SELECT * FROM ' . MODULES_TABLE . " - WHERE module_class = '" . $db->sql_escape($this->module_class) . "' + WHERE module_class = '" . phpbb::$db->sql_escape($this->module_class) . "' AND module_id = $module_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); + $result = phpbb::$db->sql_query($sql); + $row = phpbb::$db->sql_fetchrow($result); + phpbb::$db->sql_freeresult($result); if (!$row) { - trigger_error($user->lang['NO_MODULE'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); + trigger_error(phpbb::$user->lang['NO_MODULE'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } $sql = 'UPDATE ' . MODULES_TABLE . ' SET module_enabled = ' . (($action == 'enable') ? 1 : 0) . " - WHERE module_class = '" . $db->sql_escape($this->module_class) . "' + WHERE module_class = '" . phpbb::$db->sql_escape($this->module_class) . "' AND module_id = $module_id"; - $db->sql_query($sql); + phpbb::$db->sql_query($sql); - add_log('admin', 'LOG_MODULE_' . strtoupper($action), $this->lang_name($row['module_langname'])); + add_log('admin', 'LOG_MODULE_' . strtoupper($action), phpbb::$user->lang($row['module_langname'])); $this->remove_cache_file(); break; @@ -152,27 +152,27 @@ class acp_modules case 'move_down': if (!$module_id) { - trigger_error($user->lang['NO_MODULE_ID'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); + trigger_error(phpbb::$user->lang['NO_MODULE_ID'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } $sql = 'SELECT * FROM ' . MODULES_TABLE . " - WHERE module_class = '" . $db->sql_escape($this->module_class) . "' + WHERE module_class = '" . phpbb::$db->sql_escape($this->module_class) . "' AND module_id = $module_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); + $result = phpbb::$db->sql_query($sql); + $row = phpbb::$db->sql_fetchrow($result); + phpbb::$db->sql_freeresult($result); if (!$row) { - trigger_error($user->lang['NO_MODULE'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); + trigger_error(phpbb::$user->lang['NO_MODULE'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } $move_module_name = $this->move_module_by($row, $action, 1); if ($move_module_name !== false) { - add_log('admin', 'LOG_MODULE_' . strtoupper($action), $this->lang_name($row['module_langname']), $move_module_name); + add_log('admin', 'LOG_MODULE_' . strtoupper($action), phpbb::$user->lang($row['module_langname']), $move_module_name); $this->remove_cache_file(); } @@ -213,7 +213,7 @@ class acp_modules { $this->remove_cache_file(); - trigger_error($user->lang['MODULE_ADDED'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); + trigger_error(phpbb::$user->lang['MODULE_ADDED'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); } } } @@ -234,7 +234,7 @@ class acp_modules if (!$module_id) { - trigger_error($user->lang['NO_MODULE_ID'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); + trigger_error(phpbb::$user->lang['NO_MODULE_ID'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } $module_row = $this->get_module_row($module_id); @@ -272,7 +272,7 @@ class acp_modules { if (!$module_data['module_langname']) { - trigger_error($user->lang['NO_MODULE_LANGNAME'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); + trigger_error(phpbb::$user->lang['NO_MODULE_LANGNAME'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } $module_type = request_var('module_type', 'category'); @@ -301,7 +301,7 @@ class acp_modules { $this->remove_cache_file(); - trigger_error((($action == 'add') ? $user->lang['MODULE_ADDED'] : $user->lang['MODULE_EDITED']) . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); + trigger_error((($action == 'add') ? phpbb::$user->lang['MODULE_ADDED'] : phpbb::$user->lang['MODULE_EDITED']) . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); } } @@ -321,7 +321,7 @@ class acp_modules } // Name options - $s_name_options .= '<option value="' . $option . '"' . (($option == $module_data['module_basename']) ? ' selected="selected"' : '') . '>' . $this->lang_name($values['title']) . ' [' . $this->module_class . '_' . $option . ']</option>'; + $s_name_options .= '<option value="' . $option . '"' . (($option == $module_data['module_basename']) ? ' selected="selected"' : '') . '>' . phpbb::$user->lang($values['title']) . ' [' . $this->module_class . '_' . $option . ']</option>'; $template->assign_block_vars('m_names', array('NAME' => $option, 'A_NAME' => addslashes($option))); @@ -330,19 +330,19 @@ class acp_modules { if ($option == $module_data['module_basename']) { - $s_mode_options .= '<option value="' . $m_mode . '"' . (($m_mode == $module_data['module_mode']) ? ' selected="selected"' : '') . '>' . $this->lang_name($m_values['title']) . '</option>'; + $s_mode_options .= '<option value="' . $m_mode . '"' . (($m_mode == $module_data['module_mode']) ? ' selected="selected"' : '') . '>' . phpbb::$user->lang($m_values['title']) . '</option>'; } $template->assign_block_vars('m_names.modes', array( 'OPTION' => $m_mode, - 'VALUE' => $this->lang_name($m_values['title']), + 'VALUE' => phpbb::$user->lang($m_values['title']), 'A_OPTION' => addslashes($m_mode), - 'A_VALUE' => addslashes($this->lang_name($m_values['title']))) + 'A_VALUE' => addslashes(phpbb::$user->lang($m_values['title']))) ); } } - $s_cat_option = '<option value="0"' . (($module_data['parent_id'] == 0) ? ' selected="selected"' : '') . '>' . $user->lang['NO_PARENT'] . '</option>'; + $s_cat_option = '<option value="0"' . (($module_data['parent_id'] == 0) ? ' selected="selected"' : '') . '>' . phpbb::$user->lang['NO_PARENT'] . '</option>'; $template->assign_vars(array_merge(array( 'S_EDIT_MODULE' => true, @@ -353,9 +353,9 @@ class acp_modules 'U_BACK' => $this->u_action . '&parent_id=' . $this->parent_id, 'U_EDIT_ACTION' => $this->u_action . '&parent_id=' . $this->parent_id, - 'L_TITLE' => $user->lang[strtoupper($action) . '_MODULE'], + 'L_TITLE' => phpbb::$user->lang[strtoupper($action) . '_MODULE'], - 'MODULENAME' => $this->lang_name($module_data['module_langname']), + 'MODULENAME' => phpbb::$user->lang($module_data['module_langname']), 'ACTION' => $action, 'MODULE_ID' => $module_id, @@ -397,7 +397,7 @@ class acp_modules foreach ($modules_nav as $row) { - $langname = $this->lang_name($row['module_langname']); + $langname = phpbb::$user->lang($row['module_langname']); if ($row['module_id'] == $this->parent_id) { @@ -416,23 +416,23 @@ class acp_modules $sql = 'SELECT * FROM ' . MODULES_TABLE . " WHERE parent_id = {$this->parent_id} - AND module_class = '" . $db->sql_escape($this->module_class) . "' + AND module_class = '" . phpbb::$db->sql_escape($this->module_class) . "' ORDER BY left_id"; - $result = $db->sql_query($sql); + $result = phpbb::$db->sql_query($sql); - if ($row = $db->sql_fetchrow($result)) + if ($row = phpbb::$db->sql_fetchrow($result)) { do { - $langname = $this->lang_name($row['module_langname']); + $langname = phpbb::$user->lang($row['module_langname']); if (!$row['module_enabled']) { - $module_image = '<img src="images/icon_folder_lock.gif" alt="' . $user->lang['DEACTIVATED_MODULE'] .'" />'; + $module_image = '<img src="images/icon_folder_lock.gif" alt="' . phpbb::$user->lang['DEACTIVATED_MODULE'] .'" />'; } else { - $module_image = (!$row['module_basename'] || $row['left_id'] + 1 != $row['right_id']) ? '<img src="images/icon_subfolder.gif" alt="' . $user->lang['CATEGORY'] . '" />' : '<img src="images/icon_folder.gif" alt="' . $user->lang['MODULE'] . '" />'; + $module_image = (!$row['module_basename'] || $row['left_id'] + 1 != $row['right_id']) ? '<img src="images/icon_subfolder.gif" alt="' . phpbb::$user->lang['CATEGORY'] . '" />' : '<img src="images/icon_folder.gif" alt="' . phpbb::$user->lang['MODULE'] . '" />'; } $url = $this->u_action . '&parent_id=' . $this->parent_id . '&m=' . $row['module_id']; @@ -455,7 +455,7 @@ class acp_modules 'U_DISABLE' => $url . '&action=disable') ); } - while ($row = $db->sql_fetchrow($result)); + while ($row = phpbb::$db->sql_fetchrow($result)); } else if ($this->parent_id) { @@ -475,7 +475,7 @@ class acp_modules 'U_DISABLE' => $url . '&action=disable') ); } - $db->sql_freeresult($result); + phpbb::$db->sql_freeresult($result); // Quick adding module $module_infos = $this->get_module_infos(); @@ -485,12 +485,12 @@ class acp_modules foreach ($module_infos as $option => $values) { // Name options - $s_install_options .= '<optgroup label="' . $this->lang_name($values['title']) . ' [' . $this->module_class . '_' . $option . ']">'; + $s_install_options .= '<optgroup label="' . phpbb::$user->lang($values['title']) . ' [' . $this->module_class . '_' . $option . ']">'; // Build module modes foreach ($values['modes'] as $m_mode => $m_values) { - $s_install_options .= '<option value="' . $option . '::' . $m_mode . '"> ' . $this->lang_name($m_values['title']) . '</option>'; + $s_install_options .= '<option value="' . $option . '::' . $m_mode . '"> ' . phpbb::$user->lang($m_values['title']) . '</option>'; } $s_install_options .= '</optgroup>'; @@ -512,19 +512,17 @@ class acp_modules */ function get_module_row($module_id) { - global $db, $user; - $sql = 'SELECT * FROM ' . MODULES_TABLE . " - WHERE module_class = '" . $db->sql_escape($this->module_class) . "' + WHERE module_class = '" . phpbb::$db->sql_escape($this->module_class) . "' AND module_id = $module_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); + $result = phpbb::$db->sql_query($sql); + $row = phpbb::$db->sql_fetchrow($result); + phpbb::$db->sql_freeresult($result); if (!$row) { - trigger_error($user->lang['NO_MODULE'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); + trigger_error(phpbb::$user->lang['NO_MODULE'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } return $row; @@ -537,7 +535,7 @@ class acp_modules { $module_class = ($module_class === false) ? $this->module_class : $module_class; - $directory = PHPBB_ROOT_PATH . 'includes/' . $module_class . '/info/'; + $directory = PHPBB_ROOT_PATH . 'modules/' . $module_class . '/info/'; $fileinfo = array(); if (!$module) @@ -601,19 +599,19 @@ class acp_modules */ function make_module_select($select_id = false, $ignore_id = false, $ignore_acl = false, $ignore_nonpost = false, $ignore_emptycat = true, $ignore_noncat = false) { - global $db, $user, $auth; + global $auth; $sql = 'SELECT module_id, module_enabled, module_basename, parent_id, module_langname, left_id, right_id, module_auth FROM ' . MODULES_TABLE . " - WHERE module_class = '" . $db->sql_escape($this->module_class) . "' + WHERE module_class = '" . phpbb::$db->sql_escape($this->module_class) . "' ORDER BY left_id ASC"; - $result = $db->sql_query($sql); + $result = phpbb::$db->sql_query($sql); $right = $iteration = 0; $padding_store = array('0' => ''); $module_list = $padding = ''; - while ($row = $db->sql_fetchrow($result)) + while ($row = phpbb::$db->sql_fetchrow($result)) { if ($row['left_id'] < $right) { @@ -656,12 +654,12 @@ class acp_modules $selected = (is_array($select_id)) ? ((in_array($row['module_id'], $select_id)) ? ' selected="selected"' : '') : (($row['module_id'] == $select_id) ? ' selected="selected"' : ''); - $langname = $this->lang_name($row['module_langname']); + $langname = phpbb::$user->lang($row['module_langname']); $module_list .= '<option value="' . $row['module_id'] . '"' . $selected . ((!$row['module_enabled']) ? ' class="disabled"' : '') . '>' . $padding . $langname . '</option>'; $iteration++; } - $db->sql_freeresult($result); + phpbb::$db->sql_freeresult($result); unset($padding_store); @@ -673,8 +671,6 @@ class acp_modules */ function get_module_branch($module_id, $type = 'all', $order = 'descending', $include_module = true) { - global $db; - switch ($type) { case 'parents': @@ -695,13 +691,13 @@ class acp_modules $sql = 'SELECT m2.* FROM ' . MODULES_TABLE . ' m1 LEFT JOIN ' . MODULES_TABLE . " m2 ON ($condition) - WHERE m1.module_class = '" . $db->sql_escape($this->module_class) . "' - AND m2.module_class = '" . $db->sql_escape($this->module_class) . "' + WHERE m1.module_class = '" . phpbb::$db->sql_escape($this->module_class) . "' + AND m2.module_class = '" . phpbb::$db->sql_escape($this->module_class) . "' AND m1.module_id = $module_id ORDER BY m2.left_id " . (($order == 'descending') ? 'ASC' : 'DESC'); - $result = $db->sql_query($sql); + $result = phpbb::$db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + while ($row = phpbb::$db->sql_fetchrow($result)) { if (!$include_module && $row['module_id'] == $module_id) { @@ -710,7 +706,7 @@ class acp_modules $rows[] = $row; } - $db->sql_freeresult($result); + phpbb::$db->sql_freeresult($result); return $rows; } @@ -730,24 +726,12 @@ class acp_modules } /** - * Return correct language name - */ - function lang_name($module_langname) - { - global $user; - - return (!empty($user->lang[$module_langname])) ? $user->lang[$module_langname] : $module_langname; - } - - /** * Update/Add module * * @param bool $run_inline if set to true errors will be returned and no logs being written */ function update_module_data(&$module_data, $run_inline = false) { - global $db, $user; - if (!isset($module_data['module_id'])) { // no module_id means we're creating a new category/module @@ -755,11 +739,11 @@ class acp_modules { $sql = 'SELECT left_id, right_id FROM ' . MODULES_TABLE . " - WHERE module_class = '" . $db->sql_escape($module_data['module_class']) . "' + WHERE module_class = '" . phpbb::$db->sql_escape($module_data['module_class']) . "' AND module_id = " . (int) $module_data['parent_id']; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); + $result = phpbb::$db->sql_query($sql); + $row = phpbb::$db->sql_fetchrow($result); + phpbb::$db->sql_freeresult($result); if (!$row) { @@ -768,7 +752,7 @@ class acp_modules return 'PARENT_NO_EXIST'; } - trigger_error($user->lang['PARENT_NO_EXIST'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); + trigger_error(phpbb::$user->lang['PARENT_NO_EXIST'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } // Workaround @@ -777,15 +761,15 @@ class acp_modules $sql = 'UPDATE ' . MODULES_TABLE . " SET left_id = left_id + 2, right_id = right_id + 2 - WHERE module_class = '" . $db->sql_escape($module_data['module_class']) . "' + WHERE module_class = '" . phpbb::$db->sql_escape($module_data['module_class']) . "' AND left_id > {$row['right_id']}"; - $db->sql_query($sql); + phpbb::$db->sql_query($sql); $sql = 'UPDATE ' . MODULES_TABLE . " SET right_id = right_id + 2 - WHERE module_class = '" . $db->sql_escape($module_data['module_class']) . "' + WHERE module_class = '" . phpbb::$db->sql_escape($module_data['module_class']) . "' AND {$row['left_id']} BETWEEN left_id AND right_id"; - $db->sql_query($sql); + phpbb::$db->sql_query($sql); $module_data['left_id'] = (int) $row['right_id']; $module_data['right_id'] = (int) $row['right_id'] + 1; @@ -794,23 +778,23 @@ class acp_modules { $sql = 'SELECT MAX(right_id) AS right_id FROM ' . MODULES_TABLE . " - WHERE module_class = '" . $db->sql_escape($module_data['module_class']) . "'"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); + WHERE module_class = '" . phpbb::$db->sql_escape($module_data['module_class']) . "'"; + $result = phpbb::$db->sql_query($sql); + $row = phpbb::$db->sql_fetchrow($result); + phpbb::$db->sql_freeresult($result); $module_data['left_id'] = (int) $row['right_id'] + 1; $module_data['right_id'] = (int) $row['right_id'] + 2; } - $sql = 'INSERT INTO ' . MODULES_TABLE . ' ' . $db->sql_build_array('INSERT', $module_data); - $db->sql_query($sql); + $sql = 'INSERT INTO ' . MODULES_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $module_data); + phpbb::$db->sql_query($sql); - $module_data['module_id'] = $db->sql_nextid(); + $module_data['module_id'] = phpbb::$db->sql_nextid(); if (!$run_inline) { - add_log('admin', 'LOG_MODULE_ADD', $this->lang_name($module_data['module_langname'])); + add_log('admin', 'LOG_MODULE_ADD', phpbb::$user->lang($module_data['module_langname'])); } } else @@ -824,7 +808,7 @@ class acp_modules if (sizeof($branch)) { - return array($user->lang['NO_CATEGORY_TO_MODULE']); + return array(phpbb::$user->lang['NO_CATEGORY_TO_MODULE']); } } @@ -837,14 +821,14 @@ class acp_modules unset($update_ary['module_id']); $sql = 'UPDATE ' . MODULES_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $update_ary) . " - WHERE module_class = '" . $db->sql_escape($module_data['module_class']) . "' + SET ' . phpbb::$db->sql_build_array('UPDATE', $update_ary) . " + WHERE module_class = '" . phpbb::$db->sql_escape($module_data['module_class']) . "' AND module_id = " . (int) $module_data['module_id']; - $db->sql_query($sql); + phpbb::$db->sql_query($sql); if (!$run_inline) { - add_log('admin', 'LOG_MODULE_EDIT', $this->lang_name($module_data['module_langname'])); + add_log('admin', 'LOG_MODULE_EDIT', phpbb::$user->lang($module_data['module_langname'])); } } @@ -856,8 +840,6 @@ class acp_modules */ function move_module($from_module_id, $to_parent_id) { - global $db; - $moved_modules = $this->get_module_branch($from_module_id, 'children', 'descending'); $from_data = $moved_modules[0]; $diff = sizeof($moved_modules) * 2; @@ -871,17 +853,17 @@ class acp_modules // Resync parents $sql = 'UPDATE ' . MODULES_TABLE . " SET right_id = right_id - $diff - WHERE module_class = '" . $db->sql_escape($this->module_class) . "' + WHERE module_class = '" . phpbb::$db->sql_escape($this->module_class) . "' AND left_id < " . (int) $from_data['right_id'] . ' AND right_id > ' . (int) $from_data['right_id']; - $db->sql_query($sql); + phpbb::$db->sql_query($sql); // Resync righthand side of tree $sql = 'UPDATE ' . MODULES_TABLE . " SET left_id = left_id - $diff, right_id = right_id - $diff - WHERE module_class = '" . $db->sql_escape($this->module_class) . "' + WHERE module_class = '" . phpbb::$db->sql_escape($this->module_class) . "' AND left_id > " . (int) $from_data['right_id']; - $db->sql_query($sql); + phpbb::$db->sql_query($sql); if ($to_parent_id > 0) { @@ -890,18 +872,18 @@ class acp_modules // Resync new parents $sql = 'UPDATE ' . MODULES_TABLE . " SET right_id = right_id + $diff - WHERE module_class = '" . $db->sql_escape($this->module_class) . "' + WHERE module_class = '" . phpbb::$db->sql_escape($this->module_class) . "' AND " . (int) $to_data['right_id'] . ' BETWEEN left_id AND right_id - AND ' . $db->sql_in_set('module_id', $moved_ids, true); - $db->sql_query($sql); + AND ' . phpbb::$db->sql_in_set('module_id', $moved_ids, true); + phpbb::$db->sql_query($sql); // Resync the righthand side of the tree $sql = 'UPDATE ' . MODULES_TABLE . " SET left_id = left_id + $diff, right_id = right_id + $diff - WHERE module_class = '" . $db->sql_escape($this->module_class) . "' + WHERE module_class = '" . phpbb::$db->sql_escape($this->module_class) . "' AND left_id > " . (int) $to_data['right_id'] . ' - AND ' . $db->sql_in_set('module_id', $moved_ids, true); - $db->sql_query($sql); + AND ' . phpbb::$db->sql_in_set('module_id', $moved_ids, true); + phpbb::$db->sql_query($sql); // Resync moved branch $to_data['right_id'] += $diff; @@ -918,20 +900,20 @@ class acp_modules { $sql = 'SELECT MAX(right_id) AS right_id FROM ' . MODULES_TABLE . " - WHERE module_class = '" . $db->sql_escape($this->module_class) . "' - AND " . $db->sql_in_set('module_id', $moved_ids, true); - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); + WHERE module_class = '" . phpbb::$db->sql_escape($this->module_class) . "' + AND " . phpbb::$db->sql_in_set('module_id', $moved_ids, true); + $result = phpbb::$db->sql_query($sql); + $row = phpbb::$db->sql_fetchrow($result); + phpbb::$db->sql_freeresult($result); $diff = '+ ' . (int) ($row['right_id'] - $from_data['left_id'] + 1); } $sql = 'UPDATE ' . MODULES_TABLE . " SET left_id = left_id $diff, right_id = right_id $diff - WHERE module_class = '" . $db->sql_escape($this->module_class) . "' - AND " . $db->sql_in_set('module_id', $moved_ids); - $db->sql_query($sql); + WHERE module_class = '" . phpbb::$db->sql_escape($this->module_class) . "' + AND " . phpbb::$db->sql_in_set('module_id', $moved_ids); + phpbb::$db->sql_query($sql); } /** @@ -939,23 +921,21 @@ class acp_modules */ function delete_module($module_id) { - global $db, $user; - $row = $this->get_module_row($module_id); $branch = $this->get_module_branch($module_id, 'children', 'descending', false); if (sizeof($branch)) { - return array($user->lang['CANNOT_REMOVE_MODULE']); + return array(phpbb::$user->lang['CANNOT_REMOVE_MODULE']); } // If not move $diff = 2; $sql = 'DELETE FROM ' . MODULES_TABLE . " - WHERE module_class = '" . $db->sql_escape($this->module_class) . "' + WHERE module_class = '" . phpbb::$db->sql_escape($this->module_class) . "' AND module_id = $module_id"; - $db->sql_query($sql); + phpbb::$db->sql_query($sql); $row['right_id'] = (int) $row['right_id']; $row['left_id'] = (int) $row['left_id']; @@ -963,17 +943,17 @@ class acp_modules // Resync tree $sql = 'UPDATE ' . MODULES_TABLE . " SET right_id = right_id - $diff - WHERE module_class = '" . $db->sql_escape($this->module_class) . "' + WHERE module_class = '" . phpbb::$db->sql_escape($this->module_class) . "' AND left_id < {$row['right_id']} AND right_id > {$row['right_id']}"; - $db->sql_query($sql); + phpbb::$db->sql_query($sql); $sql = 'UPDATE ' . MODULES_TABLE . " SET left_id = left_id - $diff, right_id = right_id - $diff - WHERE module_class = '" . $db->sql_escape($this->module_class) . "' + WHERE module_class = '" . phpbb::$db->sql_escape($this->module_class) . "' AND left_id > {$row['right_id']}"; - $db->sql_query($sql); + phpbb::$db->sql_query($sql); - add_log('admin', 'LOG_MODULE_REMOVED', $this->lang_name($row['module_langname'])); + add_log('admin', 'LOG_MODULE_REMOVED', phpbb::$user->lang($row['module_langname'])); return array(); @@ -984,8 +964,6 @@ class acp_modules */ function move_module_by($module_row, $action = 'move_up', $steps = 1) { - global $db; - /** * Fetch all the siblings between the module's current spot * and where we want to move it to. If there are less than $steps @@ -994,17 +972,17 @@ class acp_modules */ $sql = 'SELECT module_id, left_id, right_id, module_langname FROM ' . MODULES_TABLE . " - WHERE module_class = '" . $db->sql_escape($this->module_class) . "' + WHERE module_class = '" . phpbb::$db->sql_escape($this->module_class) . "' AND parent_id = " . (int) $module_row['parent_id'] . ' AND ' . (($action == 'move_up') ? 'right_id < ' . (int) $module_row['right_id'] . ' ORDER BY right_id DESC' : 'left_id > ' . (int) $module_row['left_id'] . ' ORDER BY left_id ASC'); - $result = $db->sql_query_limit($sql, $steps); + $result = phpbb::$db->sql_query_limit($sql, $steps); $target = array(); - while ($row = $db->sql_fetchrow($result)) + while ($row = phpbb::$db->sql_fetchrow($result)) { $target = $row; } - $db->sql_freeresult($result); + phpbb::$db->sql_freeresult($result); if (!sizeof($target)) { @@ -1052,14 +1030,14 @@ class acp_modules WHEN right_id BETWEEN {$move_up_left} AND {$move_up_right} THEN -{$diff_up} ELSE {$diff_down} END - WHERE module_class = '" . $db->sql_escape($this->module_class) . "' + WHERE module_class = '" . phpbb::$db->sql_escape($this->module_class) . "' AND left_id BETWEEN {$left_id} AND {$right_id} AND right_id BETWEEN {$left_id} AND {$right_id}"; - $db->sql_query($sql); + phpbb::$db->sql_query($sql); $this->remove_cache_file(); - return $this->lang_name($target['module_langname']); + return phpbb::$user->lang($target['module_langname']); } } diff --git a/phpBB/modules/acp/acp_permissions.php b/phpBB/modules/acp/acp_permissions.php index e3d7dafd12..725532db2c 100644 --- a/phpBB/modules/acp/acp_permissions.php +++ b/phpBB/modules/acp/acp_permissions.php @@ -368,7 +368,7 @@ class acp_permissions $template->assign_vars(array( 'S_SELECT_GROUP' => true, - 'S_GROUP_OPTIONS' => group_select_options(false, false, (($user->data['user_type'] == phpbb::USER_FOUNDER) ? false : 0))) + 'S_GROUP_OPTIONS' => group_select_options(false, false, ((phpbb::$user->is_founder) ? false : 0))) ); break; @@ -414,7 +414,7 @@ class acp_permissions 'S_SELECT_USERGROUP_VIEW' => ($victim == 'usergroup_view') ? true : false, 'S_DEFINED_USER_OPTIONS' => $items['user_ids_options'], 'S_DEFINED_GROUP_OPTIONS' => $items['group_ids_options'], - 'S_ADD_GROUP_OPTIONS' => group_select_options(false, $items['group_ids'], (($user->data['user_type'] == phpbb::USER_FOUNDER) ? false : 0)), + 'S_ADD_GROUP_OPTIONS' => group_select_options(false, $items['group_ids'], ((phpbb::$user->is_founder) ? false : 0)), 'U_FIND_USERNAME' => append_sid('memberlist', 'mode=searchuser&form=add_user&field=username&select_single=true'), )); diff --git a/phpBB/modules/acp/acp_styles.php b/phpBB/modules/acp/acp_styles.php index 061de5ae76..66e87471f7 100644 --- a/phpBB/modules/acp/acp_styles.php +++ b/phpBB/modules/acp/acp_styles.php @@ -293,7 +293,7 @@ parse_css_file = {PARSE_CSS_FILE} // Save CSS contents $sql_ary = array( 'theme_mtime' => (int) filemtime(PHPBB_ROOT_PATH . "styles/{$theme_row['theme_path']}/theme/stylesheet.css"), - 'theme_data' => $this->db_theme_data($theme_row) + 'theme_data' => self::db_theme_data($theme_row) ); $sql = 'UPDATE ' . STYLES_THEME_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " @@ -974,7 +974,7 @@ parse_css_file = {PARSE_CSS_FILE} $sql_ary = array( 'theme_mtime' => time(), 'theme_storedb' => 1, - 'theme_data' => $this->db_theme_data($theme_info, $theme_data), + 'theme_data' => self::db_theme_data($theme_info, $theme_data), ); $sql = 'UPDATE ' . STYLES_THEME_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' @@ -2123,7 +2123,7 @@ parse_css_file = {PARSE_CSS_FILE} /** * Load css file contents */ - function load_css_file($path, $filename) + static function load_css_file($path, $filename) { $file = PHPBB_ROOT_PATH . "styles/$path/theme/$filename"; @@ -2149,7 +2149,7 @@ parse_css_file = {PARSE_CSS_FILE} * * @return string Stylesheet data for theme_data column in the theme table */ - function db_theme_data($theme_row, $stylesheet = false, $root_path = '') + static function db_theme_data($theme_row, $stylesheet = false, $root_path = '') { if (!$root_path) { @@ -2173,7 +2173,7 @@ parse_css_file = {PARSE_CSS_FILE} { foreach ($matches[0] as $idx => $match) { - $stylesheet = str_replace($match, acp_styles::load_css_file($theme_row['theme_path'], $matches[1][$idx]), $stylesheet); + $stylesheet = str_replace($match, self::load_css_file($theme_row['theme_path'], $matches[1][$idx]), $stylesheet); } } @@ -2939,7 +2939,7 @@ parse_css_file = {PARSE_CSS_FILE} $sql_ary += array( 'theme_storedb' => $store_db, - 'theme_data' => ($store_db) ? $this->db_theme_data($sql_ary, false, $root_path) : '', + 'theme_data' => ($store_db) ? self::db_theme_data($sql_ary, false, $root_path) : '', 'theme_mtime' => (int) filemtime(PHPBB_ROOT_PATH . "styles/$path/theme/stylesheet.css") ); break; diff --git a/phpBB/modules/acp/acp_users.php b/phpBB/modules/acp/acp_users.php index 02940154b9..1019ffad19 100644 --- a/phpBB/modules/acp/acp_users.php +++ b/phpBB/modules/acp/acp_users.php @@ -152,7 +152,7 @@ class acp_users ); // Prevent normal users/admins change/view founders if they are not a founder by themselves - if ($user->data['user_type'] != phpbb::USER_FOUNDER && $user_row['user_type'] == phpbb::USER_FOUNDER) + if (!phpbb::$user->is_founder && $user_row['user_type'] == phpbb::USER_FOUNDER) { trigger_error($user->lang['NOT_MANAGE_FOUNDER'] . adm_back_link($this->u_action), E_USER_WARNING); } @@ -718,10 +718,10 @@ class acp_users { $sql_ary = array(); - if ($user_row['user_type'] != phpbb::USER_FOUNDER || $user->data['user_type'] == phpbb::USER_FOUNDER) + if ($user_row['user_type'] != phpbb::USER_FOUNDER || phpbb::$user->is_founder) { // Only allow founders updating the founder status... - if ($user->data['user_type'] == phpbb::USER_FOUNDER) + if (phpbb::$user->is_founder) { // Setting a normal member to be a founder if ($data['user_founder'] && $user_row['user_type'] != phpbb::USER_FOUNDER) @@ -903,7 +903,7 @@ class acp_users 'L_NAME_CHARS_EXPLAIN' => sprintf($user->lang[phpbb::$config['allow_name_chars'] . '_EXPLAIN'], phpbb::$config['min_name_chars'], phpbb::$config['max_name_chars']), 'L_CHANGE_PASSWORD_EXPLAIN' => sprintf($user->lang[phpbb::$config['pass_complex'] . '_EXPLAIN'], phpbb::$config['min_pass_chars'], phpbb::$config['max_pass_chars']), 'L_POSTS_IN_QUEUE' => $user->lang('NUM_POSTS_IN_QUEUE', $user_row['posts_in_queue']), - 'S_FOUNDER' => ($user->data['user_type'] == phpbb::USER_FOUNDER) ? true : false, + 'S_FOUNDER' => phpbb::$user->is_founder, 'S_OVERVIEW' => true, 'S_USER_IP' => ($user_row['user_ip']) ? true : false, @@ -1801,7 +1801,7 @@ class acp_users $founder_manage = (int) $db->sql_fetchfield('group_founder_manage'); $db->sql_freeresult($result); - if ($user->data['user_type'] != phpbb::USER_FOUNDER && $founder_manage) + if (!phpbb::$user->is_founder && $founder_manage) { trigger_error($user->lang['NOT_ALLOWED_MANAGE_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } @@ -1921,7 +1921,7 @@ class acp_users } // Do not display those groups not allowed to be managed - if ($user->data['user_type'] != phpbb::USER_FOUNDER && $row['group_founder_manage']) + if (!phpbb::$user->is_founder && $row['group_founder_manage']) { continue; } |