From d89f60f182afa07e28d4e58f59b90dd25555e3a6 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 12 Nov 2006 15:35:43 +0000 Subject: [PATCH] consistant obtain_* functions git-svn-id: file:///svn/phpbb/trunk@6572 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/download.php | 3 +-- phpBB/includes/cache.php | 33 ++++++++++++----------- phpBB/includes/functions.php | 8 ++---- phpBB/includes/functions_display.php | 3 +-- phpBB/includes/functions_posting.php | 7 ++--- phpBB/includes/functions_user.php | 3 +-- phpBB/includes/mcp/mcp_forum.php | 3 +-- phpBB/includes/session.php | 3 +-- phpBB/includes/ucp/ucp_pm_viewfolder.php | 3 +-- phpBB/includes/ucp/ucp_pm_viewmessage.php | 6 ++--- phpBB/memberlist.php | 3 +-- phpBB/search.php | 3 +-- phpBB/viewforum.php | 3 +-- phpBB/viewtopic.php | 8 +++--- 14 files changed, 36 insertions(+), 53 deletions(-) diff --git a/phpBB/download.php b/phpBB/download.php index f60b4e08bd..64d147fa79 100644 --- a/phpBB/download.php +++ b/phpBB/download.php @@ -63,8 +63,7 @@ if ($attachment['is_orphan']) trigger_error('ERROR_NO_ATTACHMENT'); } - $extensions = array(); - $cache->obtain_attach_extensions($extensions); + $extensions = $cache->obtain_attach_extensions(); } else { diff --git a/phpBB/includes/cache.php b/phpBB/includes/cache.php index 01dcf5b722..6266d32c0f 100644 --- a/phpBB/includes/cache.php +++ b/phpBB/includes/cache.php @@ -70,13 +70,13 @@ class cache extends acm * Obtain list of naughty words and build preg style replacement arrays for use by the * calling script */ - function obtain_word_list(&$censors) + function obtain_word_list() { global $config, $user, $db; if (!$user->optionget('viewcensors') && $config['allow_nocensors']) { - return false; + return array(); } if (($censors = $this->get('word_censors')) === false) @@ -96,13 +96,13 @@ class cache extends acm $this->put('word_censors', $censors); } - return true; + return $censors; } /** * Obtain currently listed icons */ - function obtain_icons(&$icons) + function obtain_icons() { if (($icons = $this->get('icons')) === false) { @@ -127,13 +127,13 @@ class cache extends acm $this->put('icons', $icons); } - return; + return $icons; } /** * Obtain ranks */ - function obtain_ranks(&$ranks) + function obtain_ranks() { if (($ranks = $this->get('ranks')) === false) { @@ -168,13 +168,13 @@ class cache extends acm $this->put('ranks', $ranks); } - return; + return $ranks; } /** * Obtain allowed extensions */ - function obtain_attach_extensions(&$extensions, $forum_id = false) + function obtain_attach_extensions($forum_id = false) { if (($extensions = $this->get('_extensions')) === false) { @@ -254,13 +254,13 @@ class cache extends acm $extensions['_allowed_'] = array(); } - return; + return $extensions; } /** * Obtain active bots */ - function obtain_bots(&$bots) + function obtain_bots() { if (($bots = $this->get('bots')) === false) { @@ -303,7 +303,7 @@ class cache extends acm $this->put('bots', $bots); } - return; + return $bots; } /** @@ -355,9 +355,12 @@ class cache extends acm return $parsed_items; } - function obtain_disallowed_usernames(&$usernames) + /** + * Obtain disallowed usernames + */ + function obtain_disallowed_usernames() { - if (($usernames = $this->get('disallowed_usernames')) === false) + if (($usernames = $this->get('_disallowed_usernames')) === false) { global $db; @@ -372,10 +375,10 @@ class cache extends acm } $db->sql_freeresult($result); - $this->put('disallowed_usernames', $usernames); + $this->put('_disallowed_usernames', $usernames); } - return true; + return $usernames; } } diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 17c15fda30..814dcc74af 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2387,10 +2387,8 @@ function censor_text($text) if (!isset($censors) || !is_array($censors)) { - $censors = array(); - // obtain_word_list is taking care of the users censor option and the board-wide option - $cache->obtain_word_list($censors); + $censors = $cache->obtain_word_list(); } if (sizeof($censors)) @@ -2466,9 +2464,7 @@ function extension_allowed($forum_id, $extension, &$extensions) if (!sizeof($extensions)) { global $cache; - - $extensions = array(); - $cache->obtain_attach_extensions($extensions); + $extensions = $cache->obtain_attach_extensions(); } if (!isset($extensions['_allowed_'][$extension])) diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index dd9b1d7afa..086bd0532a 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -709,8 +709,7 @@ function display_attachments($forum_id, $blockname, &$attachment_data, &$update_ if (empty($extensions) || !is_array($extensions)) { - $extensions = array(); - $cache->obtain_attach_extensions($extensions); + $extensions = $cache->obtain_attach_extensions(); } // Look for missing attachment informations... diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index a16870f01c..b15466b487 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -214,8 +214,7 @@ function posting_gen_topic_icons($mode, $icon_id) global $phpbb_root_path, $config, $template, $cache; // Grab icons - $icons = array(); - $cache->obtain_icons($icons); + $icons = $cache->obtain_icons(); if (!$icon_id) { @@ -339,9 +338,7 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage return $filedata; } - $extensions = array(); - $cache->obtain_attach_extensions($extensions, $forum_id); - + $extensions = $cache->obtain_attach_extensions($forum_id); $upload->set_allowed_extensions(array_keys($extensions['_allowed_'])); $file = ($local) ? $upload->local_upload($local_storage) : $upload->form_upload($form_name); diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index a1bdec1695..15daa0c999 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1159,8 +1159,7 @@ function validate_username($username) } - $bad_usernames = array(); - $cache->obtain_disallowed_usernames($bad_usernames); + $bad_usernames = $cache->obtain_disallowed_usernames(); foreach ($bad_usernames as $bad_username) { diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index 959ff52a1b..b20bd63a08 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -87,8 +87,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info) ); // Grab icons - $icons = array(); - $cache->obtain_icons($icons); + $icons = $cache->obtain_icons(); $topic_rows = array(); diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 6a8d3142d8..b69bcc5f44 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -324,8 +324,7 @@ class session * bot, act accordingly */ $bot = false; - $active_bots = array(); - $cache->obtain_bots($active_bots); + $active_bots = $cache->obtain_bots(); foreach ($active_bots as $row) { diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php index 6ce9ef187d..862702d7fc 100644 --- a/phpBB/includes/ucp/ucp_pm_viewfolder.php +++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php @@ -26,8 +26,7 @@ function view_folder($id, $mode, $folder_id, $folder) $user->add_lang('viewforum'); // Grab icons - $icons = array(); - $cache->obtain_icons($icons); + $icons = $cache->obtain_icons(); $color_rows = array('marked', 'replied'); diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index ad386ea4b5..8da8f0bd18 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -35,8 +35,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) } // Grab icons - $icons = array(); - $cache->obtain_icons($icons); + $icons = $cache->obtain_icons(); $bbcode = false; @@ -395,8 +394,7 @@ function get_user_informations($user_id, $user_row) } // Grab ranks - $ranks = array(); - $cache->obtain_ranks($ranks); + $ranks = $cache->obtain_ranks(); // Generate online information for user if ($config['load_onlinetrack']) diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index ade2f07c39..50fa8e4954 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -58,8 +58,7 @@ $sort_dir = request_var('sd', 'a'); // Grab rank information for later -$ranks = array(); -$cache->obtain_ranks($ranks); +$ranks = $cache->obtain_ranks(); // What do you want to do today? ... oops, I think that line is taken ... diff --git a/phpBB/search.php b/phpBB/search.php index b16a92384e..44ef053014 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -421,8 +421,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) } // Grab icons - $icons = array(); - $cache->obtain_icons($icons); + $icons = $cache->obtain_icons(); // Output header if ($search_id && ($total_match_count > 1000)) diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index c3b9d73a03..21a2ebce73 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -279,8 +279,7 @@ $template->assign_vars(array( ); // Grab icons -$icons = array(); -$cache->obtain_icons($icons); +$icons = $cache->obtain_icons(); // Grab all topic data $rowset = $announcement_list = $topic_list = $global_announce_list = array(); diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 0bcaea8489..2898a1c20a 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -471,18 +471,16 @@ if ($config['allow_bookmarks'] && $user->data['is_registered'] && request_var('b } // Grab ranks -$ranks = array(); -$cache->obtain_ranks($ranks); +$ranks = $cache->obtain_ranks(); // Grab icons -$icons = array(); -$cache->obtain_icons($icons); +$icons = $cache->obtain_icons(); // Grab extensions $extensions = array(); if ($topic_data['topic_attachment']) { - $cache->obtain_attach_extensions($extensions); + $extensions = $cache->obtain_attach_extensions(); } // Forum rules listing