Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
06b69b18 | 4 | | CiviCRM version 4.5 | |
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 | */ | |
38 | class 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 | ||
983052fe | 58 | public function getAngularModules() { |
59 | $result = array(); | |
60 | $result['crmMailingAB'] = array( | |
61 | 'ext' => 'civicrm', | |
62 | 'js' => array('js/angular-crmMailingAB.js'), | |
63 | 'css' => array('css/angular-crmMailingAB.css'), | |
64 | ); | |
65 | ||
66 | $compMails = civicrm_api3('Mailing', 'get', array()); | |
67 | $campNames = civicrm_api3('Campaign', 'get', array()); | |
68 | $vargroups = civicrm_api3('Group', 'get', array()); | |
69 | ||
70 | CRM_Core_Resources::singleton()->addSetting(array( | |
71 | 'crmMailing' => array( | |
72 | 'compMails' => array_values($compMails['values']), | |
73 | 'campNames' => array_values($campNames['values']), | |
74 | 'vargroups' => array_values($vargroups['values']), | |
75 | ), | |
76 | )); | |
77 | ||
78 | ||
79 | return $result; | |
80 | } | |
81 | ||
82 | ||
e0ef6999 EM |
83 | /** |
84 | * @return bool | |
85 | */ | |
6a488035 TO |
86 | static function workflowEnabled() { |
87 | $config = CRM_Core_Config::singleton(); | |
88 | ||
89 | // early exit, since not true for most | |
90 | if (!$config->userSystem->is_drupal || | |
91 | !function_exists('module_exists') | |
92 | ) { | |
93 | return FALSE; | |
94 | } | |
95 | ||
96 | if (!module_exists('rules')) { | |
97 | return FALSE; | |
98 | } | |
99 | ||
100 | $enableWorkflow = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, | |
101 | 'civimail_workflow', | |
102 | NULL, | |
103 | FALSE | |
104 | ); | |
105 | ||
106 | return ($enableWorkflow && | |
107 | $config->userSystem->is_drupal | |
108 | ) ? TRUE : FALSE; | |
109 | } | |
110 | ||
111 | // docs inherited from interface | |
e0ef6999 EM |
112 | /** |
113 | * @param bool $getAllUnconditionally | |
114 | * | |
115 | * @return array | |
116 | */ | |
33777e4a | 117 | public function getPermissions($getAllUnconditionally = FALSE) { |
6a488035 TO |
118 | $permissions = array( |
119 | 'access CiviMail', | |
120 | 'access CiviMail subscribe/unsubscribe pages', | |
121 | 'delete in CiviMail', | |
122 | 'view public CiviMail content', | |
123 | ); | |
124 | ||
33777e4a | 125 | if (self::workflowEnabled() || $getAllUnconditionally) { |
6a488035 TO |
126 | $permissions[] = 'create mailings'; |
127 | $permissions[] = 'schedule mailings'; | |
128 | $permissions[] = 'approve mailings'; | |
129 | } | |
130 | ||
131 | return $permissions; | |
132 | } | |
133 | ||
134 | ||
135 | // docs inherited from interface | |
e0ef6999 EM |
136 | /** |
137 | * @return null | |
138 | */ | |
6a488035 TO |
139 | public function getUserDashboardElement() { |
140 | // no dashboard element for this component | |
141 | return NULL; | |
142 | } | |
143 | ||
e0ef6999 EM |
144 | /** |
145 | * @return null | |
146 | */ | |
6a488035 TO |
147 | public function getUserDashboardObject() { |
148 | // no dashboard element for this component | |
149 | return NULL; | |
150 | } | |
151 | ||
152 | // docs inherited from interface | |
e0ef6999 EM |
153 | /** |
154 | * @return array | |
155 | */ | |
6a488035 | 156 | public function registerTab() { |
2ede60ec DL |
157 | return array( |
158 | 'title' => ts('Mailings'), | |
159 | 'id' => 'mailing', | |
160 | 'url' => 'mailing', | |
161 | 'weight' => 45, | |
162 | ); | |
6a488035 TO |
163 | } |
164 | ||
165 | // docs inherited from interface | |
e0ef6999 EM |
166 | /** |
167 | * @return array | |
168 | */ | |
6a488035 TO |
169 | public function registerAdvancedSearchPane() { |
170 | return array('title' => ts('Mailings'), | |
171 | 'weight' => 20, | |
172 | ); | |
173 | } | |
174 | ||
175 | // docs inherited from interface | |
e0ef6999 EM |
176 | /** |
177 | * @return null | |
178 | */ | |
6a488035 TO |
179 | public function getActivityTypes() { |
180 | return NULL; | |
181 | } | |
182 | ||
183 | // add shortcut to Create New | |
e0ef6999 EM |
184 | /** |
185 | * @param $shortCuts | |
186 | */ | |
6a488035 TO |
187 | public function creatNewShortcut(&$shortCuts) {} |
188 | } | |
189 |