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,
61 * EXPERIMENTAL: Get a list of AngularJS modules
64 * list of modules; same format as CRM_Utils_Hook::angularModules(&$angularModules)
65 * @see CRM_Utils_Hook::angularModules
67 public function getAngularModules() {
69 $result['crmMailing'] = array(
72 'js/angular-crmMailing.js',
73 'js/angular-crmMailing/*.js',
75 'css' => array('css/angular-crmMailing.css'),
76 'partials' => array('partials/crmMailing'),
78 $result['crmMailingAB'] = array(
81 'js/angular-crmMailingAB.js',
82 'js/angular-crmMailingAB/*.js',
84 'css' => array('css/angular-crmMailingAB.css'),
85 'partials' => array('partials/crmMailingAB'),
87 $result['crmD3'] = array(
90 'js/angular-crmD3.js',
91 'bower_components/d3/d3.min.js',
95 $session = CRM_Core_Session
::singleton();
96 $contactID = $session->get('userID');
98 $params = array('options' => array('limit' => 0));
99 $civiMails = civicrm_api3('Mailing', 'get', $params +
array(
101 'return' => array('id', 'name', 'scheduled_date'),
103 $campNames = civicrm_api3('Campaign', 'get', $params);
104 $groupNames = civicrm_api3('Group', 'get', $params);
105 $headerfooterList = civicrm_api3('MailingComponent', 'get', $params);
107 $emailAdd = civicrm_api3('Email', 'get', array(
110 'contact_id' => $contactID,
112 $mesTemplate = civicrm_api3('MessageTemplate', 'get', $params +
array(
114 'return' => array("msg_html", "id", "msg_title", "msg_subject", "msg_text"),
115 'workflow_id' => array('IS NULL' => ""),
117 $mailGrp = civicrm_api3('MailingGroup', 'get', $params);
118 $mailTokens = civicrm_api3('Mailing', 'gettokens', array('entity' => array('contact', 'mailing'), 'sequential' => 1));
119 $fromAddress = civicrm_api3('OptionValue', 'get', $params +
array(
120 'option_group_id' => "from_email_address",
122 CRM_Core_Resources
::singleton()->addSetting(array(
123 'crmMailing' => array(
124 'civiMails' => array_values($civiMails['values']),
125 'campNames' => array_values($campNames['values']),
126 'groupNames' => array_values($groupNames['values']),
127 'headerfooterList' => array_values($headerfooterList['values']),
128 'mesTemplate' => array_values($mesTemplate['values']),
129 'emailAdd' => array_values($emailAdd['values']),
130 'mailGrp' => array_values($mailGrp['values']),
131 'mailTokens' => $mailTokens['values'],
132 'contactid' => $contactID,
133 'requiredTokens' => CRM_Utils_Token
::getRequiredTokens(),
134 'enableReplyTo' => (int) CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::MAILING_PREFERENCES_NAME
, 'replyTo'),
135 'fromAddress' => array_values($fromAddress['values']),
136 'defaultTestEmail' => civicrm_api3('Contact', 'getvalue', array(
137 'id' => 'user_contact_id',
140 'visibility' => CRM_Utils_Array
::makeNonAssociative(CRM_Core_SelectValues
::groupVisibility()),
141 'workflowEnabled' => CRM_Mailing_Info
::workflowEnabled(),
144 CRM_Core_Resources
::singleton()->addPermissions(array(
150 'delete in CiviMail',
159 public static function workflowEnabled() {
160 $config = CRM_Core_Config
::singleton();
162 // early exit, since not true for most
163 if (!$config->userSystem
->is_drupal ||
164 !function_exists('module_exists')
169 if (!module_exists('rules')) {
173 $enableWorkflow = CRM_Core_BAO_Setting
::getItem(CRM_Core_BAO_Setting
::MAILING_PREFERENCES_NAME
,
179 return ($enableWorkflow &&
180 $config->userSystem
->is_drupal
186 * @param bool $getAllUnconditionally
190 public function getPermissions($getAllUnconditionally = FALSE) {
191 $permissions = array(
193 'access CiviMail subscribe/unsubscribe pages',
194 'delete in CiviMail',
195 'view public CiviMail content',
198 if (self
::workflowEnabled() ||
$getAllUnconditionally) {
199 $permissions[] = 'create mailings';
200 $permissions[] = 'schedule mailings';
201 $permissions[] = 'approve mailings';
212 public function getUserDashboardElement() {
213 // no dashboard element for this component
220 public function getUserDashboardObject() {
221 // no dashboard element for this component
229 public function registerTab() {
231 'title' => ts('Mailings'),
242 public function registerAdvancedSearchPane() {
244 'title' => ts('Mailings'),
253 public function getActivityTypes() {
258 * add shortcut to Create New.
261 public function creatNewShortcut(&$shortCuts) {