ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilAccountCodesGUI Class Reference

GUI class for account codes. More...

+ Collaboration diagram for ilAccountCodesGUI:

Public Member Functions

 __construct ($a_ref_id)
 Constructor. More...
 
 executeCommand ()
 
 listCodes ()
 
 initAddCodesForm ()
 
 addCodes ()
 
 createCodes ()
 
 deleteCodes ()
 
 deleteConfirmation ()
 
 resetCodesFilter ()
 
 applyCodesFilter ()
 
 exportCodes ()
 

Protected Attributes

 $ref_id
 

Detailed Description

GUI class for account codes.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

ilAccountCodesGUI:

Definition at line 13 of file class.ilAccountCodesGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilAccountCodesGUI::__construct (   $a_ref_id)

Constructor.

Parameters
int$a_ref_id

Definition at line 22 of file class.ilAccountCodesGUI.php.

References $DIC, and $lng.

23  {
24  global $DIC;
25 
26  $lng = $DIC['lng'];
27 
28  $this->ref_id = $a_ref_id;
29  $lng->loadLanguageModule("user");
30  }
global $DIC
Definition: saml.php:7
$lng

Member Function Documentation

◆ addCodes()

ilAccountCodesGUI::addCodes ( )

Definition at line 127 of file class.ilAccountCodesGUI.php.

References $DIC, $ilErr, $lng, $tpl, and initAddCodesForm().

128  {
129  global $DIC;
130 
131  $ilAccess = $DIC['ilAccess'];
132  $ilErr = $DIC['ilErr'];
133  $tpl = $DIC['tpl'];
134  $lng = $DIC['lng'];
135 
136  if (!$ilAccess->checkAccess('write', '', $this->ref_id)) {
137  $ilErr->raiseError($lng->txt("msg_no_perm_write"), $ilErr->MESSAGE);
138  }
139 
140  $this->initAddCodesForm();
141  $tpl->setContent($this->form_gui->getHTML());
142  }
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
$ilErr
Definition: raiseError.php:18
$lng
+ Here is the call graph for this function:

◆ applyCodesFilter()

ilAccountCodesGUI::applyCodesFilter ( )

Definition at line 243 of file class.ilAccountCodesGUI.php.

References listCodes().

244  {
245  include_once("./Services/User/classes/class.ilAccountCodesTableGUI.php");
246  $utab = new ilAccountCodesTableGUI($this, "listCodes");
247  $utab->resetOffset();
248  $utab->writeFilterToSession();
249 
250  $this->listCodes();
251  }
TableGUI class for account codes.
+ Here is the call graph for this function:

◆ createCodes()

ilAccountCodesGUI::createCodes ( )

Definition at line 144 of file class.ilAccountCodesGUI.php.

References $DIC, $ilCtrl, $ilErr, $lng, $tpl, $valid, ilAccountCode\create(), IL_CAL_DATE, and initAddCodesForm().

145  {
146  global $DIC;
147 
148  $ilAccess = $DIC['ilAccess'];
149  $ilErr = $DIC['ilErr'];
150  $lng = $DIC['lng'];
151  $tpl = $DIC['tpl'];
152  $ilCtrl = $DIC['ilCtrl'];
153 
154  if (!$ilAccess->checkAccess('write', '', $this->ref_id)) {
155  $ilErr->raiseError($lng->txt("msg_no_perm_write"), $ilErr->MESSAGE);
156  }
157 
158  $this->initAddCodesForm();
159  if ($this->form_gui->checkInput()) {
160  $number = $this->form_gui->getInput('acc_codes_number');
161  switch ($this->form_gui->getInput('valid_type')) {
162  case 'valid_unlimited':
163  $valid = 0;
164  break;
165 
166  case 'valid_static':
167  $valid = $this->form_gui->getItemByPostVar('valid_date')->getDate()->get(IL_CAL_DATE);
168  break;
169 
170  case 'valid_dynamic':
171  $valid = $this->form_gui->getInput('valid_days');
172  break;
173  }
174 
175  include_once './Services/User/classes/class.ilAccountCode.php';
176 
177  $stamp = time();
178  for ($loop = 1; $loop <= $number; $loop++) {
179  ilAccountCode::create($valid, $stamp);
180  }
181 
182  ilUtil::sendSuccess($lng->txt('saved_successfully'), true);
183  $ilCtrl->redirect($this, "listCodes");
184  } else {
185  $this->form_gui->setValuesByPost();
186  $tpl->setContent($this->form_gui->getHtml());
187  }
188  }
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
$valid
$ilErr
Definition: raiseError.php:18
global $ilCtrl
Definition: ilias.php:18
$lng
const IL_CAL_DATE
static create($valid_until, $stamp)
+ Here is the call graph for this function:

◆ deleteCodes()

