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 615Line 641
	 *
* @event core.move_posts_before
* @var array post_ids Array of post ids to move

	 *
* @event core.move_posts_before
* @var array post_ids Array of post ids to move

	 * @var	string	topic_id	The topic id the posts are moved to
* @var bool auto_sync Whether or not to perform auto sync

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

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

Line 647Line 673
	 *
* @event core.move_posts_after
* @var array post_ids Array of the moved post ids

	 *
* @event core.move_posts_after
* @var array post_ids Array of the moved post ids

	 * @var	string	topic_id	The topic id the posts are moved to
* @var bool auto_sync Whether or not to perform auto sync

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

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

Line 672Line 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 2531Line 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 2583Line 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 2593Line 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 2610Line 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 2643Line 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']);
}