ILIAS  release_5-2 Revision v5.2.25-18-g3f80b82851
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 $lng.

23  {
24  global $lng;
25 
26  $this->ref_id = $a_ref_id;
27  $lng->loadLanguageModule("user");
28  }
global $lng
Definition: privfeed.php:17

Member Function Documentation

◆ addCodes()

ilAccountCodesGUI::addCodes ( )

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

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

117  {
118  global $ilAccess, $ilErr, $tpl, $lng;
119 
120  if(!$ilAccess->checkAccess('write', '', $this->ref_id))
121  {
122  $ilErr->raiseError($lng->txt("msg_no_perm_write"), $ilErr->MESSAGE);
123  }
124 
125  $this->initAddCodesForm();
126  $tpl->setContent($this->form_gui->getHTML());
127  }
global $ilErr
Definition: raiseError.php:16
global $tpl
Definition: ilias.php:8
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:

◆ applyCodesFilter()

ilAccountCodesGUI::applyCodesFilter ( )

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

References listCodes().

223  {
224  include_once("./Services/User/classes/class.ilAccountCodesTableGUI.php");
225  $utab = new ilAccountCodesTableGUI($this, "listCodes");
226  $utab->resetOffset();
227  $utab->writeFilterToSession();
228 
229  $this->listCodes();
230  }
TableGUI class for account codes.
+ Here is the call graph for this function:

◆ createCodes()

ilAccountCodesGUI::createCodes ( )

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

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

