[Customisation Database Commits] r893 - in /trunk/titania: contributions/support.php includes/tools/posting.php includes/tools/subscriptions.php language/en/email/subscribe_notify.txt language/en/email/subscribe_notify_forum.txt manage/attention.php
Nathan Guse
exreaction at phpbb.com
Fri Mar 26 02:48:35 GMT 2010
Author: exreaction
Date: Fri Mar 26 02:48:34 2010
New Revision: 893
Log:
Subscriptions for the support/discussion area and topics
Added:
trunk/titania/language/en/email/subscribe_notify_forum.txt
Modified:
trunk/titania/contributions/support.php
trunk/titania/includes/tools/posting.php
trunk/titania/includes/tools/subscriptions.php
trunk/titania/language/en/email/subscribe_notify.txt
trunk/titania/manage/attention.php
Modified: trunk/titania/contributions/support.php
==============================================================================
*** trunk/titania/contributions/support.php (original)
--- trunk/titania/contributions/support.php Fri Mar 26 02:48:34 2010
***************
*** 70,75 ****
--- 70,78 ----
if ($topic_id)
{
+ // Subscriptions
+ titania_subscriptions::handle_subscriptions(TITANIA_TOPIC, $topic_id, $topic->get_url());
+
// Check access level
if ($topic->topic_access < titania::$access_level || ($topic->topic_type == TITANIA_QUEUE_DISCUSSION && !titania::$contrib->is_author && !titania::$contrib->is_active_coauthor && !titania_types::$types[titania::$contrib->contrib_type]->acl_get('queue_discussion')))
{
***************
*** 87,92 ****
--- 90,98 ----
}
else
{
+ // Subscriptions
+ titania_subscriptions::handle_subscriptions(TITANIA_SUPPORT, titania::$contrib->contrib_id, titania::$contrib->get_url('support'));
+
// Mark all topics read
if (request_var('mark', '') == 'topics')
{
Modified: trunk/titania/includes/tools/posting.php
==============================================================================
*** trunk/titania/includes/tools/posting.php (original)
--- trunk/titania/includes/tools/posting.php Fri Mar 26 02:48:34 2010
***************
*** 149,155 ****
));
// Call our common posting handler
! $this->common_post($post_object, $message_object);
// Common stuff
phpbb::$template->assign_vars(array(
--- 149,155 ----
));
// Call our common posting handler
! $this->common_post('post', $post_object, $message_object);
// Common stuff
phpbb::$template->assign_vars(array(
***************
*** 211,217 ****
));
// Call our common posting handler
! $this->common_post($post_object, $message_object);
// Common stuff
phpbb::$template->assign_vars(array(
--- 211,217 ----
));
// Call our common posting handler
! $this->common_post('reply', $post_object, $message_object);
// Common stuff
phpbb::$template->assign_vars(array(
***************
*** 276,282 ****
));
// Call our common posting handler
! $this->common_post($post_object, $message_object);
// Common stuff
phpbb::$template->assign_vars(array(
--- 276,282 ----
));
// Call our common posting handler
! $this->common_post('edit', $post_object, $message_object);
// Common stuff
phpbb::$template->assign_vars(array(
***************
*** 350,356 ****
* @param mixed $post_object
* @param mixed $message_object
*/
! private function common_post($post_object, $message_object)
{
titania::add_lang('posting');
phpbb::$user->add_lang('posting');
--- 350,356 ----
* @param mixed $post_object
* @param mixed $message_object
*/
! private function common_post($mode, $post_object, $message_object)
{
titania::add_lang('posting');
phpbb::$user->add_lang('posting');
***************
*** 394,399 ****
--- 394,405 ----
$message_object->submit($post_object->post_access);
+ // Did they want to subscribe?
+ if (isset($_POST['notify']) && phpbb::$user->data['is_registered'])
+ {
+ titania_subscriptions::subscribe(TITANIA_TOPIC, $post_object->topic->topic_id);
+ }
+
// Unapproved posts will get a notice
if (!$post_object->topic->get_postcount())
{
***************
*** 406,416 ****
--- 412,445 ----
phpbb::$user->add_lang('posting');
trigger_error(phpbb::$user->lang['POST_STORED_MOD'] . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_TOPIC'], '<a href="' . $post_object->topic->get_url() . '">', '</a>'));
}
+ else
+ {
+ // Subscriptions
+ if ($mode == 'reply' && $post_object->post_access == TITANIA_ACCESS_PUBLIC)
+ {
+ $email_vars = array(
+ 'NAME' => $post_object->topic->topic_subject,
+ 'U_VIEW' => titania_url::append_url($post_object->topic->get_url(), array('view' => 'unread', '#' => 'unread')),
+ );
+ titania_subscriptions::send_notifications(TITANIA_TOPIC, $post_object->topic_id, 'subscribe_notify.txt', $email_vars, $post_object->post_user_id);
+ }
+ else if ($mode == 'post' && $post_object->topic->topic_access == TITANIA_ACCESS_PUBLIC)
+ {
+ $email_vars = array(
+ 'NAME' => $post_object->topic->topic_subject,
+ 'U_VIEW' => $post_object->topic->get_url(),
+ );
+ titania_subscriptions::send_notifications($post_object->post_type, $post_object->topic->parent_id, 'subscribe_notify_forum.txt', $email_vars, $post_object->post_user_id);
+ }
+ }
redirect($post_object->get_url());
}
}
+ $is_subscribed = (($mode == 'edit' || $mode == 'reply') && titania_subscriptions::is_subscribed(TITANIA_TOPIC, $post_object->topic->topic_id)) ? true : false;
+ phpbb::$template->assign_var('S_NOTIFY_ALLOWED', ((phpbb::$user->data['is_registered'] && !$is_subscribed) ? true : false));
+
$message_object->display();
}
Modified: trunk/titania/includes/tools/subscriptions.php
==============================================================================
*** trunk/titania/includes/tools/subscriptions.php (original)
--- trunk/titania/includes/tools/subscriptions.php Fri Mar 26 02:48:34 2010
***************
*** 145,158 ****
* emails of the recepiants will be personalised by the function. Ensure the
* email template has the {USERNAME} var present.
*
*/
! public static function send_notifications($object_type, $object_id, $email_tpl, $vars)
{
$sql = 'SELECT w.watch_user_id, w.watch_type, u.user_id, u.username, u.user_email
FROM ' . TITANIA_WATCH_TABLE . ' w, ' . USERS_TABLE . ' u
WHERE w.watch_user_id = u.user_id
AND w.watch_object_type = ' . (int) $object_type . '
! AND w.watch_object_id = ' . (int) $object_id;
$result = phpbb::$db->sql_query($sql);
--- 145,161 ----
* emails of the recepiants will be personalised by the function. Ensure the
* email template has the {USERNAME} var present.
*
+ * @param $exclude_user User_id of the one who posted the item to exclude them from the sending
+ *
*/
! public static function send_notifications($object_type, $object_id, $email_tpl, $vars, $exclude_user = false)
{
$sql = 'SELECT w.watch_user_id, w.watch_type, u.user_id, u.username, u.user_email
FROM ' . TITANIA_WATCH_TABLE . ' w, ' . USERS_TABLE . ' u
WHERE w.watch_user_id = u.user_id
AND w.watch_object_type = ' . (int) $object_type . '
! AND w.watch_object_id = ' . (int) $object_id .
! (($exclude_user) ? ' AND w.watch_user_id <> ' . (int) $exclude_user : '');
$result = phpbb::$db->sql_query($sql);
Modified: trunk/titania/language/en/email/subscribe_notify.txt
==============================================================================
*** trunk/titania/language/en/email/subscribe_notify.txt (original)
--- trunk/titania/language/en/email/subscribe_notify.txt Fri Mar 26 02:48:34 2010
***************
*** 2,8 ****
Hello {USERNAME},
! You are receiving this notification because you are watching the {NAME} in the phpBB Customization Database.
You may view the update at the link below:
{U_VIEW}
\ No newline at end of file
--- 2,8 ----
Hello {USERNAME},
! You are receiving this notification because you are watching {NAME} in the phpBB Customisation Database.
You may view the update at the link below:
{U_VIEW}
\ No newline at end of file
Added: trunk/titania/language/en/email/subscribe_notify_forum.txt
==============================================================================
*** trunk/titania/language/en/email/subscribe_notify_forum.txt (added)
--- trunk/titania/language/en/email/subscribe_notify_forum.txt Fri Mar 26 02:48:34 2010
***************
*** 0 ****
--- 1,8 ----
+ Subject: Update Notification - {NAME}
+
+ Hello {USERNAME},
+
+ You are receiving this notification because you are watching the area in which {NAME} has been posted in the phpBB Customisation Database.
+
+ You may view the update at the link below:
+ {U_VIEW}
\ No newline at end of file
Modified: trunk/titania/manage/attention.php
==============================================================================
*** trunk/titania/manage/attention.php (original)
--- trunk/titania/manage/attention.php Fri Mar 26 02:48:34 2010
***************
*** 117,122 ****
--- 117,136 ----
$post->post_approved = 1;
$post->submit();
+ // Load z topic
+ $post->topic->topic_id = $post->topic_id;
+ $post->topic->load();
+
+ // Subscriptions?
+ if ($post->topic->topic_last_post_id == $post->post_id && $post->post_access == TITANIA_ACCESS_PUBLIC)
+ {
+ $email_vars = array(
+ 'NAME' => $post->topic->topic_subject,
+ 'U_VIEW' => titania_url::append_url($post->topic->get_url(), array('view' => 'unread', '#' => 'unread')),
+ );
+ titania_subscriptions::send_notifications(TITANIA_TOPIC, $post->topic_id, 'subscribe_notify.txt', $email_vars, $post->post_user_id);
+ }
+
$sql = 'SELECT COUNT(post_id) AS cnt FROM ' . TITANIA_POSTS_TABLE . '
WHERE topic_id = ' . $post->topic_id . '
AND post_approved = 0';
***************
*** 129,134 ****
--- 143,158 ----
SET topic_approved = 1
WHERE topic_id = ' . $post->topic_id;
phpbb::$db->sql_query($sql);
+
+ // Subscriptions
+ if ($post->topic->topic_last_post_id == $post->post_id && $post->topic->topic_access == TITANIA_ACCESS_PUBLIC)
+ {
+ $email_vars = array(
+ 'NAME' => $post->topic->topic_subject,
+ 'U_VIEW' => $post->topic->get_url(),
+ );
+ titania_subscriptions::send_notifications($post->post_type, $post->topic->parent_id, 'subscribe_notify_forum.txt', $email_vars, $post->post_user_id);
+ }
}
}
More information about the customisationdb-commits
mailing list