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
                $reminder->set_value('reminderRecuringValue', $_POST["reminder_recuring_value"]);
            }
            $reminder->set_value('reminderAdvNoticeSent', '0');
            if (!$_POST["reminder_advnotice_value"]) {
                $reminder->set_value('reminderAdvNoticeInterval', 'No');
                $reminder->set_value('reminderAdvNoticeValue', '0');
            } else {
                $reminder->set_value('reminderAdvNoticeInterval', $_POST["reminder_advnotice_interval"]);
                $reminder->set_value('reminderAdvNoticeValue', $_POST["reminder_advnotice_value"]);
            }
            $reminder->set_value('reminderSubject', $_POST["reminder_subject"]);
            $reminder->set_value('reminderContent', rtrim($_POST["reminder_content"]));
            $reminder->set_value('reminderActive', sprintf("%d", $_POST["reminderActive"]));
            $reminder->save();
            $reminder->update_recipients($recipient_keys);
            $returnToParent = "reminder";
            $reminderID = $reminder->get_id();
            $TPL["message_good"][] = "Reminder saved.";
        } else {
            if ($_POST["reminder_delete"] && $_POST["reminder_id"]) {
                $reminder = new reminder();
                $reminder->set_id($_POST["reminder_id"]);
                $reminder->delete();
            }
        }
        $headers = array("client" => $TPL["url_alloc_client"] . "clientID=" . $parentID . "&sbs_link=reminders", "project" => $TPL["url_alloc_project"] . "projectID=" . $parentID . "&sbs_link=reminders", "task" => $TPL["url_alloc_task"] . "taskID=" . $parentID . "&sbs_link=reminders", "home" => $TPL["url_alloc_home"], "calendar" => $TPL["url_alloc_taskCalendar"] . "personID=" . $_POST["personID"], "list" => $TPL["url_alloc_reminderList"], "reminder" => $TPL["url_alloc_reminder"] . "reminderID=" . $reminderID . "&step=3", "" => $TPL["url_alloc_reminderList"]);
        alloc_redirect($headers[$returnToParent]);
        break;
    default:
        alloc_error("Unrecognized state");
}
Ejemplo n.º 3
0
 function edit_reminder($commands)
 {
     $id = $commands["reminder"];
     $options = $commands;
     $reminder = new reminder();
     if ($id and $id != "new") {
         $reminder->set_id($id);
         $reminder->select();
     } else {
         if ($id == "new") {
             // extra sanity checks, partially filled in reminder isn't much good
             if (!$options['date'] || !$options['subject'] || !$options['recipients']) {
                 $status[] = "err";
                 $message[] = "Missing one of date, subject or recipients.";
                 return array($status, $message);
             }
             if ($options['task']) {
                 $reminder->set_value('reminderType', 'task');
                 $reminder->set_value('reminderLinkID', $options['task']);
             } else {
                 if ($options['project']) {
                     $reminder->set_value('reminderType', 'project');
                     $reminder->set_value('reminderLinkID', $options['project']);
                 } else {
                     if ($options['client']) {
                         $reminder->set_value('reminderLinkID', $options['client']);
                         $reminder->set_value('reminderType', 'client');
                     }
                 }
             }
         }
     }
     // Tear apart the frequency bits
     if ($options['frequency']) {
         list($freq, $units) = sscanf($options['frequency'], "%d%c");
         $freq_units = array('h' => 'Hour', 'd' => 'Day', 'w' => 'Week', 'm' => 'Month', 'y' => 'Year');
         $options['frequency'] = $freq;
         $options['frequency_units'] = $freq_units[strtolower($units)];
     }
     if ($options['notice']) {
         list($freq, $units) = sscanf($options['notice'], "%d%c");
         $freq_units = array('h' => 'Hour', 'd' => 'Day', 'w' => 'Week', 'm' => 'Month', 'y' => 'Year');
         $options['notice'] = $freq;
         $options['notice_units'] = $freq_units[strtolower($units)];
     }
     $fields = $this->get_fields("reminder");
     foreach ($fields as $s => $d) {
         if ($options[$s]) {
             $reminder->set_value($d[0], $options[$s]);
         }
     }
     if (!$reminder->get_value("reminderRecuringInterval")) {
         $reminder->set_value("reminderRecuringInterval", "No");
     }
     if (!$reminder->get_value("reminderAdvNoticeInterval")) {
         $reminder->set_value("reminderAdvNoticeInterval", "No");
     }
     $reminder->save();
     // Deal with recipients
     if ($options['recipients']) {
         list($_x, $recipients) = $reminder->get_recipient_options();
         if ($options['recipients']) {
             $recipients = array_unique(array_merge($recipients, $options['recipients']));
         }
         if ($options['recipients_remove']) {
             $recipients = array_diff($recipients, $options['recipients_remove']);
         }
         $reminder->update_recipients($recipients);
     }
     if (is_object($reminder) && $reminder->get_id()) {
         $status[] = "yay";
         $message[] = "Reminder " . $reminder->get_id() . " saved.";
     } else {
         $status[] = "err";
         $message[] = "Reminder not saved.";
     }
     return array($status, $message);
 }