Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc refactoring #445

Merged
merged 20 commits into from May 23, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions sources/Dispatcher.class.php
Expand Up @@ -139,7 +139,6 @@ public function __construct()
'collapse' => array('BoardIndex.controller.php', 'BoardIndex_Controller', 'action_collapse'),
'contact' => array('Register.controller.php', 'Register_Controller', 'action_contact'),
'coppa' => array('Register.controller.php', 'Register_Controller', 'action_coppa'),
// 'credits' => array('Who.controller.php', 'action_credits'),
'deletemsg' => array('RemoveTopic.controller.php', 'RemoveTopic_Controller', 'action_deletemsg'),
'dlattach' => array('Attachment.controller.php', 'Attachment_Controller', 'action_dlattach'),
'disregardtopic' => array('Notify.controller.php', 'Notify_Controller', 'action_disregardtopic'),
Expand Down Expand Up @@ -202,7 +201,6 @@ public function __construct()
'vote' => array('Poll.controller.php', 'Poll_Controller', 'action_vote'),
'viewquery' => array('AdminDebug.php', 'AdminDebug_Controller', 'action_viewquery'),
'viewadminfile' => array('AdminDebug.php', 'AdminDebug_Controller', 'action_viewadminfile'),
// 'who' => array('Who.controller.php', 'action_who'), // done
'.xml' => array('News.controller.php', 'News_Controller', 'action_showfeed'),
'xmlhttp' => array('Xml.controller.php', 'action_xmlhttp'),
);
Expand Down
13 changes: 3 additions & 10 deletions sources/DumpDatabase.php
Expand Up @@ -26,17 +26,12 @@
* It uses gzip compression if compress is set in the URL/post data.
* It may possibly time out, and mess up badly if you were relying on it. :P
* The data dumped depends on whether "struct" and "data" are passed.
* It requires an administrator and the session hash by post.
* It is called from ManageMaintenance.php.
*/
function DumpDatabase2()
{
global $db_name, $scripturl, $context, $modSettings, $crlf;
global $db_prefix, $db_show_debug, $smcFunc;

// Administrators only!
if (!allowedTo('admin_forum'))
fatal_lang_error('no_dump_database', 'critical');
global $db_name, $scripturl, $modSettings;
global $db_prefix, $db_show_debug;

// We'll need a db to dump :P
$database = database();
Expand All @@ -49,8 +44,6 @@ function DumpDatabase2()
if (!isset($_REQUEST['struct']) && !isset($_REQUEST['data']))
$_REQUEST['data'] = true;

checkSession('post');

// Attempt to stop from dying...
@set_time_limit(600);
$time_limit = ini_get('max_execution_time');
Expand Down Expand Up @@ -187,7 +180,7 @@ function DumpDatabase2()
}
$db_chunks .=
$get_rows;
$current_used_memory += $smcFunc['strlen']($db_chunks);
$current_used_memory += Util::strlen($db_chunks);

