Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
bc77d7c0 TO |
6 | | This work is published under the GNU AGPLv3 license with some | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
6a488035 TO |
9 | +--------------------------------------------------------------------+ |
10 | */ | |
11 | ||
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
6a488035 TO |
16 | */ |
17 | ||
18 | /** | |
19 | * Page for voting tab interface. | |
20 | */ | |
21 | class CRM_Campaign_Page_Vote extends CRM_Core_Page { | |
22 | private $_surveyId; | |
23 | private $_interviewerId; | |
8ef12e64 | 24 | |
30c4e065 EM |
25 | /** |
26 | * @return mixed | |
27 | */ | |
00be9182 | 28 | public function reserve() { |
6a488035 TO |
29 | //build ajax voter search and selector. |
30 | $controller = new CRM_Core_Controller_Simple('CRM_Campaign_Form_Gotv', ts('Reserve Respondents')); | |
31 | $controller->set('votingTab', TRUE); | |
32 | $controller->set('subVotingTab', 'searchANDReserve'); | |
33 | ||
34 | $controller->process(); | |
35 | return $controller->run(); | |
36 | } | |
37 | ||
e0ef6999 EM |
38 | /** |
39 | * @return mixed | |
40 | */ | |
00be9182 | 41 | public function interview() { |
6a488035 TO |
42 | //build interview and release voter interface. |
43 | $controller = new CRM_Core_Controller_Simple('CRM_Campaign_Form_Task_Interview', ts('Interview Respondents')); | |
44 | $controller->set('votingTab', TRUE); | |
45 | $controller->set('subVotingTab', 'searchANDInterview'); | |
46 | if ($this->_surveyId) { | |
47 | $controller->set('surveyId', $this->_surveyId); | |
48 | } | |
49 | if ($this->_interviewerId) { | |
50 | $controller->set('interviewerId', $this->_interviewerId); | |
51 | } | |
52 | $controller->process(); | |
53 | return $controller->run(); | |
54 | } | |
55 | ||
00be9182 | 56 | public function browse() { |
be2fb01f | 57 | $this->_tabs = [ |
353ffa53 | 58 | 'reserve' => ts('Reserve Respondents'), |
6a488035 | 59 | 'interview' => ts('Interview Respondents'), |
be2fb01f | 60 | ]; |
6a488035 TO |
61 | |
62 | $this->_surveyId = CRM_Utils_Request::retrieve('sid', 'Positive', $this); | |
63 | $this->_interviewerId = CRM_Utils_Request::retrieve('cid', 'Positive', $this); | |
64 | ||
65 | $subPageType = CRM_Utils_Request::retrieve('type', 'String', $this); | |
66 | if ($subPageType) { | |
67 | $session = CRM_Core_Session::singleton(); | |
68 | $session->pushUserContext(CRM_Utils_System::url('civicrm/campaign/vote', "reset=1&subPage={$subPageType}")); | |
69 | //load the data in tabs. | |
70 | $this->{$subPageType}(); | |
71 | } | |
72 | else { | |
73 | //build the tabs. | |
74 | $this->buildTabs(); | |
75 | } | |
76 | $this->assign('subPageType', $subPageType); | |
77 | ||
4165b7e5 | 78 | CRM_Core_Resources::singleton() |
96ed17aa | 79 | ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js', 1, 'html-header') |
be2fb01f CW |
80 | ->addSetting([ |
81 | 'tabSettings' => [ | |
353ffa53 | 82 | 'active' => strtolower(CRM_Utils_Array::value('subPage', $_GET, 'reserve')), |
be2fb01f CW |
83 | ], |
84 | ]); | |
6a488035 TO |
85 | } |
86 | ||
30c4e065 EM |
87 | /** |
88 | * @return string | |
89 | */ | |
00be9182 | 90 | public function run() { |
6a488035 TO |
91 | $this->browse(); |
92 | ||
93 | return parent::run(); | |
94 | } | |
95 | ||
00be9182 | 96 | public function buildTabs() { |
be2fb01f | 97 | $allTabs = []; |
6a488035 | 98 | foreach ($this->_tabs as $name => $title) { |
6a84d0fb | 99 | // check for required permissions. |
be2fb01f CW |
100 | if (!CRM_Core_Permission::check([ |
101 | [ | |
353ffa53 TO |
102 | 'manage campaign', |
103 | 'administer CiviCampaign', | |
28a04ea9 | 104 | "{$name} campaign contacts", |
be2fb01f | 105 | ], |
5d4fcf54 | 106 | ])) { |
6a488035 TO |
107 | continue; |
108 | } | |
109 | ||
349a45b7 | 110 | $urlParams = "type={$name}"; |
6a488035 TO |
111 | if ($this->_surveyId) { |
112 | $urlParams .= "&sid={$this->_surveyId}"; | |
113 | } | |
114 | if ($this->_interviewerId) { | |
115 | $urlParams .= "&cid={$this->_interviewerId}"; | |
116 | } | |
be2fb01f | 117 | $allTabs[$name] = [ |
6a488035 | 118 | 'title' => $title, |
349a45b7 CW |
119 | 'valid' => TRUE, |
120 | 'active' => TRUE, | |
121 | 'link' => CRM_Utils_System::url('civicrm/campaign/vote', $urlParams), | |
be2fb01f | 122 | ]; |
6a488035 TO |
123 | } |
124 | ||
349a45b7 | 125 | $this->assign('tabHeader', empty($allTabs) ? FALSE : $allTabs); |
6a488035 | 126 | } |
96025800 | 127 | |
6a488035 | 128 | } |