added mailinAB table and default data
[civicrm-core.git] / CRM / Mailing / Info.php
CommitLineData
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 */
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
5c691259 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 );
983052fe 65
5c691259 66 $civiMails = civicrm_api3('Mailing', 'get', array());
67 $campNames = civicrm_api3('Campaign', 'get', array());
68 $mailStatus = civicrm_api3('MailingJob', 'get', array());
69 $groupNames = civicrm_api3('Group', 'get', array());
70 $headerfooterList = civicrm_api3('MailingComponent', 'get', array());
71 $emailAdd = civicrm_api3('Email', 'get', array(
72 'sequential' => 1,
73 'return' => "email",
74 'contact_id' => 202,
75 ));
76 $mesTemplate = civicrm_api3('MessageTemplate', 'get', array(
77 'sequential' => 1,
78 'return' => array("msg_html", "id", "msg_title"),
79 'id' => array('>' => 58),
80 ));
b88b7a13 81
5c691259 82 CRM_Core_Resources::singleton()->addSetting(array(
83 'crmMailing' => array(
84 'civiMails' => array_values($civiMails['values']),
85 'campNames' => array_values($campNames['values']),
86 'mailStatus' => array_values($mailStatus['values']),
87 'groupNames' => array_values($groupNames['values']),
88 'headerfooterList' => array_values($headerfooterList['values']),
89 'mesTemplate' => array_values($mesTemplate['values']),
90 'emailAdd' => array_values($emailAdd['values']),
91 ),
92 ));
983052fe 93
5c691259 94 return $result;
95 }
983052fe 96
97
5c691259 98 /**
e0ef6999
EM
99 * @return bool
100 */
6a488035
TO
101 static function workflowEnabled() {
102 $config = CRM_Core_Config::singleton();
103
104 // early exit, since not true for most
105 if (!$config->userSystem->is_drupal ||
106 !function_exists('module_exists')
107 ) {
108 return FALSE;
109 }
110
111 if (!module_exists('rules')) {
112 return FALSE;
113 }
114
115 $enableWorkflow = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
116 'civimail_workflow',
117 NULL,
118 FALSE
119 );
120
121 return ($enableWorkflow &&
122 $config->userSystem->is_drupal
123 ) ? TRUE : FALSE;
124 }
125
126 // docs inherited from interface
e0ef6999
EM
127 /**
128 * @param bool $getAllUnconditionally
129 *
130 * @return array
131 */
33777e4a 132 public function getPermissions($getAllUnconditionally = FALSE) {
6a488035
TO
133 $permissions = array(
134 'access CiviMail',
135 'access CiviMail subscribe/unsubscribe pages',
136 'delete in CiviMail',
137 'view public CiviMail content',
138 );
139
33777e4a 140 if (self::workflowEnabled() || $getAllUnconditionally) {
6a488035
TO
141 $permissions[] = 'create mailings';
142 $permissions[] = 'schedule mailings';
143 $permissions[] = 'approve mailings';
144 }
145
146 return $permissions;
147 }
148
149
150 // docs inherited from interface
e0ef6999
EM
151 /**
152 * @return null
153 */
6a488035
TO
154 public function getUserDashboardElement() {
155 // no dashboard element for this component
156 return NULL;
157 }
158
e0ef6999
EM
159 /**
160 * @return null
161 */
6a488035
TO
162 public function getUserDashboardObject() {
163 // no dashboard element for this component
164 return NULL;
165 }
166
167 // docs inherited from interface
e0ef6999
EM
168 /**
169 * @return array
170 */
6a488035 171 public function registerTab() {
2ede60ec
DL
172 return array(
173 'title' => ts('Mailings'),
174 'id' => 'mailing',
175 'url' => 'mailing',
176 'weight' => 45,
177 );
6a488035
TO
178 }
179
180 // docs inherited from interface
e0ef6999
EM
181 /**
182 * @return array
183 */
6a488035
TO
184 public function registerAdvancedSearchPane() {
185 return array('title' => ts('Mailings'),
186 'weight' => 20,
187 );
188 }
189
190 // docs inherited from interface
e0ef6999
EM
191 /**
192 * @return null
193 */
6a488035
TO
194 public function getActivityTypes() {
195 return NULL;
196 }
197
198 // add shortcut to Create New
e0ef6999
EM
199 /**
200 * @param $shortCuts
201 */
6a488035
TO
202 public function creatNewShortcut(&$shortCuts) {}
203}
204