aboutsummaryrefslogtreecommitdiff
path: root/mod/likes/start.php
diff options
context:
space:
mode:
authorBrett Profitt <brett.profitt@gmail.com>2011-09-29 18:16:03 -0700
committerBrett Profitt <brett.profitt@gmail.com>2011-09-29 18:16:03 -0700
commitbfdb9bb8a87a29038ba1ae25355684ae19678fdd (patch)
treea074e2d6bfa19c17b284c3950b4555cf584eabe2 /mod/likes/start.php
parent7be23080f34a8f92ca1f8d49c3aa0e6ce3472f4c (diff)
parenta458ae4e0f8e5b19884860fead6e5f901b95eca4 (diff)
downloadelgg-bfdb9bb8a87a29038ba1ae25355684ae19678fdd.tar.gz
elgg-bfdb9bb8a87a29038ba1ae25355684ae19678fdd.tar.bz2
Merge branch 'master' of github.com:brettp/Elgg
Diffstat (limited to 'mod/likes/start.php')
-rw-r--r--mod/likes/start.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/mod/likes/start.php b/mod/likes/start.php
index d45fb96b3..76b48a369 100644
--- a/mod/likes/start.php
+++ b/mod/likes/start.php
@@ -109,3 +109,52 @@ 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;
+ }
+
+ $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