ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  "supports_export" => (bool)$supports_export);
73  }
74 
75  $active = $rec["active"];
76  $needs_update = false;
77  $activation_possible = !$active;
78  $inactive_reason = "";
79 
80  // version checks
82  {
83  $active = false;
84  if (is_object($lng))
85  {
86  $inactive_reason = $lng->txt("cmps_needs_newer_ilias_version");
87  }
88  else
89  {
90  $inactive_reason = "Plugin needs a newer version of ILIAS.";
91  }
92  $activation_possible = false;
93  }
94  else if (ilComponent::isVersionGreaterString(ILIAS_VERSION_NUMERIC, $ilias_max_version))
95  {
96  $active = false;
97  if (is_object($lng))
98  {
99  $inactive_reason = $lng->txt("cmps_needs_newer_plugin_version");
100  }
101  else
102  {
103  $inactive_reason = "Plugin does not support current version of ILIAS. Newer version of plugin needed.";
104  }
105  $activation_possible = false;
106  }
107  else if ($rec["last_update_version"] == "")
108  {
109  $active = false;
110  if (is_object($lng))
111  {
112  $inactive_reason = $lng->txt("cmps_needs_update");
113  }
114  else
115  {
116  $inactive_reason = "Update needed.";
117  }
118  $needs_update = true;
119  $activation_possible = false;
120  }
121  else if (ilComponent::isVersionGreaterString($rec["last_update_version"], $version))
122  {
123  $active = false;
124  if (is_object($lng))
125  {
126  $inactive_reason = $lng->txt("cmps_needs_upgrade");
127  }
128  else
129  {
130  $inactive_reason = "Upgrade needed.";
131  }
132  $activation_possible = false;
133  }
134  else if ($rec["last_update_version"] != $version)
135  {
136  $active = false;
137  if (is_object($lng))
138  {
139  $inactive_reason = $lng->txt("cmps_needs_update");
140  }
141  else
142  {
143  $inactive_reason = "Update needed.";
144  }
145  $needs_update = true;
146  $activation_possible = false;
147  }
148 
149  $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["is_active"] = $active;
150  $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["inactive_reason"] = $inactive_reason;
151  $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["needs_update"] = $needs_update;
152  $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["activation_possible"] = $activation_possible;
153 
154  $this->got_data[$a_ctype][$a_cname][$a_slot_id][$a_pname] = true;
155  }
156  }
157 
166  function getVersion($a_ctype, $a_cname, $a_slot_id, $a_pname)
167  {
168  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
169  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["version"];
170  }
171 
180  function getIliasMinVersion($a_ctype, $a_cname, $a_slot_id, $a_pname)
181  {
182  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
183  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["ilias_min_version"];
184  }
185 
194  function getIliasMaxVersion($a_ctype, $a_cname, $a_slot_id, $a_pname)
195  {
196  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
197  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["ilias_max_version"];
198  }
199 
208  function getId($a_ctype, $a_cname, $a_slot_id, $a_pname)
209  {
210  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
211  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["id"];
212  }
213 
222  function isActive($a_ctype, $a_cname, $a_slot_id, $a_pname)
223  {
224  try
225  {
226  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
227  }
228  catch (ilPluginException $e)
229  {
230  return false;
231  }
232  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["is_active"];
233  }
234 
243  function exists($a_ctype, $a_cname, $a_slot_id, $a_pname)
244  {
245  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
246  return isset($this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]);
247  }
248 
257  function needsUpdate($a_ctype, $a_cname, $a_slot_id, $a_pname)
258  {
259  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
260  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["needs_update"];
261  }
262 
271  function getAllData($a_ctype, $a_cname, $a_slot_id, $a_pname)
272  {
273  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
274  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname];
275  }
276 
280  static function getActivePluginsForSlot($a_ctype, $a_cname, $a_slot_id)
281  {
282  // cache the list of active plugins
283  if (!isset(self::$active_plugins[$a_ctype][$a_cname][$a_slot_id]))
284  {
285  include_once "./Services/Component/classes/class.ilPlugin.php";
286 
287  self::$active_plugins[$a_ctype][$a_cname][$a_slot_id] =
288  ilPlugin::getActivePluginsForSlot($a_ctype, $a_cname, $a_slot_id);
289  }
290  return self::$active_plugins[$a_ctype][$a_cname][$a_slot_id];
291  }
292 
302  static function getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
303  {
304  // cache the plugin objects
305  if (!isset(self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname]))
306  {
307  self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname] =
308  ilPlugin::getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname);
309  }
310  return self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname];
311  }
312 
322  static function includeClass($a_ctype, $a_cname, $a_slot_id, $a_pname,
323  $a_class_file_name)
324  {
325  // cache the plugin objects
326  if (!isset(self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname]))
327  {
328  self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname] =
329  ilPlugin::getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname);
330  }
331  $pl = self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname];
332  $pl->includeClass($a_class_file_name);
333  }
334 
344  function hasLearningProgress($a_ctype, $a_cname, $a_slot_id, $a_pname)
345  {
346  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
347  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["learning_progress"];
348  }
349 
359  function supportsExport($a_ctype, $a_cname, $a_slot_id, $a_pname)
360  {
361  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
362  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["supports_export"];
363  }
364 }
365 
366 ?>
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin object.
getVersion($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get version of plugin.
Add some data
__construct()
Constructor.
const ILIAS_VERSION_NUMERIC
static isVersionGreaterString($a_ver1, $a_ver2)
isActive($a_ctype, $a_cname, $a_slot_id, $a_pname)
Checks whether plugin is active (include version checks)
static getActivePluginsForSlot($a_ctype, $a_cname, $a_slot_id)
Get all active plugins for a slot.
getIliasMaxVersion($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get Ilias Max Version.
static getActivePluginsForSlot($a_ctype, $a_cname, $a_slot_id)
Get all active plugin names for a slot.
static lookupSlotName($a_ctype, $a_cname, $a_slot_id)
Lookup slot name for component and slot id.
needsUpdate($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get version.
exists($a_ctype, $a_cname, $a_slot_id, $a_pname)
Checks whether plugin exists.
getAllData($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get all data from file in an array.
supportsExport($a_ctype, $a_cname, $a_slot_id, $a_pname)
Checks whether plugin supports export/import.
static getPluginRecord($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get record from il_plugin table.
getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get basic data of plugin from plugin.php.
static includeClass($a_ctype, $a_cname, $a_slot_id, $a_pname, $a_class_file_name)
Get Plugin Object.
Administration class for plugins.
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get Plugin Object.
hasLearningProgress($a_ctype, $a_cname, $a_slot_id, $a_pname)
Checks whether plugin has active learning progress.
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
getIliasMinVersion($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get Ilias Min Version.
global $ilDB
getId($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get ID.