Merge pull request #4115 from totten/4.5-dm-ign
[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
e0ef6999
EM
58 /**
59 * @return bool
60 */
6a488035
TO
61 static function workflowEnabled() {
62 $config = CRM_Core_Config::singleton();
63
64 // early exit, since not true for most
65 if (!$config->userSystem->is_drupal ||
66 !function_exists('module_exists')
67 ) {
68 return FALSE;
69 }
70
71 if (!module_exists('rules')) {
72 return FALSE;
73 }
74
75 $enableWorkflow = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
76 'civimail_workflow',
77 NULL,
78 FALSE
79 );
80
81 return ($enableWorkflow &&
82 $config->userSystem->is_drupal
83 ) ? TRUE : FALSE;
84 }
85
86 // docs inherited from interface
e0ef6999
EM
87 /**
88 * @param bool $getAllUnconditionally
89 *
90 * @return array
91 */
33777e4a 92 public function getPermissions($getAllUnconditionally = FALSE) {
6a488035
TO
93 $permissions = array(
94 'access CiviMail',
95 'access CiviMail subscribe/unsubscribe pages',
96 'delete in CiviMail',
97 'view public CiviMail content',
98 );
99
33777e4a 100 if (self::workflowEnabled() || $getAllUnconditionally) {
6a488035
TO
101 $permissions[] = 'create mailings';
102 $permissions[] = 'schedule mailings';
103 $permissions[] = 'approve mailings';
104 }
105
106 return $permissions;
107 }
108
109
110 // docs inherited from interface
e0ef6999
EM
111 /**
112 * @return null
113 */
6a488035
TO
114 public function getUserDashboardElement() {
115 // no dashboard element for this component
116 return NULL;
117 }
118
e0ef6999
EM
119 /**
120 * @return null
121 */
6a488035
TO
122 public function getUserDashboardObject() {
123 // no dashboard element for this component
124 return NULL;
125 }
126
127 // docs inherited from interface
e0ef6999
EM
128 /**
129 * @return array
130 */
6a488035 131 public function registerTab() {
2ede60ec
DL
132 return array(
133 'title' => ts('Mailings'),
134 'id' => 'mailing',
135 'url' => 'mailing',
136 'weight' => 45,
137 );
6a488035
TO
138 }
139
140 // docs inherited from interface
e0ef6999
EM
141 /**
142 * @return array
143 */
6a488035
TO
144 public function registerAdvancedSearchPane() {
145 return array('title' => ts('Mailings'),
146 'weight' => 20,
147 );
148 }
149
150 // docs inherited from interface
e0ef6999
EM
151 /**
152 * @return null
153 */
6a488035
TO
154 public function getActivityTypes() {
155 return NULL;
156 }
157
158 // add shortcut to Create New
e0ef6999
EM
159 /**
160 * @param $shortCuts
161 */
6a488035
TO
162 public function creatNewShortcut(&$shortCuts) {}
163}
164