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