]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/EmailSummary/sendemailsummary.php
Merge branch '1.0.x' into testing
[quix0rs-gnu-social.git] / plugins / EmailSummary / sendemailsummary.php
index 37bfdcfbd11519011e77919f6341d1f0ae27b3f4..01c11a210a009c6edbba4cf2a752c6966ca0db48 100644 (file)
@@ -1,4 +1,3 @@
-#!/usr/bin/env php
 <?php
 /*
  * StatusNet - a distributed open-source microblogging tool
 
 define('INSTALLDIR', realpath(dirname(__FILE__) . '/../..'));
 
-$shortoptions = 'i:n:a';
-$longoptions = array('id=', 'nickname=', 'all');
+$shortoptions = 'i:n:au';
+$longoptions = array('id=', 'nickname=', 'all', 'universe');
 
 $helptext = <<<END_OF_SENDEMAILSUMMARY_HELP
 sendemailsummary.php [options]
 Send an email summary of the inbox to users
 
-  -i --id       ID of user to send summary to
-  -n --nickname nickname of the user to send summary to
-  -a --all      send summary to all users
+ -i --id       ID of user to send summary to
+ -n --nickname nickname of the user to send summary to
+ -a --all      send summary to all users
+ -u --universe send summary to all users on all sites
 
 END_OF_SENDEMAILSUMMARY_HELP;
 
 require_once INSTALLDIR.'/scripts/commandline.inc';
 
-$qm = QueueManager::get();
-
-// enqueue summary for user or all users
-
-try {
-    $user = getUser();
-    $qm->enqueue($user->id, 'usersum');
-} catch (NoUserArgumentException $nuae) {
-    $qm->enqueue(null, 'sitesum');
+if (have_option('u', 'universe')) {
+    $sn = new Status_network();
+    if ($sn->find()) {
+        while ($sn->fetch()) {
+            $server = $sn->getServerName();
+            StatusNet::init($server);
+            // Different queue manager, maybe!
+            $qm = QueueManager::get();
+            $qm->enqueue(1, 'sitesum');
+        }
+    }
+} else {
+    $qm = QueueManager::get();
+    // enqueue summary for user or all users
+    try {
+        $user = getUser();
+        $qm->enqueue($user->id, 'usersum');
+    } catch (NoUserArgumentException $nuae) {
+        $qm->enqueue(1, 'sitesum');
+    }
 }