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