Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions phpBB/config/default/container/services_forum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ services:
- '@template'
- '@user'

forum.helper:
class: phpbb\forum\helper
arguments:
- '@config'
- '@dbal.conn'
- '@dispatcher'
- '@user'

forum.controller.index:
class: phpbb\forum\controller\index
arguments:
Expand Down
33 changes: 33 additions & 0 deletions phpBB/config/default/container/services_notification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,36 @@ services:
- '@request'
- '@user'
- '%core.root_path%'

notification.controller.mark_all_read:
class: phpbb\notification\controller\mark_all_read
arguments:
- '@config'
- '@controller.helper'
- '@language'
- '@request'
- '@user'

notification.controller.mark_subforums_read:
class: phpbb\notification\controller\mark_subforums_read
arguments:
- '@auth'
- '@config'
- '@controller.helper'
- '@forum.helper'
- '@language'
- '@request'
- '@user'
- '%core.root_path%'
- '%core.php_ext%'

notification.controller.mark_topics_read:
class: phpbb\notification\controller\mark_topics_read
arguments:
- '@config'
- '@controller.helper'
- '@language'
- '@request'
- '@user'
- '%core.root_path%'
- '%core.php_ext%'
19 changes: 19 additions & 0 deletions phpBB/config/default/routing/notifications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,22 @@ phpbb_notifications_mark_read:
_controller: notification.controller.mark_read:handle
requirements:
id: \d+

phpbb_notifications_mark_all_read:
path: /mark-all-read
defaults:
_controller: notification.controller.mark_all_read:handle

phpbb_notifications_mark_subforums_read:
path: /mark-subforums-read/{id}
defaults:
_controller: notification.controller.mark_subforums_read:handle
requirements:
id: \d+

phpbb_notifications_mark_topics_read:
path: /mark-topics-read/{id}
defaults:
_controller: notification.controller.mark_topics_read:handle
requirements:
id: \d+
4 changes: 2 additions & 2 deletions phpBB/includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,8 @@ function phpbb_timezone_select($user, $default = '', $truncate = false)
* Marks a topic as posted to
*
* @param string $mode (all, topics, topic, post)
* @param int|bool $forum_id Used in all, topics, and topic mode
* @param int|bool $topic_id Used in topic and post mode
* @param array|int|false $forum_id Used in all, topics, and topic mode
* @param int|false $topic_id Used in topic and post mode
* @param int $post_time 0 means current time(), otherwise to set a specific mark time
* @param int $user_id can only be used with $mode == 'post'
*/
Expand Down
170 changes: 18 additions & 152 deletions phpBB/includes/functions_display.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,89 +24,36 @@
*/
function display_forums($root_data = '', $display_moderators = true, $return_moderators = false)
{
global $db, $auth, $user, $template;
global $auth, $user, $template, $request;
global $phpbb_root_path, $phpEx, $config;
global $request, $phpbb_dispatcher, $phpbb_container;
global $phpbb_dispatcher, $phpbb_container;

$forum_rows = $subforums = $forum_ids = $forum_ids_moderator = $forum_moderators = $active_forum_ary = array();
$parent_id = $visible_forums = 0;
$parent_subforum_limit = false;

// Mark forums read?
$mark_read = $request->variable('mark', '');

if ($mark_read == 'all')
if (empty($root_data))
{
$mark_read = '';
$root_data = null;
}

if (!$root_data)
{
if ($mark_read == 'forums')
{
$mark_read = 'all';
}

$root_data = array('forum_id' => 0);
$sql_where = '';
}
else
{
$sql_where = 'left_id > ' . $root_data['left_id'] . ' AND left_id < ' . $root_data['right_id'];
}
/** @var \phpbb\controller\helper */
$controller_helper = $phpbb_container->get('controller.helper');

Comment thread
rubencm marked this conversation as resolved.
// Handle marking everything read
if ($mark_read == 'all')
{
$redirect = build_url(array('mark', 'hash', 'mark_time'));
meta_refresh(3, $redirect);
/** @var \phpbb\forum\helper */
$forum_helper = $phpbb_container->get('forum.helper');

if (check_link_hash($request->variable('hash', ''), 'global'))
{
markread('all', false, false, $request->variable('mark_time', 0));
$forum_rows = $subforums = $forum_ids_moderator = $forum_moderators = $active_forum_ary = array();
$parent_id = $visible_forums = 0;
$parent_subforum_limit = false;

if ($request->is_ajax())
{
// Tell the ajax script what language vars and URL need to be replaced
$data = array(
'NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'],
'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'],
'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums&mark_time=' . time(), false) : '',
'MESSAGE_TITLE' => $user->lang['INFORMATION'],
'MESSAGE_TEXT' => $user->lang['FORUMS_MARKED']
);
$json_response = new \phpbb\json_response();
$json_response->send($data);
}
$rows = $forum_helper->get_forums_rows($root_data);

trigger_error(
$user->lang['FORUMS_MARKED'] . '<br /><br />' .
sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect . '">', '</a>')
);
}
else
{
trigger_error(sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
}
if (!$root_data)
{
$root_data = array('forum_id' => 0);
}
Comment thread
rubencm marked this conversation as resolved.

// Display list of active topics for this category?
$show_active = (isset($root_data['forum_flags']) && ($root_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS)) ? true : false;

$sql_array = array(
'SELECT' => 'f.*',
'FROM' => array(
FORUMS_TABLE => 'f'
),
'LEFT_JOIN' => array(),
);

if ($config['load_db_lastread'] && $user->data['is_registered'])
{
$sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id');
$sql_array['SELECT'] .= ', ft.mark_time';
}
else if ($config['load_anon_lastread'] || $user->data['is_registered'])
if (!($config['load_db_lastread'] && $user->data['is_registered']) && ($config['load_anon_lastread'] || $user->data['is_registered']))
{
$tracking_topics = $request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE);
$tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array();
Expand All @@ -117,46 +64,13 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
}
}

