ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilAccountCodesGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilAccountCodesGUI:

Public Member Functions

 __construct (int $a_ref_id)
 
 executeCommand ()
 
 listCodes ()
 
 initAddCodesForm ()
 
 addCodes ()
 
 createCodes ()
 
 deleteCodes ()
 
 deleteConfirmation ()
 
 resetCodesFilter ()
 
 applyCodesFilter ()
 
 exportCodes ()
 

Protected Attributes

ilPropertyFormGUI $form_gui
 
ILIAS User StandardGUIRequest $request
 
int $ref_id
 
array $filter
 

Private Attributes

ilGlobalTemplateInterface $main_tpl
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning 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

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

Constructor & Destructor Documentation

◆ __construct()

ilAccountCodesGUI::__construct ( int  $a_ref_id)

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

References $DIC, and $lng.

32  {
33  global $DIC;
34  $this->main_tpl = $DIC->ui()->mainTemplate();
35 
36  $lng = $DIC['lng'];
37 
38  $this->ref_id = $a_ref_id;
39  $lng->loadLanguageModule("user");
40  $this->request = new \ILIAS\User\StandardGUIRequest(
41  $DIC->http(),
42  $DIC->refinery()
43  );
44  }
$lng
global $DIC
Definition: feed.php:28

Member Function Documentation

◆ addCodes()

ilAccountCodesGUI::addCodes ( )

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

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

135  : void
136  {
137  global $DIC;
138 
139  $ilAccess = $DIC['ilAccess'];
140  $ilErr = $DIC['ilErr'];
141  $tpl = $DIC['tpl'];
142  $lng = $DIC['lng'];
143 
144  if (!$ilAccess->checkAccess('write', '', $this->ref_id)) {
145  $ilErr->raiseError($lng->txt("msg_no_perm_write"), $ilErr->MESSAGE);
146  }
147 
148  $this->initAddCodesForm();
149  $tpl->setContent($this->form_gui->getHTML());
150  }
$lng
$ilErr
Definition: raiseError.php:17
global $DIC
Definition: feed.php:28
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
+ Here is the call graph for this function:

◆ applyCodesFilter()

ilAccountCodesGUI::applyCodesFilter ( )

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

References listCodes().

