ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilRegistrationCodesTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/Table/classes/class.ilTable2GUI.php");
5
16{
17
21 public function __construct($a_parent_obj, $a_parent_cmd)
22 {
23 global $DIC;
24
25 $ilCtrl = $DIC['ilCtrl'];
26 $lng = $DIC['lng'];
27
28 $this->setId("registration_code");
29
30 parent::__construct($a_parent_obj, $a_parent_cmd);
31
32 $this->addColumn("", "", "1", true);
33 foreach ($this->getSelectedColumns() as $c => $caption) {
34 if ($c == "role_local" || $c == "alimit") {
35 $c = "";
36 }
37 $this->addColumn($this->lng->txt($caption), $c);
38 }
39
40 $this->setExternalSorting(true);
41 $this->setExternalSegmentation(true);
42 $this->setEnableHeader(true);
43 $this->setFormAction($ilCtrl->getFormAction($this->parent_obj, "listCodes"));
44 $this->setRowTemplate("tpl.code_list_row.html", "Services/Registration");
45 $this->setEnableTitle(true);
46 $this->initFilter();
47 $this->setFilterCommand("applyCodesFilter");
48 $this->setResetCommand("resetCodesFilter");
49 $this->setDefaultOrderField("generated"); // #11341
50 $this->setDefaultOrderDirection("desc");
51
52 $this->setSelectAllCheckbox("id[]");
53 $this->setTopCommands(true);
54 $this->addMultiCommand("deleteConfirmation", $lng->txt("delete"));
55
56 $this->addCommandButton("exportCodes", $lng->txt("registration_codes_export"));
57
58 $this->getItems();
59 }
60
64 public function getItems()
65 {
66 global $DIC;
67
68 $rbacreview = $DIC['rbacreview'];
69 $ilObjDataCache = $DIC['ilObjDataCache'];
70
72
73 include_once("./Services/Registration/classes/class.ilRegistrationCode.php");
74
75 // #12737
76 if (!in_array($this->getOrderField(), array_keys($this->getSelectedColumns()))) {
77 $this->setOrderField($this->getDefaultOrderField());
78 }
79
85 $this->filter["code"],
86 $this->filter["role"],
87 $this->filter["generated"],
88 $this->filter["alimit"]
89 );
90
91 if (count($codes_data["set"]) == 0 && $this->getOffset() > 0) {
92 $this->resetOffset();
98 $this->filter["code"],
99 $this->filter["role"],
100 $this->filter["generated"],
101 $this->filter["alimit"]
102 );
103 }
104
105 include_once './Services/AccessControl/classes/class.ilObjRole.php';
106 $options = array();
107 foreach ($rbacreview->getGlobalRoles() as $role_id) {
108 if (!in_array($role_id, array(SYSTEM_ROLE_ID, ANONYMOUS_ROLE_ID))) {
109 $role_map[$role_id] = $ilObjDataCache->lookupTitle($role_id);
110 }
111 }
112
113 $result = array();
114 foreach ($codes_data["set"] as $k => $code) {
115 $result[$k]["code"] = $code["code"];
116 $result[$k]["code_id"] = $code["code_id"];
117
118 $result[$k]["generated"] = ilDatePresentation::formatDate(new ilDateTime($code["generated"], IL_CAL_UNIX));
119
120 if ($code["used"]) {
122 }
123
124 if ($code["role"]) {
125 $result[$k]["role"] = $this->role_map[$code["role"]];
126 }
127
128 if ($code["role_local"]) {
129 $local = array();
130 foreach (explode(";", $code["role_local"]) as $role_id) {
131 $role = ilObject::_lookupTitle($role_id);
132 if ($role) {
133 $local[] = $role;
134 }
135 }
136 if (sizeof($local)) {
137 sort($local);
138 $result[$k]["role_local"] = implode("<br />", $local);
139 }
140 }
141
142 if ($code["alimit"]) {
143 switch ($code["alimit"]) {
144 case "unlimited":
145 $result[$k]["alimit"] = $this->lng->txt("reg_access_limitation_none");
146 break;
147
148 case "absolute":
149 $result[$k]["alimit"] = $this->lng->txt("reg_access_limitation_mode_absolute_target") .
150 ": " . ilDatePresentation::formatDate(new ilDate($code["alimitdt"], IL_CAL_DATE));
151 break;
152
153 case "relative":
154 $limit_caption = array();
155 $limit = unserialize($code["alimitdt"]);
156 if ((int) $limit["d"]) {
157 $limit_caption[] = (int) $limit["d"] . " " . $this->lng->txt("days");
158 }
159 if ((int) $limit["m"]) {
160 $limit_caption[] = (int) $limit["m"] . " " . $this->lng->txt("months");
161 }
162 if ((int) $limit["y"]) {
163 $limit_caption[] = (int) $limit["y"] . " " . $this->lng->txt("years");
164 }
165 if (sizeof($limit_caption)) {
166 $result[$k]["alimit"] = $this->lng->txt("reg_access_limitation_mode_relative_target") .
167 ": " . implode(", ", $limit_caption);
168 }
169 break;
170 }
171 }
172 }
173
174 $this->setMaxCount($codes_data["cnt"]);
175 $this->setData($result);
176 }
177
178
182 public function initFilter()
183 {
184 global $DIC;
185
186 $lng = $DIC['lng'];
187 $rbacreview = $DIC['rbacreview'];
188 $ilUser = $DIC['ilUser'];
189 $ilObjDataCache = $DIC['ilObjDataCache'];
190
191 include_once("./Services/Registration/classes/class.ilRegistrationCode.php");
192
193 // code
194 include_once("./Services/Form/classes/class.ilTextInputGUI.php");
195 $ti = new ilTextInputGUI($lng->txt("registration_code"), "query");
196 $ti->setMaxLength(ilRegistrationCode::CODE_LENGTH);
197 $ti->setSize(20);
198 $ti->setSubmitFormOnEnter(true);
199 $this->addFilterItem($ti);
200 $ti->readFromSession();
201 $this->filter["code"] = $ti->getValue();
202
203 // role
204
205 $this->role_map = array();
206 foreach ($rbacreview->getGlobalRoles() as $role_id) {
207 if (!in_array($role_id, array(SYSTEM_ROLE_ID, ANONYMOUS_ROLE_ID))) {
208 $this->role_map[$role_id] = $ilObjDataCache->lookupTitle($role_id);
209 }
210 }
211
212 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
213 include_once './Services/AccessControl/classes/class.ilObjRole.php';
214 $options = array("" => $this->lng->txt("registration_roles_all")) +
215 $this->role_map;
216 $si = new ilSelectInputGUI($this->lng->txt("role"), "role");
217 $si->setOptions($options);
218 $this->addFilterItem($si);
219 $si->readFromSession();
220 $this->filter["role"] = $si->getValue();
221
222 // access limitation
223 $options = array("" => $this->lng->txt("registration_codes_access_limitation_all"),
224 "unlimited" => $this->lng->txt("reg_access_limitation_none"),
225 "absolute" => $this->lng->txt("reg_access_limitation_mode_absolute"),
226 "relative" => $this->lng->txt("reg_access_limitation_mode_relative"));
227 $si = new ilSelectInputGUI($this->lng->txt("reg_access_limitations"), "alimit");
228 $si->setOptions($options);
229 $this->addFilterItem($si);
230 $si->readFromSession();
231 $this->filter["alimit"] = $si->getValue();
232
233 // generated
234 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
235 $options = array("" => $this->lng->txt("registration_generated_all"));
236 foreach ((array) ilRegistrationCode::getGenerationDates() as $date) {
238 }
239 $si = new ilSelectInputGUI($this->lng->txt("registration_generated"), "generated");
240 $si->setOptions($options);
241 $this->addFilterItem($si);
242 $si->readFromSession();
243 $this->filter["generated"] = $si->getValue();
244 }
245
246 public function getSelectedColumns()
247 {
248 return array("code" => "registration_code",
249 "role" => "registration_codes_roles",
250 "role_local" => "registration_codes_roles_local",
251 "alimit" => "reg_access_limitations",
252 "generated" => "registration_generated",
253 "used" => "registration_used");
254 }
255
256 protected function fillRow($code)
257 {
258 $this->tpl->setVariable("ID", $code["code_id"]);
259 foreach (array_keys($this->getSelectedColumns()) as $c) {
260 $this->tpl->setVariable("VAL_" . strtoupper($c), $code[$c]);
261 }
262 }
263}
$result
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATE
const IL_CAL_UNIX
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
@classDescription Date and time handling
Class for single dates.
static _lookupTitle($a_id)
lookup object title
static getCodesData($order_field, $order_direction, $offset, $limit, $filter_code, $filter_role, $filter_generated, $filter_access_limitation)
TableGUI class for registration codes.
__construct($a_parent_obj, $a_parent_cmd)
Constructor.
fillRow($code)
Standard Version of Fill Row.
This class represents a selection list property in a property form.
Class ilTable2GUI.
setTopCommands($a_val)
Set top commands (display command buttons on top of table, too)
setEnableHeader($a_enableheader)
Set Enable Header.
setExternalSorting($a_val)
Set external sorting.
determineOffsetAndOrder($a_omit_offset=false)
Determine offset and order.
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
setData($a_data)
set table data @access public
setResetCommand($a_val, $a_caption=null)
Set reset filter command.
setEnableTitle($a_enabletitle)
Set Enable Title.
getLimit()
Get limit.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
resetOffset($a_in_determination=false)
Reset offset.
addMultiCommand($a_cmd, $a_text)
Add Command button.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
getOffset()
Get offset.
setExternalSegmentation($a_val)
Set external segmentation.
setId($a_val)
Set id.
setOrderField($a_order_field)
set order column
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setFilterCommand($a_val, $a_caption=null)
Set filter command.
getDefaultOrderField()
Get Default order field.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
getOrderDirection()
Get order direction.
setMaxCount($a_max_count)
set max.
This class represents a text property in a property form.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$code
Definition: example_050.php:99
global $ilCtrl
Definition: ilias.php:18
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18