if ($show_active)
{
$sql_array['LEFT_JOIN'][] = array(
'FROM' => array(FORUMS_ACCESS_TABLE => 'fa'),
'ON' => "fa.forum_id = f.forum_id AND fa.session_id = '" . $db->sql_escape($user->session_id) . "'"
);

$sql_array['SELECT'] .= ', fa.user_id';
}

$sql_ary = array(
'SELECT' => $sql_array['SELECT'],
'FROM' => $sql_array['FROM'],
'LEFT_JOIN' => $sql_array['LEFT_JOIN'],

'WHERE' => $sql_where,

'ORDER_BY' => 'f.left_id',
);

/**
* Event to modify the SQL query before the forum data is queried
*
* @event core.display_forums_modify_sql
* @var array sql_ary The SQL array to get the data of the forums
* @since 3.1.0-a1
*/
$vars = array('sql_ary');
extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_sql', compact($vars)));

$sql = $db->sql_build_query('SELECT', $sql_ary);
$result = $db->sql_query($sql);

$forum_tracking_info = $valid_categories = array();
$branch_root_id = $root_data['forum_id'];

/* @var $phpbb_content_visibility \phpbb\content_visibility */
$phpbb_content_visibility = $phpbb_container->get('content.visibility');

while ($row = $db->sql_fetchrow($result))
foreach ($rows as $row)
{
/**
* Event to modify the data set of a forum
Expand All @@ -173,17 +87,6 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod

$forum_id = $row['forum_id'];

// Mark forums read?
if ($mark_read == 'forums')
{
if ($auth->acl_get('f_list', $forum_id))
{
$forum_ids[] = $forum_id;
}

continue;
}

// Category with no members
if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id']))
{
Expand Down Expand Up @@ -338,43 +241,6 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
$vars = array('forum_rows', 'subforums', 'branch_root_id', 'parent_id', 'row');
extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_forum_rows', compact($vars)));
}
$db->sql_freeresult($result);

// Handle marking posts
if ($mark_read == 'forums')
{
$redirect = build_url(array('mark', 'hash', 'mark_time'));
$token = $request->variable('hash', '');
if (check_link_hash($token, 'global'))
{
markread('topics', $forum_ids, false, $request->variable('mark_time', 0));
$message = sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect . '">', '</a>');
meta_refresh(3, $redirect);

if ($request->is_ajax())
{
// Tell the ajax script what language vars and URL need to be replaced
$data = array(
'NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'],
'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'],
'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . '&f=' . $root_data['forum_id'] . '&mark=forums&mark_time=' . time(), false) : '',
'MESSAGE_TITLE' => $user->lang['INFORMATION'],
'MESSAGE_TEXT' => $user->lang['FORUMS_MARKED']
);
$json_response = new \phpbb\json_response();
$json_response->send($data);
}

trigger_error($user->lang['FORUMS_MARKED'] . '<br /><br />' . $message);
}
else
{
$message = sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>');
meta_refresh(3, $redirect);
trigger_error($message);
}

}

// Grab moderators ... if necessary
if ($display_moderators)
Expand Down Expand Up @@ -691,7 +557,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
}

$template->assign_vars(array(
'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . '&amp;f=' . $root_data['forum_id'] . '&amp;mark=forums&amp;mark_time=' . time()) : '',
'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? $controller_helper->route('phpbb_notifications_mark_subforums_read', ['id' => $root_data['forum_id'], 'hash' => generate_link_hash('global'), 'mark_time' => time()]) : '',
'S_HAS_SUBFORUM' => ($visible_forums) ? true : false,
'L_SUBFORUM' => ($visible_forums == 1) ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS'],
'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
Expand Down
4 changes: 2 additions & 2 deletions phpBB/phpbb/forum/controller/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function handle(): Response

$this->language->add_lang('viewforum');

display_forums('', $this->config['load_moderators']);
display_forums(null, $this->config['load_moderators']);

// This is shown only if display_online_list is true
$this->group_helper->display_legend();
Expand All @@ -126,7 +126,7 @@ public function handle(): Response
'S_INDEX' => true,

'U_CANONICAL' => generate_board_url() . '/',
'U_MARK_FORUMS' => ($this->user->data['is_registered'] || $this->config['load_anon_lastread']) ? $this->controller_helper->route('phpbb_index_controller', ['hash' => generate_link_hash('global'), 'mark' => 'forums', 'mark_time' => time()]) : '',
'U_MARK_FORUMS' => ($this->user->data['is_registered'] || $this->config['load_anon_lastread']) ? $this->controller_helper->route('phpbb_notifications_mark_all_read', ['hash' => generate_link_hash('global'), 'mark_time' => time()]) : '',
'U_MCP' => ($this->auth->acl_get('m_') || $this->auth->acl_getf_global('m_')) ? append_sid("{$this->phpbb_root_path}mcp.$this->phpEx", 'i=main&amp;mode=front') : '')
);

Expand Down
Loading
Loading