From c2d28fb37233eddcb698638c50339e74da178fcc Mon Sep 17 00:00:00 2001 From: ben Date: Mon, 9 Feb 2009 17:10:28 +0000 Subject: Introducing group forum notifications git-svn-id: https://code.elgg.org/elgg/trunk@2697 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/groups/languages/en.php | 2 ++ mod/groups/start.php | 65 +++++++++++++++++++++++++++++++++++---------- 2 files changed, 53 insertions(+), 14 deletions(-) diff --git a/mod/groups/languages/en.php b/mod/groups/languages/en.php index 4a0829fee..8f3d49a78 100644 --- a/mod/groups/languages/en.php +++ b/mod/groups/languages/en.php @@ -55,6 +55,8 @@ 'groups:notfound:details' => "The requested group either does not exist or you do not have access to it", 'item:object:groupforumtopic' => "Forum topics", + + 'groupforumtopic:new' => "New forum post", /* Group tools diff --git a/mod/groups/start.php b/mod/groups/start.php index cd1150a58..fbace7971 100644 --- a/mod/groups/start.php +++ b/mod/groups/start.php @@ -66,25 +66,62 @@ // Write access permissions register_plugin_hook('access:collections:write', 'all', 'groups_write_acl_plugin_hook'); - // For now, we'll hard code the groups profile items as follows: - // TODO make this user configurable - - // Language short codes must be of the form "groups:key" - // where key is the array key below - /*$CONFIG->group = array( - - 'name' => 'text', - 'description' => 'longtext', - 'briefdescription' => 'text', - 'interests' => 'tags', - 'website' => 'url', - - );*/ + // Notification hooks + if (is_callable('register_notification_object')) + register_notification_object('object', 'groupforumtopic', elgg_echo('groupforumtopic:new')); + register_elgg_event_handler('annotate','all','group_object_notifications'); + // Listen to notification events and supply a more useful message + register_plugin_hook('notify:entity:message', 'object', 'groupforumtopic_notify_message'); + // Now override icons register_plugin_hook('entity:icon:url', 'group', 'groups_groupicon_hook'); } + /** + * Event handler for group forum posts + * + */ + function group_object_notifications($event, $object_type, $object) { + + if (is_callable('object_notifications')) + if ($object instanceof ElggObject) { + if ($object->getSubtype() == 'groupforumtopic') { + object_notifications($event, $object_type, $object); + } + } + + } + + /** + * Returns a more meaningful message + * + * @param unknown_type $hook + * @param unknown_type $entity_type + * @param unknown_type $returnvalue + * @param unknown_type $params + */ + function groupforumtopic_notify_message($hook, $entity_type, $returnvalue, $params) + { + $entity = $params['entity']; + $to_entity = $params['to_entity']; + $method = $params['method']; + if (($entity instanceof ElggEntity) && ($entity->getSubtype() == 'groupforumtopic')) + { + $descr = $entity->description; + $title = $entity->title; + global $CONFIG; + $url = $entity->getURL(); + $owner = get_entity($entity->container_guid); + if ($method == 'sms') { + return elgg_echo("groupforumtopic:new") . ': ' . $url . " ({$owner->name}: {$title})"; + } else { + return "{$title}\n({$owner->name})\n\n{$url}"; + } + } + return null; + } + /** * This function loads a set of default fields into the profile, then triggers a hook letting other plugins to edit * add and delete fields. -- cgit v1.2.3