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(
194 'delete in CiviMail',
195 'edit message templates',
204 public static function workflowEnabled() {
205 $config = CRM_Core_Config
::singleton();
207 // early exit, since not true for most
208 if (!$config->userSystem
->is_drupal ||
209 !function_exists('module_exists')
214 if (!module_exists('rules')) {
218 $enableWorkflow = Civi
::settings()->get('civimail_workflow');
220 return ($enableWorkflow &&
221 $config->userSystem
->is_drupal
227 * @param bool $getAllUnconditionally
228 * @param bool $descriptions
229 * Whether to return permission descriptions
233 public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) {
234 $permissions = array(
235 'access CiviMail' => array(
236 ts('access CiviMail'),
238 'access CiviMail subscribe/unsubscribe pages' => array(
239 ts('access CiviMail subscribe/unsubscribe pages'),
240 ts('Subscribe/unsubscribe from mailing list group'),
242 'delete in CiviMail' => array(
243 ts('delete in CiviMail'),
244 ts('Delete Mailing'),
246 'view public CiviMail content' => array(
247 ts('view public CiviMail content'),
251 if (self
::workflowEnabled() ||
$getAllUnconditionally) {
252 $permissions['create mailings'] = array(
253 ts('create mailings'),
255 $permissions['schedule mailings'] = array(
256 ts('schedule mailings'),
258 $permissions['approve mailings'] = array(
259 ts('approve mailings'),
263 if (!$descriptions) {
264 foreach ($permissions as $name => $attr) {
265 $permissions[$name] = array_shift($attr);
277 public function getUserDashboardElement() {
278 // no dashboard element for this component
285 public function getUserDashboardObject() {
286 // no dashboard element for this component
294 public function registerTab() {
296 'title' => ts('Mailings'),
307 public function registerAdvancedSearchPane() {
309 'title' => ts('Mailings'),
318 public function getActivityTypes() {
323 * add shortcut to Create New.
326 public function creatNewShortcut(&$shortCuts) {