X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FEmailReminder%2FEmailReminderPlugin.php;h=9ac6275537afd6535de0a64f4e1aa0f23ae8157b;hb=546a03b5eac5f172d543a889625e2f4de446e8b7;hp=0bb10921b031a24f4eca9ef20ac63ee9c90cdab8;hpb=4989fc72d27b50196eeb9b4082305e929a4c5eaf;p=quix0rs-gnu-social.git diff --git a/plugins/EmailReminder/EmailReminderPlugin.php b/plugins/EmailReminder/EmailReminderPlugin.php index 0bb10921b0..9ac6275537 100644 --- a/plugins/EmailReminder/EmailReminderPlugin.php +++ b/plugins/EmailReminder/EmailReminderPlugin.php @@ -61,32 +61,6 @@ class EmailReminderPlugin extends Plugin 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 * @@ -114,43 +88,53 @@ class EmailReminderPlugin extends Plugin } /** + * 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); @@ -158,7 +142,7 @@ class EmailReminderPlugin extends Plugin $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(); @@ -177,14 +161,15 @@ class EmailReminderPlugin extends Plugin $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); } @@ -194,16 +179,17 @@ class EmailReminderPlugin extends Plugin * @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. 'rawdescription' => _m('Send email reminders for various things.') ); return true; } - + }