130  {
131  global $ilAccess, $ilErr, $lng, $tpl, $ilCtrl;
132 
133  if(!$ilAccess->checkAccess('write', '', $this->ref_id))
134  {
135  $ilErr->raiseError($lng->txt("msg_no_perm_write"), $ilErr->MESSAGE);
136  }
137 
138  $this->initAddCodesForm();
139  if($this->form_gui->checkInput())
140  {
141  $number = $this->form_gui->getInput('acc_codes_number');
142  switch($this->form_gui->getInput('valid_type'))
143  {
144  case 'valid_unlimited':
145  $valid = 0;
146  break;
147 
148  case 'valid_static':
149  $valid = $this->form_gui->getItemByPostVar('valid_date')->getDate()->get(IL_CAL_DATE);
150  break;
151 
152  case 'valid_dynamic':
153  $valid = $this->form_gui->getInput('valid_days');
154  break;
155  }
156 
157  include_once './Services/User/classes/class.ilAccountCode.php';
158 
159  $stamp = time();
160  for($loop = 1; $loop <= $number; $loop++)
161  {
162  ilAccountCode::create($valid, $stamp);
163  }
164 
165  ilUtil::sendSuccess($lng->txt('saved_successfully'), true);
166  $ilCtrl->redirect($this, "listCodes");
167  }
168  else
169  {
170  $this->form_gui->setValuesByPost();
171  $tpl->setContent($this->form_gui->getHtml());
172  }
173  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
global $ilErr
Definition: raiseError.php:16
$valid
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
const IL_CAL_DATE
global $lng
Definition: privfeed.php:17
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
static create($valid_until, $stamp)
+ Here is the call graph for this function:

◆ deleteCodes()

ilAccountCodesGUI::deleteCodes ( )

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

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

176  {
177  global $lng, $ilCtrl;
178 
179  include_once './Services/User/classes/class.ilAccountCode.php';
181 
182  ilUtil::sendSuccess($lng->txt('info_deleted'), true);
183  $ilCtrl->redirect($this, "listCodes");
184  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
global $ilCtrl
Definition: ilias.php:18
static deleteCodes(array $ids)
global $lng
Definition: privfeed.php:17
$_POST["username"]
+ Here is the call graph for this function:

◆ deleteConfirmation()

ilAccountCodesGUI::deleteConfirmation ( )

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

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

187  {
188  global $ilErr, $lng, $ilCtrl, $tpl;
189 
190  if(!isset($_POST["id"]))
191  {
192  $ilErr->raiseError($lng->txt("no_checkbox"), $ilErr->MESSAGE);
193  }
194 
195  include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
196  $gui = new ilConfirmationGUI();
197  $gui->setHeaderText($lng->txt("info_delete_sure"));
198  $gui->setCancel($lng->txt("cancel"), "listCodes");
199  $gui->setConfirm($lng->txt("confirm"), "deleteCodes");
200  $gui->setFormAction($ilCtrl->getFormAction($this, "deleteCodes"));
201 
202  include_once './Services/User/classes/class.ilAccountCode.php';
204  foreach($data as $code)
205  {
206  $gui->addItem("id[]", $code["code_id"], $code["code"]);
207  }
208 
209  $tpl->setContent($gui->getHTML());
210  }
global $ilErr
Definition: raiseError.php:16
$code
Definition: example_050.php:99
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
static loadCodesByIds(array $ids)
global $lng
Definition: privfeed.php:17
$_POST["username"]
Confirmation screen class.
+ Here is the call graph for this function:

◆ executeCommand()

ilAccountCodesGUI::executeCommand ( )

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

References $cmd, and $ilCtrl.

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

◆ exportCodes()

ilAccountCodesGUI::exportCodes ( )

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

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

233  {
234  global $ilAccess, $ilErr, $lng;
235 
236  if(!$ilAccess->checkAccess('read', '', $this->ref_id))
237  {
238  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->MESSAGE);
239  }
240 
241  include_once("./Services/User/classes/class.ilAccountCodesTableGUI.php");
242  $utab = new ilAccountCodesTableGUI($this, "listCodes");
243 
244  include_once './Services/User/classes/class.ilAccountCode.php';
245  $codes = ilAccountCode::getCodesForExport($utab->filter["code"], $utab->filter["valid_until"], $utab->filter["generated"]);
246 
247  if(sizeof($codes))
248  {
249  // #13497
250  ilUtil::deliverData(implode("\r\n", $codes), "ilias_account_codes_".date("d-m-Y").".txt","text/plain");
251  }
252  else
253  {
254  ilUtil::sendFailure($lng->txt("account_export_codes_no_data"));
255  $this->listCodes();
256  }
257  }
global $ilErr
Definition: raiseError.php:16
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
static getCodesForExport($filter_code, $filter_valid_until, $filter_generated)
TableGUI class for account codes.
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:

◆ initAddCodesForm()

ilAccountCodesGUI::initAddCodesForm ( )

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

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

Referenced by addCodes(), and createCodes().

72  {
73  global $ilCtrl, $lng;
74 
75  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
76 
77  $this->form_gui = new ilPropertyFormGUI();
78  $this->form_gui->setFormAction($ilCtrl->getFormAction($this, 'createCodes'));
79  $this->form_gui->setTitle($lng->txt('user_account_codes_edit_header'));
80 
81  $count = new ilNumberInputGUI($lng->txt('user_account_codes_number'), 'acc_codes_number');
82  $count->setSize(4);
83  $count->setMaxLength(4);
84  $count->setMinValue(1);
85  $count->setMaxValue(1000);
86  $count->setRequired(true);
87  $this->form_gui->addItem($count);
88 
89  $valid = new ilRadioGroupInputGUI($lng->txt('user_account_code_valid_until'), 'valid_type');
90  $valid->setRequired(true);
91 
92  $unl = new ilRadioOption($lng->txt('user_account_code_valid_until_unlimited'), 'valid_unlimited');
93  $valid->addOption($unl);
94 
95  $st = new ilRadioOption($lng->txt('user_account_code_valid_until_static'), 'valid_static');
96  $valid->addOption($st);
97 
98  $dt = new ilDateTimeInputGUI($lng->txt('date'), 'valid_date');
99  $dt->setRequired(true);
100  $st->addSubItem($dt);
101 
102  $dyn = new ilRadioOption($lng->txt('user_account_code_valid_until_dynamic'), 'valid_dynamic');
103  $valid->addOption($dyn);
104 
105  $ds = new ilNumberInputGUI($lng->txt('days'), 'valid_days');
106  $ds->setSize(5);
107  $ds->setRequired(true);
108  $dyn->addSubItem($ds);
109 
110  $this->form_gui->addItem($valid);
111 
112  $this->form_gui->addCommandButton('createCodes', $lng->txt('create'));
113  $this->form_gui->addCommandButton('listCodes', $lng->txt('cancel'));
114  }
This class represents an option in a radio group.
This class represents a property form user interface.
$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.
This class represents a number property in a property form.
setSize($a_size)
Set Size.
global $lng
Definition: privfeed.php:17
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 51 of file class.ilAccountCodesGUI.php.

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

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

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

◆ resetCodesFilter()

ilAccountCodesGUI::resetCodesFilter ( )

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

References listCodes().

213  {
214  include_once("./Services/User/classes/class.ilAccountCodesTableGUI.php");
215  $utab = new ilAccountCodesTableGUI($this, "listCodes");
216  $utab->resetOffset();
217  $utab->resetFilter();
218 
219  $this->listCodes();
220  }
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: