Пример #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
 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);
 }