3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2017 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
29 * This class introduces component to the system and provides all the
30 * information about it. It needs to extend CRM_Core_Component_Info
34 * @copyright CiviCRM LLC (c) 2004-2017
36 class CRM_Mailing_Info
extends CRM_Core_Component_Info
{
41 protected $keyword = 'mailing';
48 public function getInfo() {
51 'translatedName' => ts('CiviMail'),
52 'title' => ts('CiviCRM Mailing Engine'),
54 'showActivitiesInCore' => 1,
59 * Get AngularJS modules and their dependencies.
62 * list of modules; same format as CRM_Utils_Hook::angularModules(&$angularModules)
63 * @see CRM_Utils_Hook::angularModules
65 public function getAngularModules() {
66 // load angular files only if valid permissions are granted to the user
67 if (!CRM_Core_Permission
::check('access CiviMail')
68 && !CRM_Core_Permission
::check('create mailings')
69 && !CRM_Core_Permission
::check('schedule mailings')
70 && !CRM_Core_Permission
::check('approve mailings')
77 $reportTypes = array('detail', 'opened', 'bounce', 'clicks');
78 foreach ($reportTypes as $report) {
79 $result = civicrm_api3('ReportInstance', 'get', array(
81 'report_id' => 'mailing/' . $report));
82 $reportIds[$report] = $result['values'][0]['id'];
85 $result['crmMailing'] = include "$civicrm_root/ang/crmMailing.ang.php";
86 $result['crmMailingAB'] = include "$civicrm_root/ang/crmMailingAB.ang.php";
87 $result['crmD3'] = include "$civicrm_root/ang/crmD3.ang.php";
89 $config = CRM_Core_Config
::singleton();
90 $session = CRM_Core_Session
::singleton();
91 $contactID = $session->get('userID');
95 'options' => array('limit' => 0),
98 $groupNames = civicrm_api3('Group', 'get', $params +
array(
100 'check_permissions' => TRUE,
101 'return' => array('title', 'visibility', 'group_type', 'is_hidden'),
103 $headerfooterList = civicrm_api3('MailingComponent', 'get', $params +
array(
105 'return' => array('name', 'component_type', 'is_default', 'body_html', 'body_text'),
108 $emailAdd = civicrm_api3('Email', 'get', array(
111 'contact_id' => $contactID,
114 $mesTemplate = civicrm_api3('MessageTemplate', 'get', $params +
array(
117 'return' => array("id", "msg_title"),
118 'workflow_id' => array('IS NULL' => ""),
120 $mailTokens = civicrm_api3('Mailing', 'gettokens', array(
121 'entity' => array('contact', 'mailing'),
124 $fromAddress = civicrm_api3('OptionValue', 'get', $params +
array(
125 'option_group_id' => "from_email_address",
126 'domain_id' => CRM_Core_Config
::domainID(),
128 $enabledLanguages = CRM_Core_I18n
::languages(TRUE);
129 $isMultiLingual = (count($enabledLanguages) > 1);
130 CRM_Core_Resources
::singleton()
132 'crmMailing' => array(
133 'templateTypes' => CRM_Mailing_BAO_Mailing
::getTemplateTypes(),
134 'civiMails' => array(),
135 'campaignEnabled' => in_array('CiviCampaign', $config->enableComponents
),
136 'groupNames' => array(),
137 // @todo see if we can remove this by dynamically generating the test group list
138 'testGroupNames' => $groupNames['values'],
139 'headerfooterList' => $headerfooterList['values'],
140 'mesTemplate' => $mesTemplate['values'],
141 'emailAdd' => $emailAdd['values'],
142 'mailTokens' => $mailTokens['values'],
143 'contactid' => $contactID,
144 'requiredTokens' => CRM_Utils_Token
::getRequiredTokens(),
145 'enableReplyTo' => (int) Civi
::settings()->get('replyTo'),
146 'disableMandatoryTokensCheck' => (int) Civi
::settings()->get('disable_mandatory_tokens_check'),
147 'fromAddress' => $fromAddress['values'],
148 'defaultTestEmail' => civicrm_api3('Contact', 'getvalue', array(
149 'id' => 'user_contact_id',
152 'visibility' => CRM_Utils_Array
::makeNonAssociative(CRM_Core_SelectValues
::groupVisibility()),
153 'workflowEnabled' => CRM_Mailing_Info
::workflowEnabled(),
154 'reportIds' => $reportIds,
155 'enabledLanguages' => $enabledLanguages,
156 'isMultiLingual' => $isMultiLingual,
159 ->addPermissions(array(
166 'delete in CiviMail',
167 'edit message templates',
176 public static function workflowEnabled() {
177 $config = CRM_Core_Config
::singleton();
179 // early exit, since not true for most
180 if (!$config->userSystem
->is_drupal ||
181 !function_exists('module_exists')
186 if (!module_exists('rules')) {
190 $enableWorkflow = Civi
::settings()->get('civimail_workflow');
192 return ($enableWorkflow &&
193 $config->userSystem
->is_drupal
199 * @param bool $getAllUnconditionally
200 * @param bool $descriptions
201 * Whether to return permission descriptions
205 public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) {
206 $permissions = array(
207 'access CiviMail' => array(
208 ts('access CiviMail'),
210 'access CiviMail subscribe/unsubscribe pages' => array(
211 ts('access CiviMail subscribe/unsubscribe pages'),
212 ts('Subscribe/unsubscribe from mailing list group'),
214 'delete in CiviMail' => array(
215 ts('delete in CiviMail'),
216 ts('Delete Mailing'),
218 'view public CiviMail content' => array(
219 ts('view public CiviMail content'),
223 if (self
::workflowEnabled() ||
$getAllUnconditionally) {
224 $permissions['create mailings'] = array(
225 ts('create mailings'),
227 $permissions['schedule mailings'] = array(
228 ts('schedule mailings'),
230 $permissions['approve mailings'] = array(
231 ts('approve mailings'),
235 if (!$descriptions) {
236 foreach ($permissions as $name => $attr) {
237 $permissions[$name] = array_shift($attr);
249 public function getUserDashboardElement() {
250 // no dashboard element for this component
257 public function getUserDashboardObject() {
258 // no dashboard element for this component
266 public function registerTab() {
268 'title' => ts('Mailings'),
279 public function registerAdvancedSearchPane() {
281 'title' => ts('Mailings'),
290 public function getActivityTypes() {
295 * add shortcut to Create New.
298 public function creatNewShortcut(&$shortCuts) {