本文整理汇总了PHP中CerberusApplication::generateTicketMask方法的典型用法代码示例。如果您正苦于以下问题:PHP CerberusApplication::generateTicketMask方法的具体用法?PHP CerberusApplication::generateTicketMask怎么用?PHP CerberusApplication::generateTicketMask使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CerberusApplication
的用法示例。
在下文中一共展示了CerberusApplication::generateTicketMask方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _handleImportTicket
private function _handleImportTicket($xml)
{
$settings = CerberusSettings::getInstance();
$logger = DevblocksPlatform::getConsoleLog();
$workers = DAO_Worker::getAll();
static $email_to_worker_id = null;
static $group_name_to_id = null;
static $bucket_name_to_id = null;
// Hash Workers so we can ID their incoming tickets
if (null == $email_to_worker_id) {
$email_to_worker_id = array();
if (is_array($workers)) {
foreach ($workers as $worker) {
/* @var $worker CerberusWorker */
$email_to_worker_id[strtolower($worker->email)] = intval($worker->id);
}
}
}
// Hash Group names
if (null == $group_name_to_id) {
$groups = DAO_Group::getAll();
$group_name_to_id = array();
if (is_array($groups)) {
foreach ($groups as $group) {
$group_name_to_id[strtolower($group->name)] = intval($group->id);
}
}
}
// Hash Bucket names
if (null == $bucket_name_to_id) {
$buckets = DAO_Bucket::getAll();
$bucket_name_to_id = array();
if (is_array($buckets)) {
foreach ($buckets as $bucket) {
/* @var $bucket CerberusCategory */
// Hash by team ID and bucket name
$hash = md5($bucket->team_id . strtolower($bucket->name));
$bucket_to_id[$hash] = intval($bucket->id);
}
}
}
$sMask = (string) $xml->mask;
$sSubject = substr((string) $xml->subject, 0, 255);
$sGroup = (string) $xml->group;
$sBucket = (string) $xml->bucket;
$iCreatedDate = (int) $xml->created_date;
$iUpdatedDate = (int) $xml->updated_date;
$isWaiting = (int) $xml->is_waiting;
$isClosed = (int) $xml->is_closed;
if (empty($sMask)) {
$sMask = CerberusApplication::generateTicketMask();
}
// Find the destination Group + Bucket (or create them)
if (empty($sGroup)) {
$iDestGroupId = 0;
if (null != ($iDestGroup = DAO_Group::getDefaultGroup())) {
$iDestGroupId = $iDestGroup->id;
}
} elseif (null == ($iDestGroupId = @$group_name_to_id[strtolower($sGroup)])) {
$iDestGroupId = DAO_Group::createTeam(array(DAO_Group::TEAM_NAME => $sGroup));
// Give all superusers manager access to this new group
if (is_array($workers)) {
foreach ($workers as $worker) {
if ($worker->is_superuser) {
DAO_Group::setTeamMember($iDestGroupId, $worker->id, true);
}
}
}
// Rehash
DAO_Group::getAll(true);
$group_name_to_id[strtolower($sGroup)] = $iDestGroupId;
}
if (empty($sBucket)) {
$iDestBucketId = 0;
// Inbox
} elseif (null == ($iDestBucketId = @$bucket_name_to_id[md5($iDestGroupId . strtolower($sBucket))])) {
$iDestBucketId = DAO_Bucket::create($sBucket, $iDestGroupId);
// Rehash
DAO_Bucket::getAll(true);
$bucket_name_to_id[strtolower($sBucket)] = $iDestBucketId;
}
// Xpath the first and last "from" out of "/ticket/messages/message/headers/from"
$aMessageNodes = $xml->xpath("/ticket/messages/message");
$iNumMessages = count($aMessageNodes);
@($eFirstMessage = reset($aMessageNodes));
if (is_null($eFirstMessage)) {
$logger->warn('[Importer] Ticket ' . $sMask . " doesn't have any messages. Skipping.");
return false;
}
if (is_null($eFirstMessage->headers) || is_null($eFirstMessage->headers->from)) {
$logger->warn('[Importer] Ticket ' . $sMask . " first message doesn't provide a sender address.");
return false;
}
$sFirstWrote = self::_parseRfcAddressList($eFirstMessage->headers->from, true);
if (null == ($firstWroteInst = CerberusApplication::hashLookupAddress($sFirstWrote, true))) {
$logger->warn('[Importer] Ticket ' . $sMask . " - Invalid sender adddress: " . $sFirstWrote);
return false;
}
$eLastMessage = end($aMessageNodes);
if (is_null($eLastMessage)) {
//.........这里部分代码省略.........
示例2: doSplitMessageAction
function doSplitMessageAction()
{
@($id = DevblocksPlatform::importGPC($_REQUEST['id'], 'integer', 0));
if (null == ($orig_message = DAO_Ticket::getMessage($id))) {
return;
}
if (null == ($orig_headers = $orig_message->getHeaders())) {
return;
}
if (null == ($orig_ticket = DAO_Ticket::getTicket($orig_message->ticket_id))) {
return;
}
if (null == ($messages = DAO_Ticket::getMessagesByTicket($orig_message->ticket_id))) {
return;
}
// Create a new ticket
$new_ticket_mask = CerberusApplication::generateTicketMask();
$new_ticket_id = DAO_Ticket::createTicket(array(DAO_Ticket::CREATED_DATE => $orig_message->created_date, DAO_Ticket::UPDATED_DATE => $orig_message->created_date, DAO_Ticket::CATEGORY_ID => $orig_ticket->category_id, DAO_Ticket::FIRST_MESSAGE_ID => $orig_message->id, DAO_Ticket::FIRST_WROTE_ID => $orig_message->address_id, DAO_Ticket::LAST_WROTE_ID => $orig_message->address_id, DAO_Ticket::LAST_ACTION_CODE => CerberusTicketActionCode::TICKET_OPENED, DAO_Ticket::IS_CLOSED => CerberusTicketStatus::OPEN, DAO_Ticket::IS_DELETED => 0, DAO_Ticket::MASK => $new_ticket_mask, DAO_Ticket::SUBJECT => isset($orig_headers['subject']) ? $orig_headers['subject'] : $orig_ticket->subject, DAO_Ticket::TEAM_ID => $orig_ticket->team_id));
// [TODO] SLA?
// Copy all the original tickets requesters
$orig_requesters = DAO_Ticket::getRequestersByTicket($orig_ticket->id);
foreach ($orig_requesters as $orig_req_id => $orig_req_addy) {
DAO_Ticket::createRequester($orig_req_id, $new_ticket_id);
}
// Pull the message off the ticket (reparent)
unset($messages[$orig_message->id]);
DAO_Message::update($orig_message->id, array(DAO_Message::TICKET_ID => $new_ticket_id));
//[mdf] [CHD-979] The ticket id is also in the message_header table, so update those too
$message_headers = DAO_MessageHeader::getAll($orig_message->id);
foreach ($message_headers as $hk => $hv) {
DAO_MessageHeader::create($orig_message->id, $new_ticket_id, $hk, $hv);
}
// Reindex the original ticket (last wrote, etc.)
$last_message = end($messages);
/* @var CerberusMessage $last_message */
DAO_Ticket::updateTicket($orig_ticket->id, array(DAO_Ticket::LAST_WROTE_ID => $last_message->address_id));
// Remove requester if they don't still have messages on the original ticket
reset($messages);
$found = false;
if (is_array($messages)) {
foreach ($messages as $msgid => $msg) {
if ($msg->address_id == $orig_message->address_id) {
$found = true;
break;
}
}
}
if (!$found) {
DAO_Ticket::deleteRequester($orig_ticket->id, $orig_message->address_id);
}
DevblocksPlatform::redirect(new DevblocksHttpResponse(array('display', $new_ticket_mask)));
}
示例3: parseMessage
//.........这里部分代码省略.........
break;
}
}
$attachment_files = array();
$attachment_files['name'] = array();
$attachment_files['type'] = array();
$attachment_files['tmp_name'] = array();
$attachment_files['size'] = array();
$i = 0;
foreach ($message->files as $filename => $file) {
$attachment_files['name'][$i] = $filename;
$attachment_files['type'][$i] = $file->mime_type;
$attachment_files['tmp_name'][$i] = $file->tmpname;
$attachment_files['size'][$i] = $file->file_size;
$i++;
}
CerberusMail::sendTicketMessage(array('message_id' => $msgid, 'content' => $message->body, 'files' => $attachment_files, 'agent_id' => $worker_address->worker_id));
return $id;
} else {
// ... worker is a requester, treat as normal
$logger->info("[Parser] The external worker was a ticket requester, so we're not treating them as a watcher.");
}
} else {
// Reply: Not sent by a worker
/*
* [TODO] check that this sender is a requester on the matched ticket
* Otherwise blank out the $id
*/
}
}
$group_id = 0;
if (empty($id)) {
// New Ticket
$sMask = CerberusApplication::generateTicketMask();
$groups = DAO_Group::getAll();
// Routing new tickets
if (null != ($routing_rules = Model_MailToGroupRule::getMatches($fromAddressInst, $message))) {
if (is_array($routing_rules)) {
foreach ($routing_rules as $rule) {
// Only end up with the last 'move' action (ignore the previous)
if (isset($rule->actions['move'])) {
$group_id = intval($rule->actions['move']['group_id']);
// We don't need to move again when running rule actions
unset($rule->actions['move']);
}
}
}
}
// Make sure the group exists
if (!isset($groups[$group_id])) {
$group_id = null;
}
// Last ditch effort to check for a default group to deliver to
if (empty($group_id)) {
if (null != ($default_team = DAO_Group::getDefaultGroup())) {
$group_id = $default_team->id;
} else {
// Bounce
return null;
}
}
// [JAS] It's important to not set the group_id on the ticket until the messages exist
// or inbox filters will just abort.
$fields = array(DAO_Ticket::MASK => $sMask, DAO_Ticket::SUBJECT => $sSubject, DAO_Ticket::IS_CLOSED => 0, DAO_Ticket::FIRST_WROTE_ID => intval($fromAddressInst->id), DAO_Ticket::LAST_WROTE_ID => intval($fromAddressInst->id), DAO_Ticket::CREATED_DATE => $iDate, DAO_Ticket::UPDATED_DATE => $iDate, DAO_Ticket::LAST_ACTION_CODE => CerberusTicketActionCode::TICKET_OPENED);
$id = DAO_Ticket::createTicket($fields);
// Apply routing actions to our new ticket ID
示例4: compose
static function compose($properties)
{
@($team_id = $properties['team_id']);
@($toStr = $properties['to']);
@($cc = $properties['cc']);
@($bcc = $properties['bcc']);
@($subject = $properties['subject']);
@($content = $properties['content']);
@($files = $properties['files']);
@($no_mail = $properties['no_mail']);
@($closed = $properties['closed']);
@($move_bucket = $properties['move_bucket']);
@($next_worker_id = $properties['next_worker_id']);
@($ticket_reopen = $properties['ticket_reopen']);
@($unlock_date = $properties['unlock_date']);
$worker = CerberusApplication::getActiveWorker();
$settings = DevblocksPlatform::getPluginSettingsService();
$default_from = $settings->get('cerberusweb.core', CerberusSettings::DEFAULT_REPLY_FROM);
$default_personal = $settings->get('cerberusweb.core', CerberusSettings::DEFAULT_REPLY_PERSONAL);
$team_from = DAO_GroupSettings::get($team_id, DAO_GroupSettings::SETTING_REPLY_FROM, '');
$team_personal = DAO_GroupSettings::get($team_id, DAO_GroupSettings::SETTING_REPLY_PERSONAL, '');
$team_personal_with_worker = DAO_GroupSettings::get($team_id, DAO_GroupSettings::SETTING_REPLY_PERSONAL_WITH_WORKER, 0);
$from = !empty($team_from) ? $team_from : $default_from;
$personal = !empty($team_personal) ? $team_personal : $default_personal;
// Prefix the worker name on the personal line?
if (!empty($team_personal_with_worker) && !empty($worker)) {
$personal = $worker->getName() . ', ' . $personal;
}
$mask = CerberusApplication::generateTicketMask();
if (empty($subject)) {
$subject = '(no subject)';
}
// add mask to subject if group setting calls for it
@($group_has_subject = intval(DAO_GroupSettings::get($team_id, DAO_GroupSettings::SETTING_SUBJECT_HAS_MASK, 0)));
@($group_subject_prefix = DAO_GroupSettings::get($team_id, DAO_GroupSettings::SETTING_SUBJECT_PREFIX, ''));
$prefix = sprintf("[%s#%s] ", !empty($group_subject_prefix) ? $group_subject_prefix . ' ' : '', $mask);
$subject_mailed = sprintf('%s%s', $group_has_subject ? $prefix : '', $subject);
// [JAS]: Replace any semi-colons with commas (people like using either)
$toList = DevblocksPlatform::parseCsvString(str_replace(';', ',', $toStr));
$mail_headers = array();
$mail_headers['X-CerberusCompose'] = '1';
$mail_succeeded = true;
if (!empty($no_mail)) {
// allow compose without sending mail
// Headers needed for the ticket message
$log_headers = new Swift_Message_Headers();
$log_headers->setCharset(LANG_CHARSET_CODE);
$log_headers->set('To', $toStr);
$log_headers->set('From', !empty($personal) ? sprintf("%s <%s>", $personal, $from) : sprintf('%s', $from));
$log_headers->set('Subject', $subject_mailed);
$log_headers->set('Date', date('r'));
foreach ($log_headers->getList() as $hdr => $v) {
if (null != ($hdr_val = $log_headers->getEncoded($hdr))) {
if (!empty($hdr_val)) {
$mail_headers[$hdr] = $hdr_val;
}
}
}
} else {
// regular mail sending
try {
$mail_service = DevblocksPlatform::getMailService();
$mailer = $mail_service->getMailer(CerberusMail::getMailerDefaults());
$email = $mail_service->createMessage();
$email->setTo($toList);
// cc
$ccs = array();
if (!empty($cc) && null != ($ccList = DevblocksPlatform::parseCsvString(str_replace(';', ',', $cc)))) {
$email->setCc($ccList);
}
// bcc
if (!empty($bcc) && null != ($bccList = DevblocksPlatform::parseCsvString(str_replace(';', ',', $bcc)))) {
$email->setBcc($bccList);
}
$email->setFrom(array($from => $personal));
$email->setSubject($subject_mailed);
$email->generateId();
$headers = $email->getHeaders();
$headers->addTextHeader('X-Mailer', 'Cerberus Helpdesk (Build ' . APP_BUILD . ')');
$email->setBody($content);
// Mime Attachments
if (is_array($files) && !empty($files)) {
foreach ($files['tmp_name'] as $idx => $file) {
if (empty($file) || empty($files['name'][$idx])) {
continue;
}
$email->attach(Swift_Attachment::fromPath($file)->setFilename($files['name'][$idx]));
}
}
// [TODO] Allow separated addresses (parseRfcAddress)
// $mailer->log->enable();
if (!$mailer->send($email)) {
$mail_succeeded = false;
throw new Exception('Mail failed to send: unknown reason');
}
// $mailer->log->dump();
} catch (Exception $e) {
// tag mail as failed, add note to message after message gets created
$mail_succeeded = false;
}
//.........这里部分代码省略.........