phpBB

Code Changes

File: includes/functions_admin.php

  Unmodified   Added   Modified   Removed
Line 65Line 65
*/
function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl = false, $ignore_nonpost = false, $ignore_emptycat = true, $only_acl_post = false, $return_array = false)
{

*/
function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl = false, $ignore_nonpost = false, $ignore_emptycat = true, $only_acl_post = false, $return_array = false)
{

	global $db, $user, $auth;

	global $db, $user, $auth, $phpbb_dispatcher;


// This query is identical to the jumpbox one
$sql = 'SELECT forum_id, forum_name, parent_id, forum_type, forum_flags, forum_options, left_id, right_id
FROM ' . FORUMS_TABLE . '
ORDER BY left_id ASC';
$result = $db->sql_query($sql, 600);


// This query is identical to the jumpbox one
$sql = 'SELECT forum_id, forum_name, parent_id, forum_type, forum_flags, forum_options, left_id, right_id
FROM ' . FORUMS_TABLE . '
ORDER BY left_id ASC';
$result = $db->sql_query($sql, 600);

 

$rowset = array();
while ($row = $db->sql_fetchrow($result))
{
$rowset[(int) $row['forum_id']] = $row;
}
$db->sql_freeresult($result);


$right = 0;
$padding_store = array('0' => '');
$padding = '';
$forum_list = ($return_array) ? array() : '';


$right = 0;
$padding_store = array('0' => '');
$padding = '';
$forum_list = ($return_array) ? array() : '';

 

/**
* Modify the forum list data
*
* @event core.make_forum_select_modify_forum_list
* @var array rowset Array with the forums list data
* @since 3.1.10-RC1
*/
$vars = array('rowset');
extract($phpbb_dispatcher->trigger_event('core.make_forum_select_modify_forum_list', compact($vars)));


// Sometimes it could happen that forums will be displayed here not be displayed within the index page
// This is the result of forums not displayed at index, having list permissions and a parent of a forum with no permissions.
// If this happens, the padding could be "broken"



// Sometimes it could happen that forums will be displayed here not be displayed within the index page
// This is the result of forums not displayed at index, having list permissions and a parent of a forum with no permissions.
// If this happens, the padding could be "broken"


	while ($row = $db->sql_fetchrow($result))

	foreach ($rowset as $row)

	{
if ($row['left_id'] < $right)
{

	{
if ($row['left_id'] < $right)
{

Line 133Line 150
			$forum_list .= '<option value="' . $row['forum_id'] . '"' . (($disabled) ? ' disabled="disabled" class="disabled-option"' : $selected) . '>' . $padding . $row['forum_name'] . '</option>';
}
}

			$forum_list .= '<option value="' . $row['forum_id'] . '"' . (($disabled) ? ' disabled="disabled" class="disabled-option"' : $selected) . '>' . $padding . $row['forum_name'] . '</option>';
}
}

	$db->sql_freeresult($result);
unset($padding_store);

	unset($padding_store, $rowset);



return $forum_list;
}


return $forum_list;
}

Line 201Line 217
*/
function get_forum_list($acl_list = 'f_list', $id_only = true, $postable_only = false, $no_cache = false)
{

*/
function get_forum_list($acl_list = 'f_list', $id_only = true, $postable_only = false, $no_cache = false)
{

	global $db, $auth;

	global $db, $auth, $phpbb_dispatcher;

	static $forum_rows;

if (!isset($forum_rows))

	static $forum_rows;

if (!isset($forum_rows))

Line 255Line 271
			$rowset[] = ($id_only) ? (int) $row['forum_id'] : $row;
}
}

			$rowset[] = ($id_only) ? (int) $row['forum_id'] : $row;
}
}

 

/**
* Modify the forum list data
*
* @event core.get_forum_list_modify_data
* @var array rowset Array with the forum list data
* @since 3.1.10-RC1
*/
$vars = array('rowset');
extract($phpbb_dispatcher->trigger_event('core.get_forum_list_modify_data', compact($vars)));


return $rowset;
}


return $rowset;
}

