function updateGlobalNotification($global_notification_id, $data)
 {
     $dao = new ArtifactGlobalNotificationDao(CodendiDataAccess::instance());
     $feedback = '';
     $arr_email_address = split('[,;]', $data['addresses']);
     if (!util_validateCCList($arr_email_address, $feedback, false)) {
         $GLOBALS['Response']->addFeedback('error', $feedback);
     } else {
         $data['addresses'] = util_cleanup_emails(implode(', ', $arr_email_address));
         return $dao->modify($global_notification_id, $data);
     }
     return false;
 }
Esempio n. 2
0
 /**
  * Delete old cc list and add new email instead
  *
  * @param email: list of email addresses
  * @param comment: comment for these addresses
  *
  * @return boolean
  */
 function updateCC($email, $comment)
 {
     global $Language;
     $user_id = user_isloggedin() ? user_getid() : 100;
     $arr_email = util_split_emails($email);
     $date = time();
     $ok = true;
     $changed = false;
     if (!util_validateCCList($arr_email, $message)) {
         exit_error($Language->getText('tracker_index', 'cc_list_invalid'), $message);
     }
     //calculate old_values to put into artifact_history
     $old_value = $this->getCCEmails();
     $new_value = join(',', $arr_email);
     //look if there is really something to do or not
     list($deleted_values, $added_values) = util_double_diff_array(explode(",", $old_value), $arr_email);
     if (count($deleted_values) == 0 && count($added_values) == 0) {
         return true;
     }
     if (!$this->deleteAllCC()) {
         $GLOBALS['Response']->addFeedback('error', $Language->getText('tracker_common_artifact', 'prob_cc_list', $this->getID()));
         $ok = false;
     }
     reset($arr_email);
     while (list(, $cc) = each($arr_email)) {
         $changed = true;
         $res = $this->insertCC($cc, $user_id, $comment, $date);
         if (!$res) {
             $ok = false;
         }
     }
     if (!$ok) {
         $GLOBALS['Response']->addFeedback('error', $Language->getText('tracker_common_artifact', 'cc_add_fail'));
     } else {
         $this->addHistory('cc', $old_value, $new_value);
     }
     return $ok;
 }
 protected function updateGlobalNotification($global_notification_id, $data)
 {
     $feedback = '';
     $arr_email_address = split('[,;]', $data['addresses']);
     if (!util_validateCCList($arr_email_address, $feedback, false)) {
         $GLOBALS['Response']->addFeedback('error', $feedback);
     } else {
         $data['addresses'] = util_cleanup_emails(implode(', ', $arr_email_address));
         return $this->getGlobalDao()->modify($global_notification_id, $data);
     }
     return false;
 }
