3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
29 * This class introduces component to the system and provides all the
30 * information about it. It needs to extend CRM_Core_Component_Info
34 * @copyright CiviCRM LLC (c) 2004-2014
38 class CRM_Mailing_Info
extends CRM_Core_Component_Info
{
43 protected $keyword = 'mailing';
50 public function getInfo() {
53 'translatedName' => ts('CiviMail'),
54 'title' => 'CiviCRM Mailing Engine',
56 'showActivitiesInCore' => 1,
60 public function getAngularModules() {
62 $result['crmMailing'] = array(
65 'js/angular-crmMailing.js',
66 'js/angular-crmMailing/services.js',
67 'js/angular-crmMailing/directives.js',
69 'css' => array('css/angular-crmMailing.css'),
71 $result['crmMailingAB'] = array(
74 'js/angular-crmMailingAB.js',
75 'js/angular-crmMailingAB/services.js',
76 'js/angular-crmMailingAB/directives.js',
78 'css' => array('css/angular-crmMailingAB.css'),
80 $result['crmD3'] = array(
82 'js' => array('js/angular-crmD3.js', 'bower_components/d3/d3.min.js'),
85 $config = CRM_Core_Config
::singleton();
86 $session = CRM_Core_Session
::singleton();
87 $contactID = $session->get('userID');
88 $civiMails = civicrm_api3('Mailing', 'get', array());
89 $campNames = civicrm_api3('Campaign', 'get', array());
90 $mailingabNames = civicrm_api3('MailingAB', 'get', array());
91 $mailStatus = civicrm_api3('MailingJob', 'get', array());
92 $groupNames = civicrm_api3('Group', 'get', array());
93 $headerfooterList = civicrm_api3('MailingComponent', 'get', array());
95 // FIXME: The following two items differ between GSOC CiviMail and ABTest branches
98 $emailAdd = civicrm_api3('Email', 'get', array());
99 $mesTemplate = civicrm_api3('MessageTemplate', 'get', array(
101 'return' => array("msg_html", "id", "msg_title", "msg_subject"),
102 'id' => array('>' => 58),
107 $emailAdd = civicrm_api3('Email', 'get', array(
110 'contact_id' => $contactID,
112 $mesTemplate = civicrm_api3('MessageTemplate', 'get', array(
114 'return' => array("msg_html", "id", "msg_title", "msg_subject", "msg_text"),
115 'workflow_id' => array('IS NULL' => ""),
118 $mailGrp = civicrm_api3('MailingGroup', 'get', array());
119 $mailTokens = civicrm_api3('Mailing', 'get_token', array('usage' => 'Mailing'));
120 $fromAddress = civicrm_api3('OptionGroup', 'get', array(
122 'name' => "from_email_address",
123 'api.OptionValue.get' => array(),
125 CRM_Core_Resources
::singleton()->addSetting(array(
126 'crmMailing' => array(
127 'mailingabNames' => array_values($mailingabNames['values']),
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']),
135 'mailGrp' => array_values($mailGrp['values']),
136 'mailTokens' => array_values($mailTokens),
137 'contactid' => $contactID,
138 'enableReplyTo' => isset($config->replyTo
) ?
$config->replyTo
: 0,
139 'fromAddress' => array_values($fromAddress['values'][0]['api.OptionValue.get']['values']),
140 'defaultTestEmail' => civicrm_api3('Contact', 'getvalue', array(
141 'id' => 'user_contact_id',
144 'visibility' => array(
145 array('value' => 'Public Pages', 'label' => ts('Public Pages')),
146 array('value' => 'User and User Admin Only', 'label' => ts('User and User Admin Only')),
157 public static function workflowEnabled() {
158 $config = CRM_Core_Config
::singleton();
160 // early exit, since not true for most
161 if (!$config->userSystem
->is_drupal ||
162 !function_exists('module_exists')
167 if (!module_exists('rules')) {
171 $enableWorkflow = CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::MAILING_PREFERENCES_NAME
,
177 return ($enableWorkflow &&
178 $config->userSystem
->is_drupal
184 * @param bool $getAllUnconditionally
188 public function getPermissions($getAllUnconditionally = FALSE) {
189 $permissions = array(
191 'access CiviMail subscribe/unsubscribe pages',
192 'delete in CiviMail',
193 'view public CiviMail content',
196 if (self
::workflowEnabled() ||
$getAllUnconditionally) {
197 $permissions[] = 'create mailings';
198 $permissions[] = 'schedule mailings';
199 $permissions[] = 'approve mailings';
210 public function getUserDashboardElement() {
211 // no dashboard element for this component
218 public function getUserDashboardObject() {
219 // no dashboard element for this component
227 public function registerTab() {
229 'title' => ts('Mailings'),
240 public function registerAdvancedSearchPane() {
242 'title' => ts('Mailings'),
251 public function getActivityTypes() {
256 * add shortcut to Create New
259 public function creatNewShortcut(&$shortCuts) {