249  : void
250  {
251  $utab = new ilAccountCodesTableGUI($this, "listCodes");
252  $utab->resetOffset();
253  $utab->writeFilterToSession();
254 
255  $this->listCodes();
256  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ createCodes()

ilAccountCodesGUI::createCodes ( )

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

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

152  : void
153  {
154  global $DIC;
155 
156  $ilAccess = $DIC['ilAccess'];
157  $ilErr = $DIC['ilErr'];
158  $lng = $DIC['lng'];
159  $tpl = $DIC['tpl'];
160  $ilCtrl = $DIC['ilCtrl'];
161 
162  $valid = "";
163 
164  if (!$ilAccess->checkAccess('write', '', $this->ref_id)) {
165  $ilErr->raiseError($lng->txt("msg_no_perm_write"), $ilErr->MESSAGE);
166  }
167 
168  $this->initAddCodesForm();
169  if ($this->form_gui->checkInput()) {
170  $number = $this->form_gui->getInput('acc_codes_number');
171  switch ($this->form_gui->getInput('valid_type')) {
172  case 'valid_unlimited':
173  $valid = 0;
174  break;
175 
176  case 'valid_static':
177  $valid = $this->form_gui->getItemByPostVar('valid_date')->getDate()->get(IL_CAL_DATE);
178  break;
179 
180  case 'valid_dynamic':
181  $valid = $this->form_gui->getInput('valid_days');
182  break;
183  }
184 
185  $stamp = time();
186  for ($loop = 1; $loop <= $number; $loop++) {
187  ilAccountCode::create($valid, $stamp);
188  }
189 
190  $this->main_tpl->setOnScreenMessage('success', $lng->txt('saved_successfully'), true);
191  $ilCtrl->redirect($this, "listCodes");
192  } else {
193  $this->form_gui->setValuesByPost();
194  $tpl->setContent($this->form_gui->getHTML());
195  }
196  }
$lng
$valid
$ilErr
Definition: raiseError.php:17
global $DIC
Definition: feed.php:28
static create(string $valid_until, int $stamp)
const IL_CAL_DATE
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
+ Here is the call graph for this function:

◆ deleteCodes()

ilAccountCodesGUI::deleteCodes ( )

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

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

198  : void
199  {
200  global $DIC;
201 
202  $lng = $DIC['lng'];
203  $ilCtrl = $DIC['ilCtrl'];
204 
205  $ids = $this->request->getIds();
207 
208  $this->main_tpl->setOnScreenMessage('success', $lng->txt('info_deleted'), true);
209  $ilCtrl->redirect($this, "listCodes");
210  }
$lng
global $DIC
Definition: feed.php:28
static deleteCodes(array $ids)
+ Here is the call graph for this function:

◆ deleteConfirmation()

ilAccountCodesGUI::deleteConfirmation ( )

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

References $data, $DIC, $lng, $tpl, listCodes(), and ilAccountCode\loadCodesByIds().

212  : void
213  {
214  global $DIC;
215 
216  $lng = $DIC['lng'];
217  $ilCtrl = $DIC['ilCtrl'];
218  $tpl = $DIC['tpl'];
219 
220  $ids = $this->request->getIds();
221  if (count($ids) == 0) {
222  $this->main_tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
223  $this->listCodes();
224  }
225 
226  $gui = new ilConfirmationGUI();
227  $gui->setHeaderText($lng->txt("info_delete_sure"));
228  $gui->setCancel($lng->txt("cancel"), "listCodes");
229  $gui->setConfirm($lng->txt("confirm"), "deleteCodes");
230  $gui->setFormAction($ilCtrl->getFormAction($this, "deleteCodes"));
231 
233  foreach ($data as $code) {
234  $gui->addItem("id[]", $code["code_id"], $code["code"]);
235  }
236 
237  $tpl->setContent($gui->getHTML());
238  }
$lng
global $DIC
Definition: feed.php:28
static loadCodesByIds(array $ids)
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ executeCommand()

ilAccountCodesGUI::executeCommand ( )

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

References $DIC.

46  : void
47  {
48  global $DIC;
49 
50  $ilCtrl = $DIC['ilCtrl'];
51 
52  $next_class = $ilCtrl->getNextClass($this);
53  $cmd = $ilCtrl->getCmd();
54 
55  switch ($next_class) {
56  default:
57  if (!$cmd) {
58  $cmd = "listCodes";
59  }
60  $this->$cmd();
61  break;
62  }
63  }
global $DIC
Definition: feed.php:28

◆ exportCodes()

ilAccountCodesGUI::exportCodes ( )

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

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

258  : void
259  {
260  global $DIC;
261 
262  $ilAccess = $DIC['ilAccess'];
263  $ilErr = $DIC['ilErr'];
264  $lng = $DIC['lng'];
265 
266  if (!$ilAccess->checkAccess('read', '', $this->ref_id)) {
267  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->MESSAGE);
268  }
269 
270  $utab = new ilAccountCodesTableGUI($this, "listCodes");
271  $codes = ilAccountCode::getCodesForExport($utab->filter["code"], $utab->filter["valid_until"], $utab->filter["generated"]);
272 
273  if (count($codes)) {
274  // #13497
275  ilUtil::deliverData(implode("\r\n", $codes), "ilias_account_codes_" . date("d-m-Y") . ".txt", "text/plain");
276  } else {
277  $this->main_tpl->setOnScreenMessage('failure', $lng->txt("account_export_codes_no_data"));
278  $this->listCodes();
279  }
280  }
$lng
static getCodesForExport(string $filter_code, string $filter_valid_until, string $filter_generated)
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ilErr
Definition: raiseError.php:17
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

◆ initAddCodesForm()

ilAccountCodesGUI::initAddCodesForm ( )

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

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

Referenced by addCodes(), and createCodes().

