ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
4 include_once("./Services/Table/classes/class.ilTable2GUI.php");
5 
16 {
17 
21  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)
31  {
32  $this->addColumn($this->lng->txt($c), $c);
33  }
34 
35  $this->setExternalSorting(true);
36  $this->setExternalSegmentation(true);
37  $this->setEnableHeader(true);
38  $this->setFormAction($ilCtrl->getFormAction($this->parent_obj, "listCodes"));
39  $this->setRowTemplate("tpl.code_list_row.html", "Services/Registration");
40  $this->setEnableTitle(true);
41  $this->initFilter();
42  $this->setFilterCommand("applyCodesFilter");
43  $this->setResetCommand("resetCodesFilter");
44  $this->setDefaultOrderField("generated");
45  $this->setDefaultOrderDirection("desc");
46 
47  $this->setSelectAllCheckbox("id[]");
48  $this->setTopCommands(true);
49  $this->addMultiCommand("deleteConfirmation", $lng->txt("delete"));
50 
51  $this->addCommandButton("exportCodes", $lng->txt("registration_codes_export"));
52 
53  $this->getItems();
54  }
55 
59  function getItems()
60  {
61  global $lng;
62 
63  $this->determineOffsetAndOrder();
64 
65  include_once("./Services/Registration/classes/class.ilRegistrationCode.php");
66 
67  $order_map = array(
68  "registration_code" => "code",
69  "role" => "role",
70  "registration_generated" => "generated",
71  "registration_used" => "used"
72  );
73 
75  ilUtil::stripSlashes($order_map[$this->getOrderField()]),
79  $this->filter["code"],
80  $this->filter["role"],
81  $this->filter["generated"]
82  );
83 
84  if (count($codes_data["set"]) == 0 && $this->getOffset() > 0)
85  {
86  $this->resetOffset();
92  $this->filter["code"],
93  $this->filter["role"],
94  $this->filter["generated"]
95  );
96  }
97 
98  include_once './Services/AccessControl/classes/class.ilObjRole.php';
99  $role_map = array();
100  foreach(ilObjRole::_lookupRegisterAllowed() as $role)
101  {
102  $role_map[$role['id']] = $role['title'];
103  }
104 
105  $result = array();
106  foreach ($codes_data["set"] as $k => $code)
107  {
108  $result[$k]["registration_generated"] = ilDatePresentation::formatDate(new ilDateTime($code["generated"],IL_CAL_UNIX));
109 
110  if($code["used"])
111  {
112  $result[$k]["registration_used"] = ilDatePresentation::formatDate(new ilDateTime($code["used"],IL_CAL_UNIX));
113  }
114  else
115  {
116  $result[$k]["registration_used"] = "";
117  }
118 
119  $result[$k]["role"] = $role_map[$code["role"]];
120  $result[$k]["registration_code"] = $code["code"];
121  $result[$k]["code_id"] = $code["code_id"];
122  }
123 
124  $this->setMaxCount($codes_data["cnt"]);
125  $this->setData($result);
126  }
127 
128 
132  function initFilter()
133  {
134  global $lng, $rbacreview, $ilUser;
135 
136  include_once("./Services/Registration/classes/class.ilRegistrationCode.php");
137 
138  // code
139  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
140  $ti = new ilTextInputGUI($lng->txt("registration_code"), "query");
142  $ti->setSize(20);
143  $ti->setSubmitFormOnEnter(true);
144  $this->addFilterItem($ti);
145  $ti->readFromSession();
146  $this->filter["code"] = $ti->getValue();
147 
148  // role
149  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
150  include_once './Services/AccessControl/classes/class.ilObjRole.php';
151  $options = array("" => $this->lng->txt("registration_roles_all"));
152  foreach(ilObjRole::_lookupRegisterAllowed() as $role)
153  {
154  $options[$role['id']] = $role['title'];
155  }
156  $si = new ilSelectInputGUI($this->lng->txt("role"), "role");
157  $si->setOptions($options);
158  $this->addFilterItem($si);
159  $si->readFromSession();
160  $this->filter["role"] = $si->getValue();
161 
162  // generated
163  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
164  $options = array("" => $this->lng->txt("registration_generated_all"));
165  foreach((array)ilRegistrationCode::getGenerationDates() as $date)
166  {
167  $options[$date] = ilDatePresentation::formatDate(new ilDateTime($date,IL_CAL_UNIX));
168  }
169  $si = new ilSelectInputGUI($this->lng->txt("registration_generated"), "generated");
170  $si->setOptions($options);
171  $this->addFilterItem($si);
172  $si->readFromSession();
173  $this->filter["generated"] = $si->getValue();
174  }
175 
176  public function getSelectedColumns()
177  {
178  return array("registration_code", "role", "registration_generated", "registration_used");
179  }
180 
184  protected function fillRow($code)
185  {
186  $this->tpl->setVariable("ID", $code["code_id"]);
187  foreach ($this->getSelectedColumns() as $c)
188  {
189  $this->tpl->setVariable("VAL_".strtoupper($c), $code[$c]);
190  }
191  }
192 
193 }
194 ?>