define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
-$shortoptions = 't:e:au';
-$longoptions = array('type=', 'email=', 'all', 'universe');
+$shortoptions = 't:e:auo';
+$longoptions = array('type=', 'email=', 'all', 'universe', 'onetime');
$helptext = <<<END_OF_SENDEMAILREMINDER_HELP
sendemailreminder.php [options]
-e --email email address to send reminder to
-a --all send reminder to all addresses
-u --universe send reminder to all addresses on all sites
+ -o --onetime send one-time reminder to older addresses
END_OF_SENDEMAILREMINDER_HELP;
);
$type = null;
+$opts = array(); // special options like "onetime"
if (have_option('t', 'type')) {
$type = trim(get_option_value('t', 'type'));
exit(1);
}
+if (have_option('o', 'onetime')) {
+ $opts['onetime'] = true;
+ if (!$quiet) { print "Special one-time reminder mode.\n"; }
+}
+
$reminders = array();
switch($type) {
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();
- foreach ($reminders as $reminder) {
- extract($reminder);
- $qm->enqueue($type, 'siterem');
- if (!$quiet) { print "Sent pending {$type} reminders to all unconfirmed addresses in the known universe.\n"; }
+ try {
+ if ($sn->find()) {
+ while ($sn->fetch()) {
+ try {
+ $server = $sn->getServerName();
+ GNUsocial::init($server);
+ // Different queue manager, maybe!
+ $qm = QueueManager::get();
+ foreach ($reminders as $reminder) {
+ extract($reminder);
+ $qm->enqueue(array($type, $opts), 'siterem');
+ if (!$quiet) { print "Sent pending {$type} reminders for {$server}.\n"; }
+ }
+ } catch (Exception $e) {
+ // keep going
+ common_log(LOG_ERR, "Couldn't init {$server}.\n", __FILE__);
+ if (!$quiet) { print "Couldn't init {$server}.\n"; }
+ continue;
+ }
}
+ if (!$quiet) { print "Done! Reminders sent to all unconfirmed addresses in the known universe.\n"; }
}
+ } catch (Exception $e) {
+ if (!$quiet) { print $e->getMessage() . "\n"; }
+ common_log(LOG_ERR, $e->getMessage(), __FILE__);
+ exit(1);
}
} else {
$qm = QueueManager::get();
if (empty($result)) {
throw new Exception("No confirmation code found for {$address}.");
}
- $qm->enqueue($confirm, $utransport);
+ $qm->enqueue(array($confirm, $opts), $utransport);
if (!$quiet) { print "Sent all pending {$type} reminder to {$address}.\n"; }
}
} else if (have_option('a', 'all')) {
foreach ($reminders as $reminder) {
extract($reminder);
- $qm->enqueue($type, 'siterem');
+ $qm->enqueue(array($type, $opts), 'siterem');
if (!$quiet) { print "Sent pending {$type} reminders to all unconfirmed addresses on the site.\n"; }
}
} else {