ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
17{
18
19
23 protected $license;
27 protected $ctrl;
31 protected $tpl;
35 protected $lng;
36
37
43 public function __construct(ilObjectGUI $a_parent_gui)
44 {
45 global $ilCtrl, $tpl, $lng;
46
47 $this->ctrl = $ilCtrl;
48 $this->tpl = $tpl;
49 $this->lng = $lng;
50 $this->lng->loadLanguageModule("license");
51 $this->parent_gui = $a_parent_gui;
52 $this->license = new ilLicense($this->parent_gui->object->getId());
53 }
54
55
56 public function executeCommand()
57 {
58 global $rbacsystem, $ilErr;
59
60 // access to all functions in this class are only allowed if edit_permission is granted
61 if (!$rbacsystem->checkAccess("edit_permission", $this->parent_gui->object->getRefId())) {
62 $ilErr->raiseError($this->lng->txt("permission_denied"), $ilErr->MESSAGE);
63 }
64
65 $cmd = $this->ctrl->getCmd("editLicense");
66 $this->$cmd();
67
68 return true;
69 }
70
71
72 protected function initLicenseForm()
73 {
74 include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
76 $form->setFormAction($this->ctrl->getFormAction($this, "updateLicense"));
77 $form->setTitle($this->lng->txt('edit_license'));
78
79 $exist = new ilNumberInputGUI($this->lng->txt("existing_licenses"), "licenses");
80 $exist->setInfo($this->lng->txt("zero_licenses_explanation"));
81 $exist->setMaxLength(10);
82 $exist->setSize(10);
83 $exist->setValue($this->license->getLicenses());
84 $form->addItem($exist);
85
86 $info_used = new ilNonEditableValueGUI($this->lng->txt("used_licenses"));
87 $info_used->setInfo($this->lng->txt("used_licenses_explanation"));
88 $info_used->setValue($this->license->getAccesses());
89 $form->addItem($info_used);
90
91 $remaining_licenses = ($this->license->getLicenses() == "0") ? $this->lng->txt("arbitrary") : $this->license->getRemainingLicenses();
92
93 $info_remain = new ilNonEditableValueGUI($this->lng->txt("remaining_licenses"));
94 $info_remain->setInfo($this->lng->txt("remaining_licenses_explanation"));
95 $info_remain->setValue($remaining_licenses);
96 $form->addItem($info_remain);
97
98 $info_potential = new ilNonEditableValueGUI($this->lng->txt("potential_accesses"));
99 $info_potential->setInfo($this->lng->txt("potential_accesses_explanation"));
100 $info_potential->setValue($this->license->getPotentialAccesses());
101 $form->addItem($info_potential);
102
103 $comm = new ilTextAreaInputGUI($this->lng->txt("comment"), "remarks");
104 $comm->setRows(5);
105 $comm->setValue($this->license->getRemarks());
106 $form->addItem($comm);
107
108 $form->addCommandButton('updateLicense', $this->lng->txt('save'));
109
110 return $form;
111 }
112
113
117 protected function editLicense(ilPropertyFormGUI $a_form = null)
118 {
119 if (!$a_form) {
120 $a_form = $this->initLicenseForm();
121 }
122
123 $this->tpl->setContent($a_form->getHTML());
124 }
125
126
130 public function updateLicense()
131 {
132 $form = $this->initLicenseForm();
133 if ($form->checkInput()) {
134 $this->license->setLicenses($form->getInput("licenses"));
135 $this->license->setRemarks($form->getInput("remarks"));
136 $this->license->update();
137
138 ilUtil::sendSuccess($this->lng->txt('license_updated'), true);
139 $this->ctrl->redirect($this, "editLicense");
140 }
141
142 $form->setValuesByPost();
143 $this->editLicense($form);
144 }
145}
An exception for terminatinating execution or to throw for unit testing.
__construct(ilObjectGUI $a_parent_gui)
ilLicenseGUI constructor.
updateLicense()
Save the license form.
editLicense(ilPropertyFormGUI $a_form=null)
This class represents a non editable value in a property form.
This class represents a number property in a property form.
Class ilObjectGUI Basic methods of all Output classes.
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 $ilErr
Definition: raiseError.php:16
if(isset($_POST['submit'])) $form