From 82fc52493b5b249c723e0680212788b9436b8a74 Mon Sep 17 00:00:00 2001 From: Brett Profitt Date: Thu, 25 Aug 2011 13:49:32 -0700 Subject: Fixes #3131. Added generic liking notification text. --- mod/likes/start.php | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) (limited to 'mod/likes/start.php') diff --git a/mod/likes/start.php b/mod/likes/start.php index d45fb96b3..64be8b239 100644 --- a/mod/likes/start.php +++ b/mod/likes/start.php @@ -109,3 +109,76 @@ function likes_count($entity) { return $entity->countAnnotations('likes'); } } + +/** + * Notify $user that $liker liked his $entity. + * + * @param type $user + * @param type $liker + * @param type $entity + */ +function likes_notify_user(ElggUser $user, ElggUser $liker, ElggEntity $entity) { + + if (!$user instanceof ElggUser) { + return false; + } + + if (!$liker instanceof ElggUser) { + return false; + } + + if (!$entity instanceof ElggEntity) { + return false; + } + + // get language for entity type / subtype + // would be nice to have standardized languages.... + // we can have: + // item:object: + // subtype + // subtype:subtype + $type = $entity->getType(); + $subtype = $entity->getSubtype(); + + $strings = array( + "item:$type:$subtype", + $subtype, + "$subtype:$subtype" + ); + + $type_str = elgg_echo('likes:content'); + foreach ($strings as $string) { + $tmp = elgg_echo($string); + if ($tmp != $string) { + $type_str = $tmp; + break; + } + } + + $title_str = $entity->title; + if (!$title_str) { + $title_str = elgg_get_excerpt($entity->description); + } + + $site = get_config('site'); + + $subject = elgg_echo('likes:notifications:subject', array( + $liker->name, + $title_str + )); + + $body = elgg_echo('likes:notifications:body', array( + $user->name, + $liker->name, + $title_str, + $site->name, + $entity->getURL(), + $liker->getURL() + )); + + notify_user($user->guid, + $liker->guid, + $subject, + $body + ); +} \ No newline at end of file -- cgit v1.2.3 From f97dad2d27466b7e80bb7bd150da6aad8dd804b2 Mon Sep 17 00:00:00 2001 From: Brett Profitt Date: Thu, 25 Aug 2011 13:52:26 -0700 Subject: Removed unused code for likes notification. --- mod/likes/start.php | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) (limited to 'mod/likes/start.php') diff --git a/mod/likes/start.php b/mod/likes/start.php index 64be8b239..76b48a369 100644 --- a/mod/likes/start.php +++ b/mod/likes/start.php @@ -130,31 +130,7 @@ function likes_notify_user(ElggUser $user, ElggUser $liker, ElggEntity $entity) if (!$entity instanceof ElggEntity) { return false; } - - // get language for entity type / subtype - // would be nice to have standardized languages.... - // we can have: - // item:object: - // subtype - // subtype:subtype - $type = $entity->getType(); - $subtype = $entity->getSubtype(); - - $strings = array( - "item:$type:$subtype", - $subtype, - "$subtype:$subtype" - ); - - $type_str = elgg_echo('likes:content'); - foreach ($strings as $string) { - $tmp = elgg_echo($string); - if ($tmp != $string) { - $type_str = $tmp; - break; - } - } - + $title_str = $entity->title; if (!$title_str) { $title_str = elgg_get_excerpt($entity->description); -- cgit v1.2.3