Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
232624b1 | 4 | | CiviCRM version 4.4 | |
6a488035 TO |
5 | +--------------------------------------------------------------------+ |
6 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
7 | +--------------------------------------------------------------------+ | |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
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. | | |
13 | | | | |
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. | | |
18 | | | | |
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 | +--------------------------------------------------------------------+ | |
26 | */ | |
27 | ||
28 | /** | |
29 | * | |
30 | * @package CRM | |
31 | * @copyright CiviCRM LLC (c) 2004-2013 | |
32 | * $Id$ | |
33 | * | |
34 | */ | |
35 | ||
36 | /** | |
37 | * Page for displaying Campaigns | |
38 | */ | |
39 | class CRM_Campaign_Page_Campaign extends CRM_Core_Page { | |
40 | ||
41 | /** | |
42 | * The action links that we need to display for the browse screen | |
43 | * | |
44 | * @var array | |
45 | */ | |
46 | private static $_actionLinks; | |
47 | ||
48 | /** | |
49 | * Get the action links for this page. | |
50 | * | |
51 | * @return array $_actionLinks | |
52 | * | |
53 | */ | |
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( | |
60 | 'name' => ts('Edit'), | |
61 | 'url' => 'civicrm/campaign/add', | |
62 | 'qs' => 'reset=1&action=update&id=%%id%%', | |
63 | 'title' => ts('Update Campaign'), | |
64 | ), | |
65 | CRM_Core_Action::DISABLE => array( | |
66 | 'name' => ts('Disable'), | |
67 | 'title' => ts('Disable Campaign'), | |
4d17a233 | 68 | 'ref' => 'crm-enable-disable', |
6a488035 TO |
69 | ), |
70 | CRM_Core_Action::ENABLE => array( | |
71 | 'name' => ts('Enable'), | |
72 | 'title' => ts('Enable Campaign'), | |
4d17a233 | 73 | 'ref' => 'crm-enable-disable', |
6a488035 TO |
74 | ), |
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'), | |
80 | ), | |
81 | ); | |
82 | } | |
83 | return self::$_actionLinks; | |
84 | } | |
85 | ||
86 | function browse() { | |
4d17a233 | 87 | CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); |
6a488035 TO |
88 | |
89 | $campaigns = CRM_Campaign_BAO_Campaign::getCampaignSummary(); | |
90 | ||
91 | if (!empty($campaigns)) { | |
92 | $campaignType = CRM_Core_PseudoConstant::campaignType(); | |
93 | $campaignStatus = CRM_Core_PseudoConstant::campaignStatus(); | |
94 | ||
95 | foreach ($campaigns as $cmpid => $campaign) { | |
96 | ||
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']]; | |
103 | ||
104 | $action = array_sum(array_keys($this->actionLinks())); | |
105 | if ($campaign['is_active']) { | |
106 | $action -= CRM_Core_Action::ENABLE; | |
107 | } | |
108 | else { | |
109 | $action -= CRM_Core_Action::DISABLE; | |
110 | } | |
111 | $campaigns[$cmpid]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, | |
87dab4a4 AH |
112 | array('id' => $campaign['id']), |
113 | ts('more'), | |
114 | FALSE, | |
115 | 'campaign.selector.row', | |
116 | 'Campaign', | |
117 | $campaign['id'] | |
6a488035 TO |
118 | ); |
119 | } | |
120 | } | |
121 | ||
122 | $this->assign('campaigns', $campaigns); | |
123 | $this->assign('addCampaignUrl', CRM_Utils_System::url('civicrm/campaign/add', 'reset=1&action=add')); | |
124 | } | |
125 | ||
126 | function run() { | |
127 | if (!CRM_Core_Permission::check('administer CiviCampaign')) { | |
128 | CRM_Utils_System::permissionDenied(); | |
129 | } | |
130 | ||
131 | $action = CRM_Utils_Request::retrieve('action', 'String', | |
132 | $this, FALSE, 0 | |
133 | ); | |
134 | $this->assign('action', $action); | |
135 | $this->browse(); | |
136 | ||
137 | return parent::run(); | |
138 | } | |
139 | } | |
140 |