]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Refs #4335. Updated discussion notifications.
authorBrett Profitt <brett.profitt@gmail.com>
Wed, 22 Feb 2012 07:19:32 +0000 (23:19 -0800)
committerBrett Profitt <brett.profitt@gmail.com>
Wed, 22 Feb 2012 07:19:32 +0000 (23:19 -0800)
mod/groups/languages/en.php
mod/groups/start.php

index a4a9e2b2b080999acb10be6be5c9e01541c169f1..e51e51a142f82dfc3aae3071b08c995f7d9e3c35 100644 (file)
@@ -64,6 +64,16 @@ $english = array(
        'groups:search_in_group' => "Search in this group",
        'groups:acl' => "Group: %s",
 
+       'groups:notification' =>
+'%s added a new discussion topic to %s:
+
+%s
+%s
+
+View and reply to the discussion:
+%s
+',
+
        'groups:activity' => "Group activity",
        'groups:enableactivity' => 'Enable group activity',
        'groups:activity:none' => "There is no group activity yet",
index 86a1da2793dcc794c0ccf83a57699367984345ad..aeab0649aaeabe1783b9eb8b08fb848316813833 100644 (file)
@@ -741,7 +741,6 @@ function discussion_init() {
 
        // notifications
        register_notification_object('object', 'groupforumtopic', elgg_echo('groupforumtopic:new'));
-       elgg_register_plugin_hook_handler('object:notifications', 'object', 'group_object_notifications_intercept');
        elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'groupforumtopic_notify_message');
 }
 
@@ -855,41 +854,19 @@ function discussion_add_to_river_menu($hook, $type, $return, $params) {
 function group_object_notifications($event, $object_type, $object) {
 
        static $flag;
-       if (!isset($flag))
+       if (!isset($flag)) {
                $flag = 0;
+       }
 
        if (is_callable('object_notifications'))
                if ($object instanceof ElggObject) {
                        if ($object->getSubtype() == 'groupforumtopic') {
-                               //if ($object->countAnnotations('group_topic_post') > 0) {
                                if ($flag == 0) {
                                        $flag = 1;
                                        object_notifications($event, $object_type, $object);
                                }
-                               //}
-                       }
-               }
-}
-
-/**
- * Intercepts the notification on group topic creation and prevents a notification from going out
- * (because one will be sent on the annotation)
- *
- * @param unknown_type $hook
- * @param unknown_type $entity_type
- * @param unknown_type $returnvalue
- * @param unknown_type $params
- * @return unknown
- */
-function group_object_notifications_intercept($hook, $entity_type, $returnvalue, $params) {
-       if (isset($params)) {
-               if ($params['event'] == 'create' && $params['object'] instanceof ElggObject) {
-                       if ($params['object']->getSubtype() == 'groupforumtopic') {
-                               return true;
                        }
                }
-       }
-       return null;
 }
 
 /**
@@ -904,26 +881,23 @@ function groupforumtopic_notify_message($hook, $entity_type, $returnvalue, $para
        $entity = $params['entity'];
        $to_entity = $params['to_entity'];
        $method = $params['method'];
-       if (($entity instanceof ElggEntity) && ($entity->getSubtype() == 'groupforumtopic')) {
 
+       if (($entity instanceof ElggEntity) && ($entity->getSubtype() == 'groupforumtopic')) {
                $descr = $entity->description;
                $title = $entity->title;
                $url = $entity->getURL();
-
-               $msg = get_input('topicmessage');
-               if (empty($msg))
-                       $msg = get_input('topic_post');
-               if (!empty($msg))
-                       $msg = $msg . "\n\n"; else
-                       $msg = '';
-
-               $owner = get_entity($entity->container_guid);
-               if ($method == 'sms') {
-                       return elgg_echo("groupforumtopic:new") . ': ' . $url . " ({$owner->name}: {$title})";
-               } else {
-                       return elgg_get_logged_in_user_entity()->name . ' ' . elgg_echo("groups:viagroups") . ': ' . $title . "\n\n" . $msg . "\n\n" . $entity->getURL();
-               }
+               $owner = $entity->getOwnerEntity();
+               $group = $entity->getContainerEntity();
+
+               return elgg_echo('groups:notification', array(
+                       $owner->name,
+                       $group->name,
+                       $entity->title,
+                       $entity->description,
+                       $entity->getURL()
+               ));
        }
+       
        return null;
 }