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