ilAccountCodesGUI::deleteCodes ( )

Definition at line 190 of file class.ilAccountCodesGUI.php.

References $_POST, $DIC, $ilCtrl, $lng, and ilAccountCode\deleteCodes().

191  {
192  global $DIC;
193 
194  $lng = $DIC['lng'];
195  $ilCtrl = $DIC['ilCtrl'];
196 
197  include_once './Services/User/classes/class.ilAccountCode.php';
199 
200  ilUtil::sendSuccess($lng->txt('info_deleted'), true);
201  $ilCtrl->redirect($this, "listCodes");
202  }
global $DIC
Definition: saml.php:7
global $ilCtrl
Definition: ilias.php:18
$lng
static deleteCodes(array $ids)
$_POST["username"]
+ Here is the call graph for this function:

◆ deleteConfirmation()

ilAccountCodesGUI::deleteConfirmation ( )

Definition at line 204 of file class.ilAccountCodesGUI.php.

References $_POST, $code, $data, $DIC, $ilCtrl, $ilErr, $lng, $tpl, and ilAccountCode\loadCodesByIds().

205  {
206  global $DIC;
207 
208  $ilErr = $DIC['ilErr'];
209  $lng = $DIC['lng'];
210  $ilCtrl = $DIC['ilCtrl'];
211  $tpl = $DIC['tpl'];
212 
213  if (!isset($_POST["id"])) {
214  $ilErr->raiseError($lng->txt("no_checkbox"), $ilErr->MESSAGE);
215  }
216 
217  include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
218  $gui = new ilConfirmationGUI();
219  $gui->setHeaderText($lng->txt("info_delete_sure"));
220  $gui->setCancel($lng->txt("cancel"), "listCodes");
221  $gui->setConfirm($lng->txt("confirm"), "deleteCodes");
222  $gui->setFormAction($ilCtrl->getFormAction($this, "deleteCodes"));
223 
224  include_once './Services/User/classes/class.ilAccountCode.php';
226  foreach ($data as $code) {
227  $gui->addItem("id[]", $code["code_id"], $code["code"]);
228  }
229 
230  $tpl->setContent($gui->getHTML());
231  }
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
$code
Definition: example_050.php:99
$ilErr
Definition: raiseError.php:18
global $ilCtrl
Definition: ilias.php:18
static loadCodesByIds(array $ids)
$lng
$_POST["username"]
Confirmation screen class.
$data
Definition: bench.php:6
+ Here is the call graph for this function:

◆ executeCommand()

ilAccountCodesGUI::executeCommand ( )

Definition at line 32 of file class.ilAccountCodesGUI.php.

References $DIC, and $ilCtrl.

33  {
34  global $DIC;
35 
36  $ilCtrl = $DIC['ilCtrl'];
37 
38  $next_class = $ilCtrl->getNextClass($this);
39  $cmd = $ilCtrl->getCmd();
40 
41  switch ($next_class) {
42  default:
43  if (!$cmd) {
44  $cmd = "listCodes";
45  }
46  $this->$cmd();
47  break;
48  }
49 
50  return true;
51  }
global $DIC
Definition: saml.php:7
global $ilCtrl
Definition: ilias.php:18

◆ exportCodes()

ilAccountCodesGUI::exportCodes ( )

Definition at line 253 of file class.ilAccountCodesGUI.php.

References $DIC, $ilErr, $lng, ilUtil\deliverData(), ilAccountCode\getCodesForExport(), listCodes(), and ilUtil\sendFailure().

254  {
255  global $DIC;
256 
257  $ilAccess = $DIC['ilAccess'];
258  $ilErr = $DIC['ilErr'];
259  $lng = $DIC['lng'];
260 
261  if (!$ilAccess->checkAccess('read', '', $this->ref_id)) {
262  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->MESSAGE);
263  }
264 
265  include_once("./Services/User/classes/class.ilAccountCodesTableGUI.php");
266  $utab = new ilAccountCodesTableGUI($this, "listCodes");
267 
268  include_once './Services/User/classes/class.ilAccountCode.php';
269  $codes = ilAccountCode::getCodesForExport($utab->filter["code"], $utab->filter["valid_until"], $utab->filter["generated"]);
270 
271  if (sizeof($codes)) {
272  // #13497
273  ilUtil::deliverData(implode("\r\n", $codes), "ilias_account_codes_" . date("d-m-Y") . ".txt", "text/plain");
274  } else {
275  ilUtil::sendFailure($lng->txt("account_export_codes_no_data"));
276  $this->listCodes();
277  }
278  }
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
global $DIC
Definition: saml.php:7
static getCodesForExport($filter_code, $filter_valid_until, $filter_generated)
TableGUI class for account codes.
$ilErr
Definition: raiseError.php:18
$lng
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

