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