Skip to content

Commit

Permalink
Merge branch '6.1.4' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
jstanden committed Nov 28, 2012
2 parents 3cb74d4 + da7b4a7 commit 60f6ae4
Show file tree
Hide file tree
Showing 18 changed files with 242 additions and 195 deletions.
4 changes: 2 additions & 2 deletions api/Application.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
* - Jeff Standen, Darren Sugita, Dan Hildebrandt, Scott Luther
* WEBGROUP MEDIA LLC. - Developers of Cerberus Helpdesk
*/
define("APP_BUILD", 2012100901);
define("APP_VERSION", '6.1.3');
define("APP_BUILD", 2012112101);
define("APP_VERSION", '6.1.4');

define("APP_MAIL_PATH", APP_STORAGE_PATH . '/mail/');

Expand Down
2 changes: 1 addition & 1 deletion features/cerberusweb.core/api/dao/group.php
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ function getContext($group, &$token_labels, &$token_values, $prefix=null) {

if(is_array($fields))
foreach($fields as $cf_id => $field) {
$token_labels['worker_custom_'.$cf_id] = $prefix.$field->name;
$token_labels['custom_'.$cf_id] = $prefix.$field->name;
}

// Token values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,7 @@ function simulateActionExtension($token, $trigger, $params, DevblocksDictionaryD
break;

case 'relay_email':
return DevblocksEventHelper::simulateActionRelayEmail($params, $dict);
break;

case 'schedule_email_recipients':
Expand All @@ -837,6 +838,7 @@ function simulateActionExtension($token, $trigger, $params, DevblocksDictionaryD
break;

case 'set_owner':
return DevblocksEventHelper::simulateActionSetTicketOwner($params, $dict);
break;

case 'set_reopen_date':
Expand All @@ -847,28 +849,27 @@ function simulateActionExtension($token, $trigger, $params, DevblocksDictionaryD
break;

case 'send_email_recipients':
// Translate message tokens
$tpl_builder = DevblocksPlatform::getTemplateBuilder();
$content = $tpl_builder->build($params['content'], $dict);

$out = sprintf(">>> Sending email to recipients\n".
"%s\n",
$content
);

return $out;
return DevblocksEventHelper::simulateActionSendEmailRecipients($params, $dict);
break;

case 'set_spam_training':
$out = sprintf(">>> Setting spam training\n".
"%s\n",
$params['value'] == 'N' ? 'Not Spam' : 'Spam'
);
return $out;
break;

case 'set_status':
return DevblocksEventHelper::simulateActionSetStatus($params, $dict);
break;

case 'set_subject':
return DevblocksEventHelper::simulateActionSetSubject($params, $dict);
break;

case 'move_to':
return DevblocksEventHelper::simulateActionMoveTo($params, $dict);
break;

case 'set_sender_links':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -843,21 +843,7 @@ function simulateActionExtension($token, $trigger, $params, DevblocksDictionaryD
break;

case 'relay_email':
/*
DevblocksEventHelper::simulateActionRelayEmail(
$params,
$dict,
CerberusContexts::CONTEXT_TICKET,
$ticket_id,
$dict->ticket_group_id,
@intval($dict->ticket_bucket_id),
$dict->ticket_latest_message_id,
@intval($dict->ticket_owner_id),
$dict->ticket_latest_message_sender_address,
$dict->ticket_latest_message_sender_full_name,
$dict->ticket_subject
);
*/
return DevblocksEventHelper::simulateActionRelayEmail($params, $dict);
break;

case 'schedule_behavior':
Expand All @@ -873,19 +859,11 @@ function simulateActionExtension($token, $trigger, $params, DevblocksDictionaryD
break;

case 'send_email_recipients':
// Translate message tokens
$tpl_builder = DevblocksPlatform::getTemplateBuilder();
$content = $tpl_builder->build($params['content'], $dict);

$out = sprintf(">>> Sending email to receipients\n".
"%s\n",
$content
);

return $out;
return DevblocksEventHelper::simulateActionSendEmailRecipients($params, $dict);
break;

case 'set_owner':
return DevblocksEventHelper::simulateActionSetTicketOwner($params, $dict);
break;

case 'set_reopen_date':
Expand All @@ -895,12 +873,15 @@ function simulateActionExtension($token, $trigger, $params, DevblocksDictionaryD
break;

case 'set_status':
return DevblocksEventHelper::simulateActionSetTicketStatus($params, $dict);
break;

case 'set_subject':
return DevblocksEventHelper::simulateActionSetSubject($params, $dict);
break;

case 'move_to':
return DevblocksEventHelper::simulateActionMoveTo($params, $dict);
break;

case 'set_initial_sender_links':
Expand Down Expand Up @@ -1091,6 +1072,7 @@ function runActionExtension($token, $trigger, $params, DevblocksDictionaryDelega
break;

case 'set_subject':
// Translate message tokens
@$value = $params['value'];

$builder = DevblocksPlatform::getTemplateBuilder();
Expand Down
125 changes: 100 additions & 25 deletions features/cerberusweb.core/api/events/app/mail_received_by_app.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ function getActionExtensions() {
'replace_content' => array('label' =>'Replace text in message content'),
'reject' => array('label' =>'Reject delivery of message'),
'redirect_email' => array('label' =>'Redirect delivery to another email address'),
'send_email' => array('label' => 'Send email'),
'send_email_sender' => array('label' => 'Reply to sender'),
'set_header' => array('label' => 'Set message header'),
)
Expand Down Expand Up @@ -426,6 +427,10 @@ function renderActionExtension($token, $trigger, $params=array(), $seq=null) {
$tpl->display('devblocks:cerberusweb.core::events/mail_received_by_app/action_redirect_email.tpl');
break;

case 'send_email':
DevblocksEventHelper::renderActionSendEmail($trigger);
break;

case 'send_email_sender':
//$tpl->assign('workers', DAO_Worker::getAll());
$tpl->display('devblocks:cerberusweb.core::events/mail_received_by_app/action_send_email_sender.tpl');
Expand Down Expand Up @@ -454,12 +459,32 @@ function simulateActionExtension($token, $trigger, $params, DevblocksDictionaryD
switch($token) {
case 'append_to_content':
$tpl_builder = DevblocksPlatform::getTemplateBuilder();
$dict->body .= "\r\n" . $tpl_builder->build($params['content'], $dict);
$content = $tpl_builder->build($params['content'], $dict);
$dict->body = $dict->body . "\r\n" . $content;

$out = sprintf(">>> Prepending text to message content\n".
"Text:\n%s\n".
"Message:\n%s\n",
$content,
$dict->body
);

return $out;
break;

case 'prepend_to_content':
$tpl_builder = DevblocksPlatform::getTemplateBuilder();
$dict->body = $tpl_builder->build($params['content'], $dict) . "\r\n" . $dict->body;
$content = $tpl_builder->build($params['content'], $dict);
$dict->body = $content . "\r\n" . $dict->body;

$out = sprintf(">>> Prepending text to message content\n".
"Text:\n%s\n".
"Message:\n%s\n",
$content,
$dict->body
);

return $out;
break;

case 'replace_content':
Expand All @@ -473,46 +498,72 @@ function simulateActionExtension($token, $trigger, $params, DevblocksDictionaryD
$value = str_replace($replace, $with, $dict->body);
}

$before = $dict->body;

if(!empty($value)) {
$dict->body = trim($value,"\r\n");
}

$out = sprintf(">>> Replacing content\n".
"Before:\n%s\n".
"After:\n%s\n",
$before,
$dict->body
);

return $out;
break;

case 'reject':
$dict->pre_actions['reject'] = true;
$out = ">>> Rejecting message\n";

return $out;
break;

case 'redirect_email':
$tpl_builder = DevblocksPlatform::getTemplateBuilder();
$to = $tpl_builder->build($params['to'], $dict);

$out = sprintf(">>> Redirecting message to:\n%s",
$to
);

return $out;
break;

case 'send_email_sender':

case 'send_email':
return DevblocksEventHelper::simulateActionSendEmail($params, $dict);
break;

case 'set_header':
@$header = strtolower($params['header']);

case 'send_email_sender':
$tpl_builder = DevblocksPlatform::getTemplateBuilder();
$value = $tpl_builder->build($params['value'], $dict);
$subject = $tpl_builder->build($params['subject'], $dict);
$content = $tpl_builder->build($params['content'], $dict);

@$parser_model = $dict->_parser_model;
if(empty($parser_model) || !is_a($parser_model,'CerberusParserModel'))
break;
$out = sprintf(">>> Sending message to sender\n".
"Subject: %s\n".
"Content: \n%s\n",
$subject,
$content
);

$headers =& $parser_model->getHeaders();

if(empty($value)) {
if(isset($headers[$header]))
unset($headers[$header]);

} else {
$headers[$header] = $value;
}

return $out;
break;

case 'set_header':
$out = sprintf(">>> Setting header\n".
"Header: %s\n".
"Value: %s\n",
$header,
$value
);

return $out;
break;

default:
if('set_cf_' == substr($token,0,7)) {
@$parser_model = $dict->_parser_model;

$field_id = substr($token,7);
$custom_field = DAO_CustomField::get($field_id);
Expand All @@ -526,13 +577,27 @@ function simulateActionExtension($token, $trigger, $params, DevblocksDictionaryD
case Model_CustomField::TYPE_WORKER:
$value = $params['worker_id'];
break;
default:
case Model_CustomField::TYPE_DROPDOWN:
case Model_CustomField::TYPE_CHECKBOX:
case Model_CustomField::TYPE_DATE:
$value = $params['value'];
break;
default:
$tpl_builder = DevblocksPlatform::getTemplateBuilder();
$value = $tpl_builder->build($params['value'], $dict);
break;
}

if(!empty($parser_model))
$parser_model->getMessage()->custom_fields[$field_id] = $value;
$parser_model->getMessage()->custom_fields[$field_id] = $value;

$out = sprintf(">>> Setting custom field\n".
"Custom Field: %s\n".
"Value: %s\n",
$custom_field->name,
$value
);
return $out;
}
break;
}
Expand Down Expand Up @@ -581,6 +646,10 @@ function runActionExtension($token, $trigger, $params, DevblocksDictionaryDelega
CerberusMail::reflect($parser_model, $to);
break;

case 'send_email':
return DevblocksEventHelper::runActionSendEmail($params, $dict);
break;

case 'send_email_sender':
// Translate message tokens
$tpl_builder = DevblocksPlatform::getTemplateBuilder();
Expand Down Expand Up @@ -657,9 +726,15 @@ function runActionExtension($token, $trigger, $params, DevblocksDictionaryDelega
case Model_CustomField::TYPE_WORKER:
$value = $params['worker_id'];
break;
default:
case Model_CustomField::TYPE_DROPDOWN:
case Model_CustomField::TYPE_CHECKBOX:
case Model_CustomField::TYPE_DATE:
$value = $params['value'];
break;
default:
$tpl_builder = DevblocksPlatform::getTemplateBuilder();
$value = $tpl_builder->build($params['value'], $dict);
break;
}

$parser_model->getMessage()->custom_fields[$field_id] = $value;
Expand Down
Loading

0 comments on commit 60f6ae4

Please sign in to comment.