示例#1
0
 function add_interested_parties($commentID, $ip = array(), $op = array())
 {
     // We send this email to the default from address, so that a copy of the
     // original email is kept. The receiveEmail.php script will see that this
     // email is *from* the same address, and will then skip over it, when going
     // through the new emails.
     if (defined("ALLOC_DEFAULT_FROM_ADDRESS") && ALLOC_DEFAULT_FROM_ADDRESS) {
         list($from_address, $from_name) = parse_email_address(ALLOC_DEFAULT_FROM_ADDRESS);
         $emailRecipients[] = $from_address;
     }
     interestedParty::make_interested_parties("comment", $commentID, $ip);
     $emailRecipients[] = "interested";
     // Other parties that are added on-the-fly
     foreach ((array) $op as $email => $info) {
         if ($email && in_str("@", $email)) {
             unset($lt, $gt);
             // used above
             $str = $info["name"];
             $str and $str .= " ";
             $str and $lt = "<";
             $str and $gt = ">";
             $str .= $lt . str_replace(array("<", ">"), "", $email) . $gt;
             $emailRecipients[] = $str;
             // Add a new client contact
             if ($info["addContact"] && $info["clientID"]) {
                 $q = prepare("SELECT * FROM clientContact WHERE clientID = %d AND clientContactEmail = '%s'", $info["clientID"], trim($email));
                 $db = new db_alloc();
                 if (!$db->qr($q)) {
                     $cc = new clientContact();
                     $cc->set_value("clientContactName", trim($info["name"]));
                     $cc->set_value("clientContactEmail", trim($email));
                     $cc->set_value("clientID", sprintf("%d", $info["clientID"]));
                     $cc->save();
                 }
             }
             // Add the person to the interested parties list
             if ($info["addIP"] && !interestedParty::exists("comment", $commentID, trim($email))) {
                 $interestedParty = new interestedParty();
                 $interestedParty->set_value("fullName", trim($info["name"]));
                 $interestedParty->set_value("emailAddress", trim($email));
                 $interestedParty->set_value("entityID", $commentID);
                 $interestedParty->set_value("entity", "comment");
                 $interestedParty->set_value("external", $info["internal"] ? "0" : "1");
                 $interestedParty->set_value("interestedPartyActive", "1");
                 if (is_object($cc) && $cc->get_id()) {
                     $interestedParty->set_value("clientContactID", $cc->get_id());
                 }
                 $interestedParty->save();
             }
         }
     }
     return $emailRecipients;
 }
示例#2
0
        $client->set_value("clientModifiedUser", $current_user->get_id());
        $client->save();
        if ($client->get_id()) {
            if (rtrim($data[9])) {
                $comment = new comment();
                $comment->set_value("commentMaster", "client");
                $comment->set_value("commentMasterID", $client->get_id());
                $comment->set_value("commentType", "client");
                $comment->set_value("commentLinkID", $client->get_id());
                $comment->set_value("comment", $data[9]);
                $comment->save();
                $comment_id = $comment->get_id();
            }
            if ($data[10] || $data[11]) {
                $cc = new clientContact();
                $cc->set_value("clientID", $client->get_id());
                $cc->set_value("primaryContact", 1);
                $cc->set_value("clientContactName", $data[10]);
                $cc->set_value("clientContactEmail", $data[11]);
                $cc->save();
                $cc_id = $cc->get_id();
            }
        }
        $x++;
        echo "<br>" . $client->get_id() . " --- " . $cc_id . " --- " . $comment_id;
        if ($x > 4) {
            //die();
        }
    }
    fclose($handle);
}