]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/EmailSummary/scripts/sendemailsummary.php
Merge remote-tracking branch 'upstream/master' into social-master
[quix0rs-gnu-social.git] / plugins / EmailSummary / scripts / sendemailsummary.php
1 <?php
2 /*
3  * StatusNet - a distributed open-source microblogging tool
4  * Copyright (C) 2010, StatusNet, Inc.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Affero General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Affero General Public License for more details.
15  *
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
21
22 $shortoptions = 'i:n:au';
23 $longoptions = array('id=', 'nickname=', 'all', 'universe');
24
25 $helptext = <<<END_OF_SENDEMAILSUMMARY_HELP
26 sendemailsummary.php [options]
27 Send an email summary of the inbox to users
28
29  -i --id       ID of user to send summary to
30  -n --nickname nickname of the user to send summary to
31  -a --all      send summary to all users
32  -u --universe send summary to all users on all sites
33
34 END_OF_SENDEMAILSUMMARY_HELP;
35
36 require_once INSTALLDIR.'/scripts/commandline.inc.php';
37
38 if (have_option('u', 'universe')) {
39     $sn = new Status_network();
40     if ($sn->find()) {
41         while ($sn->fetch()) {
42             $server = $sn->getServerName();
43             GNUsocial::init($server);
44             // Different queue manager, maybe!
45             $qm = QueueManager::get();
46             $qm->enqueue(1, 'sitesum');
47         }
48     }
49 } else {
50     $qm = QueueManager::get();
51     // enqueue summary for user or all users
52     try {
53         $user = getUser();
54         $qm->enqueue($user->id, 'usersum');
55     } catch (NoUserArgumentException $nuae) {
56         $qm->enqueue(1, 'sitesum');
57     }
58 }