ILIAS  release_4-3 Revision
 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->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 
59  function editLicense()
60  {
61  $licenses = strval($this->license->getLicenses());
62  $used_licenses = strval($this->license->getAccesses());
63  $remaining_licenses = $licenses == "0" ? $this->lng->txt("arbitrary") : strval($this->license->getRemainingLicenses());
64  $potential_accesses = strval($this->license->getPotentialAccesses());
65 
66  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.lic_edit_license.html',"Services/License");
67  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
68  $this->tpl->setVariable("TXT_EDIT_LICENSE", $this->lng->txt("edit_license"));
69  $this->tpl->setVariable("TXT_EXISTING_LICENSES", $this->lng->txt("existing_licenses"));
70  $this->tpl->setVariable("LICENSES", $licenses);
71  $this->tpl->setVariable("TXT_ZERO_LICENSES_EXPLANATION", $this->lng->txt("zero_licenses_explanation"));
72  $this->tpl->setVariable("TXT_USED_LICENSES", $this->lng->txt("used_licenses"));
73  $this->tpl->setVariable("USED_LICENSES", $used_licenses);
74  $this->tpl->setVariable("TXT_USED_LICENSES_EXPLANATION", $this->lng->txt("used_licenses_explanation"));
75  $this->tpl->setVariable("TXT_REMAINING_LICENSES", $this->lng->txt("remaining_licenses"));
76  $this->tpl->setVariable("REMAINING_LICENSES", $remaining_licenses);
77  $this->tpl->setVariable("TXT_REMAINING_LICENSES_EXPLANATION", $this->lng->txt("remaining_licenses_explanation"));
78  $this->tpl->setVariable("TXT_POTENTIAL_ACCESSES", $this->lng->txt("potential_accesses"));
79  $this->tpl->setVariable("POTENTIAL_ACCESSES", $potential_accesses);
80  $this->tpl->setVariable("TXT_POTENTIAL_ACCESSES_EXPLANATION", $this->lng->txt("potential_accesses_explanation"));
81  $this->tpl->setVariable("TXT_REMARKS", $this->lng->txt("comment"));
82  $this->tpl->setVariable("REMARKS", $this->license->getRemarks());
83  $this->tpl->setVariable("BTN_UPDATE", $this->lng->txt("save"));
84  }
85 
90  function updateLicense()
91  {
92  $this->license->setLicenses((int) $_REQUEST["licenses"]);
93  $this->license->setRemarks($_REQUEST["remarks"]);
94  $this->license->update();
95  ilUtil::sendInfo($this->lng->txt('license_updated'), true);
96  $this->ctrl->redirect($this,"editLicense");
97  }
98 }
99 ?>