3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
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(
63 'js/angular-Mailing.js' ,
64 'js/angularsanitize.js' ,
65 'packages/ckeditor/ckeditor.js'
68 $result['crmMailing2'] = array(
70 'js' => array('js/angular-crmMailing2.js'),
72 $result['crmMailingAB'] = array(
75 'js/angular-crmMailingAB.js',
76 'js/angular-crmMailingAB-ReportCtrl.js',
78 'js/angular-sanitize.js',
79 'packages/ckeditor/ckeditor.js',
81 'css' => array('css/angular-crmMailingAB.css'),
84 $session = CRM_Core_Session
::singleton();
85 $contactID = $session->get('userID');
86 $civiMails = civicrm_api3('Mailing', 'get', array());
87 $campNames = civicrm_api3('Campaign', 'get', array());
88 $mailingabNames = civicrm_api3('MailingAB','get',array());
89 $mailStatus = civicrm_api3('MailingJob', 'get', array());
90 $groupNames = civicrm_api3('Group', 'get', array());
91 $headerfooterList = civicrm_api3('MailingComponent', 'get', array());
93 // FIXME: The following two items differ between GSOC CiviMail and ABTest branches
96 $emailAdd = civicrm_api3('Email', 'get', array());
97 $mesTemplate = civicrm_api3('MessageTemplate', 'get', array(
99 'return' => array("msg_html", "id", "msg_title","msg_subject"),
100 'id' => array('>' => 58),
104 $emailAdd = civicrm_api3('Email', 'get', array(
107 'contact_id' => $contactID,
109 $mesTemplate = civicrm_api3('MessageTemplate', 'get', array( 'sequential' => 1,
110 'return' => array("msg_html", "id", "msg_title", "msg_subject"),
111 'workflow_id' => array('IS NULL' => ""),
114 $mailGrp = civicrm_api3('MailingGroup','get', array());
115 $mailTokens = civicrm_api3('Mailing', 'get_token', array( 'usage' => 'Mailing'));
116 $fromAddress = civicrm_api3('OptionGroup', 'get', array(
118 'name' => "from_email_address",
119 'api.OptionValue.get' => array(),
121 CRM_Core_Resources
::singleton()->addSetting(array(
122 'crmMailing' => array(
123 'mailingabNames'=>array_values($mailingabNames['values']),
124 'civiMails' => array_values($civiMails['values']),
125 'campNames' => array_values($campNames['values']),
126 'mailStatus' => array_values($mailStatus['values']),
127 'groupNames' => array_values($groupNames['values']),
128 'headerfooterList' => array_values($headerfooterList['values']),
129 'mesTemplate' => array_values($mesTemplate['values']),
130 'emailAdd' => array_values($emailAdd['values']),
131 'mailGrp' => array_values($mailGrp['values']),
132 'mailTokens' => array_values($mailTokens),
133 'contactid' => $contactID,
134 'fromAddress' => array_values($fromAddress['values'][0]['api.OptionValue.get']['values']),
144 static function workflowEnabled() {
145 $config = CRM_Core_Config
::singleton();
147 // early exit, since not true for most
148 if (!$config->userSystem
->is_drupal ||
149 !function_exists('module_exists')
154 if (!module_exists('rules')) {
158 $enableWorkflow = CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::MAILING_PREFERENCES_NAME
,
164 return ($enableWorkflow &&
165 $config->userSystem
->is_drupal
169 // docs inherited from interface
171 * @param bool $getAllUnconditionally
175 public function getPermissions($getAllUnconditionally = FALSE) {
176 $permissions = array(
178 'access CiviMail subscribe/unsubscribe pages',
179 'delete in CiviMail',
180 'view public CiviMail content',
183 if (self
::workflowEnabled() ||
$getAllUnconditionally) {
184 $permissions[] = 'create mailings';
185 $permissions[] = 'schedule mailings';
186 $permissions[] = 'approve mailings';
193 // docs inherited from interface
197 public function getUserDashboardElement() {
198 // no dashboard element for this component
205 public function getUserDashboardObject() {
206 // no dashboard element for this component
210 // docs inherited from interface
214 public function registerTab() {
216 'title' => ts('Mailings'),
223 // docs inherited from interface
227 public function registerAdvancedSearchPane() {
228 return array('title' => ts('Mailings'),
233 // docs inherited from interface
237 public function getActivityTypes() {
241 // add shortcut to Create New
245 public function creatNewShortcut(&$shortCuts) {}