예제 #1
0
 function create_task_reminder()
 {
     // Create a reminder for this task based on the priority.
     $current_user =& singleton("current_user");
     // Get the task type
     $taskTypeName = $this->get_value("taskTypeID");
     $label = $this->get_priority_label();
     $reminderInterval = "Day";
     $intervalValue = $this->get_value("priority");
     $taskTypeName == "Parent" and $taskTypeName .= " Task";
     $subject = $taskTypeName . " Reminder: " . $this->get_id() . " " . $this->get_name() . " [" . $label . "]";
     $message = "\n\n" . $subject;
     $message .= "\n\n" . $this->get_url(true);
     $this->get_value("taskDescription") and $message .= "\n\n" . $this->get_value("taskDescription");
     $message .= "\n\n-- \nReminder created by " . $current_user->get_name() . " at " . date("Y-m-d H:i:s");
     $people[] = $this->get_value("personID");
     $label = $this->get_priority_label();
     $reminder = new reminder();
     $reminder->set_value('reminderType', "task");
     $reminder->set_value('reminderLinkID', $this->get_id());
     $reminder->set_value('reminderRecuringInterval', $reminderInterval);
     $reminder->set_value('reminderRecuringValue', $intervalValue);
     $reminder->set_value('reminderSubject', $subject);
     $reminder->set_value('reminderContent', $message);
     $reminder->set_value('reminderAdvNoticeSent', "0");
     if ($this->get_value("dateTargetStart") && $this->get_value("dateTargetStart") != date("Y-m-d")) {
         $date = $this->get_value("dateTargetStart") . " 09:00:00";
         $reminder->set_value('reminderAdvNoticeInterval', "Hour");
         $reminder->set_value('reminderAdvNoticeValue', "24");
     } else {
         $date = date("Y-m-d") . " 09:00:00";
         $reminder->set_value('reminderAdvNoticeInterval', "No");
         $reminder->set_value('reminderAdvNoticeValue', "0");
     }
     $reminder->set_value('reminderTime', $date);
     $reminder->save();
     // the negative is due to ugly reminder internals
     $reminder->update_recipients(array(-REMINDER_METAPERSON_TASK_ASSIGNEE));
 }
예제 #2
0
             $reminder->set_value('reminderRecuringInterval', $_POST["reminder_recuring_interval"]);
             $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");
예제 #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);
 }