+ $qm->connect('sitesum', 'SiteEmailSummaryHandler');
+ $qm->connect('usersum', 'UserEmailSummaryHandler');
+ return true;
+ }
+
+ /**
+ * Add a checkbox to turn off email summaries
+ *
+ * @param Action $action Action being executed (emailsettings)
+ * @param Profile $scoped Profile for whom settings are configured (current user)
+ *
+ * @return boolean hook value
+ */
+ public function onEndEmailFormData(Action $action, Profile $scoped)
+ {
+ $action->elementStart('li');
+ $action->checkbox('emailsummary',
+ // TRANS: Checkbox label in e-mail preferences form.
+ _m('Send me a periodic summary of updates from my network'),
+ Email_summary_status::getSendSummary($scoped->id));
+ $action->elementEnd('li');
+ return true;
+ }
+
+ /**
+ * Add a checkbox to turn off email summaries
+ *
+ * @param Action $action Action being executed (emailsettings)
+ * @param Profile $scoped Profile for whom settings are configured (current user)
+ *
+ * @return boolean hook value
+ */
+ public function onEndEmailSaveForm(Action $action, Profile $scoped)
+ {
+ $sendSummary = $action->boolean('emailsummary');
+
+ $ess = Email_summary_status::getKV('user_id', $scoped->id);
+
+ if (empty($ess)) {
+
+ $ess = new Email_summary_status();
+
+ $ess->user_id = $scoped->id;
+ $ess->send_summary = $sendSummary;
+ $ess->created = common_sql_now();
+ $ess->modified = common_sql_now();
+
+ $ess->insert();
+
+ } else {
+
+ $orig = clone($ess);
+
+ $ess->send_summary = $sendSummary;
+ $ess->modified = common_sql_now();
+
+ $ess->update($orig);
+ }
+
+ return true;