aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Guse <nathaniel.guse@gmail.com>2012-10-14 12:35:35 -0500
committerNathan Guse <nathaniel.guse@gmail.com>2012-10-14 12:35:35 -0500
commita48f09033810148fd9b2d5a0b6a683f14ac73a6a (patch)
treecd4fa36aaff27b628f1607dec517c3321db1e9f3
parent716635c834dd2d6644f3d47c67f7184f95a35c0b (diff)
downloadforums-a48f09033810148fd9b2d5a0b6a683f14ac73a6a.tar
forums-a48f09033810148fd9b2d5a0b6a683f14ac73a6a.tar.gz
forums-a48f09033810148fd9b2d5a0b6a683f14ac73a6a.tar.bz2
forums-a48f09033810148fd9b2d5a0b6a683f14ac73a6a.tar.xz
forums-a48f09033810148fd9b2d5a0b6a683f14ac73a6a.zip
[ticket/11103] Make sure notifications are marked read when clicking them
How do we do this? If an item is unread, the URL to view that item will be the URL to mark it as read (index.php?mark_notification=$id). When the URL is visited it marks the item as read and redirects them to the correct URL for the item. If the item is read, the URL is directly to the item. Prettify the html output PHPBB-11103
-rw-r--r--phpBB/includes/notification/manager.php2
-rw-r--r--phpBB/includes/notification/type/base.php12
-rw-r--r--phpBB/index.php24
-rw-r--r--phpBB/language/en/common.php4
-rw-r--r--phpBB/styles/prosilver/template/overall_header.html15
-rw-r--r--phpBB/styles/prosilver/template/ucp_notifications.html15
-rw-r--r--phpBB/styles/prosilver/theme/common.css26
7 files changed, 63 insertions, 35 deletions
diff --git a/phpBB/includes/notification/manager.php b/phpBB/includes/notification/manager.php
index fc9b48c624..03776de2b4 100644
--- a/phpBB/includes/notification/manager.php
+++ b/phpBB/includes/notification/manager.php
@@ -165,7 +165,7 @@ class phpbb_notification_manager
}
$load_special[$row['item_type']] = array_merge($load_special[$row['item_type']], $notification->get_load_special());
- $notifications[] = $notification;
+ $notifications[$row['notification_id']] = $notification;
}
$this->load_users($user_ids);
diff --git a/phpBB/includes/notification/type/base.php b/phpBB/includes/notification/type/base.php
index e8959d1352..9ef0e71009 100644
--- a/phpBB/includes/notification/type/base.php
+++ b/phpBB/includes/notification/type/base.php
@@ -138,7 +138,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i
'UNREAD' => $this->unread,
- 'U_MARK_READ' => append_sid($this->phpbb_root_path . 'index.' . $this->php_ext, 'mark_notification[]=' . $this->notification_id),
+ 'U_MARK_READ' => append_sid($this->phpbb_root_path . 'index.' . $this->php_ext, 'mark_notification=' . $this->notification_id),
);
}
@@ -148,7 +148,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i
* @param bool $return True to return a string containing the SQL code to update this item, False to execute it (Default: False)
* @return string
*/
- public function mark_read($return = true)
+ public function mark_read($return = false)
{
return $this->mark(false, $return);
}
@@ -159,7 +159,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i
* @param bool $return True to return a string containing the SQL code to update this item, False to execute it (Default: False)
* @return string
*/
- public function mark_unread($return = true)
+ public function mark_unread($return = false)
{
return $this->mark(true, $return);
}
@@ -352,11 +352,11 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i
$this->unread = (bool) $unread;
$where = array(
- 'item_type = ' . $this->db->sql_escape($this->item_type),
+ "item_type = '" . $this->db->sql_escape($this->item_type) . "'",
'item_id = ' . (int) $this->item_id,
'user_id = ' . (int) $this->user_id,
);
- $where = implode(' AND ' . $where);
+ $where = implode(' AND ', $where);
if ($return)
{
@@ -364,7 +364,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i
}
$sql = 'UPDATE ' . NOTIFICATIONS_TABLE . '
- SET unread = ' . $this->unread . '
+ SET unread = ' . (int) $this->unread . '
WHERE ' . $where;
$this->db->sql_query($sql);
}
diff --git a/phpBB/index.php b/phpBB/index.php
index af0441f5e3..7f85879d23 100644
--- a/phpBB/index.php
+++ b/phpBB/index.php
@@ -23,6 +23,23 @@ $user->session_begin();
$auth->acl($user->data);
$user->setup();
+// Mark notifications read
+if (($mark_notification = request_var('mark_notification', 0)))
+{
+ $notification = $phpbb_notifications->load_notifications(array(
+ 'notification_id' => $mark_notification
+ ));
+
+ if (isset($notification['notifications'][$mark_notification]))
+ {
+ $notification = $notification['notifications'][$mark_notification];
+
+ $notification->mark_read();
+
+ redirect($notification->get_url());
+ }
+}
+
// Handle the display of extension front pages
if ($ext = $request->variable('ext', ''))
{
@@ -56,13 +73,6 @@ if ($ext = $request->variable('ext', ''))
exit_handler();
}
-// Mark notifications read
-$mark_notifications = request_var('mark_notification', array(0));
-if (!empty($mark_notifications))
-{
- $phpbb_notifications->mark_notifications_read_by_id($mark_notifications);
-}
-
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
$user->add_lang('viewforum');
diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php
index 2f9f646cd3..8980c274ef 100644
--- a/phpBB/language/en/common.php
+++ b/phpBB/language/en/common.php
@@ -395,7 +395,7 @@ $lang = array_merge($lang, array(
'NOTIFICATION_POST' => '%1$s replied to the topic "%2$s".',
'NOTIFICATION_POST_APPROVED' => 'Your post was approved "%2$s".',
'NOTIFICATION_POST_DISAPPROVED' => 'Your post "%1$s" was disapproved for reason: "%2$s".',
- 'NOTIFICATION_POST_IN_QUEUE' => 'A new post titled "%2$s" was posted by "%1$s" and needs approval.',
+ 'NOTIFICATION_POST_IN_QUEUE' => 'A new post titled "%2$s" was posted by %1$s and needs approval.',
'NOTIFICATION_QUOTE' => '%1$s quoted you in the post "%2$s".',
'NOTIFICATION_REPORT_PM' => '%1$s reported a Private Message "%2$s" for reason: "%3$s".',
'NOTIFICATION_REPORT_POST' => '%1$s reported a post "%2$s" for reason: "%3$s".',
@@ -403,7 +403,7 @@ $lang = array_merge($lang, array(
'NOTIFICATION_TOPIC' => '%1$s posted a new topic "%2$s" in the forum "%3$s".',
'NOTIFICATION_TOPIC_APPROVED' => 'Your topic "%2$s" in the forum "%3$s" was approved.',
'NOTIFICATION_TOPIC_DISAPPROVED' => 'Your topic "%1$s" was disapproved for reason: "%2$s".',
- 'NOTIFICATION_TOPIC_IN_QUEUE' => 'A new topic titled "%2$s" was posted by "%1$s" and needs approval.',
+ 'NOTIFICATION_TOPIC_IN_QUEUE' => 'A new topic titled "%2$s" was posted by %1$s and needs approval.',
'NOTIFY_ADMIN' => 'Please notify the board administrator or webmaster.',
'NOTIFY_ADMIN_EMAIL' => 'Please notify the board administrator or webmaster: <a href="mailto:%1$s">%1$s</a>',
'NO_ACCESS_ATTACHMENT' => 'You are not allowed to access this file.',
diff --git a/phpBB/styles/prosilver/template/overall_header.html b/phpBB/styles/prosilver/template/overall_header.html
index e00ad555ff..20b98c6f8c 100644
--- a/phpBB/styles/prosilver/template/overall_header.html
+++ b/phpBB/styles/prosilver/template/overall_header.html
@@ -137,14 +137,15 @@
<ul class="topiclist forums">
<!-- BEGIN notifications -->
<li class="row<!-- IF notifications.UNREAD --> bg2<!-- ENDIF -->">
- <!-- IF notifications.URL --><a href="{notifications.URL}"><!-- ENDIF -->
- {notifications.AVATAR}
- <div>
- {notifications.FORMATTED_TITLE}<br />
- {notifications.TIME}
- </div>
+ <!-- IF notifications.URL or notifications.U_MARK_READ --><a href="<!-- IF notifications.UNREAD -->{notifications.U_MARK_READ}<!-- ELSE -->{notifications.URL}<!-- ENDIF -->"><!-- ENDIF -->
+ <span>
+ {notifications.AVATAR}
+ <span class="notification_title">
+ {notifications.FORMATTED_TITLE}
+ <div class="notification_time">{notifications.TIME}</div>
+ </span>
+ </span>
<!-- IF notifications.URL --></a><!-- ENDIF -->
- <!-- IF notifications.UNREAD --><a href="{notifications.U_MARK_READ}" title="{L_MARK_READ}">{L_MARK_READ}</a><!-- ENDIF -->
</li>
<!-- END notifications -->
</ul>
diff --git a/phpBB/styles/prosilver/template/ucp_notifications.html b/phpBB/styles/prosilver/template/ucp_notifications.html
index 94e8432508..f71d8698b9 100644
--- a/phpBB/styles/prosilver/template/ucp_notifications.html
+++ b/phpBB/styles/prosilver/template/ucp_notifications.html
@@ -77,14 +77,17 @@
<li class="row<!-- IF notification_list.UNREAD --> bg3<!-- ELSE --><!-- IF notification_list.S_ROW_COUNT is odd --> bg1<!-- ELSE --> bg2<!-- ENDIF --><!-- ENDIF -->">
<dl>
<dt>
- <!-- IF notification_list.URL --><a href="{notification_list.URL}"><!-- ENDIF -->
- {notification_list.AVATAR}
- <div>
- {notification_list.FORMATTED_TITLE}<br />
- {notification_list.TIME}
- </div>
+ <!-- IF notification_list.URL or notification_list.U_MARK_READ --><a href="<!-- IF notification_list.UNREAD -->{notification_list.U_MARK_READ}<!-- ELSE -->{notification_list.URL}<!-- ENDIF -->"><!-- ENDIF -->
+ <span>
+ {notification_list.AVATAR}
+ <span class="notification_title">
+ {notification_list.FORMATTED_TITLE}
+ <div class="notification_time">{notification_list.TIME}</div>
+ </span>
+ </span>
<!-- IF notification_list.URL --></a><!-- ENDIF -->
</dt>
+
<dd class="mark"><!-- IF notification_list.UNREAD --><input type="checkbox" name="mark[]" value="{notification_list.NOTIFICATION_ID}" /> <dfn>{L_MARK_READ}</dfn><!-- ENDIF --></dd>
</dl>
</li>
diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css
index 3d8d640598..c82fa5b7c8 100644
--- a/phpBB/styles/prosilver/theme/common.css
+++ b/phpBB/styles/prosilver/theme/common.css
@@ -680,15 +680,29 @@ p.rules a {
#notification_list ul li {
padding: 10px;
width: 310px;
+ line-height: 1.5em;
}
-.notification_list ul li a {
- text-decoration: none;
-}
-
-.notification_list ul li img {
+.notification_list ul li a span img {
float: left;
- padding: 0 10px 10px 0;
max-width: 50px;
max-height: 50px;
}
+
+.notification_list ul li span .notification_title {
+ float: left;
+ width: 240px;
+ margin: 0 0 0 5px;
+ word-wrap: break-word;
+ position: relative;
+ top: -0.2em;
+}
+
+.notification_list ul li dl dt span .notification_title {
+ width: auto;
+ padding: 10px 0 0 0;
+}
+
+.notification_time {
+ margin-top: 0.5em;
+}