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 $result['crmMailing'] = array(
82 'ang/crmMailing/*.js',
84 'css' => array('ang/crmMailing.css'),
85 'partials' => array('ang/crmMailing'),
87 $result['crmMailingAB'] = array(
90 'ang/crmMailingAB.js',
91 'ang/crmMailingAB/*.js',
92 'ang/crmMailingAB/*/*.js',
94 'css' => array('ang/crmMailingAB.css'),
95 'partials' => array('ang/crmMailingAB'),
97 $result['crmD3'] = array(
101 'bower_components/d3/d3.min.js',
105 $config = CRM_Core_Config
::singleton();
106 $session = CRM_Core_Session
::singleton();
107 $contactID = $session->get('userID');
110 // CRM-16155 - Limit to a reasonable number
111 $civiMails = civicrm_api3('Mailing', 'get', array(
113 'mailing_type' => array('IN' => array('standalone', 'winner')),
114 'return' => array('id', 'name', 'scheduled_date'),
118 'sort' => 'is_archived asc, scheduled_date desc',
123 'options' => array('limit' => 0),
127 $groupNames = civicrm_api3('Group', 'get', $params +
array(
129 'check_permissions' => TRUE,
130 'return' => array('title', 'visibility', 'group_type', 'is_hidden'),
132 $headerfooterList = civicrm_api3('MailingComponent', 'get', $params +
array(
134 'return' => array('name', 'component_type', 'is_default', 'body_html', 'body_text'),
137 $emailAdd = civicrm_api3('Email', 'get', array(
140 'contact_id' => $contactID,
143 $mesTemplate = civicrm_api3('MessageTemplate', 'get', $params +
array(
146 'return' => array("id", "msg_title"),
147 'workflow_id' => array('IS NULL' => ""),
149 $mailTokens = civicrm_api3('Mailing', 'gettokens', array(
150 'entity' => array('contact', 'mailing'),
153 $fromAddress = civicrm_api3('OptionValue', 'get', $params +
array(
154 'option_group_id' => "from_email_address",
155 'domain_id' => CRM_Core_Config
::domainID(),
157 CRM_Core_Resources
::singleton()
159 'crmMailing' => array(
160 'civiMails' => $civiMails['values'],
161 'campaignEnabled' => in_array('CiviCampaign', $config->enableComponents
),
162 'groupNames' => $groupNames['values'],
163 'headerfooterList' => $headerfooterList['values'],
164 'mesTemplate' => $mesTemplate['values'],
165 'emailAdd' => $emailAdd['values'],
166 'mailTokens' => $mailTokens['values'],
167 'contactid' => $contactID,
168 'requiredTokens' => CRM_Utils_Token
::getRequiredTokens(),
169 'enableReplyTo' => (int) CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::MAILING_PREFERENCES_NAME
, 'replyTo'),
170 'disableMandatoryTokensCheck' => (int) CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::MAILING_PREFERENCES_NAME
, 'disable_mandatory_tokens_check'),
171 'fromAddress' => $fromAddress['values'],
172 'defaultTestEmail' => civicrm_api3('Contact', 'getvalue', array(
173 'id' => 'user_contact_id',
176 'visibility' => CRM_Utils_Array
::makeNonAssociative(CRM_Core_SelectValues
::groupVisibility()),
177 'workflowEnabled' => CRM_Mailing_Info
::workflowEnabled(),
180 ->addPermissions(array(
186 'delete in CiviMail',
187 'edit message templates',
196 public static function workflowEnabled() {
197 $config = CRM_Core_Config
::singleton();
199 // early exit, since not true for most
200 if (!$config->userSystem
->is_drupal ||
201 !function_exists('module_exists')
206 if (!module_exists('rules')) {
210 $enableWorkflow = CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::MAILING_PREFERENCES_NAME
,
216 return ($enableWorkflow &&
217 $config->userSystem
->is_drupal
223 * @param bool $getAllUnconditionally
224 * @param bool $descriptions
225 * Whether to return permission descriptions
229 public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) {
230 $permissions = array(
231 'access CiviMail' => array(
232 ts('access CiviMail'),
234 'access CiviMail subscribe/unsubscribe pages' => array(
235 ts('access CiviMail subscribe/unsubscribe pages'),
236 ts('Subscribe/unsubscribe from mailing list group'),
238 'delete in CiviMail' => array(
239 ts('delete in CiviMail'),
240 ts('Delete Mailing'),
242 'view public CiviMail content' => array(
243 ts('view public CiviMail content'),
247 if (self
::workflowEnabled() ||
$getAllUnconditionally) {
248 $permissions[] = array(
249 'create mailings' => array(
250 ts('create mailings'),
253 $permissions[] = array(
254 'schedule mailings' => array(
255 ts('schedule mailings'),
258 $permissions[] = array(
259 'approve mailings' => array(
260 ts('approve mailings'),
265 if (!$descriptions) {
266 foreach ($permissions as $name => $attr) {
267 $permissions[$name] = array_shift($attr);
279 public function getUserDashboardElement() {
280 // no dashboard element for this component
287 public function getUserDashboardObject() {
288 // no dashboard element for this component
296 public function registerTab() {
298 'title' => ts('Mailings'),
309 public function registerAdvancedSearchPane() {
311 'title' => ts('Mailings'),
320 public function getActivityTypes() {
325 * add shortcut to Create New.
328 public function creatNewShortcut(&$shortCuts) {