3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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-2014
38 class CRM_Mailing_Info
extends CRM_Core_Component_Info
{
40 // docs inherited from interface
41 protected $keyword = 'mailing';
44 // docs inherited from interface
48 public function getInfo() {
51 'translatedName' => ts('CiviMail'),
52 'title' => 'CiviCRM Mailing Engine',
54 'showActivitiesInCore' => 1,
58 public function getAngularModules() {
60 $result['crmMailing'] = array(
62 'js' => array('js/angular-crmMailing.js', 'js/angular-crmMailing/services.js', 'js/angular-crmMailing/directives.js'),
63 'css' => array('css/angular-crmMailing.css'),
65 $result['crmMailingAB'] = array(
67 'js' => array('js/angular-crmMailingAB.js', 'js/angular-crmMailingAB/services.js', 'js/angular-crmMailingAB/directives.js'),
68 'css' => array('css/angular-crmMailingAB.css'),
70 $result['crmD3'] = array(
72 'js' => array('js/angular-crmD3.js', 'js/d3.min.js'),
75 $config = CRM_Core_Config
::singleton();
76 $session = CRM_Core_Session
::singleton();
77 $contactID = $session->get('userID');
78 $civiMails = civicrm_api3('Mailing', 'get', array());
79 $campNames = civicrm_api3('Campaign', 'get', array());
80 $mailingabNames = civicrm_api3('MailingAB', 'get', array());
81 $mailStatus = civicrm_api3('MailingJob', 'get', array());
82 $groupNames = civicrm_api3('Group', 'get', array());
83 $headerfooterList = civicrm_api3('MailingComponent', 'get', array());
85 // FIXME: The following two items differ between GSOC CiviMail and ABTest branches
88 $emailAdd = civicrm_api3('Email', 'get', array());
89 $mesTemplate = civicrm_api3('MessageTemplate', 'get', array(
91 'return' => array("msg_html", "id", "msg_title", "msg_subject"),
92 'id' => array('>' => 58),
96 $emailAdd = civicrm_api3('Email', 'get', array(
99 'contact_id' => $contactID,
101 $mesTemplate = civicrm_api3('MessageTemplate', 'get', array(
103 'return' => array("msg_html", "id", "msg_title", "msg_subject", "msg_text"),
104 'workflow_id' => array('IS NULL' => ""),
107 $mailGrp = civicrm_api3('MailingGroup', 'get', array());
108 $mailTokens = civicrm_api3('Mailing', 'get_token', array( 'usage' => 'Mailing'));
109 $fromAddress = civicrm_api3('OptionGroup', 'get', array(
111 'name' => "from_email_address",
112 'api.OptionValue.get' => array(),
114 CRM_Core_Resources
::singleton()->addSetting(array(
115 'crmMailing' => array(
116 'mailingabNames' => array_values($mailingabNames['values']),
117 'civiMails' => array_values($civiMails['values']),
118 'campNames' => array_values($campNames['values']),
119 'mailStatus' => array_values($mailStatus['values']),
120 'groupNames' => array_values($groupNames['values']),
121 'headerfooterList' => array_values($headerfooterList['values']),
122 'mesTemplate' => array_values($mesTemplate['values']),
123 'emailAdd' => array_values($emailAdd['values']),
124 'mailGrp' => array_values($mailGrp['values']),
125 'mailTokens' => array_values($mailTokens),
126 'contactid' => $contactID,
127 'enableReplyTo' => isset($config->replyTo
) ?
$config->replyTo
: 0,
128 'fromAddress' => array_values($fromAddress['values'][0]['api.OptionValue.get']['values']),
129 'defaultTestEmail' => civicrm_api3('Contact', 'getvalue', array('id' => 'user_contact_id', 'return' => 'email')),
130 'visibility' => array(
131 array('value' => 'Public Pages', 'label' => ts('Public Pages')),
132 array('value' => 'User and User Admin Only', 'label' => ts('User and User Admin Only')),
143 public static function workflowEnabled() {
144 $config = CRM_Core_Config
::singleton();
146 // early exit, since not true for most
147 if (!$config->userSystem
->is_drupal ||
148 !function_exists('module_exists')
153 if (!module_exists('rules')) {
157 $enableWorkflow = CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::MAILING_PREFERENCES_NAME
,
163 return ($enableWorkflow &&
164 $config->userSystem
->is_drupal
168 // docs inherited from interface
170 * @param bool $getAllUnconditionally
174 public function getPermissions($getAllUnconditionally = FALSE) {
175 $permissions = array(
177 'access CiviMail subscribe/unsubscribe pages',
178 'delete in CiviMail',
179 'view public CiviMail content',
182 if (self
::workflowEnabled() ||
$getAllUnconditionally) {
183 $permissions[] = 'create mailings';
184 $permissions[] = 'schedule mailings';
185 $permissions[] = 'approve mailings';
192 // docs inherited from interface
196 public function getUserDashboardElement() {
197 // no dashboard element for this component
204 public function getUserDashboardObject() {
205 // no dashboard element for this component
209 // docs inherited from interface
213 public function registerTab() {
215 'title' => ts('Mailings'),
222 // docs inherited from interface
226 public function registerAdvancedSearchPane() {
228 'title' => ts('Mailings'),
233 // docs inherited from interface
237 public function getActivityTypes() {
241 // add shortcut to Create New
245 public function creatNewShortcut(&$shortCuts) {