Line 576Line 602
*/
function move_posts($post_ids, $topic_id, $auto_sync = true)
{

*/
function move_posts($post_ids, $topic_id, $auto_sync = true)
{

	global $db;

	global $db, $phpbb_dispatcher;


if (!is_array($post_ids))
{


if (!is_array($post_ids))
{

Line 609Line 635
	{
trigger_error('NO_TOPIC');
}

	{
trigger_error('NO_TOPIC');
}

 

/**
* Perform additional actions before moving posts
*
* @event core.move_posts_before
* @var array post_ids Array of post ids to move
* @var int topic_id The topic id the posts are moved to
* @var bool auto_sync Whether or not to perform auto sync
* @var array forum_ids Array of the forum ids the posts are moved from
* @var array topic_ids Array of the topic ids the posts are moved from
* @var array forum_row Array with the forum id of the topic the posts are moved to
* @since 3.1.7-RC1
*/
$vars = array(
'post_ids',
'topic_id',
'auto_sync',
'forum_ids',
'topic_ids',
'forum_row',
);
extract($phpbb_dispatcher->trigger_event('core.move_posts_before', compact($vars)));


$sql = 'UPDATE ' . POSTS_TABLE . '
SET forum_id = ' . (int) $forum_row['forum_id'] . ", topic_id = $topic_id


$sql = 'UPDATE ' . POSTS_TABLE . '
SET forum_id = ' . (int) $forum_row['forum_id'] . ", topic_id = $topic_id

Line 619Line 667
		SET topic_id = $topic_id, in_message = 0
WHERE " . $db->sql_in_set('post_msg_id', $post_ids);
$db->sql_query($sql);

		SET topic_id = $topic_id, in_message = 0
WHERE " . $db->sql_in_set('post_msg_id', $post_ids);
$db->sql_query($sql);

 

/**
* Perform additional actions after moving posts
*
* @event core.move_posts_after
* @var array post_ids Array of the moved post ids
* @var int topic_id The topic id the posts are moved to
* @var bool auto_sync Whether or not to perform auto sync
* @var array forum_ids Array of the forum ids the posts are moved from
* @var array topic_ids Array of the topic ids the posts are moved from
* @var array forum_row Array with the forum id of the topic the posts are moved to
* @since 3.1.7-RC1
*/
$vars = array(
'post_ids',
'topic_id',
'auto_sync',
'forum_ids',
'topic_ids',
'forum_row',
);
extract($phpbb_dispatcher->trigger_event('core.move_posts_after', compact($vars)));


if ($auto_sync)
{


if ($auto_sync)
{

Line 628Line 698
		sync('topic_attachment', 'topic_id', $topic_ids);
sync('topic', 'topic_id', $topic_ids, true);
sync('forum', 'forum_id', $forum_ids, true, true);

		sync('topic_attachment', 'topic_id', $topic_ids);
sync('topic', 'topic_id', $topic_ids, true);
sync('forum', 'forum_id', $forum_ids, true, true);

 

/**
* Perform additional actions after move post sync
*
* @event core.move_posts_sync_after
* @var array post_ids Array of the moved post ids
* @var int topic_id The topic id the posts are moved to
* @var bool auto_sync Whether or not to perform auto sync
* @var array forum_ids Array of the forum ids the posts are moved from
* @var array topic_ids Array of the topic ids the posts are moved from
* @var array forum_row Array with the forum id of the topic the posts are moved to
* @since 3.1.11-RC1
*/
$vars = array(
'post_ids',
'topic_id',
'auto_sync',
'forum_ids',
'topic_ids',
'forum_row',
);
extract($phpbb_dispatcher->trigger_event('core.move_posts_sync_after', compact($vars)));

	}

// Update posted information

	}

// Update posted information

Line 785Line 877
		'notification.type.quote',
'notification.type.approve_post',
'notification.type.post_in_queue',

		'notification.type.quote',
'notification.type.approve_post',
'notification.type.post_in_queue',

 
		'notification.type.report_post',

	);

/**

	);

/**

Line 885Line 978
	$db->sql_transaction('begin');

$table_ary = array(POSTS_TABLE, REPORTS_TABLE);

	$db->sql_transaction('begin');

$table_ary = array(POSTS_TABLE, REPORTS_TABLE);

 

/**
* Perform additional actions during post(s) deletion before running the queries
*
* @event core.delete_posts_in_transaction_before
* @var array post_ids Array with deleted posts' ids
* @var array poster_ids Array with deleted posts' author ids
* @var array topic_ids Array with deleted posts' topic ids
* @var array forum_ids Array with deleted posts' forum ids
* @var string where_type Variable containing posts deletion mode
* @var mixed where_ids Array or comma separated list of post ids to delete
* @var array delete_notifications_types Array with notifications types to delete
* @var array table_ary Array with table names to delete data from
* @since 3.1.7-RC1
*/
$vars = array(
'post_ids',
'poster_ids',
'topic_ids',
'forum_ids',
'where_type',
'where_ids',
'delete_notifications_types',
'table_ary',
);
extract($phpbb_dispatcher->trigger_event('core.delete_posts_in_transaction_before', compact($vars)));


foreach ($table_ary as $table)
{


foreach ($table_ary as $table)
{

Line 1042Line 1161
*/
function delete_attachments($mode, $ids, $resync = true)
{

*/
function delete_attachments($mode, $ids, $resync = true)
{

	global $db, $config;

	global $db, $config, $phpbb_dispatcher;


// 0 is as bad as an empty array
if (empty($ids))


// 0 is as bad as an empty array
if (empty($ids))

Line 1086Line 1205
	}

$post_ids = $message_ids = $topic_ids = $physical = array();

	}

$post_ids = $message_ids = $topic_ids = $physical = array();

 

/**
* Perform additional actions before collecting data for attachment(s) deletion
*
* @event core.delete_attachments_collect_data_before
* @var string mode Variable containing attachments deletion mode, can be: post|message|topic|attach|user
* @var mixed ids Array or comma separated list of ids corresponding to the mode
* @var bool resync Flag indicating if posts/messages/topics should be synchronized
* @var string sql_id The field name to collect/delete data for depending on the mode
* @since 3.1.7-RC1
*/
$vars = array(
'mode',
'ids',
'resync',
'sql_id',
);
extract($phpbb_dispatcher->trigger_event('core.delete_attachments_collect_data_before', compact($vars)));


// Collect post and topic ids for later use if we need to touch remaining entries (if resync is enabled)
$sql = 'SELECT post_msg_id, topic_id, in_message, physical_filename, thumbnail, filesize, is_orphan


// Collect post and topic ids for later use if we need to touch remaining entries (if resync is enabled)
$sql = 'SELECT post_msg_id, topic_id, in_message, physical_filename, thumbnail, filesize, is_orphan

Line 1115Line 1252
		$physical[] = array('filename' => $row['physical_filename'], 'thumbnail' => $row['thumbnail'], 'filesize' => $row['filesize'], 'is_orphan' => $row['is_orphan']);
}
$db->sql_freeresult($result);

		$physical[] = array('filename' => $row['physical_filename'], 'thumbnail' => $row['thumbnail'], 'filesize' => $row['filesize'], 'is_orphan' => $row['is_orphan']);
}
$db->sql_freeresult($result);

 

/**
* Perform additional actions before attachment(s) deletion
*
* @event core.delete_attachments_before
* @var string mode Variable containing attachments deletion mode, can be: post|message|topic|attach|user
* @var mixed ids Array or comma separated list of ids corresponding to the mode
* @var bool resync Flag indicating if posts/messages/topics should be synchronized
* @var string sql_id The field name to collect/delete data for depending on the mode
* @var array post_ids Array with post ids for deleted attachment(s)
* @var array topic_ids Array with topic ids for deleted attachment(s)
* @var array message_ids Array with private message ids for deleted attachment(s)
* @var array physical Array with deleted attachment(s) physical file(s) data
* @since 3.1.7-RC1
*/
$vars = array(
'mode',
'ids',
'resync',
'sql_id',
'post_ids',
'topic_ids',
'message_ids',
'physical',
);
extract($phpbb_dispatcher->trigger_event('core.delete_attachments_before', compact($vars)));


// Delete attachments
$sql = 'DELETE FROM ' . ATTACHMENTS_TABLE . '


// Delete attachments
$sql = 'DELETE FROM ' . ATTACHMENTS_TABLE . '

Line 1124Line 1287

$db->sql_query($sql);
$num_deleted = $db->sql_affectedrows();


$db->sql_query($sql);
$num_deleted = $db->sql_affectedrows();

 

/**
* Perform additional actions after attachment(s) deletion from the database
*
* @event core.delete_attachments_from_database_after
* @var string mode Variable containing attachments deletion mode, can be: post|message|topic|attach|user
* @var mixed ids Array or comma separated list of ids corresponding to the mode
* @var bool resync Flag indicating if posts/messages/topics should be synchronized
* @var string sql_id The field name to collect/delete data for depending on the mode
* @var array post_ids Array with post ids for deleted attachment(s)
* @var array topic_ids Array with topic ids for deleted attachment(s)
* @var array message_ids Array with private message ids for deleted attachment(s)
* @var array physical Array with deleted attachment(s) physical file(s) data
* @var int num_deleted The number of deleted attachment(s) from the database
* @since 3.1.7-RC1
*/
$vars = array(
'mode',
'ids',
'resync',
'sql_id',
'post_ids',
'topic_ids',
'message_ids',
'physical',
'num_deleted',
);
extract($phpbb_dispatcher->trigger_event('core.delete_attachments_from_database_after', compact($vars)));


if (!$num_deleted)
{


if (!$num_deleted)
{

Line 1146Line 1337
			phpbb_unlink($file_ary['filename'], 'thumbnail', true);
}
}

			phpbb_unlink($file_ary['filename'], 'thumbnail', true);
}
}

 

/**
* Perform additional actions after attachment(s) deletion from the filesystem
*
* @event core.delete_attachments_from_filesystem_after
* @var string mode Variable containing attachments deletion mode, can be: post|message|topic|attach|user
* @var mixed ids Array or comma separated list of ids corresponding to the mode
* @var bool resync Flag indicating if posts/messages/topics should be synchronized
* @var string sql_id The field name to collect/delete data for depending on the mode
* @var array post_ids Array with post ids for deleted attachment(s)
* @var array topic_ids Array with topic ids for deleted attachment(s)
* @var array message_ids Array with private message ids for deleted attachment(s)
* @var array physical Array with deleted attachment(s) physical file(s) data
* @var int num_deleted The number of deleted attachment(s) from the database
* @var int space_removed The size of deleted files(s) from the filesystem
* @var int files_removed The number of deleted file(s) from the filesystem
* @since 3.1.7-RC1
*/
$vars = array(
'mode',
'ids',
'resync',
'sql_id',
'post_ids',
'topic_ids',
'message_ids',
'physical',
'num_deleted',
'space_removed',
'files_removed',
);
extract($phpbb_dispatcher->trigger_event('core.delete_attachments_from_filesystem_after', compact($vars)));


if ($space_removed || $files_removed)
{


if ($space_removed || $files_removed)
{

Line 2356Line 2579
/**
* Prune function
*/

/**
* Prune function
*/

function prune($forum_id, $prune_mode, $prune_date, $prune_flags = 0, $auto_sync = true)

function prune($forum_id, $prune_mode, $prune_date, $prune_flags = 0, $auto_sync = true, $prune_limit = 0)

{
global $db, $phpbb_dispatcher;


{
global $db, $phpbb_dispatcher;


Line 2408Line 2631
	* @var int		prune_flags		The prune flags
* @var bool auto_sync Whether or not to perform auto sync
* @var string sql_and SQL text appended to where clause

	* @var int		prune_flags		The prune flags
* @var bool auto_sync Whether or not to perform auto sync
* @var string sql_and SQL text appended to where clause

 
	* @var int		prune_limit		The prune limit

	* @since 3.1.3-RC1

	* @since 3.1.3-RC1

 
	* @changed 3.1.10-RC1			Added prune_limit

	*/

	*/

	$vars = array('forum_id', 'prune_mode', 'prune_date', 'prune_flags', 'auto_sync', 'sql_and');









	$vars = array(
'forum_id',
'prune_mode',
'prune_date',
'prune_flags',
'auto_sync',
'sql_and',
'prune_limit',
);

	extract($phpbb_dispatcher->trigger_event('core.prune_sql', compact($vars)));

$sql = 'SELECT topic_id

	extract($phpbb_dispatcher->trigger_event('core.prune_sql', compact($vars)));

$sql = 'SELECT topic_id

Line 2418Line 2651
		WHERE ' . $db->sql_in_set('forum_id', $forum_id) . "
AND poll_start = 0
$sql_and";

		WHERE ' . $db->sql_in_set('forum_id', $forum_id) . "
AND poll_start = 0
$sql_and";

	$result = $db->sql_query($sql);

	$result = $db->sql_query_limit($sql, $prune_limit);


$topic_list = array();
while ($row = $db->sql_fetchrow($result))


$topic_list = array();
while ($row = $db->sql_fetchrow($result))

Line 2435Line 2668
				AND poll_start > 0
AND poll_last_vote < $prune_date
$sql_and";

				AND poll_start > 0
AND poll_last_vote < $prune_date
$sql_and";

		$result = $db->sql_query($sql);

		$result = $db->sql_query_limit($sql, $prune_limit);


while ($row = $db->sql_fetchrow($result))
{


while ($row = $db->sql_fetchrow($result))
{

Line 2468Line 2701
		$prune_date = time() - ($prune_days * 86400);
$next_prune = time() + ($prune_freq * 86400);


		$prune_date = time() - ($prune_days * 86400);
$next_prune = time() + ($prune_freq * 86400);


		prune($forum_id, $prune_mode, $prune_date, $prune_flags, true);

		$result = prune($forum_id, $prune_mode, $prune_date, $prune_flags, true, 300);





 
		if ($result['topics'] == 0 && $result['posts'] == 0)
{

		$sql = 'UPDATE ' . FORUMS_TABLE . "
SET prune_next = $next_prune
WHERE forum_id = $forum_id";
$db->sql_query($sql);

		$sql = 'UPDATE ' . FORUMS_TABLE . "
SET prune_next = $next_prune
WHERE forum_id = $forum_id";
$db->sql_query($sql);

 
		}


add_log('admin', 'LOG_AUTO_PRUNE', $row['forum_name']);
}


add_log('admin', 'LOG_AUTO_PRUNE', $row['forum_name']);
}

Line 2926Line 3162
			{
$version = $row['mysql_version'];


			{
$version = $row['mysql_version'];


				if (preg_match('#(3\.23|[45]\.)#', $version))

				if (preg_match('#(3\.23|[45]\.|10\.[0-9]\.[0-9]{1,2}-+Maria)#', $version))

				{

				{

					$db_name = (preg_match('#^(?:3\.23\.(?:[6-9]|[1-9]{2}))|[45]\.#', $version)) ? "`{$db->get_db_name()}`" : $db->get_db_name();

					$db_name = (preg_match('#^(?:3\.23\.(?:[6-9]|[1-9]{2}))|[45]\.|10\.[0-9]\.[0-9]{1,2}-+Maria#', $version)) ? "`{$db->get_db_name()}`" : $db->get_db_name();


$sql = 'SHOW TABLE STATUS
FROM ' . $db_name;


$sql = 'SHOW TABLE STATUS
FROM ' . $db_name;

Line 2937Line 3173
					$database_size = 0;
while ($row = $db->sql_fetchrow($result))
{

					$database_size = 0;
while ($row = $db->sql_fetchrow($result))
{

						if ((isset($row['Type']) && $row['Type'] != 'MRG_MyISAM') || (isset($row['Engine']) && ($row['Engine'] == 'MyISAM' || $row['Engine'] == 'InnoDB')))

						if ((isset($row['Type']) && $row['Type'] != 'MRG_MyISAM') || (isset($row['Engine']) && ($row['Engine'] == 'MyISAM' || $row['Engine'] == 'InnoDB' || $row['Engine'] == 'Aria')))

						{
if ($table_prefix != '')
{

						{
if ($table_prefix != '')
{

Line 3145Line 3381
*/
function add_permission_language()
{

*/
function add_permission_language()
{

	global $user, $phpEx, $phpbb_extension_manager;

	global $config, $user, $phpEx, $phpbb_extension_manager;


// add permission language files from extensions
$finder = $phpbb_extension_manager->get_finder();



// add permission language files from extensions
$finder = $phpbb_extension_manager->get_finder();


	$lang_files = $finder




























	// We grab the language files from the default, English and user's language.
// So we can fall back to the other files like we do when using add_lang()
$default_lang_files = $english_lang_files = $user_lang_files = array();

// Search for board default language if it's not the user language
if ($config['default_lang'] != $user->lang_name)
{
$default_lang_files = $finder
->prefix('permissions_')
->suffix(".$phpEx")
->core_path('language/' . basename($config['default_lang']) . '/')
->extension_directory('/language/' . basename($config['default_lang']))
->find();
}

// Search for english, if its not the default or user language
if ($config['default_lang'] != 'en' && $user->lang_name != 'en')
{
$english_lang_files = $finder
->prefix('permissions_')
->suffix(".$phpEx")
->core_path('language/en/')
->extension_directory('/language/en')
->find();
}

// Find files in the user's language
$user_lang_files = $finder

		->prefix('permissions_')
->suffix(".$phpEx")
->core_path('language/' . $user->lang_name . '/')
->extension_directory('/language/' . $user->lang_name)
->find();

		->prefix('permissions_')
->suffix(".$phpEx")
->core_path('language/' . $user->lang_name . '/')
->extension_directory('/language/' . $user->lang_name)
->find();

 

$lang_files = array_merge($english_lang_files, $default_lang_files, $user_lang_files);


foreach ($lang_files as $lang_file => $ext_name)
{


foreach ($lang_files as $lang_file => $ext_name)
{