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() {
69 $result['crmMailing'] = array(
73 'ang/crmMailing/*.js',
75 'css' => array('ang/crmMailing.css'),
76 'partials' => array('ang/crmMailing'),
78 $result['crmMailingAB'] = array(
81 'ang/crmMailingAB.js',
82 'ang/crmMailingAB/*.js',
83 'ang/crmMailingAB/*/*.js',
85 'css' => array('ang/crmMailingAB.css'),
86 'partials' => array('ang/crmMailingAB'),
88 $result['crmD3'] = array(
92 'bower_components/d3/d3.min.js',
96 $config = CRM_Core_Config
::singleton();
97 $session = CRM_Core_Session
::singleton();
98 $contactID = $session->get('userID');
101 // CRM-16155 - Limit to a reasonable number
102 $civiMails = civicrm_api3('Mailing', 'get', array(
104 'mailing_type' => array('IN' => array('standalone', 'winner')),
105 'return' => array('id', 'name', 'scheduled_date'),
109 'sort' => 'is_archived asc, scheduled_date desc',
114 'options' => array('limit' => 0),
118 $groupNames = civicrm_api3('Group', 'get', $params +
array(
120 'check_permissions' => TRUE,
121 'return' => array('title', 'visibility', 'group_type', 'is_hidden'),
123 $headerfooterList = civicrm_api3('MailingComponent', 'get', $params +
array(
125 'return' => array('name', 'component_type', 'is_default', 'body_html', 'body_text'),
128 $emailAdd = civicrm_api3('Email', 'get', array(
131 'contact_id' => $contactID,
134 $mesTemplate = civicrm_api3('MessageTemplate', 'get', $params +
array(
137 'return' => array("id", "msg_title"),
138 'workflow_id' => array('IS NULL' => ""),
140 $mailTokens = civicrm_api3('Mailing', 'gettokens', array(
141 'entity' => array('contact', 'mailing'),
144 $fromAddress = civicrm_api3('OptionValue', 'get', $params +
array(
145 'option_group_id' => "from_email_address",
146 'domain_id' => CRM_Core_Config
::domainID(),
148 CRM_Core_Resources
::singleton()
150 'crmMailing' => array(
151 'civiMails' => $civiMails['values'],
152 'campaignEnabled' => in_array('CiviCampaign', $config->enableComponents
),
153 'groupNames' => $groupNames['values'],
154 'headerfooterList' => $headerfooterList['values'],
155 'mesTemplate' => $mesTemplate['values'],
156 'emailAdd' => $emailAdd['values'],
157 'mailTokens' => $mailTokens['values'],
158 'contactid' => $contactID,
159 'requiredTokens' => CRM_Utils_Token
::getRequiredTokens(),
160 'enableReplyTo' => (int) CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::MAILING_PREFERENCES_NAME
, 'replyTo'),
161 'disableMandatoryTokensCheck' => (int) CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::MAILING_PREFERENCES_NAME
, 'disable_mandatory_tokens_check'),
162 'fromAddress' => $fromAddress['values'],
163 'defaultTestEmail' => civicrm_api3('Contact', 'getvalue', array(
164 'id' => 'user_contact_id',
167 'visibility' => CRM_Utils_Array
::makeNonAssociative(CRM_Core_SelectValues
::groupVisibility()),
168 'workflowEnabled' => CRM_Mailing_Info
::workflowEnabled(),
171 ->addPermissions(array(
177 'delete in CiviMail',
186 public static function workflowEnabled() {
187 $config = CRM_Core_Config
::singleton();
189 // early exit, since not true for most
190 if (!$config->userSystem
->is_drupal ||
191 !function_exists('module_exists')
196 if (!module_exists('rules')) {
200 $enableWorkflow = CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::MAILING_PREFERENCES_NAME
,
206 return ($enableWorkflow &&
207 $config->userSystem
->is_drupal
213 * @param bool $getAllUnconditionally
214 * @param bool $descriptions
215 * Whether to return permission descriptions
219 public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) {
220 $permissions = array(
221 'access CiviMail' => array(
222 ts('access CiviMail'),
224 'access CiviMail subscribe/unsubscribe pages' => array(
225 ts('access CiviMail subscribe/unsubscribe pages'),
226 ts('Subscribe/unsubscribe from mailing list group'),
228 'delete in CiviMail' => array(
229 ts('delete in CiviMail'),
230 ts('Delete Mailing'),
232 'view public CiviMail content' => array(
233 ts('view public CiviMail content'),
237 if (self
::workflowEnabled() ||
$getAllUnconditionally) {
238 $permissions[] = array(
239 'create mailings' => array(
240 ts('create mailings'),
243 $permissions[] = array(
244 'schedule mailings' => array(
245 ts('schedule mailings'),
248 $permissions[] = array(
249 'approve mailings' => array(
250 ts('approve mailings'),
255 if (!$descriptions) {
256 foreach ($permissions as $name => $attr) {
257 $permissions[$name] = array_shift($attr);
269 public function getUserDashboardElement() {
270 // no dashboard element for this component
277 public function getUserDashboardObject() {
278 // no dashboard element for this component
286 public function registerTab() {
288 'title' => ts('Mailings'),
299 public function registerAdvancedSearchPane() {
301 'title' => ts('Mailings'),
310 public function getActivityTypes() {
315 * add shortcut to Create New.
318 public function creatNewShortcut(&$shortCuts) {