return true;
}
- /**
- * Load related modules when needed
- *
- * @param string $cls Name of the class to be loaded
- *
- * @return boolean hook value; true means continue processing, false
- * means stop.
- */
- function onAutoload($cls) {
- $base = dirname(__FILE__);
- $lower = strtolower($cls);
-
- $files = array("$base/classes/$cls.php",
- "$base/lib/$lower.php");
- if (substr($lower, -6) == 'action') {
- $files[] = "$base/actions/" . substr($lower, 0, -6) . ".php";
- }
- foreach ($files as $file) {
- if (file_exists($file)) {
- include_once $file;
- return false;
- }
- }
- return true;
- }
-
/**
* Register our queue handlers
*
}
/**
+ * Send a reminder and record doing so
*
- * @param type $object
- * @param type $subject
- * @param type $day
+ * @param string $type type of reminder
+ * @param mixed $object Confirm_address or Invitation object
+ * @param string $subject subjct of the email reminder
+ * @param int $day number of days
*/
static function sendReminder($type, $object, $subject, $day)
{
- common_debug("QQQQQ sendReminder() enter ... ", __FILE__);
-
- $title = "{$type}-{$day}";
-
- common_debug("QQQQ title = {$title}", __FILE__);
+ // XXX: -1 is a for the special one-time reminder (maybe 30) would be
+ // better? Like >= 30 days?
+ if ($day == -1) {
+ $title = "{$type}-onetime";
+ } else {
+ $title = "{$type}-{$day}";
+ }
// Record the fact that we sent a reminder
if (self::sendReminderEmail($type, $object, $subject, $title)) {
- common_debug("Recording reminder record for {$object->address}", __FILE__);
try {
Email_reminder::recordReminder($type, $object, $day);
+ common_log(
+ LOG_INFO,
+ "Sent {$type} reminder to {$object->address}.",
+ __FILE__
+ );
} catch (Exception $e) {
// oh noez
common_log(LOG_ERR, $e->getMessage(), __FILE__);
}
}
- common_debug("QQQQQ sendReminder() exit ... ", __FILE__);
-
return true;
}
/**
+ * Send a real live email reminder
*
- * @param type $object
- * @param type $subject
- * @param type $title
- * @return type
+ * @todo This would probably be better as two or more sep functions
+ *
+ * @param string $type type of reminder
+ * @param mixed $object Confirm_address or Invitation object
+ * @param string $subject subjct of the email reminder
+ * @param string $title title of the email reminder
+ * @return boolean true if the email subsystem doesn't explode
*/
- static function sendReminderEmail($type, $object, $subject, $title=null) {
+ static function sendReminderEmail($type, $object, $subject, $title = null) {
$sitename = common_config('site', 'name');
$recipients = array($object->address);
$inviterurl = null;
if ($type == UserInviteReminderHandler::INVITE_REMINDER) {
- $user = User::staticGet($object->user_id);
+ $user = User::getKV($object->user_id);
if (!empty($user)) {
$profile = $user->getProfile();
$inviter = $profile->getBestName();
$template = DocFile::forTitle($title, DocFile::mailPaths());
- $body = $template->toHTML(
- array(
- 'confirmurl' => $confirmUrl,
- 'inviter' => $inviter,
- 'inviterurl' => $inviterUrl
- // @todo private invitation message
- )
- );
+ $blankfillers = array('confirmurl' => $confirmUrl);
+
+ if ($type == UserInviteReminderHandler::INVITE_REMINDER) {
+ $blankfillers['inviter'] = $inviter;
+ $blankfillers['inviterurl'] = $inviterUrl;
+ // @todo private invitation message?
+ }
+
+ $body = $template->toHTML($blankfillers);
return mail_send($recipients, $headers, $body);
}
* @param type $versions
* @return type
*/
- function onPluginVersion(&$versions)
+ function onPluginVersion(array &$versions)
{
$versions[] = array(
'name' => 'EmailReminder',
- 'version' => STATUSNET_VERSION,
+ 'version' => GNUSOCIAL_VERSION,
'author' => 'Zach Copley',
'homepage' => 'http://status.net/wiki/Plugin:EmailReminder',
// TRANS: Plugin description.
);
return true;
}
+
}