ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilLicenseOverviewTableGUI.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/Table/classes/class.ilTable2GUI.php");
5 
15 {
16  protected $item_list_guis; // [array]
17 
18  function __construct($a_parent_obj, $a_parent_cmd, $a_mode, ilObjectGUI $a_parent_gui)
19  {
20  parent::__construct($a_parent_obj, $a_parent_cmd);
21 
22  $this->setId("licovw");
23  $this->setTitle($this->lng->txt("licenses"));
24 
25  $this->addColumn($this->lng->txt("title"), "title");
26  $this->addColumn($this->lng->txt("comment"));
27  $this->addColumn($this->lng->txt("existing_licenses"), "existing");
28  $this->addColumn($this->lng->txt("used_licenses"), "used");
29  $this->addColumn($this->lng->txt("remaining_licenses"), "remaining");
30  $this->addColumn($this->lng->txt("potential_accesses"), "potential");
31 
32  $this->setDefaultOrderField("title");
33  $this->setDefaultOrderDirection("ASC");
34 
35  $this->setRowTemplate("tpl.lic_show_licenses.html", "Services/License");
36 
37  $this->getItems($a_mode, $a_parent_gui);
38  }
39 
40  protected function getItems($a_mode, ilObjectGUI $a_parent_gui)
41  {
42  $data = array();
43 
45  {
46  $objects = ilLicense::_getLicensedObjects();
47  }
48  else
49  {
50  $objects = ilLicense::_getLicensedChildObjects($a_parent_gui->object->getRefId());
51  }
52  foreach($objects as $item)
53  {
54  $license = new ilLicense($item["obj_id"]);
55 
56  $remaining_licenses = ($license->getLicenses() == "0")
57  ? $this->lng->txt("arbitrary")
58  : $license->getRemainingLicenses();
59 
60  $data[] = array(
61  "title" => $item["title"]
62  ,"comment" => nl2br(trim($license->getRemarks()))
63  ,"existing" => $license->getLicenses()
64  ,"used" => $license->getAccesses()
65  ,"remaining" => $remaining_licenses
66  ,"potential" => $license->getPotentialAccesses()
67  ,"listGUI" => $this->getItemHTML($item)
68  );
69  }
70 
71  $this->setData($data);
72  }
73 
77  protected function fillRow($a_set)
78  {
79  $this->tpl->setVariable("TITLE", $a_set["listGUI"]);
80  $this->tpl->setVariable("REMARKS", $a_set["comment"]);
81  $this->tpl->setVariable("LICENSES", $a_set["existing"]);
82  $this->tpl->setVariable("USED_LICENSES", $a_set["used"]);
83  $this->tpl->setVariable("REMAINING_LICENSES", $a_set["remaining"]);
84  $this->tpl->setVariable("POTENTIAL_ACCESSES", $a_set["potential"]);
85  }
86 
90  protected function getItemHTML($item = array())
91  {
92  $item_list_gui =& $this->getItemListGUI($item["type"]);
93  $item_list_gui->enableCommands(true);
94  $item_list_gui->enableDelete(false);
95  $item_list_gui->enableCut(false);
96  $item_list_gui->enableCopy(false);
97  $item_list_gui->enablePayment(false);
98  $item_list_gui->enableLink(false);
99  $item_list_gui->enableProperties(false);
100  $item_list_gui->enableDescription(false);
101  $item_list_gui->enablePreconditions(false);
102  $item_list_gui->enableSubscribe(false);
103  $item_list_gui->enableInfoScreen(false);
104 
105  return $item_list_gui->getListItemHTML($item["ref_id"],
106  $item["obj_id"], $item["title"], $item["description"]);
107  }
108 
112  protected function getItemListGUI($a_type)
113  {
114  global $objDefinition;
115 
116  if (!is_object($this->item_list_guis[$a_type]))
117  {
118  $class = $objDefinition->getClassName($a_type);
119  $location = $objDefinition->getLocation($a_type);
120  $full_class = "ilObj".$class."ListGUI";
121  include_once($location."/class.".$full_class.".php");
122  $item_list_gui = new $full_class();
123  $this->item_list_guis[$a_type] =& $item_list_gui;
124  }
125  else
126  {
127  $item_list_gui =& $this->item_list_guis[$a_type];
128  }
129  return $item_list_gui;
130  }
131 }