ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilAccountCodesTableGUI.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{
20 function __construct($a_parent_obj, $a_parent_cmd)
21 {
22 global $ilCtrl, $lng;
23
24 $this->setId("user_account_code");
25
26 parent::__construct($a_parent_obj, $a_parent_cmd);
27
28 $this->addColumn("", "", "1", true);
29 $this->addColumn($lng->txt("user_account_code"), "code");
30 $this->addColumn($lng->txt("user_account_code_valid_until"), "valid_until");
31 $this->addColumn($lng->txt("user_account_code_generated"), "generated");
32 $this->addColumn($lng->txt("user_account_code_used"), "used");
33
34 $this->setExternalSorting(true);
35 $this->setExternalSegmentation(true);
36 $this->setEnableHeader(true);
37 $this->setFormAction($ilCtrl->getFormAction($this->parent_obj, "listCodes"));
38 $this->setRowTemplate("tpl.code_list_row.html", "Services/User");
39 $this->setEnableTitle(true);
40 $this->initFilter();
41 $this->setFilterCommand("applyCodesFilter");
42 $this->setResetCommand("resetCodesFilter");
43 $this->setDefaultOrderField("generated");
44 $this->setDefaultOrderDirection("desc");
45
46 $this->setSelectAllCheckbox("id[]");
47 $this->setTopCommands(true);
48 $this->addMultiCommand("deleteConfirmation", $lng->txt("delete"));
49
50 include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
52 $button->setCaption("user_account_codes_export");
53 $button->setCommand("exportCodes");
54 $button->setOmitPreventDoubleSubmission(true);
55 $this->addCommandButtonInstance($button);
56
57 $this->getItems();
58 }
59
63 function getItems()
64 {
65 global $lng, $rbacreview, $ilObjDataCache;
66
68
69 include_once("./Services/User/classes/class.ilAccountCode.php");
70
71 $codes_data = ilAccountCode::getCodesData(
76 $this->filter["code"],
77 $this->filter["valid_until"],
78 $this->filter["generated"]
79 );
80
81 if (count($codes_data["set"]) == 0 && $this->getOffset() > 0)
82 {
83 $this->resetOffset();
84 $codes_data = ilAccountCode::getCodesData(
89 $this->filter["code"],
90 $this->filter["valid_until"],
91 $this->filter["generated"]
92 );
93 }
94
95 $result = array();
96 foreach ($codes_data["set"] as $k => $code)
97 {
98 $result[$k]["generated"] = ilDatePresentation::formatDate(new ilDateTime($code["generated"],IL_CAL_UNIX));
99
100 if($code["used"])
101 {
103 }
104 else
105 {
106 $result[$k]["used"] = "";
107 }
108
109 if($code["valid_until"] === "0")
110 {
111 $valid = $lng->txt("user_account_code_valid_until_unlimited");
112 }
113 else if(is_numeric($code["valid_until"]))
114 {
115 $valid = $code["valid_until"]." ".($code["valid_until"] == 1 ? $lng->txt("day") : $lng->txt("days"));
116 }
117 else
118 {
120 }
121 $result[$k]["valid_until"] = $valid;
122
123 $result[$k]["code"] = $code["code"];
124 $result[$k]["code_id"] = $code["code_id"];
125 }
126
127 $this->setMaxCount($codes_data["cnt"]);
128 $this->setData($result);
129 }
130
131
135 function initFilter()
136 {
137 global $lng, $rbacreview, $ilUser;
138
139 include_once("./Services/User/classes/class.ilAccountCode.php");
140
141 // code
142 include_once("./Services/Form/classes/class.ilTextInputGUI.php");
143 $ti = new ilTextInputGUI($lng->txt("user_account_code"), "query");
144 $ti->setMaxLength(ilAccountCode::CODE_LENGTH);
145 $ti->setSize(20);
146 $ti->setSubmitFormOnEnter(true);
147 $this->addFilterItem($ti);
148 $ti->readFromSession();
149 $this->filter["code"] = $ti->getValue();
150
151 // generated
152 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
153 $options = array("" => $lng->txt("user_account_code_generated_all"));
154 foreach((array)ilAccountCode::getGenerationDates() as $date)
155 {
157 }
158 $si = new ilSelectInputGUI($lng->txt("user_account_code_generated"), "generated");
159 $si->setOptions($options);
160 $this->addFilterItem($si);
161 $si->readFromSession();
162 $this->filter["generated"] = $si->getValue();
163 }
164
168 protected function fillRow($code)
169 {
170 $this->tpl->setVariable("ID", $code["code_id"]);
171 $this->tpl->setVariable("VAL_CODE", $code["code"]);
172 $this->tpl->setVariable("VAL_VALID_UNTIL", $code["valid_until"]);
173 $this->tpl->setVariable("VAL_GENERATED", $code["generated"]);
174 $this->tpl->setVariable("VAL_USED", $code["used"]);
175 }
176}
177
178?>
$result
const IL_CAL_DATE
const IL_CAL_UNIX
static getCodesData($order_field, $order_direction, $offset, $limit, $filter_code, $filter_valid_until, $filter_generated)
TableGUI class for account codes.
__construct($a_parent_obj, $a_parent_cmd)
Constructor.
static formatDate(ilDateTime $date)
Format a date @access public.
@classDescription Date and time handling
Class for single dates.
This class represents a selection list property in a property form.
static getInstance()
Factory.
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.
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.
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.
addCommandButtonInstance(ilButtonBase $a_button)
Add Command button instance.
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.
getOffset()
Get offset.
setExternalSegmentation($a_val)
Set external segmentation.
setId($a_val)
Set id.
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.
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
$valid
$code
Definition: example_050.php:99
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
if(!is_array($argv)) $options
global $ilUser
Definition: imgupload.php:15