Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
fee14197 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | --------------------------------------------------------------------+ |
8c9251b3 | 6 | | Copyright CiviCRM LLC (c) 2004-2018 | |
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 | |
8c9251b3 | 31 | * @copyright CiviCRM LLC (c) 2004-2018 |
6a488035 TO |
32 | */ |
33 | ||
34 | /** | |
35 | * Page for voting tab interface. | |
36 | */ | |
37 | class CRM_Campaign_Page_Vote extends CRM_Core_Page { | |
38 | private $_surveyId; | |
39 | private $_interviewerId; | |
8ef12e64 | 40 | |
30c4e065 EM |
41 | /** |
42 | * @return mixed | |
43 | */ | |
00be9182 | 44 | public function reserve() { |
6a488035 TO |
45 | //build ajax voter search and selector. |
46 | $controller = new CRM_Core_Controller_Simple('CRM_Campaign_Form_Gotv', ts('Reserve Respondents')); | |
47 | $controller->set('votingTab', TRUE); | |
48 | $controller->set('subVotingTab', 'searchANDReserve'); | |
49 | ||
50 | $controller->process(); | |
51 | return $controller->run(); | |
52 | } | |
53 | ||
e0ef6999 EM |
54 | /** |
55 | * @return mixed | |
56 | */ | |
00be9182 | 57 | public function interview() { |
6a488035 TO |
58 | //build interview and release voter interface. |
59 | $controller = new CRM_Core_Controller_Simple('CRM_Campaign_Form_Task_Interview', ts('Interview Respondents')); | |
60 | $controller->set('votingTab', TRUE); | |
61 | $controller->set('subVotingTab', 'searchANDInterview'); | |
62 | if ($this->_surveyId) { | |
63 | $controller->set('surveyId', $this->_surveyId); | |
64 | } | |
65 | if ($this->_interviewerId) { | |
66 | $controller->set('interviewerId', $this->_interviewerId); | |
67 | } | |
68 | $controller->process(); | |
69 | return $controller->run(); | |
70 | } | |
71 | ||
00be9182 | 72 | public function browse() { |
94880218 | 73 | $this->_tabs = array( |
353ffa53 | 74 | 'reserve' => ts('Reserve Respondents'), |
6a488035 TO |
75 | 'interview' => ts('Interview Respondents'), |
76 | ); | |
77 | ||
78 | $this->_surveyId = CRM_Utils_Request::retrieve('sid', 'Positive', $this); | |
79 | $this->_interviewerId = CRM_Utils_Request::retrieve('cid', 'Positive', $this); | |
80 | ||
81 | $subPageType = CRM_Utils_Request::retrieve('type', 'String', $this); | |
82 | if ($subPageType) { | |
83 | $session = CRM_Core_Session::singleton(); | |
84 | $session->pushUserContext(CRM_Utils_System::url('civicrm/campaign/vote', "reset=1&subPage={$subPageType}")); | |
85 | //load the data in tabs. | |
86 | $this->{$subPageType}(); | |
87 | } | |
88 | else { | |
89 | //build the tabs. | |
90 | $this->buildTabs(); | |
91 | } | |
92 | $this->assign('subPageType', $subPageType); | |
93 | ||
4165b7e5 | 94 | CRM_Core_Resources::singleton() |
96ed17aa | 95 | ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js', 1, 'html-header') |
94880218 | 96 | ->addSetting(array( |
353ffa53 TO |
97 | 'tabSettings' => array( |
98 | 'active' => strtolower(CRM_Utils_Array::value('subPage', $_GET, 'reserve')), | |
28a04ea9 | 99 | ), |
353ffa53 | 100 | )); |
6a488035 TO |
101 | } |
102 | ||
30c4e065 EM |
103 | /** |
104 | * @return string | |
105 | */ | |
00be9182 | 106 | public function run() { |
6a488035 TO |
107 | $this->browse(); |
108 | ||
109 | return parent::run(); | |
110 | } | |
111 | ||
00be9182 | 112 | public function buildTabs() { |
6a488035 TO |
113 | $allTabs = array(); |
114 | foreach ($this->_tabs as $name => $title) { | |
6a84d0fb | 115 | // check for required permissions. |
353ffa53 TO |
116 | if (!CRM_Core_Permission::check(array( |
117 | array( | |
118 | 'manage campaign', | |
119 | 'administer CiviCampaign', | |
28a04ea9 | 120 | "{$name} campaign contacts", |
121 | ), | |
353ffa53 TO |
122 | )) |
123 | ) { | |
6a488035 TO |
124 | continue; |
125 | } | |
126 | ||
349a45b7 | 127 | $urlParams = "type={$name}"; |
6a488035 TO |
128 | if ($this->_surveyId) { |
129 | $urlParams .= "&sid={$this->_surveyId}"; | |
130 | } | |
131 | if ($this->_interviewerId) { | |
132 | $urlParams .= "&cid={$this->_interviewerId}"; | |
133 | } | |
349a45b7 | 134 | $allTabs[$name] = array( |
6a488035 | 135 | 'title' => $title, |
349a45b7 CW |
136 | 'valid' => TRUE, |
137 | 'active' => TRUE, | |
138 | 'link' => CRM_Utils_System::url('civicrm/campaign/vote', $urlParams), | |
6a488035 TO |
139 | ); |
140 | } | |
141 | ||
349a45b7 | 142 | $this->assign('tabHeader', empty($allTabs) ? FALSE : $allTabs); |
6a488035 | 143 | } |
96025800 | 144 | |
6a488035 | 145 | } |