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 include_once
"Services/UIComponent/Button/classes/class.ilLinkButton.php";
62 $button->setCaption(
"user_account_codes_add");
63 $button->setUrl($ilCtrl->getLinkTarget($this,
"addCodes"));
64 $ilToolbar->addButtonInstance($button);
66 include_once(
"./Services/User/classes/class.ilAccountCodesTableGUI.php");
68 $tpl->setContent($ctab->getHTML());
75 include_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
78 $this->form_gui->setFormAction($ilCtrl->getFormAction($this,
'createCodes'));
79 $this->form_gui->setTitle($lng->txt(
'user_account_codes_edit_header'));
81 $count =
new ilNumberInputGUI($lng->txt(
'user_account_codes_number'),
'acc_codes_number');
83 $count->setMaxLength(4);
84 $count->setMinValue(1);
85 $count->setMaxValue(1000);
86 $count->setRequired(
true);
87 $this->form_gui->addItem($count);
92 $unl =
new ilRadioOption($lng->txt(
'user_account_code_valid_until_unlimited'),
'valid_unlimited');
95 $st =
new ilRadioOption($lng->txt(
'user_account_code_valid_until_static'),
'valid_static');
100 $st->addSubItem($dt);
102 $dyn =
new ilRadioOption($lng->txt(
'user_account_code_valid_until_dynamic'),
'valid_dynamic');
107 $ds->setRequired(
true);
108 $dyn->addSubItem($ds);
110 $this->form_gui->addItem(
$valid);
112 $this->form_gui->addCommandButton(
'createCodes', $lng->txt(
'create'));
113 $this->form_gui->addCommandButton(
'listCodes', $lng->txt(
'cancel'));
120 if(!$ilAccess->checkAccess(
'write',
'', $this->ref_id))
122 $ilErr->raiseError($lng->txt(
"msg_no_perm_write"), $ilErr->MESSAGE);
126 $tpl->setContent($this->form_gui->getHTML());
133 if(!$ilAccess->checkAccess(
'write',
'', $this->ref_id))
135 $ilErr->raiseError($lng->txt(
"msg_no_perm_write"), $ilErr->MESSAGE);
139 if($this->form_gui->checkInput())
141 $number = $this->form_gui->getInput(
'acc_codes_number');
142 switch($this->form_gui->getInput(
'valid_type'))
144 case 'valid_unlimited':
149 $valid = $this->form_gui->getInput(
'valid_date');
153 case 'valid_dynamic':
154 $valid = $this->form_gui->getInput(
'valid_days');
158 include_once
'./Services/User/classes/class.ilAccountCode.php';
161 for($loop = 1; $loop <= $number; $loop++)
167 $ilCtrl->redirect($this,
"listCodes");
171 $this->form_gui->setValuesByPost();
172 $tpl->setContent($this->form_gui->getHtml());
180 include_once
'./Services/User/classes/class.ilAccountCode.php';
184 $ilCtrl->redirect($this,
"listCodes");
193 $ilErr->raiseError($lng->txt(
"no_checkbox"), $ilErr->MESSAGE);
196 include_once
'./Services/Utilities/classes/class.ilConfirmationGUI.php';
198 $gui->setHeaderText($lng->txt(
"info_delete_sure"));
199 $gui->setCancel($lng->txt(
"cancel"),
"listCodes");
200 $gui->setConfirm($lng->txt(
"confirm"),
"deleteCodes");
201 $gui->setFormAction($ilCtrl->getFormAction($this,
"deleteCodes"));
203 include_once
'./Services/User/classes/class.ilAccountCode.php';
205 foreach($data as $code)
207 $gui->addItem(
"id[]", $code[
"code_id"], $code[
"code"]);
210 $tpl->setContent($gui->getHTML());
215 include_once(
"./Services/User/classes/class.ilAccountCodesTableGUI.php");
217 $utab->resetOffset();
218 $utab->resetFilter();
225 include_once(
"./Services/User/classes/class.ilAccountCodesTableGUI.php");
227 $utab->resetOffset();
228 $utab->writeFilterToSession();
237 if(!$ilAccess->checkAccess(
'read',
'', $this->ref_id))
239 $ilErr->raiseError($lng->txt(
"msg_no_perm_read"), $ilErr->MESSAGE);
242 include_once(
"./Services/User/classes/class.ilAccountCodesTableGUI.php");
245 include_once
'./Services/User/classes/class.ilAccountCode.php';
251 ilUtil::deliverData(implode(
"\r\n", $codes),
"ilias_account_codes_".date(
"d-m-Y").
".txt",
"text/plain");