Beispiel #1
0
 /**
  * A generic method to edit entities
  * @param string $entity which type of entity to edit
  * @param integer $id the id of the entity
  * @param array $options the edit options see email/lib/command.inc.php for the various options
  * @return array success or failure object
  */
 public function edit_entity($entity, $id, $options = false)
 {
     $options[$entity] = $id;
     if (strtolower($options[$entity]) == "help") {
         return array("status" => "msg", "message" => command::get_help($entity));
     } else {
         if ($options) {
             $command = new command();
             return $command->run_commands($options);
         }
     }
 }
Beispiel #2
0
 function process_one_email($email_receive)
 {
     $current_user =& singleton("current_user");
     $orig_current_user =& $current_user;
     // wrap db queries in a transaction
     $db = new db_alloc();
     $db->start_transaction();
     inbox::change_current_user($email_receive->mail_headers["from"]);
     $current_user =& singleton("current_user");
     $email_receive->save_email();
     // Run any commands that have been embedded in the email
     $command = new command();
     $fields = $command->get_fields();
     $commands = $email_receive->get_commands($fields);
     try {
         $command->run_commands($commands, $email_receive);
     } catch (Exception $e) {
         $current_user =& $orig_current_user;
         singleton("current_user", $current_user);
         $db->query("ROLLBACK");
         $failed = true;
         throw new Exception($e);
     }
     // Commit the db, and move the email into its storage location eg: INBOX.task1234
     if (!$failed && !$TPL["message"]) {
         $db->commit();
         $email_receive->archive();
     }
     // Put current_user back to normal
     $current_user =& $orig_current_user;
     singleton("current_user", $current_user);
 }