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 'extra' => 'onclick = "enableDisable( %%id%%,\'' . 'CRM_Campaign_BAO_Campaign' . '\',\'' . 'enable-disable' . '\' );"',
69 'ref' => 'disable-action',
71 CRM_Core_Action
::ENABLE
=> array(
72 'name' => ts('Enable'),
73 'title' => ts('Enable Campaign'),
74 'extra' => 'onclick = "enableDisable( %%id%%,\'' . 'CRM_Campaign_BAO_Campaign' . '\',\'' . 'disable-enable' . '\' );"',
75 'ref' => 'enable-action',
77 CRM_Core_Action
::DELETE
=> array(
78 'name' => ts('Delete'),
79 'url' => 'civicrm/campaign/add',
80 'qs' => 'action=delete&reset=1&id=%%id%%',
81 'title' => ts('Delete Campaign'),
85 return self
::$_actionLinks;
90 $campaigns = CRM_Campaign_BAO_Campaign
::getCampaignSummary();
92 if (!empty($campaigns)) {
93 $campaignType = CRM_Core_PseudoConstant
::campaignType();
94 $campaignStatus = CRM_Core_PseudoConstant
::campaignStatus();
96 foreach ($campaigns as $cmpid => $campaign) {
98 $campaigns[$cmpid]['campaign_id'] = $campaign['id'];
99 $campaigns[$cmpid]['title'] = $campaign['title'];
100 $campaigns[$cmpid]['name'] = $campaign['name'];
101 $campaigns[$cmpid]['description'] = $campaign['description'];
102 $campaigns[$cmpid]['campaign_type_id'] = $campaignType[$campaign['campaign_type_id']];
103 $campaigns[$cmpid]['status_id'] = $campaignStatus[$campaign['status_id']];
105 $action = array_sum(array_keys($this->actionLinks()));
106 if ($campaign['is_active']) {
107 $action -= CRM_Core_Action
::ENABLE
;
110 $action -= CRM_Core_Action
::DISABLE
;
112 $campaigns[$cmpid]['action'] = CRM_Core_Action
::formLink(self
::actionLinks(), $action,
113 array('id' => $campaign['id']),
116 'campaign.selector.row',
123 $this->assign('campaigns', $campaigns);
124 $this->assign('addCampaignUrl', CRM_Utils_System
::url('civicrm/campaign/add', 'reset=1&action=add'));
128 if (!CRM_Core_Permission
::check('administer CiviCampaign')) {
129 CRM_Utils_System
::permissionDenied();
132 $action = CRM_Utils_Request
::retrieve('action', 'String',
135 $this->assign('action', $action);
138 return parent
::run();