function make_token_add_comment_from_email() { $current_user =& singleton("current_user"); if (!is_object($current_user) || !$current_user->get_id()) { alloc_error("Cannot make token, current_user is not set.", true); } $token = new token(); $token->set_value("tokenEntity", "comment"); $token->set_value("tokenEntityID", $this->get_id()); $token->set_value("tokenActionID", 2); $token->set_value("tokenActive", 1); $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(); return $hash; }
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(); } } } }