]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/EmailReminder/classes/Email_reminder.php
Merge branch '1.0.x' of gitorious.org:statusnet/mainline into 1.0.x
[quix0rs-gnu-social.git] / plugins / EmailReminder / classes / Email_reminder.php
index c462e726aa82b87c603f74332f77a5ffa2c16834..29af05a9150c225ca525eca37fdd483dacc3a48b 100644 (file)
@@ -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
@@ -55,40 +53,45 @@ class Email_reminder extends Managed_DataObject
     }
 
     /**
+     * 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();