26 $this->ref_id = $a_ref_id;
27 $lng->loadLanguageModule(
"user");
34 $next_class = $ilCtrl->getNextClass($this);
35 $cmd = $ilCtrl->getCmd();
55 if(!$ilAccess->checkAccess(
'read',
'',$this->ref_id))
57 $ilErr->raiseError($lng->txt(
"msg_no_perm_read"),$ilErr->MESSAGE);
60 $ilToolbar->addButton($lng->txt(
"user_account_codes_add"),
61 $ilCtrl->getLinkTarget($this,
"addCodes"));
63 include_once(
"./Services/User/classes/class.ilAccountCodesTableGUI.php");
65 $tpl->setContent($ctab->getHTML());
72 include_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
75 $this->form_gui->setFormAction($ilCtrl->getFormAction($this,
'createCodes'));
76 $this->form_gui->setTitle($lng->txt(
'user_account_codes_edit_header'));
78 $count =
new ilNumberInputGUI($lng->txt(
'user_account_codes_number'),
'acc_codes_number');
80 $count->setMaxLength(4);
81 $count->setMinValue(1);
82 $count->setMaxValue(1000);
83 $count->setRequired(
true);
84 $this->form_gui->addItem($count);
89 $unl =
new ilRadioOption($lng->txt(
'user_account_code_valid_until_unlimited'),
'valid_unlimited');
92 $st =
new ilRadioOption($lng->txt(
'user_account_code_valid_until_static'),
'valid_static');
99 $dyn =
new ilRadioOption($lng->txt(
'user_account_code_valid_until_dynamic'),
'valid_dynamic');
104 $ds->setRequired(
true);
105 $dyn->addSubItem($ds);
107 $this->form_gui->addItem(
$valid);
109 $this->form_gui->addCommandButton(
'createCodes', $lng->txt(
'create'));
110 $this->form_gui->addCommandButton(
'listCodes', $lng->txt(
'cancel'));
117 if(!$ilAccess->checkAccess(
'write',
'', $this->ref_id))
119 $ilErr->raiseError($lng->txt(
"msg_no_perm_write"), $ilErr->MESSAGE);
123 $tpl->setContent($this->form_gui->getHTML());
130 if(!$ilAccess->checkAccess(
'write',
'', $this->ref_id))
132 $ilErr->raiseError($lng->txt(
"msg_no_perm_write"), $ilErr->MESSAGE);
136 if($this->form_gui->checkInput())
138 $number = $this->form_gui->getInput(
'acc_codes_number');
139 switch($this->form_gui->getInput(
'valid_type'))
141 case 'valid_unlimited':
146 $valid = $this->form_gui->getInput(
'valid_date');
150 case 'valid_dynamic':
151 $valid = $this->form_gui->getInput(
'valid_days');
155 include_once
'./Services/User/classes/class.ilAccountCode.php';
158 for($loop = 1; $loop <= $number; $loop++)
164 $ilCtrl->redirect($this,
"listCodes");
168 $this->form_gui->setValuesByPost();
169 $tpl->setContent($this->form_gui->getHtml());
177 include_once
'./Services/User/classes/class.ilAccountCode.php';
181 $ilCtrl->redirect($this,
"listCodes");
190 $ilErr->raiseError($lng->txt(
"no_checkbox"), $ilErr->MESSAGE);
193 include_once
'./Services/Utilities/classes/class.ilConfirmationGUI.php';
195 $gui->setHeaderText($lng->txt(
"info_delete_sure"));
196 $gui->setCancel($lng->txt(
"cancel"),
"listCodes");
197 $gui->setConfirm($lng->txt(
"confirm"),
"deleteCodes");
198 $gui->setFormAction($ilCtrl->getFormAction($this,
"deleteCodes"));
200 include_once
'./Services/User/classes/class.ilAccountCode.php';
202 foreach($data as $code)
204 $gui->addItem(
"id[]", $code[
"code_id"], $code[
"code"]);
207 $tpl->setContent($gui->getHTML());
212 include_once(
"./Services/User/classes/class.ilAccountCodesTableGUI.php");
214 $utab->resetOffset();
215 $utab->resetFilter();
222 include_once(
"./Services/User/classes/class.ilAccountCodesTableGUI.php");
224 $utab->resetOffset();
225 $utab->writeFilterToSession();
234 if(!$ilAccess->checkAccess(
'read',
'', $this->ref_id))
236 $ilErr->raiseError($lng->txt(
"msg_no_perm_read"), $ilErr->MESSAGE);
239 include_once(
"./Services/User/classes/class.ilAccountCodesTableGUI.php");
242 include_once
'./Services/User/classes/class.ilAccountCode.php';
248 ilUtil::deliverData(implode(
"\r\n", $codes),
"ilias_account_codes_".date(
"d-m-Y").
".txt",
"text/plain");