Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
6a488035 TO |
2 | /* |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
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 list of Gender | |
38 | */ | |
39 | class CRM_Report_Page_Options extends CRM_Core_Page_Basic { | |
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 | |
6a488035 TO |
47 | */ |
48 | static $_links = NULL; | |
49 | ||
50 | /** | |
51 | * The option group name | |
52 | * | |
53 | * @var array | |
6a488035 TO |
54 | */ |
55 | static $_gName = NULL; | |
56 | ||
57 | /** | |
58 | * The option group name in display format (capitalized, without underscores...etc) | |
59 | * | |
60 | * @var array | |
6a488035 TO |
61 | */ |
62 | static $_GName = NULL; | |
63 | ||
64 | /** | |
65 | * The option group id | |
66 | * | |
67 | * @var array | |
6a488035 TO |
68 | */ |
69 | static $_gId = NULL; | |
70 | ||
71 | /** | |
72 | * Obtains the group name from url and sets the title. | |
73 | * | |
74 | * @return void | |
6a488035 | 75 | */ |
00be9182 | 76 | public function preProcess() { |
6a488035 TO |
77 | $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE); |
78 | $this->_id = CRM_Utils_Request::retrieve('id', 'String', $this, FALSE); | |
79 | ||
80 | self::$_gName = "report_template"; | |
81 | ||
82 | if (self::$_gName) { | |
83 | self::$_gId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', self::$_gName, 'id', 'name'); | |
84 | } | |
85 | else { | |
86 | CRM_Core_Error::fatal(); | |
87 | } | |
88 | ||
89 | self::$_GName = ucwords(str_replace('_', ' ', self::$_gName)); | |
90 | ||
91 | $this->assign('GName', self::$_GName); | |
92 | $newReportURL = CRM_Utils_System::url("civicrm/admin/report/register", | |
93 | 'reset=1' | |
94 | ); | |
95 | $this->assign('newReport', $newReportURL); | |
96 | CRM_Utils_System::setTitle(ts('Registered Templates')); | |
97 | } | |
98 | ||
99 | /** | |
100 | * Get BAO Name | |
101 | * | |
a6c01b45 CW |
102 | * @return string |
103 | * Classname of BAO. | |
6a488035 | 104 | */ |
00be9182 | 105 | public function getBAOName() { |
6a488035 TO |
106 | return 'CRM_Core_BAO_OptionValue'; |
107 | } | |
108 | ||
109 | /** | |
110 | * Get action Links | |
111 | * | |
a6c01b45 CW |
112 | * @return array |
113 | * (reference) of action links | |
6a488035 | 114 | */ |
00be9182 | 115 | public function &links() { |
6a488035 TO |
116 | if (!(self::$_links)) { |
117 | self::$_links = array( | |
118 | CRM_Core_Action::UPDATE => array( | |
119 | 'name' => ts('Edit'), | |
120 | 'url' => 'civicrm/admin/report/register/' . self::$_gName, | |
121 | 'qs' => 'action=update&id=%%id%%&reset=1', | |
122 | 'title' => ts('Edit %1', array(1 => self::$_gName)), | |
123 | ), | |
124 | CRM_Core_Action::DISABLE => array( | |
125 | 'name' => ts('Disable'), | |
4d17a233 | 126 | 'ref' => 'crm-enable-disable', |
6a488035 TO |
127 | 'title' => ts('Disable %1', array(1 => self::$_gName)), |
128 | ), | |
129 | CRM_Core_Action::ENABLE => array( | |
130 | 'name' => ts('Enable'), | |
4d17a233 | 131 | 'ref' => 'crm-enable-disable', |
6a488035 TO |
132 | 'title' => ts('Enable %1', array(1 => self::$_gName)), |
133 | ), | |
134 | CRM_Core_Action::DELETE => array( | |
135 | 'name' => ts('Delete'), | |
136 | 'url' => 'civicrm/admin/report/register/' . self::$_gName, | |
137 | 'qs' => 'action=delete&id=%%id%%&reset=1', | |
138 | 'title' => ts('Delete %1 Type', array(1 => self::$_gName)), | |
139 | ), | |
140 | ); | |
141 | } | |
142 | ||
143 | return self::$_links; | |
144 | } | |
145 | ||
146 | /** | |
147 | * Run the basic page (run essentially starts execution for that page). | |
148 | * | |
149 | * @return void | |
150 | */ | |
00be9182 | 151 | public function run() { |
6a488035 TO |
152 | $this->preProcess(); |
153 | return parent::run(); | |
154 | } | |
155 | ||
156 | /** | |
157 | * Browse all options | |
158 | * | |
159 | * | |
160 | * @return void | |
6a488035 | 161 | */ |
00be9182 | 162 | public function browse() { |
6a488035 TO |
163 | $groupParams = array('name' => self::$_gName); |
164 | $optionValue = CRM_Core_OptionValue::getRows($groupParams, $this->links(), 'weight'); | |
353ffa53 TO |
165 | $gName = self::$_gName; |
166 | $returnURL = CRM_Utils_System::url("civicrm/admin/report/options/$gName", | |
6a488035 TO |
167 | "reset=1" |
168 | ); | |
169 | $filter = "option_group_id = " . self::$_gId; | |
170 | ||
171 | $session = new CRM_Core_Session(); | |
172 | $session->replaceUserContext($returnURL); | |
173 | CRM_Utils_Weight::addOrder($optionValue, 'CRM_Core_DAO_OptionValue', | |
174 | 'id', $returnURL, $filter | |
175 | ); | |
176 | $this->assign('rows', $optionValue); | |
177 | } | |
178 | ||
179 | /** | |
180 | * Get name of edit form | |
181 | * | |
a6c01b45 CW |
182 | * @return string |
183 | * Classname of edit form. | |
6a488035 | 184 | */ |
00be9182 | 185 | public function editForm() { |
6a488035 TO |
186 | return 'CRM_Report_Form_Register'; |
187 | } | |
188 | ||
189 | /** | |
190 | * Get edit form name | |
191 | * | |
a6c01b45 CW |
192 | * @return string |
193 | * name of this page. | |
6a488035 | 194 | */ |
00be9182 | 195 | public function editName() { |
6a488035 TO |
196 | return self::$_GName; |
197 | } | |
198 | ||
199 | /** | |
200 | * Get user context. | |
201 | * | |
da6b46f4 EM |
202 | * @param null $mode |
203 | * | |
a6c01b45 CW |
204 | * @return string |
205 | * user context. | |
6a488035 | 206 | */ |
00be9182 | 207 | public function userContext($mode = NULL) { |
6a488035 TO |
208 | return 'civicrm/report/options/' . self::$_gName; |
209 | } | |
210 | ||
211 | /** | |
100fef9d | 212 | * Get userContext params |
6a488035 | 213 | * |
7e06c9f5 TO |
214 | * @param int $mode |
215 | * Mode that we are in. | |
6a488035 TO |
216 | * |
217 | * @return string | |
6a488035 | 218 | */ |
00be9182 | 219 | public function userContextParams($mode = NULL) { |
6a488035 TO |
220 | return 'reset=1&action=browse'; |
221 | } | |
222 | } |