本文整理汇总了PHP中CerberusApplication::getHelpdeskSenders方法的典型用法代码示例。如果您正苦于以下问题:PHP CerberusApplication::getHelpdeskSenders方法的具体用法?PHP CerberusApplication::getHelpdeskSenders怎么用?PHP CerberusApplication::getHelpdeskSenders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CerberusApplication
的用法示例。
在下文中一共展示了CerberusApplication::getHelpdeskSenders方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getMailingListFromMatches
private function _getMailingListFromMatches($matches)
{
$workers = DAO_Worker::getAllActive();
$helpdesk_senders = CerberusApplication::getHelpdeskSenders();
$notify_emails = array();
if (is_array($matches)) {
foreach ($matches as $filter) {
if (!$filter instanceof Model_WatcherMailFilter) {
continue;
}
// If the worker no longer exists or is disabled
if (!isset($workers[$filter->worker_id])) {
continue;
}
if (isset($filter->actions['email']['to']) && is_array($filter->actions['email']['to'])) {
foreach ($filter->actions['email']['to'] as $addy) {
$addy = strtolower($addy);
// Don't allow a worker to usurp a helpdesk address
if (isset($helpdesk_senders[$addy])) {
continue;
}
if (!isset($notify_emails[$addy])) {
$notify_emails[$addy] = $addy;
}
}
}
}
}
return $notify_emails;
}
示例2: parseMessage
/**
* Enter description here...
*
* @param CerberusParserMessage $message
* @return integer
*/
public static function parseMessage(CerberusParserMessage $message, $options = array())
{
/*
* options:
* 'no_autoreply'
*/
$logger = DevblocksPlatform::getConsoleLog();
$settings = DevblocksPlatform::getPluginSettingsService();
$helpdesk_senders = CerberusApplication::getHelpdeskSenders();
// Pre-parse mail filters
$pre_filters = Model_PreParseRule::getMatches($message);
if (is_array($pre_filters) && !empty($pre_filters)) {
// Load filter action manifests for reuse
$ext_action_mfts = DevblocksPlatform::getExtensions('cerberusweb.mail_filter.action', false);
// Loop through all matching filters
foreach ($pre_filters as $pre_filter) {
// Do something with matching filter's actions
foreach ($pre_filter->actions as $action_key => $action) {
switch ($action_key) {
case 'blackhole':
return NULL;
break;
case 'redirect':
@($to = $action['to']);
CerberusMail::reflect($message, $to);
return NULL;
break;
case 'bounce':
@($msg = $action['message']);
@($subject = 'Delivery failed: ' . self::fixQuotePrintableString($message->headers['subject']));
// [TODO] Follow the RFC spec on a true bounce
if (null != ($fromAddressInst = CerberusParser::getAddressFromHeaders($message->headers))) {
CerberusMail::quickSend($fromAddressInst->email, $subject, $msg);
}
return NULL;
break;
default:
// Plugin pre-parser filter actions
if (isset($ext_action_mfts[$action_key])) {
if (null != @($ext_action = $ext_action_mfts[$action_key]->createInstance())) {
try {
/* @var $ext_action Extension_MailFilterAction */
$ext_action->run($pre_filter, $message);
} catch (Exception $e) {
}
}
}
break;
}
}
}
}
$headers =& $message->headers;
// From
if (null == ($fromAddressInst = CerberusParser::getAddressFromHeaders($headers))) {
$logger->err("[Parser] 'From' address could not be created.");
return NULL;
}
// To/Cc/Bcc
$to = array();
$sTo = @$headers['to'];
$bIsNew = true;
if (!empty($sTo)) {
// [TODO] Do we still need this RFC address parser?
$to = CerberusParser::parseRfcAddress($sTo);
}
// Subject
// Fix quote printable subject (quoted blocks can appear anywhere in subject)
$sSubject = "";
if (isset($headers['subject']) && !empty($headers['subject'])) {
$sSubject = $headers['subject'];
if (is_array($sSubject)) {
$sSubject = array_shift($sSubject);
}
}
// The subject can still end up empty after QP decode
if (empty($sSubject)) {
$sSubject = "(no subject)";
}
// Date
$iDate = @strtotime($headers['date']);
// If blank, or in the future, set to the current date
if (empty($iDate) || $iDate > time()) {
$iDate = time();
}
// Is banned?
if (1 == $fromAddressInst->is_banned) {
$logger->info("[Parser] Ignoring ticket from banned address: " . $fromAddressInst->email);
return NULL;
}
// Overloadable
$enumSpamTraining = '';
// Message Id / References / In-Reply-To
@($sMessageId = $headers['message-id']);
//.........这里部分代码省略.........
示例3: render
function render()
{
$tpl = DevblocksPlatform::getTemplateService();
$tpl->assign('path', $this->_TPL_PATH);
$visit = CerberusApplication::getVisit();
$active_worker = $visit->getWorker();
$response = DevblocksPlatform::getHttpResponse();
$tpl->assign('request_path', implode('/', $response->path));
// Remember the last tab/URL
if (null == ($selected_tab = @$response->path[1])) {
$selected_tab = $visit->get(CerberusVisit::KEY_MAIL_MODE, '');
}
$tpl->assign('selected_tab', $selected_tab);
// ====== Renders
switch ($selected_tab) {
case 'compose':
if (!$active_worker->hasPriv('core.mail.send')) {
break;
}
$settings = DevblocksPlatform::getPluginSettingsService();
// Workers
$workers = DAO_Worker::getAllActive();
$tpl->assign('workers', $workers);
// Groups
$teams = DAO_Group::getAll();
$tpl->assign_by_ref('teams', $teams);
// Groups+Buckets
$team_categories = DAO_Bucket::getTeams();
$tpl->assign('team_categories', $team_categories);
// SendMailToolbarItem Extensions
$sendMailToolbarItems = DevblocksPlatform::getExtensions('cerberusweb.mail.send.toolbaritem', true);
if (!empty($sendMailToolbarItems)) {
$tpl->assign('sendmail_toolbaritems', $sendMailToolbarItems);
}
// Attachments
$tpl->assign('upload_max_filesize', ini_get('upload_max_filesize'));
// Link to last created ticket
if ($visit->exists('compose.last_ticket')) {
$ticket_mask = $visit->get('compose.last_ticket');
$tpl->assign('last_ticket_mask', $ticket_mask);
$visit->set('compose.last_ticket', null);
// clear
}
$tpl->display('file:' . $this->_TPL_PATH . 'tickets/compose/index.tpl');
break;
case 'create':
if (!$active_worker->hasPriv('core.mail.log_ticket')) {
break;
}
// Workers
$workers = DAO_Worker::getAllActive();
$tpl->assign('workers', $workers);
// Groups
$teams = DAO_Group::getAll();
$tpl->assign('teams', $teams);
// Destinations
$destinations = CerberusApplication::getHelpdeskSenders();
$tpl->assign('destinations', $destinations);
// Group+Buckets
$team_categories = DAO_Bucket::getTeams();
$tpl->assign('team_categories', $team_categories);
// LogMailToolbarItem Extensions
$logMailToolbarItems = DevblocksPlatform::getExtensions('cerberusweb.mail.log.toolbaritem', true);
if (!empty($logMailToolbarItems)) {
$tpl->assign('logmail_toolbaritems', $logMailToolbarItems);
}
// Attachments
$tpl->assign('upload_max_filesize', ini_get('upload_max_filesize'));
// Link to last created ticket
if ($visit->exists('compose.last_ticket')) {
$ticket_mask = $visit->get('compose.last_ticket');
$tpl->assign('last_ticket_mask', $ticket_mask);
$visit->set('compose.last_ticket', null);
// clear
}
$tpl->display('file:' . $this->_TPL_PATH . 'tickets/create/index.tpl');
break;
default:
// Clear all undo actions on reload
C4_TicketView::clearLastActions();
$quick_search_type = $visit->get('quick_search_type');
$tpl->assign('quick_search_type', $quick_search_type);
$tpl->display('file:' . $this->_TPL_PATH . 'tickets/index.tpl');
break;
}
}
示例4: _sendForwards
private function _sendForwards($event, $is_inbound)
{
@($ticket_id = $event->params['ticket_id']);
@($message_id = $event->params['message_id']);
@($send_worker_id = $event->params['worker_id']);
$ticket = DAO_Ticket::getTicket($ticket_id);
$helpdesk_senders = CerberusApplication::getHelpdeskSenders();
$workers = DAO_Worker::getAllActive();
// [JAS]: Don't send obvious spam to watchers.
if ($ticket->spam_score >= 0.9) {
return true;
}
@($notifications = DAO_WorkerMailForward::getWhere(sprintf("%s = %d", DAO_WorkerMailForward::GROUP_ID, $ticket->team_id)));
// Bail out early if we have no forwards for this group
if (empty($notifications)) {
return;
}
$message = DAO_Ticket::getMessage($message_id);
$headers = $message->getHeaders();
// The whole flipping Swift section needs wrapped to catch exceptions
try {
$settings = CerberusSettings::getInstance();
$reply_to = $settings->get(CerberusSettings::DEFAULT_REPLY_FROM, '');
// See if we need a group-specific reply-to
if (!empty($ticket->team_id)) {
@($group_from = DAO_GroupSettings::get($ticket->team_id, DAO_GroupSettings::SETTING_REPLY_FROM, ''));
if (!empty($group_from)) {
$reply_to = $group_from;
}
}
$sender = DAO_Address::get($message->address_id);
$sender_email = strtolower($sender->email);
$sender_split = explode('@', $sender_email);
if (!is_array($sender_split) || count($sender_split) != 2) {
return;
}
// If return-path is blank
if (isset($headers['return-path']) && $headers['return-path'] == '<>') {
return;
}
// Ignore bounces
if ($sender_split[1] == "postmaster" || $sender_split[1] == "mailer-daemon") {
return;
}
// Ignore autoresponses autoresponses
if (isset($headers['auto-submitted']) && $headers['auto-submitted'] != 'no') {
return;
}
// Headers
//==========
// Build mailing list
$send_to = array();
foreach ($notifications as $n) {
/* @var $n Model_WorkerMailForward */
if (!isset($n->group_id) || !isset($n->bucket_id)) {
continue;
}
// if worker no longer exists or is disabled
if (!isset($workers[$n->worker_id])) {
continue;
}
// Don't allow a worker to usurp a helpdesk address
if (isset($helpdesk_senders[$n->email])) {
continue;
}
if ($n->group_id == $ticket->team_id && ($n->bucket_id == -1 || $n->bucket_id == $ticket->category_id)) {
// Event checking
if ($is_inbound && ($n->event == 'i' || $n->event == 'io') || !$is_inbound && ($n->event == 'o' || $n->event == 'io') || $is_inbound && $n->event == 'r' && $ticket->next_worker_id == $n->worker_id) {
$send_to[$n->email] = true;
}
}
}
// Attachments
$attachments = $message->getAttachments();
$mime_attachments = array();
if (is_array($attachments)) {
foreach ($attachments as $attachment) {
if (0 == strcasecmp($attachment->display_name, 'original_message.html')) {
continue;
}
$attachment_path = APP_STORAGE_PATH . '/attachments/';
// [TODO] This is highly redundant in the codebase
if (!file_exists($attachment_path . $attachment->filepath)) {
continue;
}
$file =& new Swift_File($attachment_path . $attachment->filepath);
$mime_attachments[] =& new Swift_Message_Attachment($file, $attachment->display_name, $attachment->mime_type);
}
}
// Send copies
if (is_array($send_to) && !empty($send_to)) {
$mail_service = DevblocksPlatform::getMailService();
$mailer = $mail_service->getMailer(CerberusMail::getMailerDefaults());
foreach ($send_to as $to => $bool) {
// Proxy the message
$rcpt_to = new Swift_RecipientList();
$a_rcpt_to = array();
$mail_from = new Swift_Address($sender->email);
$rcpt_to->addTo($to);
$a_rcpt_to = new Swift_Address($to);
//.........这里部分代码省略.........
示例5: sendTicketMessage
static function sendTicketMessage($properties = array())
{
$settings = DevblocksPlatform::getPluginSettingsService();
$helpdesk_senders = CerberusApplication::getHelpdeskSenders();
@($from_addy = $settings->get('cerberusweb.core', CerberusSettings::DEFAULT_REPLY_FROM, $_SERVER['SERVER_ADMIN']));
@($from_personal = $settings->get('cerberusweb.core', CerberusSettings::DEFAULT_REPLY_PERSONAL, ''));
// [TODO] If we still don't have a $from_addy we need a graceful failure.
/*
* [TODO] Move these into constants?
'message_id'
-----'ticket_id'
'subject'
'to'
'cc'
'bcc'
'content'
'files'
'closed'
'ticket_reopen'
'unlock_date'
'bucket_id'
'agent_id',
'is_autoreply',
'dont_send',
'dont_save_copy'
*/
$mail_succeeded = true;
try {
// objects
$mail_service = DevblocksPlatform::getMailService();
$mailer = $mail_service->getMailer(CerberusMail::getMailerDefaults());
$mail = $mail_service->createMessage();
// properties
@($reply_message_id = $properties['message_id']);
@($content = $properties['content']);
@($files = $properties['files']);
@($forward_files = $properties['forward_files']);
@($worker_id = $properties['agent_id']);
@($subject = $properties['subject']);
$message = DAO_Ticket::getMessage($reply_message_id);
$message_headers = DAO_MessageHeader::getAll($reply_message_id);
$ticket_id = $message->ticket_id;
$ticket = DAO_Ticket::getTicket($ticket_id);
// [TODO] Check that message|ticket isn't NULL
// If this ticket isn't spam trained and our outgoing message isn't an autoreply
if ($ticket->spam_training == CerberusTicketSpamTraining::BLANK && (!isset($properties['is_autoreply']) || !$properties['is_autoreply'])) {
CerberusBayes::markTicketAsNotSpam($ticket_id);
}
// Allow teams to override the default from/personal
@($group_reply = DAO_GroupSettings::get($ticket->team_id, DAO_GroupSettings::SETTING_REPLY_FROM, ''));
@($group_personal = DAO_GroupSettings::get($ticket->team_id, DAO_GroupSettings::SETTING_REPLY_PERSONAL, ''));
@($group_personal_with_worker = DAO_GroupSettings::get($ticket->team_id, DAO_GroupSettings::SETTING_REPLY_PERSONAL_WITH_WORKER, 0));
if (!empty($group_reply)) {
$from_addy = $group_reply;
}
if (!empty($group_personal)) {
$from_personal = $group_personal;
}
// Prefix the worker name on the personal line?
if (!empty($group_personal_with_worker) && null != ($reply_worker = DAO_Worker::getAgent($worker_id))) {
$from_personal = $reply_worker->getName() . (!empty($from_personal) ? ', ' . $from_personal : "");
}
// Headers
$mail->setFrom(array($from_addy => $from_personal));
$mail->generateId();
$headers = $mail->getHeaders();
$headers->addTextHeader('X-Mailer', 'Cerberus Helpdesk (Build ' . APP_BUILD . ')');
// Subject
if (empty($subject)) {
$subject = $ticket->subject;
}
if (!empty($properties['to'])) {
// forward
$mail->setSubject($subject);
} else {
// reply
@($group_has_subject = intval(DAO_GroupSettings::get($ticket->team_id, DAO_GroupSettings::SETTING_SUBJECT_HAS_MASK, 0)));
@($group_subject_prefix = DAO_GroupSettings::get($ticket->team_id, DAO_GroupSettings::SETTING_SUBJECT_PREFIX, ''));
$prefix = sprintf("[%s#%s] ", !empty($group_subject_prefix) ? $group_subject_prefix . ' ' : '', $ticket->mask);
$mail->setSubject(sprintf('Re: %s%s', $group_has_subject ? $prefix : '', $subject));
}
// References
if (!empty($message) && false !== @($in_reply_to = $message_headers['message-id'])) {
$headers->addTextHeader('References', $in_reply_to);
$headers->addTextHeader('In-Reply-To', $in_reply_to);
}
// Auto-reply handling (RFC-3834 compliant)
if (isset($properties['is_autoreply']) && $properties['is_autoreply']) {
$headers->addTextHeader('Auto-Submitted', 'auto-replied');
if (null == ($first_address = DAO_Address::get($ticket->first_wrote_address_id))) {
return;
}
// Don't send e-mail to ourselves
if (isset($helpdesk_senders[$first_address->email])) {
return;
}
// Make sure we haven't mailed this address an autoreply within 5 minutes
if ($first_address->last_autoreply > 0 && $first_address->last_autoreply > time() - 300) {
return;
}
//.........这里部分代码省略.........