89  : void
90  {
91  global $DIC;
92 
93  $ilCtrl = $DIC['ilCtrl'];
94  $lng = $DIC['lng'];
95 
96  $this->form_gui = new ilPropertyFormGUI();
97  $this->form_gui->setFormAction($ilCtrl->getFormAction($this, 'createCodes'));
98  $this->form_gui->setTitle($lng->txt('user_account_codes_edit_header'));
99 
100  $count = new ilNumberInputGUI($lng->txt('user_account_codes_number'), 'acc_codes_number');
101  $count->setSize(4);
102  $count->setMaxLength(4);
103  $count->setMinValue(1);
104  $count->setMaxValue(1000);
105  $count->setRequired(true);
106  $this->form_gui->addItem($count);
107 
108  $valid = new ilRadioGroupInputGUI($lng->txt('user_account_code_valid_until'), 'valid_type');
109  $valid->setRequired(true);
110 
111  $unl = new ilRadioOption($lng->txt('user_account_code_valid_until_unlimited'), 'valid_unlimited');
112  $valid->addOption($unl);
113 
114  $st = new ilRadioOption($lng->txt('user_account_code_valid_until_static'), 'valid_static');
115  $valid->addOption($st);
116 
117  $dt = new ilDateTimeInputGUI($lng->txt('date'), 'valid_date');
118  $dt->setRequired(true);
119  $st->addSubItem($dt);
120 
121  $dyn = new ilRadioOption($lng->txt('user_account_code_valid_until_dynamic'), 'valid_dynamic');
122  $valid->addOption($dyn);
123 
124  $ds = new ilNumberInputGUI($lng->txt('days'), 'valid_days');
125  $ds->setSize(5);
126  $ds->setRequired(true);
127  $dyn->addSubItem($ds);
128 
129  $this->form_gui->addItem($valid);
130 
131  $this->form_gui->addCommandButton('createCodes', $lng->txt('create'));
132  $this->form_gui->addCommandButton('listCodes', $lng->txt('cancel'));
133  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$lng
$valid
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
This class represents a property in a property form.
This class represents a number property in a property form.
setRequired(bool $a_required)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listCodes()

ilAccountCodesGUI::listCodes ( )

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

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

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

65  : void
66  {
67  global $DIC;
68 
69  $ilAccess = $DIC['ilAccess'];
70  $ilErr = $DIC['ilErr'];
71  $ilCtrl = $DIC['ilCtrl'];
72  $ilToolbar = $DIC['ilToolbar'];
73  $lng = $DIC['lng'];
74  $tpl = $DIC['tpl'];
75 
76  if (!$ilAccess->checkAccess('read', '', $this->ref_id)) {
77  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->MESSAGE);
78  }
79 
80  $button = ilLinkButton::getInstance();
81  $button->setCaption("user_account_codes_add");
82  $button->setUrl($ilCtrl->getLinkTarget($this, "addCodes"));
83  $ilToolbar->addButtonInstance($button);
84 
85  $ctab = new ilAccountCodesTableGUI($this, "listCodes");
86  $tpl->setContent($ctab->getHTML());
87  }
$lng
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ilErr
Definition: raiseError.php:17
global $DIC
Definition: feed.php:28
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetCodesFilter()

ilAccountCodesGUI::resetCodesFilter ( )

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

References listCodes().

240  : void
241  {
242  $utab = new ilAccountCodesTableGUI($this, "listCodes");
243  $utab->resetOffset();
244  $utab->resetFilter();
245 
246  $this->listCodes();
247  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

Field Documentation

◆ $filter

array ilAccountCodesGUI::$filter
protected

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

◆ $form_gui

ilPropertyFormGUI ilAccountCodesGUI::$form_gui
protected

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

◆ $main_tpl

ilGlobalTemplateInterface ilAccountCodesGUI::$main_tpl
private

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

◆ $ref_id

int ilAccountCodesGUI::$ref_id
protected

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

◆ $request

ILIAS User StandardGUIRequest ilAccountCodesGUI::$request
protected

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


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