ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $ilCtrl, $lng;
24
25 $this->setId("registration_code");
26
27 parent::__construct($a_parent_obj, $a_parent_cmd);
28
29 $this->addColumn("", "", "1", true);
30 foreach ($this->getSelectedColumns() as $c => $caption) {
31 if ($c == "role_local" || $c == "alimit") {
32 $c = "";
33 }
34 $this->addColumn($this->lng->txt($caption), $c);
35 }
36
37 $this->setExternalSorting(true);
38 $this->setExternalSegmentation(true);
39 $this->setEnableHeader(true);
40 $this->setFormAction($ilCtrl->getFormAction($this->parent_obj, "listCodes"));
41 $this->setRowTemplate("tpl.code_list_row.html", "Services/Registration");
42 $this->setEnableTitle(true);
43 $this->initFilter();
44 $this->setFilterCommand("applyCodesFilter");
45 $this->setResetCommand("resetCodesFilter");
46 $this->setDefaultOrderField("generated"); // #11341
47 $this->setDefaultOrderDirection("desc");
48
49 $this->setSelectAllCheckbox("id[]");
50 $this->setTopCommands(true);
51 $this->addMultiCommand("deleteConfirmation", $lng->txt("delete"));
52
53 $this->addCommandButton("exportCodes", $lng->txt("registration_codes_export"));
54
55 $this->getItems();
56 }
57
61 public function getItems()
62 {
63 global $rbacreview, $ilObjDataCache;
64
66
67 include_once("./Services/Registration/classes/class.ilRegistrationCode.php");
68
69 // #12737
70 if (!in_array($this->getOrderField(), array_keys($this->getSelectedColumns()))) {
71 $this->setOrderField($this->getDefaultOrderField());
72 }
73
79 $this->filter["code"],
80 $this->filter["role"],
81 $this->filter["generated"],
82 $this->filter["alimit"]
83 );
84
85 if (count($codes_data["set"]) == 0 && $this->getOffset() > 0) {
86 $this->resetOffset();
92 $this->filter["code"],
93 $this->filter["role"],
94 $this->filter["generated"],
95 $this->filter["alimit"]
96 );
97 }
98
99 include_once './Services/AccessControl/classes/class.ilObjRole.php';
100 $options = array();
101 foreach ($rbacreview->getGlobalRoles() as $role_id) {
102 if (!in_array($role_id, array(SYSTEM_ROLE_ID, ANONYMOUS_ROLE_ID))) {
103 $role_map[$role_id] = $ilObjDataCache->lookupTitle($role_id);
104 }
105 }
106
107 $result = array();
108 foreach ($codes_data["set"] as $k => $code) {
109 $result[$k]["code"] = $code["code"];
110 $result[$k]["code_id"] = $code["code_id"];
111
112 $result[$k]["generated"] = ilDatePresentation::formatDate(new ilDateTime($code["generated"], IL_CAL_UNIX));
113
114 if ($code["used"]) {
116 }
117
118 if ($code["role"]) {
119 $result[$k]["role"] = $this->role_map[$code["role"]];
120 }
121
122 if ($code["role_local"]) {
123 $local = array();
124 foreach (explode(";", $code["role_local"]) as $role_id) {
125 $role = ilObject::_lookupTitle($role_id);
126 if ($role) {
127 $local[] = $role;
128 }
129 }
130 if (sizeof($local)) {
131 sort($local);
132 $result[$k]["role_local"] = implode("<br />", $local);
133 }
134 }
135
136 if ($code["alimit"]) {
137 switch ($code["alimit"]) {
138 case "unlimited":
139 $result[$k]["alimit"] = $this->lng->txt("reg_access_limitation_none");
140 break;
141
142 case "absolute":
143 $result[$k]["alimit"] = $this->lng->txt("reg_access_limitation_mode_absolute_target") .
144 ": " . ilDatePresentation::formatDate(new ilDate($code["alimitdt"], IL_CAL_DATE));
145 break;
146
147 case "relative":
148 $limit_caption = array();
149 $limit = unserialize($code["alimitdt"]);
150 if ((int) $limit["d"]) {
151 $limit_caption[] = (int) $limit["d"] . " " . $this->lng->txt("days");
152 }
153 if ((int) $limit["m"]) {
154 $limit_caption[] = (int) $limit["m"] . " " . $this->lng->txt("months");
155 }
156 if ((int) $limit["y"]) {
157 $limit_caption[] = (int) $limit["y"] . " " . $this->lng->txt("years");
158 }
159 if (sizeof($limit_caption)) {
160 $result[$k]["alimit"] = $this->lng->txt("reg_access_limitation_mode_relative_target") .
161 ": " . implode(", ", $limit_caption);
162 }
163 break;
164 }
165 }
166 }
167
168 $this->setMaxCount($codes_data["cnt"]);
169 $this->setData($result);
170 }
171
172
176 public function initFilter()
177 {
178 global $lng, $rbacreview, $ilUser, $ilObjDataCache;
179
180 include_once("./Services/Registration/classes/class.ilRegistrationCode.php");
181
182 // code
183 include_once("./Services/Form/classes/class.ilTextInputGUI.php");
184 $ti = new ilTextInputGUI($lng->txt("registration_code"), "query");
185 $ti->setMaxLength(ilRegistrationCode::CODE_LENGTH);
186 $ti->setSize(20);
187 $ti->setSubmitFormOnEnter(true);
188 $this->addFilterItem($ti);
189 $ti->readFromSession();
190 $this->filter["code"] = $ti->getValue();
191
192 // role
193
194 $this->role_map = array();
195 foreach ($rbacreview->getGlobalRoles() as $role_id) {
196 if (!in_array($role_id, array(SYSTEM_ROLE_ID, ANONYMOUS_ROLE_ID))) {
197 $this->role_map[$role_id] = $ilObjDataCache->lookupTitle($role_id);
198 }
199 }
200
201 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
202 include_once './Services/AccessControl/classes/class.ilObjRole.php';
203 $options = array("" => $this->lng->txt("registration_roles_all"))+
204 $this->role_map;
205 $si = new ilSelectInputGUI($this->lng->txt("role"), "role");
206 $si->setOptions($options);
207 $this->addFilterItem($si);
208 $si->readFromSession();
209 $this->filter["role"] = $si->getValue();
210
211 // access limitation
212 $options = array("" => $this->lng->txt("registration_codes_access_limitation_all"),
213 "unlimited" => $this->lng->txt("reg_access_limitation_none"),
214 "absolute" => $this->lng->txt("reg_access_limitation_mode_absolute"),
215 "relative" => $this->lng->txt("reg_access_limitation_mode_relative"));
216 $si = new ilSelectInputGUI($this->lng->txt("reg_access_limitations"), "alimit");
217 $si->setOptions($options);
218 $this->addFilterItem($si);
219 $si->readFromSession();
220 $this->filter["alimit"] = $si->getValue();
221
222 // generated
223 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
224 $options = array("" => $this->lng->txt("registration_generated_all"));
225 foreach ((array) ilRegistrationCode::getGenerationDates() as $date) {
227 }
228 $si = new ilSelectInputGUI($this->lng->txt("registration_generated"), "generated");
229 $si->setOptions($options);
230 $this->addFilterItem($si);
231 $si->readFromSession();
232 $this->filter["generated"] = $si->getValue();
233 }
234
235 public function getSelectedColumns()
236 {
237 return array("code" => "registration_code",
238 "role" => "registration_codes_roles",
239 "role_local" => "registration_codes_roles_local",
240 "alimit" => "reg_access_limitations",
241 "generated" => "registration_generated",
242 "used" => "registration_used");
243 }
244
245 protected function fillRow($code)
246 {
247 $this->tpl->setVariable("ID", $code["code_id"]);
248 foreach (array_keys($this->getSelectedColumns()) as $c) {
249 $this->tpl->setVariable("VAL_" . strtoupper($c), $code[$c]);
250 }
251 }
252}
$result
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
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)
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.
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.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
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
$ilUser
Definition: imgupload.php:18