sendemailsummary.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
  20. $shortoptions = 'i:n:au';
  21. $longoptions = array('id=', 'nickname=', 'all', 'universe');
  22. $helptext = <<<END_OF_SENDEMAILSUMMARY_HELP
  23. sendemailsummary.php [options]
  24. Send an email summary of the inbox to users
  25. -i --id ID of user to send summary to
  26. -n --nickname nickname of the user to send summary to
  27. -a --all send summary to all users
  28. -u --universe send summary to all users on all sites
  29. END_OF_SENDEMAILSUMMARY_HELP;
  30. require_once INSTALLDIR.'/scripts/commandline.inc';
  31. if (have_option('u', 'universe')) {
  32. $sn = new Status_network();
  33. if ($sn->find()) {
  34. while ($sn->fetch()) {
  35. $server = $sn->getServerName();
  36. GNUsocial::init($server);
  37. // Different queue manager, maybe!
  38. $qm = QueueManager::get();
  39. $qm->enqueue(1, 'sitesum');
  40. }
  41. }
  42. } else {
  43. $qm = QueueManager::get();
  44. // enqueue summary for user or all users
  45. try {
  46. $user = getUser();
  47. $qm->enqueue($user->id, 'usersum');
  48. } catch (NoUserArgumentException $nuae) {
  49. $qm->enqueue(1, 'sitesum');
  50. }
  51. }