self_birthday_notification.diff (6,699 bytes)
diff --git a/sources/hooks/systems/notifications/cns_self_birthday.php b/sources/hooks/systems/notifications/cns_self_birthday.php
new file mode 100644
index 0000000..694b33e
--- /dev/null
+++ b/sources/hooks/systems/notifications/cns_self_birthday.php
@@ -0,0 +1,58 @@
+<?php /*
+
+ Composr
+ Copyright (c) ocProducts, 2004-2016
+
+ See text/EN/licence.txt for full licencing information.
+
+
+ NOTE TO PROGRAMMERS:
+ Do not edit this file. If you need to make changes, save your changed file to the appropriate *_custom folder
+ **** If you ignore this advice, then your website upgrades (e.g. for bug fixes) will likely kill your changes ****
+
+*/
+
+/**
+ * @license http://opensource.org/licenses/cpal_1.0 Common Public Attribution License
+ * @copyright ocProducts Ltd
+ * @package core_cns
+ */
+
+/**
+ * Hook class.
+ */
+class Hook_notification_cns_self_birthday extends Hook_Notification
+{
+ /**
+ * Get a list of all the notification codes this hook can handle.
+ * (Addons can define hooks that handle whole sets of codes, so hooks are written so they can take wide authority)
+ *
+ * @return array List of codes (mapping between code names, and a pair: section and labelling for those codes)
+ */
+ public function list_handled_codes()
+ {
+ $list = array();
+ if (get_option('enable_birthdays') != '0') {
+ $list['cns_self_birthday'] = array(do_lang('MEMBERS'), do_lang('cns:NOTIFICATION_TYPE_cns_self_birthday'));
+ }
+ return $list;
+ }
+
+ /**
+ * Get a list of members who have enabled this notification (i.e. have permission to AND have chosen to or are defaulted to).
+ *
+ * @param ID_TEXT $notification_code Notification code
+ * @param ?SHORT_TEXT $category The category within the notification code (null: none)
+ * @param ?array $to_member_ids List of member IDs we are restricting to (null: no restriction). This effectively works as a intersection set operator against those who have enabled.
+ * @param integer $start Start position (for pagination)
+ * @param integer $max Maximum (for pagination)
+ * @return array A pair: Map of members to their notification setting, and whether there may be more
+ */
+ public function list_members_who_have_enabled($notification_code, $category = null, $to_member_ids = null, $start = 0, $max = 300)
+ {
+ $members = $this->_all_members_who_have_enabled($notification_code, $category, $to_member_ids, $start, $max);
+ $members = $this->_all_members_who_have_enabled_with_page_access($members, 'members', $notification_code, $category, $to_member_ids, $start, $max);
+
+ return $members;
+ }
+}
diff --git a/sources/hooks/systems/cron/cns_birthdays.php b/sources/hooks/systems/cron/cns_birthdays.php
index e77a6a9..7bf922b 100644
--- a/sources/hooks/systems/cron/cns_birthdays.php
+++ b/sources/hooks/systems/cron/cns_birthdays.php
@@ -71,16 +71,38 @@ class Hook_cron_cns_birthdays
)
);
+ // Randoms (if not batched)...
+
+ if (count($_birthdays) == 1) {
+ dispatch_notification('cns_birthday', null, $subject, $mail);
+ }
+
+ // Friend...
+
if (addon_installed('chat')) {
$friends = $GLOBALS['SITE_DB']->query_select('chat_friends', array('member_likes'), array('member_liked' => $_birthday['id']));
dispatch_notification('cns_friend_birthday', null, $subject, $mail, collapse_1d_complexity('member_likes', $friends));
}
- if (count($_birthdays) == 1) {
- dispatch_notification('cns_birthday', null, $subject, $mail);
- }
+ // Self...
+
+ $subject_self = do_lang('SELF_BIRTHDAY_NOTIFICATION_MAIL_SUBJECT', get_site_name(), $displayname, $username);
+ $mail_self = do_notification_lang(
+ 'SELF_BIRTHDAY_NOTIFICATION_MAIL',
+ comcode_escape(get_site_name()),
+ comcode_escape($username),
+ array(
+ $member_url->evaluate(),
+ $birthday_url->evaluate(),
+ comcode_escape($displayname)
+ )
+ );
+
+ dispatch_notification('cns_self_birthday', null, $subject_self, $mail_self, array($_birthday['id']));
}
+ // Randoms (if batched)...
+
if (count($_birthdays) > 1) {
$combined_birthdays_subject = do_lang('COMBINED_BIRTHDAY_NOTIFICATION_MAIL_SUBJECT', get_site_name(), integer_format(count($_birthdays)));
$combined_birthdays_mail = do_notification_lang('COMBINED_BIRTHDAY_NOTIFICATION_MAIL', comcode_escape(get_site_name()), $combined_birthdays_mail, comcode_escape(integer_format(count($_birthdays))));
diff --git a/lang_custom/EN/cns.ini b/lang_custom/EN/cns.ini
new file mode 100644
index 0000000..6e0be91
--- /dev/null
+++ b/lang_custom/EN/cns.ini
@@ -0,0 +1,47 @@
+SELF_BIRTHDAY_NOTIFICATION_MAIL=Happy Birthday {2}, from your committee members at {1}. We hope you enjoy your special day.
diff --git a/lang/EN/cns.ini b/lang/EN/cns.ini
index 77b9741..70ae286 100644
--- a/lang/EN/cns.ini
+++ b/lang/EN/cns.ini
@@ -811,6 +792,7 @@ NOTIFICATION_TYPE_cns_group_declined=Your usergroup join request was declined
NOTIFICATION_TYPE_cns_username_changed=Your username changed
NOTIFICATION_TYPE_cns_password_changed=Your password changed
NOTIFICATION_TYPE_cns_friend_birthday=Your friend's birthday is today
+NOTIFICATION_TYPE_cns_self_birthday=Happy Birthday to you
NOTIFICATION_TYPE_cns_birthday=A member's birthday today
NOTIFICATION_TYPE_cns_club=New club added
NOTIFICATION_TYPE_cns_member_joined_group=A member joined a usergroup
@@ -822,6 +804,8 @@ NEW_MEMBER_NOTIFICATION_MAIL_SUBJECT={1} has joined {2}
NEW_MEMBER_NOTIFICATION_MAIL=A new member, {1}, has joined {2}. You can view his/her profile at:\n[url="{3}"]{3}[/url]
BIRTHDAY_NOTIFICATION_MAIL_SUBJECT=It's {2}'s birthday
BIRTHDAY_NOTIFICATION_MAIL=It's {{{2}}}'s birthday. Come congratulate them on {1}:\n[url="{4}"]{4}[/url]
+SELF_BIRTHDAY_NOTIFICATION_MAIL_SUBJECT=Happy Birthday
+SELF_BIRTHDAY_NOTIFICATION_MAIL=Happy Birthday {2}, from all the staff at {1}. We hope you enjoy your special day.
COMBINED_BIRTHDAY_NOTIFICATION_MAIL_SUBJECT=Birthday Bonanza
COMBINED_BIRTHDAY_NOTIFICATION_MAIL=It is the birthday of {3} members on {1}. Wish them Happy Birthday...{2}
COMBINED_BIRTHDAY_NOTIFICATION_MAIL_ITEM=\n - {{{2}}} -- [url="{4}"]{4}[/url]