Exemple #1
0
 function add_notification($tokenActionID, $maxUsed, $name, $desc, $recipients, $datetime = false)
 {
     $current_user =& singleton("current_user");
     $token = new token();
     $token->set_value("tokenEntity", "task");
     $token->set_value("tokenEntityID", $this->get_id());
     $token->set_value("tokenActionID", $tokenActionID);
     $token->set_value("tokenActive", 1);
     $token->set_value("tokenMaxUsed", $maxUsed);
     $token->set_value("tokenCreatedBy", $current_user->get_id());
     $token->set_value("tokenCreatedDate", date("Y-m-d H:i:s"));
     $hash = $token->generate_hash();
     $token->set_value("tokenHash", $hash);
     $token->save();
     if ($token->get_id()) {
         $reminder = new reminder();
         $reminder->set_value("reminderType", "task");
         $reminder->set_value("reminderLinkID", $this->get_id());
         $reminder->set_value("reminderHash", $hash);
         $reminder->set_value("reminderSubject", $name);
         $reminder->set_value("reminderContent", $desc);
         if ($datetime) {
             $reminder->set_value("reminderTime", $datetime);
         }
         $reminder->save();
         if ($reminder->get_id()) {
             foreach ($recipients as $row) {
                 $reminderRecipient = new reminderRecipient();
                 $reminderRecipient->set_value("reminderID", $reminder->get_id());
                 $reminderRecipient->set_value($row["field"], $row["who"]);
                 $reminderRecipient->save();
             }
         }
     }
 }
Exemple #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:
Exemple #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);
 }