3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * Page for displaying list of Gender
21 class CRM_Report_Page_Options
extends CRM_Core_Page_Basic
{
23 public $useLivePageJS = TRUE;
26 * The action links that we need to display for the browse screen.
30 public static $_links = NULL;
33 * The option group name.
37 public static $_gName = NULL;
40 * The option group name in display format (capitalized, without underscores...etc)
44 public static $_GName = NULL;
47 * The option group id.
51 public static $_gId = NULL;
54 * Obtains the group name from url and sets the title.
56 public function preProcess() {
57 $this->_action
= CRM_Utils_Request
::retrieve('action', 'String', $this, FALSE);
58 $this->_id
= CRM_Utils_Request
::retrieve('id', 'String', $this, FALSE);
60 self
::$_gName = "report_template";
63 self
::$_gId = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_OptionGroup', self
::$_gName, 'id', 'name');
66 CRM_Core_Error
::fatal();
69 self
::$_GName = ucwords(str_replace('_', ' ', self
::$_gName));
71 $this->assign('GName', self
::$_GName);
72 $newReportURL = CRM_Utils_System
::url("civicrm/admin/report/register",
75 $this->assign('newReport', $newReportURL);
76 CRM_Utils_System
::setTitle(ts('Registered Templates'));
85 public function getBAOName() {
86 return 'CRM_Core_BAO_OptionValue';
93 * (reference) of action links.
95 public function &links() {
96 if (!(self
::$_links)) {
98 CRM_Core_Action
::UPDATE
=> [
100 'url' => 'civicrm/admin/report/register/' . self
::$_gName,
101 'qs' => 'action=update&id=%%id%%&reset=1',
102 'title' => ts('Edit %1', [1 => self
::$_gName]),
104 CRM_Core_Action
::DISABLE
=> [
105 'name' => ts('Disable'),
106 'ref' => 'crm-enable-disable',
107 'title' => ts('Disable %1', [1 => self
::$_gName]),
109 CRM_Core_Action
::ENABLE
=> [
110 'name' => ts('Enable'),
111 'ref' => 'crm-enable-disable',
112 'title' => ts('Enable %1', [1 => self
::$_gName]),
114 CRM_Core_Action
::DELETE
=> [
115 'name' => ts('Delete'),
116 'url' => 'civicrm/admin/report/register/' . self
::$_gName,
117 'qs' => 'action=delete&id=%%id%%&reset=1',
118 'title' => ts('Delete %1 Type', [1 => self
::$_gName]),
123 return self
::$_links;
127 * Run the basic page (run essentially starts execution for that page).
129 public function run() {
131 return parent
::run();
135 * Browse all options.
137 public function browse() {
138 $groupParams = ['name' => self
::$_gName];
139 $optionValue = CRM_Core_OptionValue
::getRows($groupParams, $this->links(), 'weight');
140 $gName = self
::$_gName;
141 $returnURL = CRM_Utils_System
::url("civicrm/admin/report/options/$gName",
144 $filter = "option_group_id = " . self
::$_gId;
146 $session = new CRM_Core_Session();
147 $session->replaceUserContext($returnURL);
148 CRM_Utils_Weight
::addOrder($optionValue, 'CRM_Core_DAO_OptionValue',
149 'id', $returnURL, $filter
151 $this->assign('rows', $optionValue);
155 * Get name of edit form.
158 * Classname of edit form.
160 public function editForm() {
161 return 'CRM_Report_Form_Register';
165 * Get edit form name.
170 public function editName() {
171 return self
::$_GName;
182 public function userContext($mode = NULL) {
183 return 'civicrm/report/options/' . self
::$_gName;
187 * Get userContext params.
190 * Mode that we are in.
194 public function userContextParams($mode = NULL) {
195 return 'reset=1&action=browse';