ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
4 include_once "./Services/License/classes/class.ilLicense.php";
5 
18 {
23  function ilLicenseGUI(&$a_parent_gui)
24  {
25  global $ilCtrl, $tpl, $lng;
26 
27  $this->module = "Services/License";
28  $this->ctrl =& $ilCtrl;
29  $this->tpl =& $tpl;
30  $this->lng =& $lng;
31  $this->lng->loadLanguageModule("license");
32  $this->parent_gui =& $a_parent_gui;
33  $this->license =& new ilLicense($this->parent_gui->object->getId());
34  }
35 
40  function &executeCommand()
41  {
42  global $rbacsystem, $ilErr;
43 
44  // access to all functions in this class are only allowed if edit_permission is granted
45  if (!$rbacsystem->checkAccess("edit_permission",$this->parent_gui->object->getRefId()))
46  {
47  $ilErr->raiseError($this->lng->txt("permission_denied"),$ilErr->MESSAGE);
48  }
49 
50  $cmd = $this->ctrl->getCmd("editLicense");
51  $this->$cmd();
52 
53  return true;
54  }
55 
60  function editLicense()
61  {
62  $licenses = strval($this->license->getLicenses());
63  $used_licenses = strval($this->license->getAccesses());
64  $remaining_licenses = $licenses == "0" ? $this->lng->txt("arbitrary") : strval($this->license->getRemainingLicenses());
65  $potential_accesses = strval($this->license->getPotentialAccesses());
66 
67  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.lic_edit_license.html',$this->module);
68  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
69  $this->tpl->setVariable("TXT_EDIT_LICENSE", $this->lng->txt("edit_license"));
70  $this->tpl->setVariable("TXT_EXISTING_LICENSES", $this->lng->txt("existing_licenses"));
71  $this->tpl->setVariable("LICENSES", $licenses);
72  $this->tpl->setVariable("TXT_ZERO_LICENSES_EXPLANATION", $this->lng->txt("zero_licenses_explanation"));
73  $this->tpl->setVariable("TXT_USED_LICENSES", $this->lng->txt("used_licenses"));
74  $this->tpl->setVariable("USED_LICENSES", $used_licenses);
75  $this->tpl->setVariable("TXT_USED_LICENSES_EXPLANATION", $this->lng->txt("used_licenses_explanation"));
76  $this->tpl->setVariable("TXT_REMAINING_LICENSES", $this->lng->txt("remaining_licenses"));
77  $this->tpl->setVariable("REMAINING_LICENSES", $remaining_licenses);
78  $this->tpl->setVariable("TXT_REMAINING_LICENSES_EXPLANATION", $this->lng->txt("remaining_licenses_explanation"));
79  $this->tpl->setVariable("TXT_POTENTIAL_ACCESSES", $this->lng->txt("potential_accesses"));
80  $this->tpl->setVariable("POTENTIAL_ACCESSES", $potential_accesses);
81  $this->tpl->setVariable("TXT_POTENTIAL_ACCESSES_EXPLANATION", $this->lng->txt("potential_accesses_explanation"));
82  $this->tpl->setVariable("TXT_REMARKS", $this->lng->txt("comment"));
83  $this->tpl->setVariable("REMARKS", $this->license->getRemarks());
84  $this->tpl->setVariable("BTN_UPDATE", $this->lng->txt("save"));
85  }
86 
91  function updateLicense()
92  {
93  $this->license->setLicenses((int) $_REQUEST["licenses"]);
94  $this->license->setRemarks($_REQUEST["remarks"]);
95  $this->license->update();
96  ilUtil::sendInfo($this->lng->txt('license_updated'), true);
97  $this->ctrl->redirect($this,"editLicense");
98  }
99 }
100 ?>