ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPluginAdmin.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 
6 include_once("./Services/Component/classes/class.ilComponent.php");
7 
17 {
18  var $got_data = false;
19 
24  static $active_plugins = array();
25 
30  static $plugin_objects = array();
31 
32 
36  function __construct()
37  {
38  }
39 
48  private final function getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname)
49  {
50  global $ilDB, $lng;
51 
52  if (!isset($this->got_data[$a_ctype][$a_cname][$a_slot_id][$a_pname]))
53  {
54  include_once "./Services/Component/classes/class.ilPluginSlot.php";
55  $slot_name = ilPluginSlot::lookupSlotName($a_ctype, $a_cname, $a_slot_id);
56 
57  $plugin_php_file = "./Customizing/global/plugins/".$a_ctype."/".
58  $a_cname."/".$slot_name."/".$a_pname."/plugin.php";
59 
60  $rec = ilPlugin::getPluginRecord($a_ctype, $a_cname, $a_slot_id, $a_pname);
61 
62  if (is_file($plugin_php_file))
63  {
64  include_once($plugin_php_file);
65  $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname] =
66  array("version" => $version, "id" => $id,
67  "ilias_min_version" => $ilias_min_version,
68  "ilias_max_version" => $ilias_max_version,
69  "responsible" => $responsible,
70  "responsible_mail" => $responsible_mail,
71  "learning_progress" => (bool)$learning_progress);
72  }
73 
74  $active = $rec["active"];
75  $needs_update = false;
76  $activation_possible = !$active;
77  $inactive_reason = "";
78 
79  // version checks
81  {
82  $active = false;
83  if (is_object($lng))
84  {
85  $inactive_reason = $lng->txt("cmps_needs_newer_ilias_version");
86  }
87  else
88  {
89  $inactive_reason = "Plugin needs a newer version of ILIAS.";
90  }
91  $activation_possible = false;
92  }
93  else if (ilComponent::isVersionGreaterString(ILIAS_VERSION_NUMERIC, $ilias_max_version))
94  {
95  $active = false;
96  if (is_object($lng))
97  {
98  $inactive_reason = $lng->txt("cmps_needs_newer_plugin_version");
99  }
100  else
101  {
102  $inactive_reason = "Plugin does not support current version of ILIAS. Newer version of plugin needed.";
103  }
104  $activation_possible = false;
105  }
106  else if ($rec["last_update_version"] == "")
107  {
108  $active = false;
109  if (is_object($lng))
110  {
111  $inactive_reason = $lng->txt("cmps_needs_update");
112  }
113  else
114  {
115  $inactive_reason = "Update needed.";
116  }
117  $needs_update = true;
118  $activation_possible = false;
119  }
120  else if (ilComponent::isVersionGreaterString($rec["last_update_version"], $version))
121  {
122  $active = false;
123  if (is_object($lng))
124  {
125  $inactive_reason = $lng->txt("cmps_needs_upgrade");
126  }
127  else
128  {
129  $inactive_reason = "Upgrade needed.";
130  }
131  $activation_possible = false;
132  }
133  else if ($rec["last_update_version"] != $version)
134  {
135  $active = false;
136  if (is_object($lng))
137  {
138  $inactive_reason = $lng->txt("cmps_needs_update");
139  }
140  else
141  {
142  $inactive_reason = "Update needed.";
143  }
144  $needs_update = true;
145  $activation_possible = false;
146  }
147 
148  $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["is_active"] = $active;
149  $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["inactive_reason"] = $inactive_reason;
150  $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["needs_update"] = $needs_update;
151  $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["activation_possible"] = $activation_possible;
152 
153  $this->got_data[$a_ctype][$a_cname][$a_slot_id][$a_pname] = true;
154  }
155  }
156 
165  function getVersion($a_ctype, $a_cname, $a_slot_id, $a_pname)
166  {
167  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
168  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["version"];
169  }
170 
179  function getIliasMinVersion($a_ctype, $a_cname, $a_slot_id, $a_pname)
180  {
181  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
182  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["ilias_min_version"];
183  }
184 
193  function getIliasMaxVersion($a_ctype, $a_cname, $a_slot_id, $a_pname)
194  {
195  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
196  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["ilias_max_version"];
197  }
198 
207  function getId($a_ctype, $a_cname, $a_slot_id, $a_pname)
208  {
209  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
210  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["id"];
211  }
212 
221  function isActive($a_ctype, $a_cname, $a_slot_id, $a_pname)
222  {
223  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
224  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["is_active"];
225  }
226 
235  function exists($a_ctype, $a_cname, $a_slot_id, $a_pname)
236  {
237  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
238  return isset($this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]);
239  }
240 
249  function needsUpdate($a_ctype, $a_cname, $a_slot_id, $a_pname)
250  {
251  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
252  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["needs_update"];
253  }
254 
263  function getAllData($a_ctype, $a_cname, $a_slot_id, $a_pname)
264  {
265  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
266  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname];
267  }
268 
272  function getActivePluginsForSlot($a_ctype, $a_cname, $a_slot_id)
273  {
274  // cache the list of active plugins
275  if (!isset(self::$active_plugins[$a_ctype][$a_cname][$a_slot_id]))
276  {
277  include_once "./Services/Component/classes/class.ilPlugin.php";
278 
279  self::$active_plugins[$a_ctype][$a_cname][$a_slot_id] =
280  ilPlugin::getActivePluginsForSlot($a_ctype, $a_cname, $a_slot_id);
281  }
282  return self::$active_plugins[$a_ctype][$a_cname][$a_slot_id];
283  }
284 
294  static function getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
295  {
296  // cache the plugin objects
297  if (!isset(self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname]))
298  {
299  self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname] =
300  ilPlugin::getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname);
301  }
302  return self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname];
303  }
304 
314  static function includeClass($a_ctype, $a_cname, $a_slot_id, $a_pname,
315  $a_class_file_name)
316  {
317  // cache the plugin objects
318  if (!isset(self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname]))
319  {
320  self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname] =
321  ilPlugin::getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname);
322  }
323  $pl = self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname];
324  $pl->includeClass($a_class_file_name);
325  }
326 
335  function hasLearningProgress($a_ctype, $a_cname, $a_slot_id, $a_pname)
336  {
337  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
338  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["learning_progress"];
339  }
340 }
341 
342 ?>