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/actions/likes/add.php | 13 +------- mod/likes/languages/en.php | 23 +++++++++++-- mod/likes/start.php | 73 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 14 deletions(-) (limited to 'mod/likes') diff --git a/mod/likes/actions/likes/add.php b/mod/likes/actions/likes/add.php index b76c1bea9..a6a8d6c45 100644 --- a/mod/likes/actions/likes/add.php +++ b/mod/likes/actions/likes/add.php @@ -41,18 +41,7 @@ if (!$annotation) { // notify if poster wasn't owner if ($entity->owner_guid != $user->guid) { - notify_user($entity->owner_guid, - $user->guid, - elgg_echo('likes:email:subject'), - elgg_echo('likes:email:body', array( - $user->name, - $entity->title, - //$comment_text, - $entity->getURL(), - $user->name, - $user->getURL() - )) - ); + likes_notify_user($entity->getOwnerEntity(), $user, $entity); } system_message(elgg_echo("likes:likes")); diff --git a/mod/likes/languages/en.php b/mod/likes/languages/en.php index aad2a7f24..29b379506 100644 --- a/mod/likes/languages/en.php +++ b/mod/likes/languages/en.php @@ -17,9 +17,28 @@ $english = array( 'likes:userlikedthis' => '%s like', 'likes:userslikedthis' => '%s likes', 'likes:river:annotate' => 'likes', - 'likes:email:body' => '%s liked %s', - 'likes:email:subject' => 'A user liked one of your objects', + 'river:likes' => 'likes %s %s', + + // notifications. yikes. + 'likes:notifications:subject' => '%s likes your post "%s"', + 'likes:notifications:body' => +'Hi %1$s, + +%2$s likes your post "%3$s" on %4$s! + +See your original post here: + +%5$s + +or view %2$s\'s profile here: + +%6$s + +Thanks, +%4$s +', + ); add_translation('en', $english); 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') 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 From d9d3cc65e96c54332f22f90ac17b014dfe183ddf Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 24 Sep 2011 17:29:41 -0400 Subject: Fixes #3828 correct list classes --- engine/lib/deprecated-1.8.php | 2 +- engine/lib/river.php | 2 +- engine/lib/views.php | 2 +- mod/likes/views/default/likes/count.php | 9 +++++++-- mod/likes/views/default/likes/css.php | 2 +- mod/likes/views/default/likes/js.php | 2 +- mod/messageboard/views/default/messageboard/js.php | 2 +- views/default/css/elements/components.php | 4 ++-- 8 files changed, 15 insertions(+), 10 deletions(-) (limited to 'mod/likes') diff --git a/engine/lib/deprecated-1.8.php b/engine/lib/deprecated-1.8.php index f0f4bd9dc..beba7d2b7 100644 --- a/engine/lib/deprecated-1.8.php +++ b/engine/lib/deprecated-1.8.php @@ -2424,7 +2424,7 @@ $posted_max = 0, $pagination = true) { 'offset' => $offset, 'limit' => $limit, 'pagination' => $pagination, - 'list-class' => 'elgg-river-list', + 'list-class' => 'elgg-list-river', ); return elgg_view('page/components/list', $params); diff --git a/engine/lib/river.php b/engine/lib/river.php index 64ddcfdc1..a11e6145c 100644 --- a/engine/lib/river.php +++ b/engine/lib/river.php @@ -378,7 +378,7 @@ function elgg_list_river(array $options = array()) { 'offset' => (int) max(get_input('offset', 0), 0), 'limit' => (int) max(get_input('limit', 20), 0), 'pagination' => TRUE, - 'list_class' => 'elgg-river', + 'list_class' => 'elgg-list-river elgg-river', // @todo remove elgg-river in Elgg 1.9 ); $options = array_merge($defaults, $options); diff --git a/engine/lib/views.php b/engine/lib/views.php index f6e5aa6b8..9a236508f 100644 --- a/engine/lib/views.php +++ b/engine/lib/views.php @@ -1044,7 +1044,7 @@ $list_type_toggle = true, $pagination = true) { function elgg_view_annotation_list($annotations, array $vars = array()) { $defaults = array( 'items' => $annotations, - 'list_class' => 'elgg-annotation-list', + 'list_class' => 'elgg-list-annotation elgg-annotation-list', // @todo remove elgg-annotation-list in Elgg 1.9 'full_view' => true, 'offset_key' => 'annoff', ); diff --git a/mod/likes/views/default/likes/count.php b/mod/likes/views/default/likes/count.php index bdc50bcd1..071a069bd 100644 --- a/mod/likes/views/default/likes/count.php +++ b/mod/likes/views/default/likes/count.php @@ -24,8 +24,13 @@ if ($num_of_likes) { 'href' => "#likes-$guid" ); $list = elgg_view('output/url', $params); - $list .= "