fix version in header
[civicrm-core.git] / CRM / Mailing / Info.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
39de6fd5 4 | CiviCRM version 4.6 |
6a488035 5 +--------------------------------------------------------------------+
06b69b18 6 | Copyright CiviCRM LLC (c) 2004-2014 |
6a488035
TO
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
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. |
13 | |
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. |
18 | |
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 +--------------------------------------------------------------------+
26*/
27
28/**
29 * This class introduces component to the system and provides all the
30 * information about it. It needs to extend CRM_Core_Component_Info
31 * abstract class.
32 *
33 * @package CRM
06b69b18 34 * @copyright CiviCRM LLC (c) 2004-2014
6a488035
TO
35 * $Id$
36 *
37 */
38class CRM_Mailing_Info extends CRM_Core_Component_Info {
39
40 // docs inherited from interface
41 protected $keyword = 'mailing';
42
43
44 // docs inherited from interface
e0ef6999
EM
45 /**
46 * @return array
47 */
6a488035
TO
48 public function getInfo() {
49 return array(
50 'name' => 'CiviMail',
51 'translatedName' => ts('CiviMail'),
52 'title' => 'CiviCRM Mailing Engine',
53 'search' => 1,
54 'showActivitiesInCore' => 1,
55 );
56 }
57
4aef704e 58 public function getAngularModules() {
59 $result = array();
88e9e883 60 $result['crmMailing'] = array(
030dce01 61 'ext' => 'civicrm',
96ac27bd
TO
62 'js' => array('js/angular-crmMailing.js', 'js/angular-crmMailing/services.js', 'js/angular-crmMailing/directives.js'),
63 'css' => array('css/angular-crmMailing.css'),
6bea4a47 64 );
4aef704e 65 $result['crmMailingAB'] = array(
66 'ext' => 'civicrm',
efd95528 67 'js' => array('js/angular-crmMailingAB.js', 'js/angular-crmMailingAB/services.js', 'js/angular-crmMailingAB/directives.js'),
4aef704e 68 'css' => array('css/angular-crmMailingAB.css'),
69 );
d74bca86
TO
70 $result['crmD3'] = array(
71 'ext' => 'civicrm',
72 'js' => array('js/angular-crmD3.js', 'js/d3.min.js'),
73 );
983052fe 74
cd5dd333 75 $config = CRM_Core_Config::singleton();
6bea4a47
TO
76 $session = CRM_Core_Session::singleton();
77 $contactID = $session->get('userID');
4aef704e 78 $civiMails = civicrm_api3('Mailing', 'get', array());
79 $campNames = civicrm_api3('Campaign', 'get', array());
493b91cf 80 $mailingabNames = civicrm_api3('MailingAB','get',array());
4aef704e 81 $mailStatus = civicrm_api3('MailingJob', 'get', array());
82 $groupNames = civicrm_api3('Group', 'get', array());
83 $headerfooterList = civicrm_api3('MailingComponent', 'get', array());
6bea4a47
TO
84
85 // FIXME: The following two items differ between GSOC CiviMail and ABTest branches
86 if (FALSE) {
87 // AB Test
88 $emailAdd = civicrm_api3('Email', 'get', array());
89 $mesTemplate = civicrm_api3('MessageTemplate', 'get', array(
90 'sequential' => 1,
91 'return' => array("msg_html", "id", "msg_title","msg_subject"),
92 'id' => array('>' => 58),
93 ));
94 } else {
95 // CiviMail UI
96 $emailAdd = civicrm_api3('Email', 'get', array(
97 'sequential' => 1,
98 'return' => "email",
99 'contact_id' => $contactID,
100 ));
101 $mesTemplate = civicrm_api3('MessageTemplate', 'get', array( 'sequential' => 1,
744bebee 102 'return' => array("msg_html", "id", "msg_title", "msg_subject", "msg_text"),
6bea4a47
TO
103 'workflow_id' => array('IS NULL' => ""),
104 ));
105 }
106 $mailGrp = civicrm_api3('MailingGroup','get', array());
107 $mailTokens = civicrm_api3('Mailing', 'get_token', array( 'usage' => 'Mailing'));
3d053687 108 $fromAddress = civicrm_api3('OptionGroup', 'get', array(
4aef704e 109 'sequential' => 1,
3d053687
SR
110 'name' => "from_email_address",
111 'api.OptionValue.get' => array(),
4aef704e 112 ));
4aef704e 113 CRM_Core_Resources::singleton()->addSetting(array(
114 'crmMailing' => array(
493b91cf 115 'mailingabNames'=>array_values($mailingabNames['values']),
4aef704e 116 'civiMails' => array_values($civiMails['values']),
117 'campNames' => array_values($campNames['values']),
118 'mailStatus' => array_values($mailStatus['values']),
119 'groupNames' => array_values($groupNames['values']),
120 'headerfooterList' => array_values($headerfooterList['values']),
121 'mesTemplate' => array_values($mesTemplate['values']),
122 'emailAdd' => array_values($emailAdd['values']),
6bea4a47 123 'mailGrp' => array_values($mailGrp['values']),
467cd00c 124 'mailTokens' => array_values($mailTokens),
6bea4a47 125 'contactid' => $contactID,
b9772453 126 'enableReplyTo' => isset($config->replyTo) ? $config->replyTo : 0,
6bea4a47 127 'fromAddress' => array_values($fromAddress['values'][0]['api.OptionValue.get']['values']),
13cb08ff 128 'defaultTestEmail' => civicrm_api3('Contact', 'getvalue', array('id' => 'user_contact_id', 'return' => 'email')),
30a3791a
TO
129 'visibility' => array(
130 array('value' => 'Public Pages', 'label' => ts('Public Pages')),
131 array('value' => 'User and User Admin Only', 'label' => ts('User and User Admin Only')),
132 ),
4aef704e 133 ),
134 ));
983052fe 135
4aef704e 136 return $result;
137 }
983052fe 138
4aef704e 139 /**
e0ef6999
EM
140 * @return bool
141 */
6a488035
TO
142 static function workflowEnabled() {
143 $config = CRM_Core_Config::singleton();
144
145 // early exit, since not true for most
146 if (!$config->userSystem->is_drupal ||
147 !function_exists('module_exists')
148 ) {
149 return FALSE;
150 }
151
152 if (!module_exists('rules')) {
153 return FALSE;
154 }
155
156 $enableWorkflow = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
157 'civimail_workflow',
158 NULL,
159 FALSE
160 );
161
162 return ($enableWorkflow &&
163 $config->userSystem->is_drupal
164 ) ? TRUE : FALSE;
165 }
166
167 // docs inherited from interface
e0ef6999
EM
168 /**
169 * @param bool $getAllUnconditionally
170 *
171 * @return array
172 */
33777e4a 173 public function getPermissions($getAllUnconditionally = FALSE) {
6a488035
TO
174 $permissions = array(
175 'access CiviMail',
176 'access CiviMail subscribe/unsubscribe pages',
177 'delete in CiviMail',
178 'view public CiviMail content',
179 );
180
33777e4a 181 if (self::workflowEnabled() || $getAllUnconditionally) {
6a488035
TO
182 $permissions[] = 'create mailings';
183 $permissions[] = 'schedule mailings';
184 $permissions[] = 'approve mailings';
185 }
186
187 return $permissions;
188 }
189
190
191 // docs inherited from interface
e0ef6999
EM
192 /**
193 * @return null
194 */
6a488035
TO
195 public function getUserDashboardElement() {
196 // no dashboard element for this component
197 return NULL;
198 }
199
e0ef6999
EM
200 /**
201 * @return null
202 */
6a488035
TO
203 public function getUserDashboardObject() {
204 // no dashboard element for this component
205 return NULL;
206 }
207
208 // docs inherited from interface
e0ef6999
EM
209 /**
210 * @return array
211 */
6a488035 212 public function registerTab() {
2ede60ec
DL
213 return array(
214 'title' => ts('Mailings'),
215 'id' => 'mailing',
216 'url' => 'mailing',
217 'weight' => 45,
218 );
6a488035
TO
219 }
220
221 // docs inherited from interface
e0ef6999
EM
222 /**
223 * @return array
224 */
6a488035
TO
225 public function registerAdvancedSearchPane() {
226 return array('title' => ts('Mailings'),
227 'weight' => 20,
228 );
229 }
230
231 // docs inherited from interface
e0ef6999
EM
232 /**
233 * @return null
234 */
6a488035
TO
235 public function getActivityTypes() {
236 return NULL;
237 }
238
239 // add shortcut to Create New
e0ef6999
EM
240 /**
241 * @param $shortCuts
242 */
6a488035
TO
243 public function creatNewShortcut(&$shortCuts) {}
244}
245