3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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-2015
38 class CRM_Mailing_Info
extends CRM_Core_Component_Info
{
43 protected $keyword = 'mailing';
50 public function getInfo() {
53 'translatedName' => ts('CiviMail'),
54 'title' => 'CiviCRM Mailing Engine',
56 'showActivitiesInCore' => 1,
61 * Get AngularJS modules and their dependencies
64 * list of modules; same format as CRM_Utils_Hook::angularModules(&$angularModules)
65 * @see CRM_Utils_Hook::angularModules
67 public function getAngularModules() {
68 // load angular files only if valid permissions are granted to the user
69 if (!CRM_Core_Permission
::check('access CiviMail')
70 && !CRM_Core_Permission
::check('create mailings')
71 && !CRM_Core_Permission
::check('schedule mailings')
72 && !CRM_Core_Permission
::check('approve mailings')
78 $reportTypes = array('detail', 'opened', 'bounce', 'clicks');
79 foreach ($reportTypes as $report) {
80 $result = civicrm_api3('ReportInstance', 'get', array(
82 'report_id' => 'mailing/' . $report));
83 $reportIds[$report] = $result['values'][0]['id'];
86 $result['crmMailing'] = array(
90 'ang/crmMailing/*.js',
92 'css' => array('ang/crmMailing.css'),
93 'partials' => array('ang/crmMailing'),
95 $result['crmMailingAB'] = array(
98 'ang/crmMailingAB.js',
99 'ang/crmMailingAB/*.js',
100 'ang/crmMailingAB/*/*.js',
102 'css' => array('ang/crmMailingAB.css'),
103 'partials' => array('ang/crmMailingAB'),
105 $result['crmD3'] = array(
109 'bower_components/d3/d3.min.js',
113 $config = CRM_Core_Config
::singleton();
114 $session = CRM_Core_Session
::singleton();
115 $contactID = $session->get('userID');
118 // CRM-16155 - Limit to a reasonable number
119 $civiMails = civicrm_api3('Mailing', 'get', array(
121 'mailing_type' => array('IN' => array('standalone', 'winner')),
122 'return' => array('id', 'name', 'scheduled_date'),
126 'sort' => 'is_archived asc, scheduled_date desc',
131 'options' => array('limit' => 0),
135 $groupNames = civicrm_api3('Group', 'get', $params +
array(
137 'check_permissions' => TRUE,
138 'return' => array('title', 'visibility', 'group_type', 'is_hidden'),
140 $headerfooterList = civicrm_api3('MailingComponent', 'get', $params +
array(
142 'return' => array('name', 'component_type', 'is_default', 'body_html', 'body_text'),
145 $emailAdd = civicrm_api3('Email', 'get', array(
148 'contact_id' => $contactID,
151 $mesTemplate = civicrm_api3('MessageTemplate', 'get', $params +
array(
154 'return' => array("id", "msg_title"),
155 'workflow_id' => array('IS NULL' => ""),
157 $mailTokens = civicrm_api3('Mailing', 'gettokens', array(
158 'entity' => array('contact', 'mailing'),
161 $fromAddress = civicrm_api3('OptionValue', 'get', $params +
array(
162 'option_group_id' => "from_email_address",
163 'domain_id' => CRM_Core_Config
::domainID(),
165 CRM_Core_Resources
::singleton()
167 'crmMailing' => array(
168 'templateTypes' => CRM_Mailing_BAO_Mailing
::getTemplateTypes(),
169 'civiMails' => $civiMails['values'],
170 'campaignEnabled' => in_array('CiviCampaign', $config->enableComponents
),
171 'groupNames' => $groupNames['values'],
172 'headerfooterList' => $headerfooterList['values'],
173 'mesTemplate' => $mesTemplate['values'],
174 'emailAdd' => $emailAdd['values'],
175 'mailTokens' => $mailTokens['values'],
176 'contactid' => $contactID,
177 'requiredTokens' => CRM_Utils_Token
::getRequiredTokens(),
178 'enableReplyTo' => (int) CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::MAILING_PREFERENCES_NAME
, 'replyTo'),
179 'disableMandatoryTokensCheck' => (int) CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::MAILING_PREFERENCES_NAME
, 'disable_mandatory_tokens_check'),
180 'fromAddress' => $fromAddress['values'],
181 'defaultTestEmail' => civicrm_api3('Contact', 'getvalue', array(
182 'id' => 'user_contact_id',
185 'visibility' => CRM_Utils_Array
::makeNonAssociative(CRM_Core_SelectValues
::groupVisibility()),
186 'workflowEnabled' => CRM_Mailing_Info
::workflowEnabled(),
187 'reportIds' => $reportIds,
190 ->addPermissions(array(
197 'delete in CiviMail',
198 'edit message templates',
207 public static function workflowEnabled() {
208 $config = CRM_Core_Config
::singleton();
210 // early exit, since not true for most
211 if (!$config->userSystem
->is_drupal ||
212 !function_exists('module_exists')
217 if (!module_exists('rules')) {
221 $enableWorkflow = CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::MAILING_PREFERENCES_NAME
,
227 return ($enableWorkflow &&
228 $config->userSystem
->is_drupal
234 * @param bool $getAllUnconditionally
235 * @param bool $descriptions
236 * Whether to return permission descriptions
240 public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) {
241 $permissions = array(
242 'access CiviMail' => array(
243 ts('access CiviMail'),
245 'access CiviMail subscribe/unsubscribe pages' => array(
246 ts('access CiviMail subscribe/unsubscribe pages'),
247 ts('Subscribe/unsubscribe from mailing list group'),
249 'delete in CiviMail' => array(
250 ts('delete in CiviMail'),
251 ts('Delete Mailing'),
253 'view public CiviMail content' => array(
254 ts('view public CiviMail content'),
258 if (self
::workflowEnabled() ||
$getAllUnconditionally) {
259 $permissions[] = array(
260 'create mailings' => array(
261 ts('create mailings'),
264 $permissions[] = array(
265 'schedule mailings' => array(
266 ts('schedule mailings'),
269 $permissions[] = array(
270 'approve mailings' => array(
271 ts('approve mailings'),
276 if (!$descriptions) {
277 foreach ($permissions as $name => $attr) {
278 $permissions[$name] = array_shift($attr);
290 public function getUserDashboardElement() {
291 // no dashboard element for this component
298 public function getUserDashboardObject() {
299 // no dashboard element for this component
307 public function registerTab() {
309 'title' => ts('Mailings'),
320 public function registerAdvancedSearchPane() {
322 'title' => ts('Mailings'),
331 public function getActivityTypes() {
336 * add shortcut to Create New.
339 public function creatNewShortcut(&$shortCuts) {