Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
6a488035 TO |
2 | |
3 | /* | |
4 | +--------------------------------------------------------------------+ | |
06b69b18 | 5 | | CiviCRM version 4.5 | |
6a488035 | 6 | +--------------------------------------------------------------------+ |
06b69b18 | 7 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
8 | +--------------------------------------------------------------------+ |
9 | | This file is a part of CiviCRM. | | |
10 | | | | |
11 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
12 | | under the terms of the GNU Affero General Public License | | |
13 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
14 | | | | |
15 | | CiviCRM is distributed in the hope that it will be useful, but | | |
16 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
17 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
18 | | See the GNU Affero General Public License for more details. | | |
19 | | | | |
20 | | You should have received a copy of the GNU Affero General Public | | |
21 | | License and the CiviCRM Licensing Exception along | | |
22 | | with this program; if not, contact CiviCRM LLC | | |
23 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
24 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
25 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
26 | +--------------------------------------------------------------------+ | |
27 | */ | |
28 | ||
29 | /** | |
30 | * | |
31 | * @package CRM | |
06b69b18 | 32 | * @copyright CiviCRM LLC (c) 2004-2014 |
6a488035 TO |
33 | * $Id$ |
34 | * | |
35 | */ | |
36 | ||
37 | /** | |
38 | * Page for displaying list of Gender | |
39 | */ | |
40 | class CRM_Report_Page_Options extends CRM_Core_Page_Basic { | |
41 | ||
96f50de2 CW |
42 | public $useLivePageJS = TRUE; |
43 | ||
6a488035 TO |
44 | /** |
45 | * The action links that we need to display for the browse screen | |
46 | * | |
47 | * @var array | |
48 | * @static | |
49 | */ | |
50 | static $_links = NULL; | |
51 | ||
52 | /** | |
53 | * The option group name | |
54 | * | |
55 | * @var array | |
56 | * @static | |
57 | */ | |
58 | static $_gName = NULL; | |
59 | ||
60 | /** | |
61 | * The option group name in display format (capitalized, without underscores...etc) | |
62 | * | |
63 | * @var array | |
64 | * @static | |
65 | */ | |
66 | static $_GName = NULL; | |
67 | ||
68 | /** | |
69 | * The option group id | |
70 | * | |
71 | * @var array | |
72 | * @static | |
73 | */ | |
74 | static $_gId = NULL; | |
75 | ||
76 | /** | |
77 | * Obtains the group name from url and sets the title. | |
78 | * | |
79 | * @return void | |
80 | * @access public | |
81 | * | |
82 | */ | |
83 | function preProcess() { | |
84 | $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE); | |
85 | $this->_id = CRM_Utils_Request::retrieve('id', 'String', $this, FALSE); | |
86 | ||
87 | self::$_gName = "report_template"; | |
88 | ||
89 | if (self::$_gName) { | |
90 | self::$_gId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', self::$_gName, 'id', 'name'); | |
91 | } | |
92 | else { | |
93 | CRM_Core_Error::fatal(); | |
94 | } | |
95 | ||
96 | self::$_GName = ucwords(str_replace('_', ' ', self::$_gName)); | |
97 | ||
98 | $this->assign('GName', self::$_GName); | |
99 | $newReportURL = CRM_Utils_System::url("civicrm/admin/report/register", | |
100 | 'reset=1' | |
101 | ); | |
102 | $this->assign('newReport', $newReportURL); | |
103 | CRM_Utils_System::setTitle(ts('Registered Templates')); | |
104 | } | |
105 | ||
106 | /** | |
107 | * Get BAO Name | |
108 | * | |
109 | * @return string Classname of BAO. | |
110 | */ | |
111 | function getBAOName() { | |
112 | return 'CRM_Core_BAO_OptionValue'; | |
113 | } | |
114 | ||
115 | /** | |
116 | * Get action Links | |
117 | * | |
118 | * @return array (reference) of action links | |
119 | */ | |
120 | function &links() { | |
121 | if (!(self::$_links)) { | |
122 | self::$_links = array( | |
123 | CRM_Core_Action::UPDATE => array( | |
124 | 'name' => ts('Edit'), | |
125 | 'url' => 'civicrm/admin/report/register/' . self::$_gName, | |
126 | 'qs' => 'action=update&id=%%id%%&reset=1', | |
127 | 'title' => ts('Edit %1', array(1 => self::$_gName)), | |
128 | ), | |
129 | CRM_Core_Action::DISABLE => array( | |
130 | 'name' => ts('Disable'), | |
4d17a233 | 131 | 'ref' => 'crm-enable-disable', |
6a488035 TO |
132 | 'title' => ts('Disable %1', array(1 => self::$_gName)), |
133 | ), | |
134 | CRM_Core_Action::ENABLE => array( | |
135 | 'name' => ts('Enable'), | |
4d17a233 | 136 | 'ref' => 'crm-enable-disable', |
6a488035 TO |
137 | 'title' => ts('Enable %1', array(1 => self::$_gName)), |
138 | ), | |
139 | CRM_Core_Action::DELETE => array( | |
140 | 'name' => ts('Delete'), | |
141 | 'url' => 'civicrm/admin/report/register/' . self::$_gName, | |
142 | 'qs' => 'action=delete&id=%%id%%&reset=1', | |
143 | 'title' => ts('Delete %1 Type', array(1 => self::$_gName)), | |
144 | ), | |
145 | ); | |
146 | } | |
147 | ||
148 | return self::$_links; | |
149 | } | |
150 | ||
151 | /** | |
152 | * Run the basic page (run essentially starts execution for that page). | |
153 | * | |
154 | * @return void | |
155 | */ | |
156 | function run() { | |
157 | $this->preProcess(); | |
158 | return parent::run(); | |
159 | } | |
160 | ||
161 | /** | |
162 | * Browse all options | |
163 | * | |
164 | * | |
165 | * @return void | |
166 | * @access public | |
167 | * @static | |
168 | */ | |
169 | function browse() { | |
170 | $groupParams = array('name' => self::$_gName); | |
171 | $optionValue = CRM_Core_OptionValue::getRows($groupParams, $this->links(), 'weight'); | |
172 | $gName = self::$_gName; | |
173 | $returnURL = CRM_Utils_System::url("civicrm/admin/report/options/$gName", | |
174 | "reset=1" | |
175 | ); | |
176 | $filter = "option_group_id = " . self::$_gId; | |
177 | ||
178 | $session = new CRM_Core_Session(); | |
179 | $session->replaceUserContext($returnURL); | |
180 | CRM_Utils_Weight::addOrder($optionValue, 'CRM_Core_DAO_OptionValue', | |
181 | 'id', $returnURL, $filter | |
182 | ); | |
183 | $this->assign('rows', $optionValue); | |
184 | } | |
185 | ||
186 | /** | |
187 | * Get name of edit form | |
188 | * | |
189 | * @return string Classname of edit form. | |
190 | */ | |
191 | function editForm() { | |
192 | return 'CRM_Report_Form_Register'; | |
193 | } | |
194 | ||
195 | /** | |
196 | * Get edit form name | |
197 | * | |
198 | * @return string name of this page. | |
199 | */ | |
200 | function editName() { | |
201 | return self::$_GName; | |
202 | } | |
203 | ||
204 | /** | |
205 | * Get user context. | |
206 | * | |
da6b46f4 EM |
207 | * @param null $mode |
208 | * | |
6a488035 TO |
209 | * @return string user context. |
210 | */ | |
211 | function userContext($mode = NULL) { | |
212 | return 'civicrm/report/options/' . self::$_gName; | |
213 | } | |
214 | ||
215 | /** | |
216 | * function to get userContext params | |
217 | * | |
218 | * @param int $mode mode that we are in | |
219 | * | |
220 | * @return string | |
221 | * @access public | |
222 | */ | |
223 | function userContextParams($mode = NULL) { | |
224 | return 'reset=1&action=browse'; | |
225 | } | |
226 | } | |
227 |