ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
6include_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 }
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 try
224 {
225 $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
226 }
227 catch (ilPluginException $e)
228 {
229 return false;
230 }
231 return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["is_active"];
232 }
233
242 function exists($a_ctype, $a_cname, $a_slot_id, $a_pname)
243 {
244 $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
245 return isset($this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]);
246 }
247
256 function needsUpdate($a_ctype, $a_cname, $a_slot_id, $a_pname)
257 {
258 $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
259 return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["needs_update"];
260 }
261
270 function getAllData($a_ctype, $a_cname, $a_slot_id, $a_pname)
271 {
272 $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
273 return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname];
274 }
275
279 function getActivePluginsForSlot($a_ctype, $a_cname, $a_slot_id)
280 {
281 // cache the list of active plugins
282 if (!isset(self::$active_plugins[$a_ctype][$a_cname][$a_slot_id]))
283 {
284 include_once "./Services/Component/classes/class.ilPlugin.php";
285
286 self::$active_plugins[$a_ctype][$a_cname][$a_slot_id] =
287 ilPlugin::getActivePluginsForSlot($a_ctype, $a_cname, $a_slot_id);
288 }
289 return self::$active_plugins[$a_ctype][$a_cname][$a_slot_id];
290 }
291
301 static function getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
302 {
303 // cache the plugin objects
304 if (!isset(self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname]))
305 {
306 self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname] =
307 ilPlugin::getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname);
308 }
309 return self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname];
310 }
311
321 static function includeClass($a_ctype, $a_cname, $a_slot_id, $a_pname,
322 $a_class_file_name)
323 {
324 // cache the plugin objects
325 if (!isset(self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname]))
326 {
327 self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname] =
328 ilPlugin::getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname);
329 }
330 $pl = self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname];
331 $pl->includeClass($a_class_file_name);
332 }
333
342 function hasLearningProgress($a_ctype, $a_cname, $a_slot_id, $a_pname)
343 {
344 $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
345 return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["learning_progress"];
346 }
347}
348
349?>
static isVersionGreaterString($a_ver1, $a_ver2)
Administration class for plugins.
getVersion($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get version of plugin.
exists($a_ctype, $a_cname, $a_slot_id, $a_pname)
Checks whether plugin exists.
static includeClass($a_ctype, $a_cname, $a_slot_id, $a_pname, $a_class_file_name)
Get Plugin Object.
getIliasMaxVersion($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get Ilias Max Version.
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.
getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get basic data of plugin from plugin.php.
__construct()
Constructor.
getId($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get ID.
getAllData($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get all data from file in an array.
getIliasMinVersion($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get Ilias Min Version.
isActive($a_ctype, $a_cname, $a_slot_id, $a_pname)
Checks whether plugin is active (include version checks)
needsUpdate($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get version.
getActivePluginsForSlot($a_ctype, $a_cname, $a_slot_id)
Get all active plugins for a slot.
static lookupSlotName($a_ctype, $a_cname, $a_slot_id)
Lookup slot name for component and slot id.
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin object.
static getPluginRecord($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get record from il_plugin table.
static getActivePluginsForSlot($a_ctype, $a_cname, $a_slot_id)
Get all active plugins for a slot.
const ILIAS_VERSION_NUMERIC
global $lng
Definition: privfeed.php:40
global $ilDB