示例#1
0
 function make_interested_parties($entity, $entityID, $encoded_parties = array())
 {
     // Nuke entries from interestedParty
     $db = new db_alloc();
     $db->start_transaction();
     // Add entries to interestedParty
     if (is_array($encoded_parties)) {
         foreach ($encoded_parties as $encoded) {
             $info = interestedParty::get_decoded_interested_party_identifier($encoded);
             $info["entity"] = $entity;
             $info["entityID"] = $entityID;
             $info["emailAddress"] or $info["emailAddress"] = $info["email"];
             $ipIDs[] = interestedParty::add_interested_party($info);
         }
     }
     $q = prepare("UPDATE interestedParty\n                     SET interestedPartyActive = 0\n                   WHERE entity = '%s'\n                     AND entityID = %d", $entity, $entityID);
     $ipIDs and $q .= " AND " . sprintf_implode(" AND ", "interestedPartyID != %d", $ipIDs);
     $db->query($q);
     $db->commit();
 }
示例#2
0
        } else {
            //$email_receive->mark_seen(); in alouy we want the emails to still appear new (as opposed to alloc with receiveEmail.php)
            $email_receive->archive();
        }
        // Else if we have a key, append to comment
    } else {
        // Skip over emails that are from alloc. These emails are kept only for
        // posterity and should not be parsed and downloaded and re-emailed etc.
        if (same_email_address($email_receive->mail_headers["from"], ALLOC_DEFAULT_FROM_ADDRESS)) {
            $email_receive->mark_seen();
            $email_receive->archive();
        } else {
            inbox::process_one_email($email_receive);
        }
    }
} catch (Exception $e) {
    // There may have been a database error, so let the database know it can run this next bit
    db_alloc::$stop_doing_queries = false;
    // Try forwarding the errant email
    try {
        $email_receive->forward(config::get_config_item("allocEmailAdmin"), "Email command failed", "\n" . $e->getMessage() . "\n\n" . $e->getTraceAsString());
        // If that fails, try last-ditch email send
    } catch (Exception $e) {
        mail(config::get_config_item("allocEmailAdmin"), "Email command failed(2)", "\n" . $e->getMessage() . "\n\n" . $e->getTraceAsString());
    }
}
// Commit the db, and move the email into its storage location eg: INBOX.task1234
$db->commit();
//$email_receive->archive();
$email_receive->expunge();
$email_receive->close();
示例#3
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);
 }