3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2010, StatusNet, Inc.
6 * Sends an email summary of the inbox to users in the network
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Affero General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Affero General Public License for more details.
20 * You should have received a copy of the GNU Affero General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 * @author Evan Prodromou <evan@status.net>
26 * @copyright 2010 StatusNet, Inc.
27 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
28 * @link http://status.net/
31 if (!defined('STATUSNET')) {
36 * Plugin for sending email summaries to users
40 * @author Brion Vibber <brionv@status.net>
41 * @author Evan Prodromou <evan@status.net>
42 * @copyright 2010 StatusNet, Inc.
43 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
44 * @link http://status.net/
46 class EmailSummaryPlugin extends Plugin
49 * Database schema setup
51 * @return boolean hook value
53 function onCheckSchema()
55 $schema = Schema::get();
57 // For storing user-submitted flags on profiles
58 $schema->ensureTable('email_summary_status', Email_summary_status::schemaDef());
63 * Version info for this plugin
65 * @param array &$versions array of version data
67 * @return boolean hook value; true means continue processing, false means stop.
69 function onPluginVersion(&$versions)
71 $versions[] = array('name' => 'EmailSummary',
72 'version' => GNUSOCIAL_VERSION,
73 'author' => 'Evan Prodromou',
74 'homepage' => 'http://status.net/wiki/Plugin:EmailSummary',
76 // TRANS: Plugin description.
77 _m('Send an email summary of the inbox to users.'));
82 * Register our queue handlers
84 * @param QueueManager $qm Current queue manager
86 * @return boolean hook value
88 function onEndInitializeQueueManager($qm)
90 $qm->connect('sitesum', 'SiteEmailSummaryHandler');
91 $qm->connect('usersum', 'UserEmailSummaryHandler');
96 * Add a checkbox to turn off email summaries
98 * @param Action $action Action being executed (emailsettings)
100 * @return boolean hook value
102 function onEndEmailFormData($action)
104 $user = common_current_user();
106 $action->elementStart('li');
107 $action->checkbox('emailsummary',
108 // TRANS: Checkbox label in e-mail preferences form.
109 _m('Send me a periodic summary of updates from my network'),
110 Email_summary_status::getSendSummary($user->id));
111 $action->elementEnd('li');
116 * Add a checkbox to turn off email summaries
118 * @param Action $action Action being executed (emailsettings)
120 * @return boolean hook value
122 function onEndEmailSaveForm($action)
124 $sendSummary = $action->boolean('emailsummary');
126 $user = common_current_user();
130 $ess = Email_summary_status::getKV('user_id', $user->id);
134 $ess = new Email_summary_status();
136 $ess->user_id = $user->id;
137 $ess->send_summary = $sendSummary;
138 $ess->created = common_sql_now();
139 $ess->modified = common_sql_now();
147 $ess->send_summary = $sendSummary;
148 $ess->modified = common_sql_now();