3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
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
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 $result['crmMailing'] = array(
80 'ang/crmMailing/*.js',
82 'css' => array('ang/crmMailing.css'),
83 'partials' => array('ang/crmMailing'),
85 $result['crmMailingAB'] = array(
88 'ang/crmMailingAB.js',
89 'ang/crmMailingAB/*.js',
90 'ang/crmMailingAB/*/*.js',
92 'css' => array('ang/crmMailingAB.css'),
93 'partials' => array('ang/crmMailingAB'),
95 $result['crmD3'] = array(
99 'bower_components/d3/d3.min.js',
103 $config = CRM_Core_Config
::singleton();
104 $session = CRM_Core_Session
::singleton();
105 $contactID = $session->get('userID');
107 // Get past mailings.
108 // CRM-16155 - Limit to a reasonable number.
109 $civiMails = civicrm_api3('Mailing', 'get', array(
111 'mailing_type' => array('IN' => array('standalone', 'winner')),
112 'domain_id' => CRM_Core_Config
::domainID(),
113 'return' => array('id', 'name', 'scheduled_date'),
117 'sort' => 'is_archived asc, scheduled_date desc',
122 'options' => array('limit' => 0),
126 $groupNames = civicrm_api3('Group', 'get', $params +
array(
128 'check_permissions' => TRUE,
129 'return' => array('title', 'visibility', 'group_type', 'is_hidden'),
131 $headerfooterList = civicrm_api3('MailingComponent', 'get', $params +
array(
133 'return' => array('name', 'component_type', 'is_default', 'body_html', 'body_text'),
136 $emailAdd = civicrm_api3('Email', 'get', array(
139 'contact_id' => $contactID,
142 $mesTemplate = civicrm_api3('MessageTemplate', 'get', $params +
array(
145 'return' => array("id", "msg_title"),
146 'workflow_id' => array('IS NULL' => ""),
148 $mailTokens = civicrm_api3('Mailing', 'gettokens', array(
149 'entity' => array('contact', 'mailing'),
152 $fromAddress = civicrm_api3('OptionValue', 'get', $params +
array(
153 'option_group_id' => "from_email_address",
154 'domain_id' => CRM_Core_Config
::domainID(),
156 CRM_Core_Resources
::singleton()
158 'crmMailing' => array(
159 'civiMails' => $civiMails['values'],
160 'campaignEnabled' => in_array('CiviCampaign', $config->enableComponents
),
161 'groupNames' => $groupNames['values'],
162 'headerfooterList' => $headerfooterList['values'],
163 'mesTemplate' => $mesTemplate['values'],
164 'emailAdd' => $emailAdd['values'],
165 'mailTokens' => $mailTokens['values'],
166 'contactid' => $contactID,
167 'requiredTokens' => CRM_Utils_Token
::getRequiredTokens(),
168 'enableReplyTo' => (int) CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::MAILING_PREFERENCES_NAME
, 'replyTo'),
169 'disableMandatoryTokensCheck' => (int) CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::MAILING_PREFERENCES_NAME
, 'disable_mandatory_tokens_check'),
170 'fromAddress' => $fromAddress['values'],
171 'defaultTestEmail' => civicrm_api3('Contact', 'getvalue', array(
172 'id' => 'user_contact_id',
175 'visibility' => CRM_Utils_Array
::makeNonAssociative(CRM_Core_SelectValues
::groupVisibility()),
176 'workflowEnabled' => CRM_Mailing_Info
::workflowEnabled(),
179 ->addPermissions(array(
185 'delete in CiviMail',
186 'edit message templates',
195 public static function workflowEnabled() {
196 $config = CRM_Core_Config
::singleton();
198 // early exit, since not true for most
199 if (!$config->userSystem
->is_drupal ||
200 !function_exists('module_exists')
205 if (!module_exists('rules')) {
209 $enableWorkflow = CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::MAILING_PREFERENCES_NAME
,
215 return ($enableWorkflow &&
216 $config->userSystem
->is_drupal
222 * @param bool $getAllUnconditionally
223 * @param bool $descriptions
224 * Whether to return permission descriptions
228 public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) {
229 $permissions = array(
230 'access CiviMail' => array(
231 ts('access CiviMail'),
233 'access CiviMail subscribe/unsubscribe pages' => array(
234 ts('access CiviMail subscribe/unsubscribe pages'),
235 ts('Subscribe/unsubscribe from mailing list group'),
237 'delete in CiviMail' => array(
238 ts('delete in CiviMail'),
239 ts('Delete Mailing'),
241 'view public CiviMail content' => array(
242 ts('view public CiviMail content'),
246 if (self
::workflowEnabled() ||
$getAllUnconditionally) {
247 $permissions[] = array(
248 'create mailings' => array(
249 ts('create mailings'),
252 $permissions[] = array(
253 'schedule mailings' => array(
254 ts('schedule mailings'),
257 $permissions[] = array(
258 'approve mailings' => array(
259 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) {