Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
06b69b18 | 4 | | CiviCRM version 4.5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06b69b18 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
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 | |
06b69b18 | 31 | * @copyright CiviCRM LLC (c) 2004-2014 |
6a488035 TO |
32 | * $Id$ |
33 | * | |
34 | */ | |
35 | ||
36 | /** | |
37 | * Page for displaying Campaigns | |
38 | */ | |
39 | class CRM_Campaign_Page_Campaign extends CRM_Core_Page { | |
40 | ||
96f50de2 CW |
41 | public $useLivePageJS = TRUE; |
42 | ||
6a488035 TO |
43 | /** |
44 | * The action links that we need to display for the browse screen | |
45 | * | |
46 | * @var array | |
47 | */ | |
48 | private static $_actionLinks; | |
49 | ||
50 | /** | |
51 | * Get the action links for this page. | |
52 | * | |
53 | * @return array $_actionLinks | |
54 | * | |
55 | */ | |
56 | function &actionLinks() { | |
57 | // check if variable _actionsLinks is populated | |
58 | if (!isset(self::$_actionLinks)) { | |
59 | $deleteExtra = ts('Are you sure you want to delete this Campaign?'); | |
60 | self::$_actionLinks = array( | |
61 | CRM_Core_Action::UPDATE => array( | |
62 | 'name' => ts('Edit'), | |
63 | 'url' => 'civicrm/campaign/add', | |
64 | 'qs' => 'reset=1&action=update&id=%%id%%', | |
65 | 'title' => ts('Update Campaign'), | |
66 | ), | |
67 | CRM_Core_Action::DISABLE => array( | |
68 | 'name' => ts('Disable'), | |
69 | 'title' => ts('Disable Campaign'), | |
4d17a233 | 70 | 'ref' => 'crm-enable-disable', |
6a488035 TO |
71 | ), |
72 | CRM_Core_Action::ENABLE => array( | |
73 | 'name' => ts('Enable'), | |
74 | 'title' => ts('Enable Campaign'), | |
4d17a233 | 75 | 'ref' => 'crm-enable-disable', |
6a488035 TO |
76 | ), |
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'), | |
82 | ), | |
83 | ); | |
84 | } | |
85 | return self::$_actionLinks; | |
86 | } | |
87 | ||
88 | function browse() { | |
89 | ||
90 | $campaigns = CRM_Campaign_BAO_Campaign::getCampaignSummary(); | |
91 | ||
92 | if (!empty($campaigns)) { | |
93 | $campaignType = CRM_Core_PseudoConstant::campaignType(); | |
94 | $campaignStatus = CRM_Core_PseudoConstant::campaignStatus(); | |
95 | ||
96 | foreach ($campaigns as $cmpid => $campaign) { | |
97 | ||
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']]; | |
104 | ||
105 | $action = array_sum(array_keys($this->actionLinks())); | |
106 | if ($campaign['is_active']) { | |
107 | $action -= CRM_Core_Action::ENABLE; | |
108 | } | |
109 | else { | |
110 | $action -= CRM_Core_Action::DISABLE; | |
111 | } | |
112 | $campaigns[$cmpid]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, | |
87dab4a4 AH |
113 | array('id' => $campaign['id']), |
114 | ts('more'), | |
115 | FALSE, | |
116 | 'campaign.selector.row', | |
117 | 'Campaign', | |
118 | $campaign['id'] | |
6a488035 TO |
119 | ); |
120 | } | |
121 | } | |
122 | ||
123 | $this->assign('campaigns', $campaigns); | |
124 | $this->assign('addCampaignUrl', CRM_Utils_System::url('civicrm/campaign/add', 'reset=1&action=add')); | |
125 | } | |
126 | ||
30c4e065 EM |
127 | /** |
128 | * @return string | |
129 | */ | |
6a488035 TO |
130 | function run() { |
131 | if (!CRM_Core_Permission::check('administer CiviCampaign')) { | |
132 | CRM_Utils_System::permissionDenied(); | |
133 | } | |
134 | ||
135 | $action = CRM_Utils_Request::retrieve('action', 'String', | |
136 | $this, FALSE, 0 | |
137 | ); | |
138 | $this->assign('action', $action); | |
139 | $this->browse(); | |
140 | ||
141 | return parent::run(); | |
142 | } | |
143 | } | |
144 |