Exemplo n.º 1
0
 /**
  * Get the raw content through a DB call
  * $param string The unique mail_id
  * $return string The complete raw email
  */
 function getRawContent($mail_id)
 {
     $db = new DBEngine();
     $this->raw = $db->get_raw_mail($mail_id, $this->recipient);
     // Mark read
     if (in_array($this->recipient, $_SESSION['sessionMail']) && $this->raw) {
         $db->update_msgrcpt_rs($mail_id, $this->recipient, 'v');
     }
 }
Exemplo n.º 2
0
/**
* Update messages function
* @param string $content_type 'B', 'S', ...
* @param array $emailaddresses recipient email address(es)
* @param array $mail_id_array containing mail_id of messages to be deleted
* @param bool $all false (default) or true, if true all messages will be deleted
* @result return array of messages whose release failed
*/
function updateMessages($flag, $content_type, $emailaddresses, $mail_id_array, $all = false)
{
    $result_array = array();
    $db = new DBEngine();
    // Set autocommit to false to improve speed of $flag set
    $result = $db->db->autoCommit(false);
    $db->check_for_error($result, 'PEAR DB autoCommit(false)');
    if ($all) {
        $res = $db->get_user_messages($content_type, $emailaddresses, 'msgs.time_num', 'DESC', '', false, 0, 0, true);
        for ($i = 0; is_array($res) && $i < count($res); $i++) {
            $rs = $res[$i];
            if (Auth::isMailAdmin() || in_array($rs['email'], $emailaddresses)) {
                if (!$db->update_msgrcpt_rs($rs['mail_id'], $rs['email'], $flag)) {
                    $rs = $result[0];
                    $result_array[$i] = array("mail_id" => $mail_id, "from_addr" => $rs['from_addr'], "subject" => $rs['subject'], "time_num" => $rs['time_num'], "spam_level" => $rs['spam_level'], "status" => "Error: " . $db->get_err());
                }
            } else {
                continue;
            }
        }
    } else {
        $i = 0;
        foreach ($mail_id_array as $mail_id_recip) {
            // Get mail_id and recipient email address
            //$temp = preg_split('/_/', $mail_id_recip, 2);
            //$mail_id = $temp[0];
            //$recip_email = $temp[1];
            $mail_id = substr($mail_id_recip, 0, 12);
            $recip_email = substr($mail_id_recip, 13);
            // Check if logged in user is admin or logged in user is trying to delete his own messages
            if (Auth::isMailAdmin() || in_array($recip_email, $emailaddresses)) {
                $result = $db->get_message($recip_email, $mail_id);
            } else {
                continue;
            }
            if (!$db->update_msgrcpt_rs($mail_id, $recip_email, $flag)) {
                $rs = $result[0];
                $result_array[$i] = array("mail_id" => $mail_id, "from_addr" => $rs['from_addr'], "subject" => $rs['subject'], "time_num" => $rs['time_num'], "spam_level" => $rs['spam_level'], "status" => "Error: " . $db->get_err());
                $i++;
            }
        }
    }
    // Commit, then set autocommit back to true
    $result = $db->db->commit();
    $db->check_for_error($result, 'PEAR DB commit()');
    $result = $db->db->autoCommit(true);
    $db->check_for_error($result, 'PEAR DB autoCommit(true)');
    // Return array of messages whose release failed
    return $result_array;
}