consistant obtain_* functions

git-svn-id: file:///svn/phpbb/trunk@6572 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2006-11-12 15:35:43 +00:00
parent b0217ddc11
commit d89f60f182
14 changed files with 36 additions and 53 deletions

View file

@ -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
{

View file

@ -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;
}
}

View file

@ -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]))

View file

@ -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...

View file

@ -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);

View file

@ -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)
{

View file

@ -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();

View file

@ -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)
{

View file

@ -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');

View file

@ -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'])

View file

@ -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 ...

View file

@ -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))

View file

@ -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();

View file

@ -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