]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch '1.0.x' of gitorious.org:statusnet/mainline into 1.0.x
authorZach Copley <zach@status.net>
Mon, 20 Jun 2011 20:14:19 +0000 (13:14 -0700)
committerZach Copley <zach@status.net>
Mon, 20 Jun 2011 20:14:19 +0000 (13:14 -0700)
* '1.0.x' of gitorious.org:statusnet/mainline: (31 commits)
  Enable TinyMCE for the blog form
  upgrade TinyMCE to 3.4.x
  correctly purify input for Blog_entry
  better management of HTML input
  correctly return the HTML representation of a new blog entry
  Fine-tuning Blog_entry class
  don't double-show summary and content
  move class BlogEntry to Blog_entry for DB_DataObject compliance
  get right output context for BlogEntryListItem
  correct staticGet() declaration
  First coded version of blog plugin
  push regex pattern for UUID to that class
  Localisation updates from http://translatewiki.net.
  Document a few messages I missed.
  Add translator documentation. Broke a few long lines. i18n/L10n updates. Whitespace updates.
  Localisation updates from http://translatewiki.net.
  Add missing translator documentation.
  Update translator documentation. Whitespace updates.
  Fix i18n issues. Cannot use a PHP variable in a gettext messages. Needs to be replaced. Whitespace updates.
  Add translator documentation.
  ...

Conflicts:
plugins/EmailReminder/EmailReminderPlugin.php
plugins/EmailReminder/lib/userinvitereminderhandler.php

1  2 
plugins/EmailReminder/EmailReminderPlugin.php
plugins/EmailReminder/classes/Email_reminder.php
plugins/EmailReminder/lib/userconfirmregreminderhandler.php
plugins/EmailReminder/lib/userinvitereminderhandler.php

