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