Esempio n. 4
0
function plugin_forumml_process_mail($plug, $reply = false)
{
    $request =& HTTPRequest::instance();
    $hp =& ForumML_HTMLPurifier::instance();
    // Instantiate a new Mail class
    $mail =& new Mail();
    // Build mail headers
    $to = mail_get_listname_from_list_id($request->get('list')) . "@" . $GLOBALS['sys_lists_host'];
    $mail->setTo($to);
    $from = user_getrealname(user_getid()) . " <" . user_getemail(user_getid()) . ">";
    $mail->setFrom($from);
    $vMsg = new Valid_Text('message');
    if ($request->valid($vMsg)) {
        $message = $request->get('message');
    }
    $subject = $request->get('subject');
    $mail->setSubject($subject);
    if ($reply) {
        // set In-Reply-To header
        $hres = plugin_forumml_get_message_headers($request->get('reply_to'));
        $reply_to = db_result($hres, 0, 'value');
        $mail->addAdditionalHeader("In-Reply-To", $reply_to);
    }
    $continue = true;
    if ($request->validArray(new Valid_Email('ccs')) && $request->exist('ccs')) {
        $cc_array = array();
        $idx = 0;
        foreach ($request->get('ccs') as $cc) {
            if (trim($cc) != "") {
                $cc_array[$idx] = $hp->purify($cc, CODENDI_PURIFIER_FULL);
                $idx++;
            }
        }
        // Checks sanity of CC List
        $err = '';
        if (!util_validateCCList($cc_array, $err)) {
            $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_forumml', 'invalid_mail', $err));
            $continue = false;
        } else {
            // add list of cc users to mail mime
            if (count($cc_array) > 0) {
                $cc_list = util_normalize_emails(implode(',', $cc_array));
                $mail->setCc($cc_list, true);
            }
        }
    }
    if ($continue) {
        // Process attachments
        // Define boundaries as specified in RFC:
        // http://www.w3.org/Protocols/rfc1341/7_2_Multipart.html
        $boundary = '----=_NextPart';
        $boundaryStart = '--' . $boundary;
        $boundaryEnd = '--' . $boundary . '--';
        // Attachments headers
        if (isset($_FILES["files"]) && count($_FILES["files"]['name']) > 0) {
            $attachment = "";
            $text = "This is a multi-part message in MIME format.\n";
            $text = "{$boundaryStart}\n";
            $text .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
            $text .= "Content-Transfer-Encoding: 8bit\n\n";
            $text .= $message;
            $text .= "\n\n";
            foreach ($_FILES["files"]['name'] as $i => $fileName) {
                $attachment .= "{$boundaryStart}\n";
                $attachment .= "Content-Type:" . $_FILES["files"]["type"][$i] . "; name=" . $fileName . "\n";
                $attachment .= "Content-Transfer-Encoding: base64\n";
                $attachment .= "Content-Disposition: attachment; filename=" . $fileName . "\n\n";
                $attachment .= chunk_split(base64_encode(file_get_contents($_FILES["files"]["tmp_name"][$i])));
            }
            $attachment .= "\n{$boundaryEnd}\n";
            $body = $text . $attachment;
            // force MimeType to multipart/mixed as default (when instantiating new Mail object) is text/plain
            $mail->setMimeType('multipart/mixed; boundary="' . $boundary . '"');
            $mail->addAdditionalHeader("MIME-Version", "1.0");
        } else {
            $body = $message;
        }
        $mail->setBody($body);
        if ($mail->send()) {
            $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_forumml', 'mail_succeed'));
        } else {
            $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_forumml', 'mail_fail'));
            $continue = false;
        }
    }
    return $continue;
}
Esempio n. 5
0
 //
 //      Modify several Artifacts
 //
 // Check if users can update anonymously
 if (!user_isloggedin() && !$ath->allowsAnon()) {
     exit_not_logged_in();
 }
 if (!$ath->userIsAdmin()) {
     exit_permission_denied();
     return;
 }
 // First check parameters
 // CC
 $add_cc = $request->get('add_cc');
 $array_add_cc = split('[,;]', $add_cc);
 if ($add_cc && !util_validateCCList($array_add_cc, $message)) {
     exit_error($Language->getText('tracker_index', 'cc_list_invalid'), $message);
 }
 // Files
 if (isset($_FILES['input_file']['error']) && $_FILES['input_file']['error'] != UPLOAD_ERR_NO_FILE && !util_check_fileupload($_FILES['input_file']['tmp_name'])) {
     exit_error($Language->getText('global', 'error'), $Language->getText('tracker_index', 'invalid_filename'));
 }
 $report_id = $request->get('report_id');
 if ($report_id) {
     // Create factories
     $report_fact = new ArtifactReportFactory();
     // Create the HTML report object
     $art_report_html = $report_fact->getArtifactReportHtml($report_id, $atid);
     $query = $art_field_fact->extractFieldList(true, 'query_');
     $advsrch = $request->get('advsrch');
     $art_report_html->getQueryElements($query, $advsrch, $from, $where);
Esempio n. 6
0
function plugin_forumml_process_mail($plug, $reply = false)
{
    $request =& HTTPRequest::instance();
    $hp =& ForumML_HTMLPurifier::instance();
    // Instantiate a new Mail class
    $mail = new Codendi_Mail();
    // Build mail headers
    $to = mail_get_listname_from_list_id($request->get('list')) . "@" . $GLOBALS['sys_lists_host'];
    $mail->setTo($to);
    $from = user_getrealname(user_getid()) . " <" . user_getemail(user_getid()) . ">";
    $mail->setFrom($from);
    $vMsg = new Valid_Text('message');
    if ($request->valid($vMsg)) {
        $message = $request->get('message');
    }
    $subject = $request->get('subject');
    $mail->setSubject($subject);
    if ($reply) {
        // set In-Reply-To header
        $hres = plugin_forumml_get_message_headers($request->get('reply_to'));
        $reply_to = db_result($hres, 0, 'value');
        $mail->addAdditionalHeader("In-Reply-To", $reply_to);
    }
    $continue = true;
    if ($request->validArray(new Valid_Email('ccs')) && $request->exist('ccs')) {
        $cc_array = array();
        $idx = 0;
        foreach ($request->get('ccs') as $cc) {
            if (trim($cc) != "") {
                $cc_array[$idx] = $hp->purify($cc, CODENDI_PURIFIER_FULL);
                $idx++;
            }
        }
        // Checks sanity of CC List
        $err = '';
        if (!util_validateCCList($cc_array, $err)) {
            $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_forumml', 'invalid_mail', $err));
            $continue = false;
        } else {
            // add list of cc users to mail mime
            if (count($cc_array) > 0) {
                $cc_list = util_normalize_emails(implode(',', $cc_array));
                $mail->setCc($cc_list, true);
            }
        }
    }
    if ($continue) {
        // Process attachments
        if (isset($_FILES["files"]) && count($_FILES["files"]['name']) > 0) {
            foreach ($_FILES["files"]['name'] as $i => $fileName) {
                $data = file_get_contents($_FILES["files"]["tmp_name"][$i]);
                $mime_type = $_FILES["files"]["type"][$i];
                $mail->addAttachment($data, $mime_type, $fileName);
            }
        }
        $mail->setBodyText($message);
        if ($mail->send()) {
            $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_forumml', 'mail_succeed'));
        } else {
            $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_forumml', 'mail_fail'));
            $continue = false;
        }
    }
    return $continue;
}