ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilLicenseGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once "./Services/License/classes/class.ilLicense.php";
5
18{
23 function ilLicenseGUI(&$a_parent_gui)
24 {
25 global $ilCtrl, $tpl, $lng;
26
27 $this->ctrl =& $ilCtrl;
28 $this->tpl =& $tpl;
29 $this->lng =& $lng;
30 $this->lng->loadLanguageModule("license");
31 $this->parent_gui =& $a_parent_gui;
32 $this->license =& new ilLicense($this->parent_gui->object->getId());
33 }
34
39 function &executeCommand()
40 {
41 global $rbacsystem, $ilErr;
42
43 // access to all functions in this class are only allowed if edit_permission is granted
44 if (!$rbacsystem->checkAccess("edit_permission",$this->parent_gui->object->getRefId()))
45 {
46 $ilErr->raiseError($this->lng->txt("permission_denied"),$ilErr->MESSAGE);
47 }
48
49 $cmd = $this->ctrl->getCmd("editLicense");
50 $this->$cmd();
51
52 return true;
53 }
54
55 protected function initLicenseForm()
56 {
57 include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
58 $form = new ilPropertyFormGUI();
59 $form->setFormAction($this->ctrl->getFormAction($this, "updateLicense"));
60 $form->setTitle($this->lng->txt('edit_license'));
61
62 $exist = new ilNumberInputGUI($this->lng->txt("existing_licenses"), "licenses");
63 $exist->setInfo($this->lng->txt("zero_licenses_explanation"));
64 $exist->setMaxLength(10);
65 $exist->setSize(10);
66 $exist->setValue($this->license->getLicenses());
67 $form->addItem($exist);
68
69 $info_used = new ilNonEditableValueGUI($this->lng->txt("used_licenses"));
70 $info_used->setInfo($this->lng->txt("used_licenses_explanation"));
71 $info_used->setValue($this->license->getAccesses());
72 $form->addItem($info_used);
73
74 $remaining_licenses = ($this->license->getLicenses() == "0")
75 ? $this->lng->txt("arbitrary")
76 : $this->license->getRemainingLicenses();
77
78 $info_remain = new ilNonEditableValueGUI($this->lng->txt("remaining_licenses"));
79 $info_remain->setInfo($this->lng->txt("remaining_licenses_explanation"));
80 $info_remain->setValue($remaining_licenses);
81 $form->addItem($info_remain);
82
83 $info_potential = new ilNonEditableValueGUI($this->lng->txt("potential_accesses"));
84 $info_potential->setInfo($this->lng->txt("potential_accesses_explanation"));
85 $info_potential->setValue($this->license->getPotentialAccesses());
86 $form->addItem($info_potential);
87
88 $comm = new ilTextAreaInputGUI($this->lng->txt("comment"), "remarks");
89 $comm->setRows(5);
90 $comm->setValue($this->license->getRemarks());
91 $form->addItem($comm);
92
93 $form->addCommandButton('updateLicense', $this->lng->txt('save'));
94
95 return $form;
96 }
97
102 function editLicense(ilPropertyFormGUI $a_form = null)
103 {
104 if(!$a_form)
105 {
106 $a_form = $this->initLicenseForm();
107 }
108
109 $this->tpl->setContent($a_form->getHTML());
110 }
111
116 function updateLicense()
117 {
118 $form = $this->initLicenseForm();
119 if($form->checkInput())
120 {
121 $this->license->setLicenses($form->getInput("licenses"));
122 $this->license->setRemarks($form->getInput("remarks"));
123 $this->license->update();
124
125 ilUtil::sendSuccess($this->lng->txt('license_updated'), true);
126 $this->ctrl->redirect($this,"editLicense");
127 }
128
129 $form->setValuesByPost();
130 $this->editLicense($form);
131 }
132}
global $tpl
Definition: ilias.php:8
ilLicenseGUI(&$a_parent_gui)
Constructor @access public.
& executeCommand()
Execute a command (main entry point) @access public.
updateLicense()
Save the license form @access public.
editLicense(ilPropertyFormGUI $a_form=null)
Show the license form @access public.
This class represents a non editable value in a property form.
This class represents a number property in a property form.
This class represents a property form user interface.
This class represents a text area property in a property form.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
$cmd
Definition: sahs_server.php:35