Merge pull request #7076 from totten/4.6-weight-sgn
[civicrm-core.git] / CRM / Mailing / Info.php
index 1905d16ed0dc47b8fc8cee0b4d5fa547d8c5740d..377b673678a6386b0b8eb3ca855cf54a1a6edcf7 100644 (file)
@@ -65,6 +65,15 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info {
    * @see CRM_Utils_Hook::angularModules
    */
   public function getAngularModules() {
+    // load angular files only if valid permissions are granted to the user
+    if (!CRM_Core_Permission::check('access CiviMail')
+      || !CRM_Core_Permission::check('create mailings')
+      || !CRM_Core_Permission::check('schedule mailings')
+      || !CRM_Core_Permission::check('approve mailings')
+    ) {
+      return array();
+    }
+
     $result = array();
     $result['crmMailing'] = array(
       'ext' => 'civicrm',
@@ -117,6 +126,7 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info {
 
     $groupNames = civicrm_api3('Group', 'get', $params + array(
       'is_active' => 1,
+      'check_permissions' => TRUE,
       'return' => array('title', 'visibility', 'group_type', 'is_hidden'),
     ));
     $headerfooterList = civicrm_api3('MailingComponent', 'get', $params + array(
@@ -130,11 +140,10 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info {
       '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(
@@ -143,6 +152,7 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info {
     ));
     $fromAddress = civicrm_api3('OptionValue', 'get', $params + array(
       'option_group_id' => "from_email_address",
+      'domain_id' => CRM_Core_Config::domainID(),
     ));
     CRM_Core_Resources::singleton()
       ->addSetting(array(
@@ -174,6 +184,7 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info {
         'schedule mailings',
         'approve mailings',
         'delete in CiviMail',
+        'edit message templates',
       ));
 
     return $result;