◆ initAddCodesForm()

ilAccountCodesGUI::initAddCodesForm ( )

Definition at line 79 of file class.ilAccountCodesGUI.php.

References $DIC, $ilCtrl, $lng, $valid, ilFormPropertyGUI\setRequired(), and ilNumberInputGUI\setSize().

Referenced by addCodes(), and createCodes().

80  {
81  global $DIC;
82 
83  $ilCtrl = $DIC['ilCtrl'];
84  $lng = $DIC['lng'];
85 
86  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
87 
88  $this->form_gui = new ilPropertyFormGUI();
89  $this->form_gui->setFormAction($ilCtrl->getFormAction($this, 'createCodes'));
90  $this->form_gui->setTitle($lng->txt('user_account_codes_edit_header'));
91 
92  $count = new ilNumberInputGUI($lng->txt('user_account_codes_number'), 'acc_codes_number');
93  $count->setSize(4);
94  $count->setMaxLength(4);
95  $count->setMinValue(1);
96  $count->setMaxValue(1000);
97  $count->setRequired(true);
98  $this->form_gui->addItem($count);
99 
100  $valid = new ilRadioGroupInputGUI($lng->txt('user_account_code_valid_until'), 'valid_type');
101  $valid->setRequired(true);
102 
103  $unl = new ilRadioOption($lng->txt('user_account_code_valid_until_unlimited'), 'valid_unlimited');
104  $valid->addOption($unl);
105 
106  $st = new ilRadioOption($lng->txt('user_account_code_valid_until_static'), 'valid_static');
107  $valid->addOption($st);
108 
109  $dt = new ilDateTimeInputGUI($lng->txt('date'), 'valid_date');
110  $dt->setRequired(true);
111  $st->addSubItem($dt);
112 
113  $dyn = new ilRadioOption($lng->txt('user_account_code_valid_until_dynamic'), 'valid_dynamic');
114  $valid->addOption($dyn);
115 
116  $ds = new ilNumberInputGUI($lng->txt('days'), 'valid_days');
117  $ds->setSize(5);
118  $ds->setRequired(true);
119  $dyn->addSubItem($ds);
120 
121  $this->form_gui->addItem($valid);
122 
123  $this->form_gui->addCommandButton('createCodes', $lng->txt('create'));
124  $this->form_gui->addCommandButton('listCodes', $lng->txt('cancel'));
125  }
This class represents an option in a radio group.
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
$valid
This class represents a date/time property in a property form.
global $ilCtrl
Definition: ilias.php:18
This class represents a property in a property form.
$lng
This class represents a number property in a property form.
setSize($a_size)
Set Size.
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listCodes()

ilAccountCodesGUI::listCodes ( )

Definition at line 53 of file class.ilAccountCodesGUI.php.

References $DIC, $ilCtrl, $ilErr, $lng, $tpl, and ilLinkButton\getInstance().

Referenced by applyCodesFilter(), exportCodes(), and resetCodesFilter().

54  {
55  global $DIC;
56 
57  $ilAccess = $DIC['ilAccess'];
58  $ilErr = $DIC['ilErr'];
59  $ilCtrl = $DIC['ilCtrl'];
60  $ilToolbar = $DIC['ilToolbar'];
61  $lng = $DIC['lng'];
62  $tpl = $DIC['tpl'];
63 
64  if (!$ilAccess->checkAccess('read', '', $this->ref_id)) {
65  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->MESSAGE);
66  }
67 
68  include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
69  $button = ilLinkButton::getInstance();
70  $button->setCaption("user_account_codes_add");
71  $button->setUrl($ilCtrl->getLinkTarget($this, "addCodes"));
72  $ilToolbar->addButtonInstance($button);
73 
74  include_once("./Services/User/classes/class.ilAccountCodesTableGUI.php");
75  $ctab = new ilAccountCodesTableGUI($this, "listCodes");
76  $tpl->setContent($ctab->getHTML());
77  }
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
TableGUI class for account codes.
$ilErr
Definition: raiseError.php:18
global $ilCtrl
Definition: ilias.php:18
$lng
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetCodesFilter()

ilAccountCodesGUI::resetCodesFilter ( )

Definition at line 233 of file class.ilAccountCodesGUI.php.

References listCodes().

234  {
235  include_once("./Services/User/classes/class.ilAccountCodesTableGUI.php");
236  $utab = new ilAccountCodesTableGUI($this, "listCodes");
237  $utab->resetOffset();
238  $utab->resetFilter();
239 
240  $this->listCodes();
241  }
TableGUI class for account codes.
+ Here is the call graph for this function:

Field Documentation

◆ $ref_id

ilAccountCodesGUI::$ref_id
protected

Definition at line 15 of file class.ilAccountCodesGUI.php.


The documentation for this class was generated from the following file: