3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
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
{
40 // docs inherited from interface
41 protected $keyword = 'mailing';
44 // docs inherited from interface
48 public function getInfo() {
51 'translatedName' => ts('CiviMail'),
52 'title' => 'CiviCRM Mailing Engine',
54 'showActivitiesInCore' => 1,
58 public function getAngularModules() {
60 $result['crmMailing'] = array(
62 'js' => array('js/angular-newMailing.js' , 'js/angularsanitize.js'),
64 $session = CRM_Core_Session
::singleton();
65 $contactID = $session->get('userID');
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(
74 'contact_id' => $contactID,
76 $mesTemplate = civicrm_api3('MessageTemplate', 'get', array( 'sequential' => 1,
77 'return' => array("msg_html", "id", "msg_title", "msg_subject"),
78 'workflow_id' => array('IS NULL' => ""),
80 $mailGrp = civicrm_api3('MailingGroup','get', array());
81 $mailTokens = civicrm_api3('Mailing', 'get_token', array( 'usage' => 'Mailing'));
85 CRM_Core_Resources
::singleton()->addSetting(array(
86 'crmMailing' => array(
87 'civiMails' => array_values($civiMails['values']),
88 'campNames' => array_values($campNames['values']),
89 'mailStatus' => array_values($mailStatus['values']),
90 'groupNames' => array_values($groupNames['values']),
91 'headerfooterList' => array_values($headerfooterList['values']),
92 'mesTemplate' => array_values($mesTemplate['values']),
93 'emailAdd' => array_values($emailAdd['values']),
94 'mailGrp' => array_values($mailGrp['values']),
95 'mailTokens' => array_values($mailTokens),
96 'contactid' => $contactID
105 static function workflowEnabled() {
106 $config = CRM_Core_Config
::singleton();
108 // early exit, since not true for most
109 if (!$config->userSystem
->is_drupal ||
110 !function_exists('module_exists')
115 if (!module_exists('rules')) {
119 $enableWorkflow = CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::MAILING_PREFERENCES_NAME
,
125 return ($enableWorkflow &&
126 $config->userSystem
->is_drupal
130 // docs inherited from interface
132 * @param bool $getAllUnconditionally
136 public function getPermissions($getAllUnconditionally = FALSE) {
137 $permissions = array(
139 'access CiviMail subscribe/unsubscribe pages',
140 'delete in CiviMail',
141 'view public CiviMail content',
144 if (self
::workflowEnabled() ||
$getAllUnconditionally) {
145 $permissions[] = 'create mailings';
146 $permissions[] = 'schedule mailings';
147 $permissions[] = 'approve mailings';
154 // docs inherited from interface
158 public function getUserDashboardElement() {
159 // no dashboard element for this component
166 public function getUserDashboardObject() {
167 // no dashboard element for this component
171 // docs inherited from interface
175 public function registerTab() {
177 'title' => ts('Mailings'),
184 // docs inherited from interface
188 public function registerAdvancedSearchPane() {
189 return array('title' => ts('Mailings'),
194 // docs inherited from interface
198 public function getActivityTypes() {
202 // add shortcut to Create New
206 public function creatNewShortcut(&$shortCuts) {}