Example #1
0
 function get_help($type)
 {
     $message = ucwords($type) . " fields:";
     $fields = command::get_fields($type);
     foreach ((array) $fields as $k => $arr) {
         $message .= "\n      " . $k . ":\t" . $arr[1];
     }
     return $message;
 }
Example #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);
 }