From 3fbac076ceb4773aa3c985d24eeaf306aa0b6a42 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 17 Mar 2012 23:52:01 +0100 Subject: [ticket/10714] Use new phpbb_log class in add_log function PHPBB3-10714 --- phpBB/includes/functions.php | 89 ++++++++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 40 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index ecec1e5e4a..9a1485f37a 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3357,65 +3357,74 @@ function parse_cfg_file($filename, $lines = false) */ function add_log() { - global $db, $user; + // This is all just an ugly hack to add "Dependency Injection" to a function + // the only real code is the function call which maps this function to a method. + static $static_log = null; + + $args = func_get_args(); + $log = (isset($args[0])) ? $args[0] : false; - // In phpBB 3.1.x i want to have logging in a class to be able to control it - // For now, we need a quite hakish approach to circumvent logging for some actions - // @todo implement cleanly - if (!empty($GLOBALS['skip_add_log'])) + if ($log instanceof phpbb_log_interface) + { + $static_log = $log; + return true; + } + else if ($log === false) { return false; } - $args = func_get_args(); + $tmp_log = $static_log; - $mode = array_shift($args); - $reportee_id = ($mode == 'user') ? intval(array_shift($args)) : ''; - $forum_id = ($mode == 'mod') ? intval(array_shift($args)) : ''; - $topic_id = ($mode == 'mod') ? intval(array_shift($args)) : ''; - $action = array_shift($args); - $data = (!sizeof($args)) ? '' : serialize($args); - - $sql_ary = array( - 'user_id' => (empty($user->data)) ? ANONYMOUS : $user->data['user_id'], - 'log_ip' => $user->ip, - 'log_time' => time(), - 'log_operation' => $action, - 'log_data' => $data, - ); + // no log class set, create a temporary one ourselves to keep backwards compatability + if ($tmp_log === null) + { + $tmp_log = new phpbb_log(LOG_TABLE); + } + + $mode = array_shift($args); + // This looks kind of dirty, but add_log has some additional data before the log_operation + $additional_data = array(); switch ($mode) { case 'admin': - $sql_ary['log_type'] = LOG_ADMIN; + case 'critical': break; - case 'mod': - $sql_ary += array( - 'log_type' => LOG_MOD, - 'forum_id' => $forum_id, - 'topic_id' => $topic_id - ); + // forum_id + $additional_data[] = array_shift($args); + // topic_id + $additional_data[] = array_shift($args); break; - case 'user': - $sql_ary += array( - 'log_type' => LOG_USERS, - 'reportee_id' => $reportee_id - ); + // reportee_id + $additional_data[] = array_shift($args); break; - - case 'critical': - $sql_ary['log_type'] = LOG_CRITICAL; - break; - default: - return false; + /** + * @todo: enable when events are merged + * + global $phpbb_dispatcher; + + if ($phpbb_dispatcher != null) + { + $vars = array('mode', 'args', 'additional_data'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.function_add_log', $event); + extract($event->get_data_filtered($vars)); + } + */ } + $log_operation = array_shift($args); + $additional_data = array_merge($additional_data, $args); + + global $user; - $db->sql_query('INSERT INTO ' . LOG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); + $user_id = (empty($user->data)) ? ANONYMOUS : $user->data['user_id']; + $user_ip = (empty($user->ip)) ? '' : $user->ip; - return $db->sql_nextid(); + return $tmp_log->add($mode, $user_id, $user_ip, $log_operation, time(), $additional_data); } /** -- cgit v1.2.1 From cff15ec307d76b004b6a825fb51b5dd3c8da58f2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 18 Mar 2012 13:47:24 +0100 Subject: [ticket/10714] Use keys for the log data instead of requiring a special order PHPBB3-10714 --- phpBB/includes/functions.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 9a1485f37a..3e3d796ba2 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3392,14 +3392,11 @@ function add_log() case 'critical': break; case 'mod': - // forum_id - $additional_data[] = array_shift($args); - // topic_id - $additional_data[] = array_shift($args); + $additional_data['forum_id'] = array_shift($args); + $additional_data['topic_id'] = array_shift($args); break; case 'user': - // reportee_id - $additional_data[] = array_shift($args); + $additional_data['reportee_id'] = array_shift($args); break; default: /** -- cgit v1.2.1 From 2c7f498c1b43cfb96f868e9b0f9b80ad5ec626a8 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 24 Mar 2012 17:13:17 +0100 Subject: [ticket/10714] Change $phpbb_dispatcher calls to the new layout PHPBB3-10714 --- phpBB/includes/functions.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 3e3d796ba2..c5a1543277 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3407,9 +3407,7 @@ function add_log() if ($phpbb_dispatcher != null) { $vars = array('mode', 'args', 'additional_data'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.function_add_log', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.function_add_log', $vars, $vars)); } */ } -- cgit v1.2.1 From 151346c6e053e925b5cfcf2845eca532509bbc80 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 21 Aug 2012 13:25:26 +0200 Subject: [ticket/10714] Remove event core.function_add_log, add_log should be used instead PHPBB3-10714 --- phpBB/includes/functions.php | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index c5a1543277..b5d0c4d62f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3398,18 +3398,6 @@ function add_log() case 'user': $additional_data['reportee_id'] = array_shift($args); break; - default: - /** - * @todo: enable when events are merged - * - global $phpbb_dispatcher; - - if ($phpbb_dispatcher != null) - { - $vars = array('mode', 'args', 'additional_data'); - extract($phpbb_dispatcher->trigger_event('core.function_add_log', $vars, $vars)); - } - */ } $log_operation = array_shift($args); $additional_data = array_merge($additional_data, $args); -- cgit v1.2.1 From d289bc13acc0ab0329cac25742ae22560a80c607 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 21 Aug 2012 16:49:08 +0200 Subject: [ticket/10714] Remove dependency injection and use global instead This avoids loading functions_admin.php globally and was suggested by naderman PHPBB3-10714 --- phpBB/includes/functions.php | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index b5d0c4d62f..e202273204 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3357,29 +3357,20 @@ function parse_cfg_file($filename, $lines = false) */ function add_log() { - // This is all just an ugly hack to add "Dependency Injection" to a function - // the only real code is the function call which maps this function to a method. - static $static_log = null; + global $phpbb_log; $args = func_get_args(); $log = (isset($args[0])) ? $args[0] : false; - if ($log instanceof phpbb_log_interface) - { - $static_log = $log; - return true; - } - else if ($log === false) + if ($log === false) { return false; } - $tmp_log = $static_log; - // no log class set, create a temporary one ourselves to keep backwards compatability - if ($tmp_log === null) + if ($phpbb_log === null) { - $tmp_log = new phpbb_log(LOG_TABLE); + $phpbb_log = new phpbb_log(LOG_TABLE); } $mode = array_shift($args); @@ -3407,7 +3398,7 @@ function add_log() $user_id = (empty($user->data)) ? ANONYMOUS : $user->data['user_id']; $user_ip = (empty($user->ip)) ? '' : $user->ip; - return $tmp_log->add($mode, $user_id, $user_ip, $log_operation, time(), $additional_data); + return $phpbb_log->add($mode, $user_id, $user_ip, $log_operation, time(), $additional_data); } /** -- cgit v1.2.1 From e45fb0025ec8c27147caee7e3c14902f2e3f02c5 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 8 Sep 2012 12:05:55 -0500 Subject: [ticket/11103] Output the notifications to the template For now, just dumping the notifications in the header. PHPBB3-11103 --- phpBB/includes/functions.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 834f57a38b..7632ea1fcb 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4778,7 +4778,7 @@ function phpbb_http_login($param) function page_header($page_title = '', $display_online_list = true, $item_id = 0, $item = 'forum') { global $db, $config, $template, $SID, $_SID, $_EXTRA_URL, $user, $auth, $phpEx, $phpbb_root_path; - global $phpbb_dispatcher; + global $phpbb_dispatcher, $phpbb_container; if (defined('HEADER_INC')) { @@ -5092,6 +5092,13 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'A_COOKIE_SETTINGS' => addslashes('; path=' . $config['cookie_path'] . ((!$config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1') ? '' : '; domain=' . $config['cookie_domain']) . ((!$config['cookie_secure']) ? '' : '; secure')), )); + // Output the notifications + $phpbb_notifications = $phpbb_container->get('notifications'); + foreach ($phpbb_notifications->load_notifications() as $notification) + { + $notification->display(); + } + // application/xhtml+xml not used because of IE header('Content-type: text/html; charset=UTF-8'); -- cgit v1.2.1 From 5502f3c4aa30ce72131f2a55bcfa3db7a4059427 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sun, 9 Sep 2012 17:20:39 -0500 Subject: [ticket/11103] Restyle the notification list Very rough (lots of inline CSS, very ugly) PHPBB3-11103 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 7632ea1fcb..e5c7839894 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5096,7 +5096,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 $phpbb_notifications = $phpbb_container->get('notifications'); foreach ($phpbb_notifications->load_notifications() as $notification) { - $notification->display(); + $template->assign_block_vars('notifications', $notification->prepare_for_display()); } // application/xhtml+xml not used because of IE -- cgit v1.2.1 From fb0ed78c8fffe95d40e47c8dd27d44973eba88ae Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 14 Sep 2012 15:59:13 -0500 Subject: [ticket/11103] Store the item's parent id for marking things read Mark topics/posts read from the markread() function. Identify unread items by a grey background in the header (for now) PHPBB3-11103 --- phpBB/includes/functions.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index e5c7839894..3d3dd1f5bc 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1285,15 +1285,20 @@ function phpbb_timezone_select($user, $default = '', $truncate = false) function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $user_id = 0) { global $db, $user, $config; - global $request; + global $request, $phpbb_container; if ($mode == 'all') { if ($forum_id === false || !sizeof($forum_id)) { + // Mark all forums read (index page) + + // Mark all topic notifications read for this user + $notifications = $phpbb_container->get('notifications'); + $notifications->mark_notifications_read('topic', false, $user->data['user_id'], $post_time); + if ($config['load_db_lastread'] && $user->data['is_registered']) { - // Mark all forums read (index page) $db->sql_query('DELETE FROM ' . TOPICS_TRACK_TABLE . " WHERE user_id = {$user->data['user_id']}"); $db->sql_query('DELETE FROM ' . FORUMS_TRACK_TABLE . " WHERE user_id = {$user->data['user_id']}"); $db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_lastmark = ' . time() . " WHERE user_id = {$user->data['user_id']}"); @@ -1330,6 +1335,10 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ $forum_id = array($forum_id); } + // Mark topic notifications read for this user in this forum + $notifications = $phpbb_container->get('notifications'); + $notifications->mark_notifications_read_by_parent('topic', $forum_id, $user->data['user_id'], $post_time); + // Add 0 to forums array to mark global announcements correctly // $forum_id[] = 0; @@ -1424,6 +1433,11 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ return; } + // Mark post notifications read for this user in this topic + $notifications = $phpbb_container->get('notifications'); + $notifications->mark_notifications_read_by_parent('post', $topic_id, $user->data['user_id'], $post_time); + $notifications->mark_notifications_read_by_parent('quote', $topic_id, $user->data['user_id'], $post_time); + if ($config['load_db_lastread'] && $user->data['is_registered']) { $sql = 'UPDATE ' . TOPICS_TRACK_TABLE . ' -- cgit v1.2.1 From f083c6d7765b63ad0179bc82a3d9f0abbf08637c Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 14 Sep 2012 16:15:15 -0500 Subject: [ticket/11103] Mark all post/quote notifications read when marking topics Mark forum read marks all topics read, so do so properly for notifications PHPBB3-11103 --- phpBB/includes/functions.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 3d3dd1f5bc..b996fef292 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1339,6 +1339,21 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ $notifications = $phpbb_container->get('notifications'); $notifications->mark_notifications_read_by_parent('topic', $forum_id, $user->data['user_id'], $post_time); + // Mark all post/quote notifications read for this user in this forum + $topic_ids = array(); + $sql = 'SELECT topic_id + FROM ' . TOPICS_TABLE . ' + WHERE ' . $db->sql_in_set('forum_id', $forum_id); + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) + { + $topic_ids[] = $row['topic_id']; + } + $db->sql_freeresult($result); + + $notifications->mark_notifications_read_by_parent('post', $topic_ids, $user->data['user_id'], $post_time); + $notifications->mark_notifications_read_by_parent('quote', $topic_ids, $user->data['user_id'], $post_time); + // Add 0 to forums array to mark global announcements correctly // $forum_id[] = 0; -- cgit v1.2.1 From ed1ec8e720a7ec3c1270cd631cc37e531f315f26 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 14 Sep 2012 16:54:20 -0500 Subject: [ticket/11103] Add/Update/Mark Read functions accept an array for the type This saves a lot of code in some areas (where the same data is sent, just for different types) Notifications for bookmarks PHPBB3-11103 --- phpBB/includes/functions.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index b996fef292..aec7759f19 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1351,8 +1351,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ } $db->sql_freeresult($result); - $notifications->mark_notifications_read_by_parent('post', $topic_ids, $user->data['user_id'], $post_time); - $notifications->mark_notifications_read_by_parent('quote', $topic_ids, $user->data['user_id'], $post_time); + $notifications->mark_notifications_read_by_parent(array('quote', 'bookmark', 'post'), $topic_ids, $user->data['user_id'], $post_time); // Add 0 to forums array to mark global announcements correctly // $forum_id[] = 0; @@ -1450,8 +1449,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ // Mark post notifications read for this user in this topic $notifications = $phpbb_container->get('notifications'); - $notifications->mark_notifications_read_by_parent('post', $topic_id, $user->data['user_id'], $post_time); - $notifications->mark_notifications_read_by_parent('quote', $topic_id, $user->data['user_id'], $post_time); + $notifications->mark_notifications_read_by_parent(array('quote', 'bookmark', 'post'), $topic_id, $user->data['user_id'], $post_time); if ($config['load_db_lastread'] && $user->data['is_registered']) { -- cgit v1.2.1 From 8e977544fb6763412e45f84791de8c3eccf321c9 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 14 Sep 2012 17:01:08 -0500 Subject: [ticket/11103] Normalization of $phpbb_notifications variable name Use $phpbb_notifications instead of $notifications everywhere for consistency and conflict prevention. PHPBB3-11103 --- phpBB/includes/functions.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index aec7759f19..b7243227bd 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1294,8 +1294,8 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ // Mark all forums read (index page) // Mark all topic notifications read for this user - $notifications = $phpbb_container->get('notifications'); - $notifications->mark_notifications_read('topic', false, $user->data['user_id'], $post_time); + $phpbb_notifications = $phpbb_container->get('notifications'); + $phpbb_notifications->mark_notifications_read('topic', false, $user->data['user_id'], $post_time); if ($config['load_db_lastread'] && $user->data['is_registered']) { @@ -1336,8 +1336,8 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ } // Mark topic notifications read for this user in this forum - $notifications = $phpbb_container->get('notifications'); - $notifications->mark_notifications_read_by_parent('topic', $forum_id, $user->data['user_id'], $post_time); + $phpbb_notifications = $phpbb_container->get('notifications'); + $phpbb_notifications->mark_notifications_read_by_parent('topic', $forum_id, $user->data['user_id'], $post_time); // Mark all post/quote notifications read for this user in this forum $topic_ids = array(); @@ -1351,7 +1351,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ } $db->sql_freeresult($result); - $notifications->mark_notifications_read_by_parent(array('quote', 'bookmark', 'post'), $topic_ids, $user->data['user_id'], $post_time); + $phpbb_notifications->mark_notifications_read_by_parent(array('quote', 'bookmark', 'post'), $topic_ids, $user->data['user_id'], $post_time); // Add 0 to forums array to mark global announcements correctly // $forum_id[] = 0; @@ -1448,8 +1448,8 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ } // Mark post notifications read for this user in this topic - $notifications = $phpbb_container->get('notifications'); - $notifications->mark_notifications_read_by_parent(array('quote', 'bookmark', 'post'), $topic_id, $user->data['user_id'], $post_time); + $phpbb_notifications = $phpbb_container->get('notifications'); + $phpbb_notifications->mark_notifications_read_by_parent(array('quote', 'bookmark', 'post'), $topic_id, $user->data['user_id'], $post_time); if ($config['load_db_lastread'] && $user->data['is_registered']) { -- cgit v1.2.1 From 7589a3093d95048f5a8cfdc6259501f43fd3fe10 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 14 Sep 2012 18:30:12 -0500 Subject: [ticket/11103] Display all unread notifications by default Add unread count to the page title PHPBB3-11103 --- phpBB/includes/functions.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index b7243227bd..e26db56442 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4994,6 +4994,14 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 $timezone_name = $user->lang['timezones'][$timezone_name]; } + // Output the notifications + $phpbb_notifications = $phpbb_container->get('notifications'); + $notifications = $phpbb_notifications->load_notifications(); + foreach ($notifications['notifications'] as $notification) + { + $template->assign_block_vars('notifications', $notification->prepare_for_display()); + } + // The following assigns all _common_ variables that may be used at any point in a template. $template->assign_vars(array( 'SITENAME' => $config['sitename'], @@ -5008,6 +5016,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'RECORD_USERS' => $l_online_record, 'PRIVATE_MESSAGE_INFO' => $l_privmsgs_text, 'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread, + 'NUM_UNREAD_NOTIFICATIONS' => $notifications['unread_count'], 'S_USER_NEW_PRIVMSG' => $user->data['user_new_privmsg'], 'S_USER_UNREAD_PRIVMSG' => $user->data['user_unread_privmsg'], @@ -5119,13 +5128,6 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'A_COOKIE_SETTINGS' => addslashes('; path=' . $config['cookie_path'] . ((!$config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1') ? '' : '; domain=' . $config['cookie_domain']) . ((!$config['cookie_secure']) ? '' : '; secure')), )); - // Output the notifications - $phpbb_notifications = $phpbb_container->get('notifications'); - foreach ($phpbb_notifications->load_notifications() as $notification) - { - $template->assign_block_vars('notifications', $notification->prepare_for_display()); - } - // application/xhtml+xml not used because of IE header('Content-type: text/html; charset=UTF-8'); -- cgit v1.2.1 From 05b573ebf76c737f89deaefd22ce963aa910e5d1 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 15 Sep 2012 13:51:02 -0500 Subject: [ticket/11103] Topic and post dis/approval notifications Remove the formatted title function, plaintext is not needed since email templates are used Fix a number of bugs. PHPBB3-11103 --- phpBB/includes/functions.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index cb8dddd5f8..e9d673455c 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1295,7 +1295,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ // Mark all topic notifications read for this user $phpbb_notifications = $phpbb_container->get('notifications'); - $phpbb_notifications->mark_notifications_read('topic', false, $user->data['user_id'], $post_time); + $phpbb_notifications->mark_notifications_read(array('topic', 'quote', 'bookmark', 'post', 'approve_topic', 'approve_post'), false, $user->data['user_id'], $post_time); if ($config['load_db_lastread'] && $user->data['is_registered']) { @@ -1337,7 +1337,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ // Mark topic notifications read for this user in this forum $phpbb_notifications = $phpbb_container->get('notifications'); - $phpbb_notifications->mark_notifications_read_by_parent('topic', $forum_id, $user->data['user_id'], $post_time); + $phpbb_notifications->mark_notifications_read_by_parent(array('topic', 'approve_topic'), $forum_id, $user->data['user_id'], $post_time); // Mark all post/quote notifications read for this user in this forum $topic_ids = array(); @@ -1351,7 +1351,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ } $db->sql_freeresult($result); - $phpbb_notifications->mark_notifications_read_by_parent(array('quote', 'bookmark', 'post'), $topic_ids, $user->data['user_id'], $post_time); + $phpbb_notifications->mark_notifications_read_by_parent(array('quote', 'bookmark', 'post', 'approve_post'), $topic_ids, $user->data['user_id'], $post_time); // Add 0 to forums array to mark global announcements correctly // $forum_id[] = 0; @@ -1449,7 +1449,8 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ // Mark post notifications read for this user in this topic $phpbb_notifications = $phpbb_container->get('notifications'); - $phpbb_notifications->mark_notifications_read_by_parent(array('quote', 'bookmark', 'post'), $topic_id, $user->data['user_id'], $post_time); + $phpbb_notifications->mark_notifications_read(array('topic', 'approve_topic'), $topic_id, $user->data['user_id'], $post_time); + $phpbb_notifications->mark_notifications_read_by_parent(array('quote', 'bookmark', 'post', 'approve_post'), $topic_id, $user->data['user_id'], $post_time); if ($config['load_db_lastread'] && $user->data['is_registered']) { -- cgit v1.2.1 From 98731b127748af4673fdee92db2e139e84fd4d4b Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 20 Sep 2012 10:36:11 -0500 Subject: [ticket/11103] Prettify the output for prosilver. Create a way to mark items read from the output list. PHPBB3-11103 --- phpBB/includes/functions.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index e9d673455c..92cea20d10 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4997,7 +4997,10 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 // Output the notifications $phpbb_notifications = $phpbb_container->get('notifications'); - $notifications = $phpbb_notifications->load_notifications(); + $notifications = $phpbb_notifications->load_notifications(array( + 'all_unread' => true, + 'limit' => 5, + )); foreach ($notifications['notifications'] as $notification) { $template->assign_block_vars('notifications', $notification->prepare_for_display()); -- cgit v1.2.1 From 48ccc9eb93c8413f05f6a50d40e597f560c671d8 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 27 Sep 2012 18:25:37 -0500 Subject: [ticket/11103] UCP Notification Options can now be set PHPBB3-11103 --- phpBB/includes/functions.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 92cea20d10..92d72b6636 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5021,6 +5021,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'PRIVATE_MESSAGE_INFO' => $l_privmsgs_text, 'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread, 'NUM_UNREAD_NOTIFICATIONS' => $notifications['unread_count'], + 'NOTIFICATIONS_CNT' => $user->lang('NOTIFICATIONS_CNT', $notifications['unread_count']), 'S_USER_NEW_PRIVMSG' => $user->data['user_new_privmsg'], 'S_USER_UNREAD_PRIVMSG' => $user->data['user_unread_privmsg'], -- cgit v1.2.1 From 07fb66ac1090dfe92431ed749b520115595f7927 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 4 Oct 2012 14:31:00 -0500 Subject: [ticket/11103] Do not abbreviate template output PHPBB3-11103 --- phpBB/includes/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 162b0046b5..d005ccaaab 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5020,8 +5020,8 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'RECORD_USERS' => $l_online_record, 'PRIVATE_MESSAGE_INFO' => $l_privmsgs_text, 'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread, - 'NUM_UNREAD_NOTIFICATIONS' => $notifications['unread_count'], - 'NOTIFICATIONS_CNT' => $user->lang('NOTIFICATIONS_CNT', $notifications['unread_count']), + 'UNREAD_NOTIFICATIONS_COUNT' => $notifications['unread_count'], + 'NOTIFICATIONS_COUNT' => $user->lang('NOTIFICATIONS_COUNT', $notifications['unread_count']), 'S_USER_NEW_PRIVMSG' => $user->data['user_new_privmsg'], 'S_USER_UNREAD_PRIVMSG' => $user->data['user_unread_privmsg'], -- cgit v1.2.1 From b9bc65eed88bbd2dff12102909903cbf4dc9b368 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 4 Oct 2012 14:47:13 -0500 Subject: [ticket/11103] Make $phpbb_notifications a global and use it everywhere Do not use phpbb_container everywhere (makes testing difficult) PHPBB3-11103 --- phpBB/includes/functions.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index d005ccaaab..9513c6919f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1285,7 +1285,7 @@ function phpbb_timezone_select($user, $default = '', $truncate = false) function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $user_id = 0) { global $db, $user, $config; - global $request, $phpbb_container; + global $request, $phpbb_notifications; if ($mode == 'all') { @@ -1294,7 +1294,6 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ // Mark all forums read (index page) // Mark all topic notifications read for this user - $phpbb_notifications = $phpbb_container->get('notifications'); $phpbb_notifications->mark_notifications_read(array('topic', 'quote', 'bookmark', 'post', 'approve_topic', 'approve_post'), false, $user->data['user_id'], $post_time); if ($config['load_db_lastread'] && $user->data['is_registered']) @@ -1336,7 +1335,6 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ } // Mark topic notifications read for this user in this forum - $phpbb_notifications = $phpbb_container->get('notifications'); $phpbb_notifications->mark_notifications_read_by_parent(array('topic', 'approve_topic'), $forum_id, $user->data['user_id'], $post_time); // Mark all post/quote notifications read for this user in this forum @@ -1448,7 +1446,6 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ } // Mark post notifications read for this user in this topic - $phpbb_notifications = $phpbb_container->get('notifications'); $phpbb_notifications->mark_notifications_read(array('topic', 'approve_topic'), $topic_id, $user->data['user_id'], $post_time); $phpbb_notifications->mark_notifications_read_by_parent(array('quote', 'bookmark', 'post', 'approve_post'), $topic_id, $user->data['user_id'], $post_time); @@ -4806,7 +4803,7 @@ function phpbb_http_login($param) function page_header($page_title = '', $display_online_list = true, $item_id = 0, $item = 'forum') { global $db, $config, $template, $SID, $_SID, $_EXTRA_URL, $user, $auth, $phpEx, $phpbb_root_path; - global $phpbb_dispatcher, $phpbb_container; + global $phpbb_dispatcher, $phpbb_notifications; if (defined('HEADER_INC')) { @@ -4996,7 +4993,6 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 } // Output the notifications - $phpbb_notifications = $phpbb_container->get('notifications'); $notifications = $phpbb_notifications->load_notifications(array( 'all_unread' => true, 'limit' => 5, -- cgit v1.2.1 From 0bab8ff777bcb82361b75441c085ee2e510db5cc Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 5 Oct 2012 13:43:03 -0500 Subject: [ticket/11103] ACP option to enable/disable notifications output in header PHPBB3-11103 --- phpBB/includes/functions.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 9513c6919f..795bfb77bf 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4993,13 +4993,17 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 } // Output the notifications - $notifications = $phpbb_notifications->load_notifications(array( - 'all_unread' => true, - 'limit' => 5, - )); - foreach ($notifications['notifications'] as $notification) + if ($config['load_notifications']) { - $template->assign_block_vars('notifications', $notification->prepare_for_display()); + $notifications = $phpbb_notifications->load_notifications(array( + 'all_unread' => true, + 'limit' => 5, + )); + + foreach ($notifications['notifications'] as $notification) + { + $template->assign_block_vars('notifications', $notification->prepare_for_display()); + } } // The following assigns all _common_ variables that may be used at any point in a template. @@ -5016,8 +5020,9 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'RECORD_USERS' => $l_online_record, 'PRIVATE_MESSAGE_INFO' => $l_privmsgs_text, 'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread, - 'UNREAD_NOTIFICATIONS_COUNT' => $notifications['unread_count'], - 'NOTIFICATIONS_COUNT' => $user->lang('NOTIFICATIONS_COUNT', $notifications['unread_count']), + 'UNREAD_NOTIFICATIONS_COUNT' => ($config['load_notifications']) ? $notifications['unread_count'] : '', + 'NOTIFICATIONS_COUNT' => ($config['load_notifications']) ? $user->lang('NOTIFICATIONS_COUNT', $notifications['unread_count']) : '', + 'S_NOTIFICATIONS_DISPLAY' => $config['load_notifications'], 'S_USER_NEW_PRIVMSG' => $user->data['user_new_privmsg'], 'S_USER_UNREAD_PRIVMSG' => $user->data['user_unread_privmsg'], -- cgit v1.2.1 From 61a1467c90e865f43c359bb8678d27b5e571f21f Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Tue, 16 Oct 2012 16:47:18 -0500 Subject: [ticket/11103] U_VIEW_ALL_NOTIFICATIONS Link PHPBB3-11103 --- phpBB/includes/functions.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 2645e55446..790724d3c5 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5020,8 +5020,10 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'RECORD_USERS' => $l_online_record, 'PRIVATE_MESSAGE_INFO' => $l_privmsgs_text, 'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread, + 'UNREAD_NOTIFICATIONS_COUNT' => ($config['load_notifications']) ? $notifications['unread_count'] : '', 'NOTIFICATIONS_COUNT' => ($config['load_notifications']) ? $user->lang('NOTIFICATIONS_COUNT', $notifications['unread_count']) : '', + 'U_VIEW_ALL_NOTIFICATIONS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=ucp_notifications'), 'S_NOTIFICATIONS_DISPLAY' => $config['load_notifications'], 'S_USER_NEW_PRIVMSG' => $user->data['user_new_privmsg'], -- cgit v1.2.1 From ae670cc87df197e44b768667b853e1dae3009b4d Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 18 Oct 2012 18:32:13 -0500 Subject: [ticket/11103] Remove unnecessary comments Comments that are not needed because the actions are completely self-explanatory PHPBB3-11103 --- phpBB/includes/functions.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 0af8e824c8..2827dae1a8 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1386,7 +1386,6 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ $forum_id = array($forum_id); } - // Mark topic notifications read for this user in this forum $phpbb_notifications->mark_notifications_read_by_parent(array('topic', 'approve_topic'), $forum_id, $user->data['user_id'], $post_time); // Mark all post/quote notifications read for this user in this forum -- cgit v1.2.1 From 94d682f77431add84867bb0b196ad0719b293606 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 20 Oct 2012 20:54:18 -0500 Subject: [ticket/11103] Use the full class name as the item_type/method This is going to require you recreate the db tables. PHPBB3-11103 --- phpBB/includes/functions.php | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 2827dae1a8..3488a3003b 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1330,7 +1330,14 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ // Mark all forums read (index page) // Mark all topic notifications read for this user - $phpbb_notifications->mark_notifications_read(array('topic', 'quote', 'bookmark', 'post', 'approve_topic', 'approve_post'), false, $user->data['user_id'], $post_time); + $phpbb_notifications->mark_notifications_read(array( + 'phpbb_notification_type_topic', + 'phpbb_notification_type_quote', + 'phpbb_notification_type_bookmark', + 'phpbb_notification_type_post', + 'phpbb_notification_type_approve_topic', + 'phpbb_notification_type_approve_post', + ), false, $user->data['user_id'], $post_time); if ($config['load_db_lastread'] && $user->data['is_registered']) { @@ -1386,7 +1393,10 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ $forum_id = array($forum_id); } - $phpbb_notifications->mark_notifications_read_by_parent(array('topic', 'approve_topic'), $forum_id, $user->data['user_id'], $post_time); + $phpbb_notifications->mark_notifications_read_by_parent(array( + 'phpbb_notification_type_topic', + 'phpbb_notification_type_approve_topic', + ), $forum_id, $user->data['user_id'], $post_time); // Mark all post/quote notifications read for this user in this forum $topic_ids = array(); @@ -1400,7 +1410,12 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ } $db->sql_freeresult($result); - $phpbb_notifications->mark_notifications_read_by_parent(array('quote', 'bookmark', 'post', 'approve_post'), $topic_ids, $user->data['user_id'], $post_time); + $phpbb_notifications->mark_notifications_read_by_parent(array( + 'phpbb_notification_type_quote', + 'phpbb_notification_type_bookmark', + 'phpbb_notification_type_post', + 'phpbb_notification_type_approve_post', + ), $topic_ids, $user->data['user_id'], $post_time); // Add 0 to forums array to mark global announcements correctly // $forum_id[] = 0; @@ -1500,8 +1515,16 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ } // Mark post notifications read for this user in this topic - $phpbb_notifications->mark_notifications_read(array('topic', 'approve_topic'), $topic_id, $user->data['user_id'], $post_time); - $phpbb_notifications->mark_notifications_read_by_parent(array('quote', 'bookmark', 'post', 'approve_post'), $topic_id, $user->data['user_id'], $post_time); + $phpbb_notifications->mark_notifications_read(array( + 'phpbb_notification_type_topic', + 'phpbb_notification_type_approve_topic', + ), $topic_id, $user->data['user_id'], $post_time); + $phpbb_notifications->mark_notifications_read_by_parent(array( + 'phpbb_notification_type_quote', + 'phpbb_notification_type_bookmark', + 'phpbb_notification_type_post', + 'phpbb_notification_type_approve_post', + ), $topic_id, $user->data['user_id'], $post_time); if ($config['load_db_lastread'] && $user->data['is_registered']) { -- cgit v1.2.1 From 35089bc0136e019724ee4b6c301fb94da52173cf Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 11 Nov 2012 12:18:04 +0100 Subject: [ticket/10714] Fix some comments PHPBB3-10714 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index e202273204..93dfb4cd7f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3367,7 +3367,7 @@ function add_log() return false; } - // no log class set, create a temporary one ourselves to keep backwards compatability + // no log class set, create a temporary one ourselves to keep backwards compatibility if ($phpbb_log === null) { $phpbb_log = new phpbb_log(LOG_TABLE); -- cgit v1.2.1 From 2afb8b9df873c3f9572a32ab7a62ea8ba8d8a45b Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Tue, 20 Nov 2012 18:14:48 -0600 Subject: [ticket/11103] Create user loader class, update for DIC Create a very basic user loader class to handle querying/storing user data in a centralized location. Use DIC collection service for notification types/methods. Cleanup unused dependencies. Fix some other issues. PHPBB3-11103 --- phpBB/includes/functions.php | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 4e26d2c642..283ed4a657 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1331,12 +1331,12 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ // Mark all topic notifications read for this user $phpbb_notifications->mark_notifications_read(array( - 'phpbb_notification_type_topic', - 'phpbb_notification_type_quote', - 'phpbb_notification_type_bookmark', - 'phpbb_notification_type_post', - 'phpbb_notification_type_approve_topic', - 'phpbb_notification_type_approve_post', + 'topic', + 'quote', + 'bookmark', + 'post', + 'approve_topic', + 'approve_post', ), false, $user->data['user_id'], $post_time); if ($config['load_db_lastread'] && $user->data['is_registered']) @@ -1394,8 +1394,8 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ } $phpbb_notifications->mark_notifications_read_by_parent(array( - 'phpbb_notification_type_topic', - 'phpbb_notification_type_approve_topic', + 'topic', + 'approve_topic', ), $forum_id, $user->data['user_id'], $post_time); // Mark all post/quote notifications read for this user in this forum @@ -1411,10 +1411,10 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ $db->sql_freeresult($result); $phpbb_notifications->mark_notifications_read_by_parent(array( - 'phpbb_notification_type_quote', - 'phpbb_notification_type_bookmark', - 'phpbb_notification_type_post', - 'phpbb_notification_type_approve_post', + 'quote', + 'bookmark', + 'post', + 'approve_post', ), $topic_ids, $user->data['user_id'], $post_time); // Add 0 to forums array to mark global announcements correctly @@ -1516,14 +1516,14 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ // Mark post notifications read for this user in this topic $phpbb_notifications->mark_notifications_read(array( - 'phpbb_notification_type_topic', - 'phpbb_notification_type_approve_topic', + 'topic', + 'approve_topic', ), $topic_id, $user->data['user_id'], $post_time); $phpbb_notifications->mark_notifications_read_by_parent(array( - 'phpbb_notification_type_quote', - 'phpbb_notification_type_bookmark', - 'phpbb_notification_type_post', - 'phpbb_notification_type_approve_post', + 'quote', + 'bookmark', + 'post', + 'approve_post', ), $topic_id, $user->data['user_id'], $post_time); if ($config['load_db_lastread'] && $user->data['is_registered']) -- cgit v1.2.1 From 70d23380aa55c2aab33c1c2e5cea57f186314584 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 7 Dec 2012 15:11:56 +0100 Subject: [ticket/10714] Rely on global instead of creating an instance PHPBB3-10714 --- phpBB/includes/functions.php | 6 ------ 1 file changed, 6 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 93dfb4cd7f..7c1a48f913 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3367,12 +3367,6 @@ function add_log() return false; } - // no log class set, create a temporary one ourselves to keep backwards compatibility - if ($phpbb_log === null) - { - $phpbb_log = new phpbb_log(LOG_TABLE); - } - $mode = array_shift($args); // This looks kind of dirty, but add_log has some additional data before the log_operation -- cgit v1.2.1 From 6dee2539419ba2c050830b7677294603a63b559a Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sun, 9 Dec 2012 17:01:08 -0600 Subject: [ticket/11259] Make phpbb_admin_path available everywhere PHPBB3-11259 --- phpBB/includes/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index e492f97022..5fa5c5f505 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5339,7 +5339,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 function page_footer($run_cron = true, $display_template = true, $exit_handler = true) { global $db, $config, $template, $user, $auth, $cache, $starttime, $phpbb_root_path, $phpEx; - global $request, $phpbb_dispatcher; + global $request, $phpbb_dispatcher, $phpbb_admin_path; // A listener can set this variable to `true` when it overrides this function $page_footer_override = false; @@ -5395,7 +5395,7 @@ function page_footer($run_cron = true, $display_template = true, $exit_handler = 'TRANSLATION_INFO' => (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['TRANSLATION_INFO'] : '', 'CREDIT_LINE' => $user->lang('POWERED_BY', 'phpBB® Forum Software © phpBB Group'), - 'U_ACP' => ($auth->acl_get('a_') && !empty($user->data['is_registered'])) ? append_sid("{$phpbb_root_path}adm/index.$phpEx", false, true, $user->session_id) : '') + 'U_ACP' => ($auth->acl_get('a_') && !empty($user->data['is_registered'])) ? append_sid("{$phpbb_admin_path}index.$phpEx", false, true, $user->session_id) : '') ); // Call cron-type script -- cgit v1.2.1 From 249f3c8885d461ae3981dfd7b62093c2175175e3 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 13 Dec 2012 19:19:40 -0600 Subject: [ticket/11103] Instantiate $phpbb_notifications as needed https://github.com/phpbb/phpbb3/pull/992#discussion_r2413976 PHPBB3-11103 --- phpBB/includes/functions.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 6f619ef51d..9b284c5ca9 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1328,7 +1328,7 @@ function phpbb_timezone_select($user, $default = '', $truncate = false) function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $user_id = 0) { global $db, $user, $config; - global $request, $phpbb_notifications; + global $request, $phpbb_container; $post_time = ($post_time === 0 || $post_time > time()) ? time() : (int) $post_time; @@ -1338,6 +1338,8 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ { // Mark all forums read (index page) + $phpbb_notifications = $phpbb_container->get('notification_manager'); + // Mark all topic notifications read for this user $phpbb_notifications->mark_notifications_read(array( 'topic', @@ -1402,6 +1404,8 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ $forum_id = array($forum_id); } + $phpbb_notifications = $phpbb_container->get('notification_manager'); + $phpbb_notifications->mark_notifications_read_by_parent(array( 'topic', 'approve_topic', @@ -1523,11 +1527,14 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ return; } + $phpbb_notifications = $phpbb_container->get('notification_manager'); + // Mark post notifications read for this user in this topic $phpbb_notifications->mark_notifications_read(array( 'topic', 'approve_topic', ), $topic_id, $user->data['user_id'], $post_time); + $phpbb_notifications->mark_notifications_read_by_parent(array( 'quote', 'bookmark', @@ -5042,7 +5049,7 @@ function phpbb_build_hidden_fields_for_query_params($request, $exclude = null) function page_header($page_title = '', $display_online_list = true, $item_id = 0, $item = 'forum') { global $db, $config, $template, $SID, $_SID, $_EXTRA_URL, $user, $auth, $phpEx, $phpbb_root_path; - global $phpbb_dispatcher, $request, $phpbb_notifications; + global $phpbb_dispatcher, $request, $phpbb_container; if (defined('HEADER_INC')) { @@ -5230,10 +5237,13 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 { $timezone_name = $user->lang['timezones'][$timezone_name]; } - + // Output the notifications - if ($config['load_notifications']) + $notifications = false; + if ($config['load_notifications'] && $user->data['user_id'] != ANONYMOUS && $user->data['user_type'] != USER_IGNORE) { + $phpbb_notifications = $phpbb_container->get('notification_manager'); + $notifications = $phpbb_notifications->load_notifications(array( 'all_unread' => true, 'limit' => 5, @@ -5264,8 +5274,8 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread, 'HIDDEN_FIELDS_FOR_JUMPBOX' => $hidden_fields_for_jumpbox, - 'UNREAD_NOTIFICATIONS_COUNT' => ($config['load_notifications']) ? $notifications['unread_count'] : '', - 'NOTIFICATIONS_COUNT' => ($config['load_notifications']) ? $user->lang('NOTIFICATIONS_COUNT', $notifications['unread_count']) : '', + 'UNREAD_NOTIFICATIONS_COUNT' => ($notifications !== false) ? $notifications['unread_count'] : '', + 'NOTIFICATIONS_COUNT' => ($notifications !== false) ? $user->lang('NOTIFICATIONS_COUNT', $notifications['unread_count']) : '', 'U_VIEW_ALL_NOTIFICATIONS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=ucp_notifications'), 'S_NOTIFICATIONS_DISPLAY' => $config['load_notifications'], -- cgit v1.2.1 From 447e845274daedd12bc40f813680fb5df64d114a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 23 Jan 2013 00:21:01 +0100 Subject: [ticket/10714] Remove fallback code from previous commits and move global PHPBB3-10714 --- phpBB/includes/functions.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 590fc15aa7..6f9d8ad8d6 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3512,16 +3512,9 @@ function parse_cfg_file($filename, $lines = false) */ function add_log() { - global $phpbb_log; + global $phpbb_log, $user; $args = func_get_args(); - $log = (isset($args[0])) ? $args[0] : false; - - if ($log === false) - { - return false; - } - $mode = array_shift($args); // This looks kind of dirty, but add_log has some additional data before the log_operation @@ -3539,11 +3532,10 @@ function add_log() $additional_data['reportee_id'] = array_shift($args); break; } + $log_operation = array_shift($args); $additional_data = array_merge($additional_data, $args); - global $user; - $user_id = (empty($user->data)) ? ANONYMOUS : $user->data['user_id']; $user_ip = (empty($user->ip)) ? '' : $user->ip; -- cgit v1.2.1 From 7ad577a86afa379d67812ed184b7a59a32c64e9e Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 15 Feb 2013 16:02:33 -0600 Subject: [ticket/11103] Add Notification Settings link in flyout menu PHPBB3-11103 --- phpBB/includes/functions.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 0c514e7205..8ba7b2c24b 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5277,6 +5277,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'UNREAD_NOTIFICATIONS_COUNT' => ($notifications !== false) ? $notifications['unread_count'] : '', 'NOTIFICATIONS_COUNT' => ($notifications !== false) ? $user->lang('NOTIFICATIONS_COUNT', $notifications['unread_count']) : '', 'U_VIEW_ALL_NOTIFICATIONS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=ucp_notifications'), + 'U_NOTIFICATION_SETTINGS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=ucp_notifications&mode=notification_options'), 'S_NOTIFICATIONS_DISPLAY' => $config['load_notifications'], 'S_USER_NEW_PRIVMSG' => $user->data['user_new_privmsg'], -- cgit v1.2.1 From e8b3e8498d9842296a905fdaad8c0c32e31bceb4 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 24 Feb 2013 12:54:05 +0100 Subject: [ticket/7262] Backport set_config() and set_config_count() docs from develop. PHPBB3-7262 --- phpBB/includes/functions.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 571c863839..04b69f8c69 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -137,7 +137,14 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false) } /** -* Set config value. Creates missing config entry. +* Sets a configuration option's value. +* +* @param string $config_name The configuration option's name +* @param string $config_value New configuration value +* @param bool $is_dynamic Whether this variable should be cached or if it +* changes too frequently to be efficiently cached. +* +* @return null */ function set_config($config_name, $config_value, $is_dynamic = false) { @@ -166,7 +173,14 @@ function set_config($config_name, $config_value, $is_dynamic = false) } /** -* Set dynamic config value with arithmetic operation. +* Increments an integer config value directly in the database. +* +* @param string $config_name The configuration option's name +* @param int $increment Amount to increment by +* @param bool $is_dynamic Whether this variable should be cached or if it +* changes too frequently to be efficiently cached. +* +* @return null */ function set_config_count($config_name, $increment, $is_dynamic = false) { -- cgit v1.2.1 From a9037a68c177d396b2ed4b9bfcaad64536a01aaa Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 24 Feb 2013 13:03:48 +0100 Subject: [ticket/7262] Add $is_dynamic example to set_config() and set_config_count(). The logic is the other way around here in comparison to develop's phpbb_config_db class, so add examples to make things more clear. PHPBB3-7262 --- phpBB/includes/functions.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 04b69f8c69..2ca7d7f898 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -141,8 +141,9 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false) * * @param string $config_name The configuration option's name * @param string $config_value New configuration value -* @param bool $is_dynamic Whether this variable should be cached or if it -* changes too frequently to be efficiently cached. +* @param bool $is_dynamic Whether this variable should be cached (false) or +* if it changes too frequently (true) to be +* efficiently cached. * * @return null */ @@ -177,8 +178,9 @@ function set_config($config_name, $config_value, $is_dynamic = false) * * @param string $config_name The configuration option's name * @param int $increment Amount to increment by -* @param bool $is_dynamic Whether this variable should be cached or if it -* changes too frequently to be efficiently cached. +* @param bool $is_dynamic Whether this variable should be cached (false) or +* if it changes too frequently (true) to be +* efficiently cached. * * @return null */ -- cgit v1.2.1 From 6bf64d5620b1b9f165a65b50042c391a29ef151c Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 24 Feb 2013 13:37:52 +0100 Subject: [ticket/7262] Add note about set_config() not updating is_dynamic. PHPBB3-7262 --- phpBB/includes/functions.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 2ca7d7f898..ccd2d3147c 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -139,6 +139,9 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false) /** * Sets a configuration option's value. * +* Please note that this function does not update the is_dynamic value for +* an already existing config option. +* * @param string $config_name The configuration option's name * @param string $config_value New configuration value * @param bool $is_dynamic Whether this variable should be cached (false) or -- cgit v1.2.1 From c1b4cdb1883bb6771a303624ece131eb5c7f071d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 25 Feb 2013 15:57:21 +0100 Subject: [ticket/10714] Update add_log docs block with @param and @deprecated PHPBB3-10714 --- phpBB/includes/functions.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 6f9d8ad8d6..d9116084fd 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3508,7 +3508,18 @@ function parse_cfg_file($filename, $lines = false) } /** -* Add log event +* Add log entry +* +* @param string $mode The mode defines which log_type is used and from which log the entry is retrieved +* @param int $forum_id Mode 'mod' ONLY: forum id of the related item, NOT INCLUDED otherwise +* @param int $topic_id Mode 'mod' ONLY: topic id of the related item, NOT INCLUDED otherwise +* @param int $reportee_id Mode 'user' ONLY: user id of the reportee, NOT INCLUDED otherwise +* @param string $log_operation Name of the operation +* @param array $additional_data More arguments can be added, depending on the log_type +* +* @return int|bool Returns the log_id, if the entry was added to the database, false otherwise. +* +* @deprecated Use $phpbb_log->add() instead */ function add_log() { -- cgit v1.2.1