3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2013
37 * Page for displaying Campaigns
39 class CRM_Campaign_Page_Campaign
extends CRM_Core_Page
{
42 * The action links that we need to display for the browse screen
46 private static $_actionLinks;
49 * Get the action links for this page.
51 * @return array $_actionLinks
54 function &actionLinks() {
55 // check if variable _actionsLinks is populated
56 if (!isset(self
::$_actionLinks)) {
57 $deleteExtra = ts('Are you sure you want to delete this Campaign?');
58 self
::$_actionLinks = array(
59 CRM_Core_Action
::UPDATE
=> array(
61 'url' => 'civicrm/campaign/add',
62 'qs' => 'reset=1&action=update&id=%%id%%',
63 'title' => ts('Update Campaign'),
65 CRM_Core_Action
::DISABLE
=> array(
66 'name' => ts('Disable'),
67 'title' => ts('Disable Campaign'),
68 'ref' => 'crm-enable-disable',
70 CRM_Core_Action
::ENABLE
=> array(
71 'name' => ts('Enable'),
72 'title' => ts('Enable Campaign'),
73 'ref' => 'crm-enable-disable',
75 CRM_Core_Action
::DELETE
=> array(
76 'name' => ts('Delete'),
77 'url' => 'civicrm/campaign/add',
78 'qs' => 'action=delete&reset=1&id=%%id%%',
79 'title' => ts('Delete Campaign'),
83 return self
::$_actionLinks;
87 CRM_Core_Resources
::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
89 $campaigns = CRM_Campaign_BAO_Campaign
::getCampaignSummary();
91 if (!empty($campaigns)) {
92 $campaignType = CRM_Core_PseudoConstant
::campaignType();
93 $campaignStatus = CRM_Core_PseudoConstant
::campaignStatus();
95 foreach ($campaigns as $cmpid => $campaign) {
97 $campaigns[$cmpid]['campaign_id'] = $campaign['id'];
98 $campaigns[$cmpid]['title'] = $campaign['title'];
99 $campaigns[$cmpid]['name'] = $campaign['name'];
100 $campaigns[$cmpid]['description'] = $campaign['description'];
101 $campaigns[$cmpid]['campaign_type_id'] = $campaignType[$campaign['campaign_type_id']];
102 $campaigns[$cmpid]['status_id'] = $campaignStatus[$campaign['status_id']];
104 $action = array_sum(array_keys($this->actionLinks()));
105 if ($campaign['is_active']) {
106 $action -= CRM_Core_Action
::ENABLE
;
109 $action -= CRM_Core_Action
::DISABLE
;
111 $campaigns[$cmpid]['action'] = CRM_Core_Action
::formLink(self
::actionLinks(), $action,
112 array('id' => $campaign['id']),
115 'campaign.selector.row',
122 $this->assign('campaigns', $campaigns);
123 $this->assign('addCampaignUrl', CRM_Utils_System
::url('civicrm/campaign/add', 'reset=1&action=add'));
127 if (!CRM_Core_Permission
::check('administer CiviCampaign')) {
128 CRM_Utils_System
::permissionDenied();
131 $action = CRM_Utils_Request
::retrieve('action', 'String',
134 $this->assign('action', $action);
137 return parent
::run();