index 701d04e01647d76aa86260b40b2fd905d9d0b654,b2fc02d2e88c4d02aedff9ac26bfcc7d2eb22fc6..815537c659f18e4051923f1b122876caca6f89c6
@@@ -114,25 -114,22 +114,25 @@@ class EmailReminderPlugin extends Plugi
      }
  
      /**
 +     * 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);
              } catch (Exception $e) {
              }
          }
  
 -        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);
  
          $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);
      }
              'version'        => STATUSNET_VERSION,
              'author'         => 'Zach Copley',
              'homepage'       => 'http://status.net/wiki/Plugin:EmailReminder',
+             // TRANS: Plugin description.
              'rawdescription' => _m('Send email reminders for various things.')
          );
          return true;
      }
 +
  }
index 58dc2e14609577cbbea5ef36bfb69f6c44b4b2ae,c462e726aa82b87c603f74332f77a5ffa2c16834..29af05a9150c225ca525eca37fdd483dacc3a48b
@@@ -28,6 -28,8 +28,6 @@@
  
  class Email_reminder extends Managed_DataObject
  {
 -    const INVITE_REMINDER   = 'invite'; // @todo Move this to the invite reminder handler
 -
      public $__table = 'email_reminder';
  
      public $type;     // type of reminder
@@@ -46,7 -48,6 +46,6 @@@
       * @param mixed  $v Value to lookup
       *
       * @return QnA_Answer object found, or null for no hits
-      *
       */
      function staticGet($k, $v=null)
      {
      }
  
      /**
 +     * Do we need to send a reminder?
       *
 -     * @param type $type
 -     * @param type $confirm
 -     * @param type $day
 -     * @return type
 +     * @param string $type      type of reminder
 +     * @param Object $object    an object with a 'code' property
 +     *                          (Confirm_address or Invitation)
 +     * @param int    $days      Number of days after the code was created
 +     * @return boolean true if any Email_reminder records were found
       */
 -    static function needsReminder($type, $confirm, $days) {
 +    static function needsReminder($type, $object, $days = null) {
  
          $reminder        = new Email_reminder();
          $reminder->type  = $type;
 -        $reminder->code  = $confirm->code;
 -        $reminder->days  = $days;
 -
 -        $result = $reminder->find(true);
 +        $reminder->code  = $object->code;
 +        if (!empty($days)) {
 +            $reminder->days  = $days;
 +        }
 +        $result = $reminder->find();
  
 -        if (empty($result)) {
 -            return true;
 +        if (!empty($result)) {
 +            return false;
          }
  
 -        return false;
 +        return true;
      }
  
      /**
 +     * Record a record of sending the reminder
       *
 -     * @param type $type
 -     * @param type $confirm
 -     * @param type $day
 -     * @return type
 +     * @param string $type      type of reminder
 +     * @param Object $object    an object with a 'code' property
 +     *                          (Confirm_address or Invitation)
 +     * @param int    $days      Number of days after the code was created
 +     * @return int   $result    row ID of the new reminder record
       */
 -    static function recordReminder($type, $confirm, $days) {
 +    static function recordReminder($type, $object, $days) {
  
          $reminder        = new Email_reminder();
          $reminder->type  = $type;
 -        $reminder->code  = $confirm->code;
 +        $reminder->code  = $object->code;
          $reminder->days  = $days;
          $reminder->sent  = $reminder->created = common_sql_now();
          $result          = $reminder->insert();
          if (empty($result)) {
              common_log_db_error($reminder, 'INSERT', __FILE__);
                  throw new ServerException(
+                     // TRANS: Server exception thrown when a reminder record could not be inserted into the database.
                      _m('Database error inserting reminder record.')
              );
          }
index d8345c10a92d35262ed75b655e1314f78acff58f,eda93a33d5e3e51490aa47460e7d4aee731bed24..f5f3091b6f0bd395c1a03a3eb46d1ae8c43a8205
@@@ -1,5 -1,4 +1,4 @@@
  <?php
  /**
   * StatusNet - the distributed open-source microblogging tool
   *
@@@ -26,6 -25,7 +25,7 @@@
   * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
   * @link      http://status.net/
   */
  if (!defined('STATUSNET')) {
      exit(1);
  }
@@@ -64,34 -64,16 +64,34 @@@ class UserConfirmRegReminderHandler ext
       *
       * @todo abstract this bit further
       *
 -     * @param Confirm_address $confirm
 +     * @param array $regitem confirmation address and any special options
       * @return boolean success value
       */
 -    function sendNextReminder($confirm)
 +    function sendNextReminder($regitem)
      {
 +        list($confirm, $opts) = $regitem;
 +
          $regDate = strtotime($confirm->modified); // Seems like my best bet
          $now     = strtotime('now');
  
          // Days since registration
          $days = ($now - $regDate) / 86499; // 60*60*24 = 86499
 +        // $days = ($now - $regDate) / 120; // Two mins, good for testing
 +
 +        if ($days > 7 && isset($opts['onetime'])) {
 +            // Don't send the reminder if we're past the normal reminder window and
 +            // we've already pestered her at all before
 +            if (Email_reminder::needsReminder(self::REGISTER_REMINDER, $confirm)) {
 +                common_log(LOG_INFO, "Sending one-time registration confirmation reminder to {$confirm->address}", __FILE__);
 +                $subject = _m("One time reminder - please confirm your registration!");
 +                return EmailReminderPlugin::sendReminder(
 +                    self::REGISTER_REMINDER,
 +                    $confirm,
 +                    $subject,
 +                    -1 // special one-time indicator
 +                );
 +            }
 +        }
  
          // Welcome to one of the ugliest switch statement I've ever written
  
          case ($days > 1 && $days < 2):
              if (Email_reminder::needsReminder(self::REGISTER_REMINDER, $confirm, 1)) {
                  common_log(LOG_INFO, "Sending one day registration confirmation reminder to {$confirm->address}", __FILE__);
-                 $subject = _m("Reminder - please confirm your registration!");
+                 // TRANS: Subject for reminder e-mail.
+                 $subject = _m('Reminder - please confirm your registration!');
                  return EmailReminderPlugin::sendReminder(
                      self::REGISTER_REMINDER,
                      $confirm,
                      $subject,
 -                1);
 +                    1
 +                );
              } else {
                  return true;
              }
          case ($days > 3 && $days < 4):
              if (Email_reminder::needsReminder(self::REGISTER_REMINDER, $confirm, 3)) {
                  common_log(LOG_INFO, "Sending three day registration confirmation reminder to {$confirm->address}", __FILE__);
-                 $subject = _m("Second reminder - please confirm your registration!");
+                 // TRANS: Subject for reminder e-mail.
+                 $subject = _m('Second reminder - please confirm your registration!');
                      return EmailReminderPlugin::sendReminder(
                          self::REGISTER_REMINDER,
                          $confirm,
          case ($days > 7 && $days < 8):
              if (Email_reminder::needsReminder(self::REGISTER_REMINDER, $confirm, 7)) {
                  common_log(LOG_INFO, "Sending one week registration confirmation reminder to {$confirm->address}", __FILE__);
-                 $subject = _m("Final reminder - please confirm your registration!");
+                 // TRANS: Subject for reminder e-mail.
+                 $subject = _m('Final reminder - please confirm your registration!');
                  return EmailReminderPlugin::sendReminder(
                      self::REGISTER_REMINDER,
                      $confirm,
          }
          return true;
      }
  }
index 4ca68be686ad753d0fe116818f8681d689219b7a,5e5c6726414950bcad460c9c77c91cdfc6175eb3..70c666178c389a1e5911552a0d64eccfcc654577
@@@ -25,6 -25,7 +25,7 @@@
   * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
   * @link      http://status.net/
   */
  if (!defined('STATUSNET')) {
      exit(1);
  }
@@@ -62,42 -63,25 +63,43 @@@ class UserInviteReminderHandler extend
       *
       * @todo Abstract this stuff further
       *
 -     * @param Invitation $invitation
 +     * @param array $invitem Invitation obj and any special options
       * @return boolean success value
       */
 -    function sendNextReminder($invitation)
 +    function sendNextReminder($invitem)
      {
 +        list($invitation, $opts) = $invitem;
 +
          $invDate = strtotime($invitation->created);
          $now     = strtotime('now');
  
          // Days since first invitation was sent
          $days = ($now - $invDate) / 86499; // 60*60*24 = 86499
 +        // $days = ($now - $regDate) / 120; // Two mins, good for testing
  
          $siteName = common_config('site', 'name');
  
 +        if ($days > 7 && isset($opts['onetime'])) {
 +            // Don't send the reminder if we're past the normal reminder window and
 +            // we've already pestered her at all before
 +            if (Email_reminder::needsReminder(self::INVITE_REMINDER, $invitation)) {
 +                common_log(LOG_INFO, "Sending one-time invitation reminder to {$invitation->address}", __FILE__);
 +                $subject = _m("One time reminder - you have been invited to join {$siteName}!");
 +                return EmailReminderPlugin::sendReminder(
 +                    self::INVITE_REMINDER,
 +                    $invitation,
 +                    $subject,
 +                    -1 // special one-time indicator
 +                );
 +            }
 +        }
 +
          switch($days) {
          case ($days > 1 && $days < 2):
              if (Email_reminder::needsReminder(self::INVITE_REMINDER, $invitation, 1)) {
                  common_log(LOG_INFO, "Sending one day invitation reminder to {$invitation->address}", __FILE__);
-                 $subject = _m("Reminder - you have been invited to join {$siteName}!");
+                 // TRANS: Subject for reminder e-mail. %s is the StatusNet sitename.
+                 $subject = sprintf(_m('Reminder - You have been invited to join %s!'),$siteName);
                  return EmailReminderPlugin::sendReminder(
                      self::INVITE_REMINDER,
                      $invitation,
          case ($days > 3 && $days < 4):
              if (Email_reminder::needsReminder(self::INVITE_REMINDER, $invitation, 3)) {
                  common_log(LOG_INFO, "Sending three day invitation reminder to {$invitation->address}", __FILE__);
-                 $subject = _m("Final reminder - you have been invited to join {$siteName}!");
+                 // TRANS: Subject for reminder e-mail. %s is the StatusNet sitename.
+                 $subject = sprintf(_m('Final reminder - you have been invited to join %s!'),$siteName);
                      return EmailReminderPlugin::sendReminder(
                          self::INVITE_REMINDER,
                          $invitation,
          }
          return true;
      }
  }