'contact_id' => $contactID,
));
- // FIXME: Loading the contents of every template into the dom does not scale well
$mesTemplate = civicrm_api3('MessageTemplate', 'get', $params + array(
'sequential' => 1,
'is_active' => 1,
- 'return' => array("msg_html", "id", "msg_title", "msg_subject", "msg_text"),
+ 'return' => array("id", "msg_title"),
'workflow_id' => array('IS NULL' => ""),
));
$mailTokens = civicrm_api3('Mailing', 'gettokens', array(
window.tpls = tpls;
var lastModifiedTpl = null;
return {
+ // Get a template
+ // @param id MessageTemplate id (per APIv3)
// @return Promise MessageTemplate (per APIv3)
get: function get(id) {
- id = '' + id; // parseInt(id);
var dfr = $q.defer();
- var tpl = _.where(tpls, {id: id});
- if (id && tpl && tpl[0]) {
- dfr.resolve(tpl[0]);
- }
- else {
- dfr.reject(id);
- }
+ var tpl = CRM.api3('MessageTemplate', 'get', {
+ "sequential": 1,
+ "return": "id,msg_subject,msg_html,msg_title,msg_text",
+ "id": id
+ }).done(function(result) {
+ if (result.is_error) {
+ dfr.reject(id);
+ }
+ else {
+ dfr.resolve(result['values'][0]);
+ }
+ });
return dfr.promise;
},
// Save a template