Ejemplo n.º 1
0
 function add_reopen_reminder($date)
 {
     $rows = $this->get_reopen_reminders();
     // If this reopen event already exists, do nothing
     // Allows the form to be saved without changing anything
     // the 8:30 is the same as creation, below.
     if ($date) {
         $check_date = strtotime($date . " 08:30:00");
         foreach ($rows as $r) {
             if (strtotime($r['reminderTime']) == $check_date) {
                 return;
             }
         }
     }
     foreach ($rows as $r) {
         $reminder = new reminder();
         $reminder->set_id($r['rID']);
         $reminder->select();
         $reminder->deactivate();
     }
     // alloc-cli can pass 'null' to kill future reopening
     // Removing the field in the web UI does the same
     if ($check_date && $date != 'null') {
         $tokenActionID = 4;
         //$maxUsed = 1; nope, so people can have recurring reminders
         $name = "Task reopened: " . $this->get_name(array("prefixTaskID" => true));
         $desc = "This reminder will have automatically reopened this task, if it was pending:\n\n" . $this->get_name(array("prefixTaskID" => true));
         $recipients = array(array("field" => "metaPersonID", "who" => -2), array("field" => "metaPersonID", "who" => -3));
         if (strlen($date) <= "10") {
             $date .= " 08:30:00";
         }
         $this->add_notification($tokenActionID, $maxUsed, $name, $desc, $recipients, $date);
     }
 }
Ejemplo n.º 2
0
$query = prepare("SELECT *\n                    FROM reminder\n                   WHERE reminderActive = 1\n                     AND reminderAdvNoticeSent = 0\n                     AND NOW() > \n                         CASE\n                           WHEN reminderAdvNoticeInterval = 'Minute' THEN DATE_SUB(reminderTime, INTERVAL reminderAdvNoticeValue MINUTE)\n                           WHEN reminderAdvNoticeInterval = 'Hour'   THEN DATE_SUB(reminderTime, INTERVAL reminderAdvNoticeValue HOUR)\n                           WHEN reminderAdvNoticeInterval = 'Day'    THEN DATE_SUB(reminderTime, INTERVAL reminderAdvNoticeValue DAY)\n                           WHEN reminderAdvNoticeInterval = 'Week'   THEN DATE_SUB(reminderTime, INTERVAL reminderAdvNoticeValue WEEK)\n                           WHEN reminderAdvNoticeInterval = 'No'     THEN NULL\n                         END\n                 ");
$db->query($query);
while ($db->next_record()) {
    $reminder = new reminder();
    $reminder->read_db_record($db);
    //echo "<br>Adv: ".$reminder->get_id();
    $current_user = new person();
    $current_user->load_current_user($db->f('reminderCreatedUser'));
    singleton("current_user", $current_user);
    if (!$reminder->is_alive()) {
        $reminder->deactivate();
    } else {
        $reminder->mail_advnotice();
    }
}
// do reminders
$query = prepare("SELECT *\n                    FROM reminder\n                   WHERE reminderActive = 1\n                     AND (reminderTime IS NULL OR NOW() > reminderTime)\n                 ");
$db->query($query);
while ($db->next_record()) {
    $reminder = new reminder();
    $reminder->read_db_record($db);
    //echo "<br>Rem: ".$reminder->get_id();
    $current_user = new person();
    $current_user->load_current_user($db->f('reminderCreatedUser'));
    singleton("current_user", $current_user);
    if (!$reminder->is_alive()) {
        $reminder->deactivate();
    } else {
        $reminder->mail_reminder();
    }
}