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