$db_backup .= $db_chunks;
unset($db_chunks);
Expand Down
5 changes: 3 additions & 2 deletions sources/Errors.php
Expand Up @@ -32,6 +32,7 @@
* @param string $error_type = 'general'
* @param string $file = null
* @param int $line = null
*
* @return string, the error message
*/
function log_error($error_message, $error_type = 'general', $file = null, $line = null)
Expand Down Expand Up @@ -147,8 +148,8 @@ function fatal_error($error, $log = 'general')
* - the information is logged if log is specified.
*
* @param $error
* @param $log
* @param $sprintf
* @param $log = 'general'
* @param $sprintf = array()
*/
function fatal_lang_error($error, $log = 'general', $sprintf = array())
{
Expand Down
11 changes: 5 additions & 6 deletions sources/Load.php
Expand Up @@ -1796,13 +1796,13 @@ function loadSubTemplate($sub_template_name, $fatal = false)
* Add a CSS file for output later
*
* @param string $filename
* @param array $params
* @param array $params = array()
* Keys are the following:
* - ['local'] (true/false): define if the file is local
* - ['fallback'] (true/false): if false will attempt to load the file from the default theme if not found in the current theme
* - ['stale'] (true/false/string): if true or null, use cache stale, false do not, or used a supplied string
*
* @param string $id
* @param string $id = ''
*/
function loadCSSFile($filenames, $params = array(), $id = '')
{
Expand Down Expand Up @@ -1877,15 +1877,15 @@ function loadCSSFile($filenames, $params = array(), $id = '')
* need specific parameters on a per file basis, call it multiple times
*
* @param array $filenames
* @param array $params
* @param array $params = array()
* Keys are the following:
* - ['local'] (true/false): define if the file is local
* - ['defer'] (true/false): define if the file should load in <head> or before the closing <html> tag
* - ['fallback'] (true/false): if true will attempt to load the file from the default theme if not found in the current
* - ['async'] (true/false): if the script should be loaded asynchronously (HTML5)
* - ['stale'] (true/false/string): if true or null, use cache stale, false do not, or used a supplied string
*
* @param string $id
* @param string $id = ''
*/
function loadJavascriptFile($filenames, $params = array(), $id = '')
{
Expand Down Expand Up @@ -1990,7 +1990,7 @@ function addInlineJavascript($javascript, $defer = false)
* Load a language file. Tries the current and default themes as well as the user and global languages.
*
* @param string $template_name
* @param string $lang
* @param string $lang = ''
* @param bool $fatal = true
* @param bool $force_reload = false
* @return string The language actually loaded.
Expand Down Expand Up @@ -2179,7 +2179,6 @@ function getBoardParents($id_parent)
* Attempt to reload our known languages.
*
* @param bool $use_cache = true
* @param bool $favor_utf8 = true
* @return array
*/
function getLanguages($use_cache = true)
Expand Down
4 changes: 2 additions & 2 deletions sources/Security.php
Expand Up @@ -22,8 +22,8 @@
die('No access...');

/**
* Check if the user is who he/she says he is
* Makes sure the user is who they claim to be by requiring a password to be typed in every hour.
* Check if the user is who he/she says he is.
* This function makes sure the user is who they claim to be by requiring a password to be typed in every hour.
* This check can be turned on and off by the securityDisable setting.
* Uses the adminLogin() function of subs/Auth.subs.php if they need to login, which saves all request
* (POST and GET) data.
Expand Down
26 changes: 16 additions & 10 deletions sources/admin/Admin.php
Expand Up @@ -611,21 +611,19 @@ public function action_home()
{
global $forum_version, $txt, $scripturl, $context, $user_info;

// we need a little help
require_once(SUBSDIR . '/Membergroups.subs.php');

// You have to be able to do at least one of the below to see this page.
isAllowedTo(array('admin_forum', 'manage_permissions', 'moderate_forum', 'manage_membergroups', 'manage_bans', 'send_mail', 'edit_news', 'manage_boards', 'manage_smileys', 'manage_attachments'));

// Find all of this forum's administrators...
require_once(SUBSDIR . '/Membergroups.subs.php');
if (listMembergroupMembers_Href($context['administrators'], 1, 32) && allowedTo('manage_membergroups'))
{
// Add a 'more'-link if there are more than 32.
$context['more_admins_link'] = '<a href="' . $scripturl . '?action=moderate;area=viewgroups;sa=members;group=1">' . $txt['more'] . '</a>';
}

// Load the credits stuff.
require_once(CONTROLLERDIR . '/Who.controller.php');
action_credits(true);

// This makes it easier to get the latest news with your time format.
$context['time_format'] = urlencode($user_info['time_format']);
$context['forum_version'] = $forum_version;
Expand Down Expand Up @@ -722,26 +720,34 @@ public function action_home()
/**
* The credits section in admin panel.
*
* Accessed by ?action=admin;area=credits
* Accessed by ?action=admin;area=credits
*/
public function action_credits()
{
global $forum_version, $txt, $scripturl, $context, $user_info;

// we need a little help from our friends
require_once(SUBSDIR . '/Membergroups.subs.php');
require_once(CONTROLLERDIR . '/Who.controller.php');

// You have to be able to do at least one of the below to see this page.
isAllowedTo(array('admin_forum', 'manage_permissions', 'moderate_forum', 'manage_membergroups', 'manage_bans', 'send_mail', 'edit_news', 'manage_boards', 'manage_smileys', 'manage_attachments'));

// Find all of this forum's administrators...
require_once(SUBSDIR . '/Membergroups.subs.php');
if (listMembergroupMembers_Href($context['administrators'], 1, 32) && allowedTo('manage_membergroups'))
{
// Add a 'more'-link if there are more than 32.
$context['more_admins_link'] = '<a href="' . $scripturl . '?action=moderate;area=viewgroups;sa=members;group=1">' . $txt['more'] . '</a>';
}

// Load the credits stuff.
require_once(CONTROLLERDIR . '/Who.controller.php');
action_credits(true);
// Load credits.
$context[$context['admin_menu_name']]['tab_data'] = array(
'title' => $txt['support_credits_title'],
'help' => '',
'description' => '',
);
loadLanguage('Who');
prepareCreditsData();

// This makes it easier to get the latest news with your time format.
$context['time_format'] = urlencode($user_info['time_format']);
Expand Down
4 changes: 2 additions & 2 deletions sources/admin/ManageBoards.php
Expand Up @@ -772,7 +772,7 @@ private function _initBoardSettingsForm()
$this->_boardSettings = new Settings_Form();

// Load the boards list - for the recycle bin!
require_once(SUBSDIR . '/MessageIndex.subs.php');
require_once(SUBSDIR . '/Boards.subs.php');
$boards = getBoardList(array('not_redirection' => true), true);
$recycle_boards = array('');
foreach ($boards as $board)
Expand Down Expand Up @@ -801,7 +801,7 @@ private function _initBoardSettingsForm()
public function settings()
{
// Load the boards list - for the recycle bin!
require_once(SUBSDIR . '/MessageIndex.subs.php');
require_once(SUBSDIR . '/Boards.subs.php');
$boards = getBoardList(array('not_redirection' => true), true);
$recycle_boards = array('');
foreach ($boards as $board)
Expand Down
4 changes: 2 additions & 2 deletions sources/admin/ManageCalendar.php
Expand Up @@ -308,7 +308,7 @@ private function _initCalendarSettingsForm()
$this->_calendarSettings = new Settings_Form();

// Load the boards list.
require_once(SUBSDIR . '/MessageIndex.subs.php');
require_once(SUBSDIR . '/Boards.subs.php');
$boards_list = getBoardList(array('not_redirection' => true), true);
$boards = array('');
foreach ($boards_list as $board)
Expand Down Expand Up @@ -359,7 +359,7 @@ public function settings()
global $txt;

// Load the boards list.
require_once(SUBSDIR . '/MessageIndex.subs.php');
require_once(SUBSDIR . '/Boards.subs.php');
$boards_list = getBoardList(array('not_redirection' => true), true);
$boards = array('');
foreach ($boards_list as $board)
Expand Down
9 changes: 8 additions & 1 deletion sources/admin/ManageMaintenance.php
Expand Up @@ -229,7 +229,7 @@ public function action_topics()
{
global $context, $txt;

require_once(SUBSDIR . '/MessageIndex.subs.php');
require_once(SUBSDIR . '/Boards.subs.php');
// Let's load up the boards in case they are useful.
$context += getBoardList(array('use_permissions' => true, 'not_redirection' => true));

Expand Down Expand Up @@ -777,12 +777,19 @@ public function action_reattribute_display()

/**
* Handling function for the backup stuff.
* It requires an administrator and the session hash by post.
* This method simply forwards to DumpDatabase2().
*/
public function action_backup_display()
{
validateToken('admin-maint');

// Administrators only!
if (!allowedTo('admin_forum'))
fatal_lang_error('no_dump_database', 'critical');

checkSession('post');

require_once(SOURCEDIR . '/DumpDatabase.php');
DumpDatabase2();
}
Expand Down
4 changes: 2 additions & 2 deletions sources/admin/ManageMembergroups.php
Expand Up @@ -465,7 +465,7 @@ public function action_add()
require_once(SUBSDIR . '/Membergroups.subs.php');
$context['groups'] = getBasicMembergroupData(array('globalmod'), array(), 'min_posts, id_group != {int:global_mod_group}, group_name');

require_once(SUBSDIR . '/MessageIndex.subs.php');
require_once(SUBSDIR . '/Boards.subs.php');
$context += getBoardList(array('use_permissions' => true));

// Include a list of boards per category for easy toggling.
Expand Down Expand Up @@ -711,7 +711,7 @@ public function action_edit()
$context['boards'] = array();
if ($groups['id_group'] == 2 || $groups['id_group'] > 3)
{
require_once(SUBSDIR . '/MessageIndex.subs.php');
require_once(SUBSDIR . '/Boards.subs.php');
$context += getBoardList(array('access' => $groups['id_group'], 'not_redirection' => true));

// Include a list of boards per category for easy toggling.
Expand Down
2 changes: 1 addition & 1 deletion sources/admin/ManageSmileys.php
Expand Up @@ -1347,7 +1347,7 @@ public function action_editicon()
'use_permissions' => true,
'selected_board' => isset($context['icon']['board_id']) ? $context['icon']['board_id'] : 0,
);
require_once(SUBSDIR . '/MessageIndex.subs.php');
require_once(SUBSDIR . '/Boards.subs.php');
$context += getBoardList($boardListOptions);
}
}
Expand Down
2 changes: 1 addition & 1 deletion sources/controllers/Calendar.controller.php
Expand Up @@ -291,7 +291,7 @@ function action_event_post()
fatal_lang_error('cannot_post_new', 'permission');

// Load the list of boards and categories in the context.
require_once(SUBSDIR . '/MessageIndex.subs.php');
require_once(SUBSDIR . '/Boards.subs.php');
$boardListOptions = array(
'included_boards' => in_array(0, $boards) ? null : $boards,
'not_redirection' => true,
Expand Down