function hesk_stripQuotedText($message) { global $hesk_settings, $hesklang; // Stripping quoted text disabled? if (!$hesk_settings['strip_quoted']) { return $message; } // Loop through available languages and ty to find the tag foreach ($hesk_settings['languages'] as $language => $settings) { if (($found = strpos($message, $settings['hr'])) !== false) { // "Reply above this line" tag found, strip quoted reply $message = substr($message, 0, $found); $message .= "\n" . $hesklang['qrr']; // Set language to the detected language hesk_setLanguage($language); break; } } return $message; }
function hesk_notifyStaff($email_template, $sql_where, $is_ticket = 1) { global $hesk_settings, $hesklang, $ticket; // Demo mode if (defined('HESK_DEMO')) { return true; } $admins = array(); $res = hesk_dbQuery("SELECT `email`,`language`,`isadmin`,`categories` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` WHERE {$sql_where} ORDER BY `language`"); while ($myuser = hesk_dbFetchAssoc($res)) { /* Is this an administrator? */ if ($myuser['isadmin']) { $admins[] = array('email' => $myuser['email'], 'language' => $myuser['language']); continue; } /* Not admin, is he/she allowed this category? */ $myuser['categories'] = explode(',', $myuser['categories']); if (in_array($ticket['category'], $myuser['categories'])) { $admins[] = array('email' => $myuser['email'], 'language' => $myuser['language']); continue; } } if (count($admins) > 0) { /* Make sure each user gets email in his/her preferred language */ $current_language = 'NONE'; $recipients = array(); $hasMessage = hesk_doesTemplateHaveTag($email_template, '%%MESSAGE%%'); /* Loop through staff */ foreach ($admins as $admin) { /* If admin language is NULL force default HESK language */ if (!$admin['language'] || !isset($hesk_settings['languages'][$admin['language']])) { $admin['language'] = HESK_DEFAULT_LANGUAGE; } /* Generate message or add email to the list of recepients */ if ($admin['language'] == $current_language) { /* We already have the message, just add email to the recipients list */ $recipients[] = $admin['email']; } else { /* Send email messages in previous languages (if required) */ if ($current_language != 'NONE') { /* Send e-mail to staff */ hesk_mail(implode(',', $recipients), $subject, $message, $htmlMessage, array(), array(), $hasMessage); /* Reset list of email addresses */ $recipients = array(); } /* Set new language */ hesk_setLanguage($admin['language']); /* Format staff email subject and message for this language */ $subject = hesk_getEmailSubject($email_template, $ticket); $message = hesk_getEmailMessage($email_template, $ticket, $is_ticket); $htmlMessage = hesk_getHtmlMessage($email_template, $ticket, $is_ticket); $hasMessage = hesk_doesTemplateHaveTag($email_template, '%%MESSAGE%%'); /* Add email to the recipients list */ $recipients[] = $admin['email']; /* Remember the last processed language */ $current_language = $admin['language']; } } /* Send email messages to the remaining staff */ hesk_mail(implode(',', $recipients), $subject, $message, $htmlMessage, array(), array(), $hasMessage); /* Reset language to original one */ hesk_resetLanguage(); } return true; }