3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2016 |
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-2016
36 class CRM_Mailing_Info
extends CRM_Core_Component_Info
{
41 protected $keyword = 'mailing';
48 public function getInfo() {
51 'translatedName' => ts('CiviMail'),
52 'title' => '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')
76 $reportTypes = array('detail', 'opened', 'bounce', 'clicks');
77 foreach ($reportTypes as $report) {
78 $result = civicrm_api3('ReportInstance', 'get', array(
80 'report_id' => 'mailing/' . $report));
81 $reportIds[$report] = $result['values'][0]['id'];
84 $result['crmMailing'] = array(
88 'ang/crmMailing/*.js',
90 'css' => array('ang/crmMailing.css'),
91 'partials' => array('ang/crmMailing'),
93 $result['crmMailingAB'] = array(
96 'ang/crmMailingAB.js',
97 'ang/crmMailingAB/*.js',
98 'ang/crmMailingAB/*/*.js',
100 'css' => array('ang/crmMailingAB.css'),
101 'partials' => array('ang/crmMailingAB'),
103 $result['crmD3'] = array(
107 'bower_components/d3/d3.min.js',
111 $config = CRM_Core_Config
::singleton();
112 $session = CRM_Core_Session
::singleton();
113 $contactID = $session->get('userID');
115 // Get past mailings.
116 // CRM-16155 - Limit to a reasonable number.
117 $civiMails = civicrm_api3('Mailing', 'get', array(
119 'mailing_type' => array('IN' => array('standalone', 'winner')),
120 'domain_id' => CRM_Core_Config
::domainID(),
121 'return' => array('id', 'name', 'scheduled_date'),
125 'sort' => 'is_archived asc, scheduled_date desc',
130 'options' => array('limit' => 0),
134 $groupNames = civicrm_api3('Group', 'get', $params +
array(
136 'check_permissions' => TRUE,
137 'return' => array('title', 'visibility', 'group_type', 'is_hidden'),
139 $headerfooterList = civicrm_api3('MailingComponent', 'get', $params +
array(
141 'return' => array('name', 'component_type', 'is_default', 'body_html', 'body_text'),
144 $emailAdd = civicrm_api3('Email', 'get', array(
147 'contact_id' => $contactID,
150 $mesTemplate = civicrm_api3('MessageTemplate', 'get', $params +
array(
153 'return' => array("id", "msg_title"),
154 'workflow_id' => array('IS NULL' => ""),
156 $mailTokens = civicrm_api3('Mailing', 'gettokens', array(
157 'entity' => array('contact', 'mailing'),
160 $fromAddress = civicrm_api3('OptionValue', 'get', $params +
array(
161 'option_group_id' => "from_email_address",
162 'domain_id' => CRM_Core_Config
::domainID(),
164 CRM_Core_Resources
::singleton()
166 'crmMailing' => array(
167 'civiMails' => $civiMails['values'],
168 'campaignEnabled' => in_array('CiviCampaign', $config->enableComponents
),
169 'groupNames' => $groupNames['values'],
170 'headerfooterList' => $headerfooterList['values'],
171 'mesTemplate' => $mesTemplate['values'],
172 'emailAdd' => $emailAdd['values'],
173 'mailTokens' => $mailTokens['values'],
174 'contactid' => $contactID,
175 'requiredTokens' => CRM_Utils_Token
::getRequiredTokens(),
176 'enableReplyTo' => (int) Civi
::settings()->get('replyTo'),
177 'disableMandatoryTokensCheck' => (int) Civi
::settings()->get('disable_mandatory_tokens_check'),
178 'fromAddress' => $fromAddress['values'],
179 'defaultTestEmail' => civicrm_api3('Contact', 'getvalue', array(
180 'id' => 'user_contact_id',
183 'visibility' => CRM_Utils_Array
::makeNonAssociative(CRM_Core_SelectValues
::groupVisibility()),
184 'workflowEnabled' => CRM_Mailing_Info
::workflowEnabled(),
185 'reportIds' => $reportIds,
188 ->addPermissions(array(
195 'delete in CiviMail',
196 'edit message templates',
205 public static function workflowEnabled() {
206 $config = CRM_Core_Config
::singleton();
208 // early exit, since not true for most
209 if (!$config->userSystem
->is_drupal ||
210 !function_exists('module_exists')
215 if (!module_exists('rules')) {
219 $enableWorkflow = Civi
::settings()->get('civimail_workflow');
221 return ($enableWorkflow &&
222 $config->userSystem
->is_drupal
228 * @param bool $getAllUnconditionally
229 * @param bool $descriptions
230 * Whether to return permission descriptions
234 public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) {
235 $permissions = array(
236 'access CiviMail' => array(
237 ts('access CiviMail'),
239 'access CiviMail subscribe/unsubscribe pages' => array(
240 ts('access CiviMail subscribe/unsubscribe pages'),
241 ts('Subscribe/unsubscribe from mailing list group'),
243 'delete in CiviMail' => array(
244 ts('delete in CiviMail'),
245 ts('Delete Mailing'),
247 'view public CiviMail content' => array(
248 ts('view public CiviMail content'),
252 if (self
::workflowEnabled() ||
$getAllUnconditionally) {
253 $permissions['create mailings'] = array(
254 ts('create mailings'),
256 $permissions['schedule mailings'] = array(
257 ts('schedule mailings'),
259 $permissions['approve mailings'] = array(
260 ts('approve mailings'),
264 if (!$descriptions) {
265 foreach ($permissions as $name => $attr) {
266 $permissions[$name] = array_shift($attr);
278 public function getUserDashboardElement() {
279 // no dashboard element for this component
286 public function getUserDashboardObject() {
287 // no dashboard element for this component
295 public function registerTab() {
297 'title' => ts('Mailings'),
308 public function registerAdvancedSearchPane() {
310 'title' => ts('Mailings'),
319 public function getActivityTypes() {
324 * add shortcut to Create New.
327 public function creatNewShortcut(&$shortCuts) {