ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilLicenseOverviewGUI.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 require_once "./Services/License/classes/class.ilLicense.php";
5 
6 define("LIC_MODE_ADMINISTRATION",1);
7 define("LIC_MODE_REPOSITORY",2);
8 
21 {
26  function ilLicenseOverviewGUI(&$a_parent_gui, $a_mode=LIC_MODE_REPOSITORY)
27  {
28  global $ilCtrl, $tpl, $lng;
29 
30  $this->mode = $a_mode;
31  $this->ctrl =& $ilCtrl;
32  $this->tpl =& $tpl;
33  $this->lng =& $lng;
34  $this->lng->loadLanguageModule("license");
35  $this->parent_gui =& $a_parent_gui;
36  }
37 
42  function &executeCommand()
43  {
44  global $rbacsystem, $ilErr;
45 
46  // access to all functions in this class are only allowed if read is granted
47  if (!$rbacsystem->checkAccess("read",$this->parent_gui->object->getRefId()))
48  {
49  $ilErr->raiseError($this->lng->txt("permission_denied"),$ilErr->MESSAGE);
50  }
51 
52  $cmd = $this->ctrl->getCmd("showLicenses");
53  $this->$cmd();
54 
55  return true;
56  }
57 
62  function showLicenses()
63  {
64  include_once './Services/Table/classes/class.ilTableGUI.php';
65 
66  if ($this->mode == LIC_MODE_ADMINISTRATION)
67  {
68  $objects = ilLicense::_getLicensedObjects();
69  }
70  else
71  {
72  $objects = ilLicense::_getLicensedChildObjects($this->parent_gui->object->getRefId());
73  }
74 
75  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.lic_show_licenses.html',"Services/License");
76 
77  foreach ($objects as $data)
78  {
79  $license =& new ilLicense($data["obj_id"]);
80  $licenses = strval($license->getLicenses());
81  $remarks = $license->getRemarks();
82  $used_licenses = strval($license->getAccesses());
83  $remaining_licenses = $licenses == "0" ? $this->lng->txt("arbitrary") : strval($license->getRemainingLicenses());
84  $potential_accesses = strval($license->getPotentialAccesses());
85 
86  $this->tpl->setCurrentBlock("table_row");
87  $this->tpl->setVariable("TITLE", $this->getItemHTML($data));
88  $this->tpl->setVariable("REMARKS", $remarks);
89  $this->tpl->setVariable("LICENSES", $licenses);
90  $this->tpl->setVariable("USED_LICENSES", $used_licenses);
91  $this->tpl->setVariable("REMAINING_LICENSES", $remaining_licenses);
92  $this->tpl->setVariable("POTENTIAL_ACCESSES", $potential_accesses);
93  $this->tpl->parseCurrentBlock();
94  }
95 
96  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
97  $this->tpl->setVariable("TXT_REMARKS", $this->lng->txt("comment"));
98  $this->tpl->setVariable("TXT_EXISTING_LICENSES", $this->lng->txt("existing_licenses"));
99  $this->tpl->setVariable("TXT_USED_LICENSES", $this->lng->txt("used_licenses"));
100  $this->tpl->setVariable("TXT_REMAINING_LICENSES", $this->lng->txt("remaining_licenses"));
101  $this->tpl->setVariable("TXT_POTENTIAL_ACCESSES", $this->lng->txt("potential_accesses"));
102  $this->tpl->setVariable("TXT_USED_LICENSES_EXPLANATION", $this->lng->txt("used_licenses_explanation"));
103  $this->tpl->setVariable("TXT_REMAINING_LICENSES_EXPLANATION", $this->lng->txt("remaining_licenses_explanation"));
104  $this->tpl->setVariable("TXT_POTENTIAL_ACCESSES_EXPLANATION", $this->lng->txt("potential_accesses_explanation"));
105  }
106 
107 
111  function getItemHTML($item = array())
112  {
113  $item_list_gui =& $this->getItemListGUI($item["type"]);
114  $item_list_gui->enableCommands(true);
115  $item_list_gui->enableDelete(false);
116  $item_list_gui->enableCut(false);
117  $item_list_gui->enableCopy(false);
118  $item_list_gui->enablePayment(false);
119  $item_list_gui->enableLink(false);
120  $item_list_gui->enableProperties(false);
121  $item_list_gui->enableDescription(false);
122  $item_list_gui->enablePreconditions(false);
123  $item_list_gui->enableSubscribe(false);
124  $item_list_gui->enableInfoScreen(false);
125 
126  return $item_list_gui->getListItemHTML($item["ref_id"],
127  $item["obj_id"], $item["title"], $item["description"]);
128  }
129 
133  function &getItemListGUI($a_type)
134  {
135  global $objDefinition;
136  if (!is_object($this->item_list_guis[$a_type]))
137  {
138  $class = $objDefinition->getClassName($a_type);
139  $location = $objDefinition->getLocation($a_type);
140  $full_class = "ilObj".$class."ListGUI";
141  include_once($location."/class.".$full_class.".php");
142  $item_list_gui = new $full_class();
143  $this->item_list_guis[$a_type] =& $item_list_gui;
144  }
145  else
146  {
147  $item_list_gui =& $this->item_list_guis[$a_type];
148  }
149  return $item_list_gui;
150  }
151 }
152 ?>