* @param array $defaults
* (reference ) an assoc array to hold the flattened values.
*
- * @return CRM_Core_BAO_MessageTemplate object
- * @static
+ * @return CRM_Core_BAO_MessageTemplate
*/
public static function retrieve(&$params, &$defaults) {
$messageTemplates = new CRM_Core_DAO_MessageTemplate();
*
* @return Object
* DAO object on sucess, NULL otherwise
- * @static
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_MessageTemplate', $id, 'is_active', $is_active);
* @param array $params
* Reference array contains the values submitted by the form.
*
- * @static
*
* @return object
*/
/**
* Delete the Message Templates
*
- * @static
- *
* @param int $messageTemplatesID
- *
- * @return object
+ * @return void
*/
public static function del($messageTemplatesID) {
// make sure messageTemplatesID is an integer
/**
* Get the Message Templates
*
- * @static
*
* @param bool $all
*
$smarty = CRM_Core_Smarty::singleton();
foreach (array(
'text',
- 'html'
+ 'html',
) as $elem) {
$$elem = $smarty->fetch("string:{$$elem}");
}
/**
* Revert a message template to its default subject+text+HTML state
*
- * @param int id id of the template
+ * @param int $id id of the template
*
* @return void
*/
public static function revert($id) {
- $diverted = new self;
+ $diverted = new CRM_Core_BAO_MessageTemplate();
$diverted->id = (int) $id;
$diverted->find(1);
CRM_Core_Error::fatal(ts('Did not find a message template with id of %1.', array(1 => $id)));
}
- $orig = new self;
+ $orig = new CRM_Core_BAO_MessageTemplate();
$orig->workflow_id = $diverted->workflow_id;
$orig->is_reserved = 1;
$orig->find(1);
* A string-keyed array of function params, see function body for details.
*
* @return array
- * of four parameters: a boolean whether the email was sent, and the subject, text and HTML templates
+ * Array of four parameters: a boolean whether the email was sent, and the subject, text and HTML templates
*/
public static function sendTemplate($params) {
$defaults = array(
else {
CRM_Core_Error::fatal(ts('No such message template: option group %1, option value %2.', array(
1 => $params['groupName'],
- 2 => $params['valueName']
+ 2 => $params['valueName'],
)));
}
}
// replace tokens in the three elements (in subject as if it was the text body)
$domain = CRM_Core_BAO_Domain::getDomain();
$hookTokens = array();
- $mailing = new CRM_Mailing_BAO_Mailing;
+ $mailing = new CRM_Mailing_BAO_Mailing();
$mailing->body_text = $text;
$mailing->body_html = $html;
$tokens = $mailing->getTokens();
$text = CRM_Utils_Token::replaceContactTokens($text, $contact, FALSE, $tokens['text'], FALSE, TRUE);
$html = CRM_Utils_Token::replaceContactTokens($html, $contact, FALSE, $tokens['html'], FALSE, TRUE);
-
$contactArray = array($contactID => $contact);
CRM_Utils_Hook::tokenValues($contactArray,
array($contactID),
$subject = "{strip}$subject{/strip}";
// parse the three elements with Smarty
-
-
$smarty = CRM_Core_Smarty::singleton();
foreach ($params['tplParams'] as $name => $value) {
$smarty->assign($name, $value);
foreach (array(
'subject',
'text',
- 'html'
+ 'html',
) as $elem) {
$$elem = $smarty->fetch("string:{$$elem}");
}