ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPluginAdmin.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2008 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
25 include_once("./Services/Component/classes/class.ilComponent.php");
26 
36 {
37  var $got_data = false;
38 
43  static $active_plugins = array();
44 
49  static $plugin_objects = array();
50 
51 
55  function __construct()
56  {
57  }
58 
67  private final function getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname)
68  {
69  global $ilDB, $lng;
70 
71  if (!isset($this->got_data[$a_ctype][$a_cname][$a_slot_id][$a_pname]))
72  {
73  include_once "./Services/Component/classes/class.ilPluginSlot.php";
74  $slot_name = ilPluginSlot::lookupSlotName($a_ctype, $a_cname, $a_slot_id);
75 
76  $plugin_php_file = "./Customizing/global/plugins/".$a_ctype."/".
77  $a_cname."/".$slot_name."/".$a_pname."/plugin.php";
78 
79  $rec = ilPlugin::getPluginRecord($a_ctype, $a_cname, $a_slot_id, $a_pname);
80 
81  if (is_file($plugin_php_file))
82  {
83  include_once($plugin_php_file);
84  $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname] =
85  array("version" => $version, "id" => $id,
86  "ilias_min_version" => $ilias_min_version,
87  "ilias_max_version" => $ilias_max_version,
88  "responsible" => $responsible,
89  "responsible_mail" => $responsible_mail,
90  "learning_progress" => (bool)$learning_progress);
91  }
92 
93  $active = $rec["active"];
94  $needs_update = false;
95  $activation_possible = !$active;
96  $inactive_reason = "";
97 
98  // version checks
100  {
101  $active = false;
102  if (is_object($lng))
103  {
104  $inactive_reason = $lng->txt("cmps_needs_newer_ilias_version");
105  }
106  else
107  {
108  $inactive_reason = "Plugin needs a newer version of ILIAS.";
109  }
110  $activation_possible = false;
111  }
112  else if (ilComponent::isVersionGreaterString(ILIAS_VERSION_NUMERIC, $ilias_max_version))
113  {
114  $active = false;
115  if (is_object($lng))
116  {
117  $inactive_reason = $lng->txt("cmps_needs_newer_plugin_version");
118  }
119  else
120  {
121  $inactive_reason = "Plugin does not support current version of ILIAS. Newer version of plugin needed.";
122  }
123  $activation_possible = false;
124  }
125  else if ($rec["last_update_version"] == "")
126  {
127  $active = false;
128  if (is_object($lng))
129  {
130  $inactive_reason = $lng->txt("cmps_needs_update");
131  }
132  else
133  {
134  $inactive_reason = "Update needed.";
135  }
136  $needs_update = true;
137  $activation_possible = false;
138  }
139  else if (ilComponent::isVersionGreaterString($rec["last_update_version"], $version))
140  {
141  $active = false;
142  if (is_object($lng))
143  {
144  $inactive_reason = $lng->txt("cmps_needs_upgrade");
145  }
146  else
147  {
148  $inactive_reason = "Upgrade needed.";
149  }
150  $activation_possible = false;
151  }
152  else if ($rec["last_update_version"] != $version)
153  {
154  $active = false;
155  if (is_object($lng))
156  {
157  $inactive_reason = $lng->txt("cmps_needs_update");
158  }
159  else
160  {
161  $inactive_reason = "Update needed.";
162  }
163  $needs_update = true;
164  $activation_possible = false;
165  }
166 
167  $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["is_active"] = $active;
168  $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["inactive_reason"] = $inactive_reason;
169  $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["needs_update"] = $needs_update;
170  $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["activation_possible"] = $activation_possible;
171 
172  $this->got_data[$a_ctype][$a_cname][$a_slot_id][$a_pname] = true;
173  }
174  }
175 
184  function getVersion($a_ctype, $a_cname, $a_slot_id, $a_pname)
185  {
186  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
187  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["version"];
188  }
189 
198  function getIliasMinVersion($a_ctype, $a_cname, $a_slot_id, $a_pname)
199  {
200  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
201  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["ilias_min_version"];
202  }
203 
212  function getIliasMaxVersion($a_ctype, $a_cname, $a_slot_id, $a_pname)
213  {
214  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
215  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["ilias_max_version"];
216  }
217 
226  function getId($a_ctype, $a_cname, $a_slot_id, $a_pname)
227  {
228  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
229  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["id"];
230  }
231 
240  function isActive($a_ctype, $a_cname, $a_slot_id, $a_pname)
241  {
242  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
243  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["is_active"];
244  }
245 
254  function exists($a_ctype, $a_cname, $a_slot_id, $a_pname)
255  {
256  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
257  return isset($this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]);
258  }
259 
268  function needsUpdate($a_ctype, $a_cname, $a_slot_id, $a_pname)
269  {
270  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
271  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["needs_update"];
272  }
273 
282  function getAllData($a_ctype, $a_cname, $a_slot_id, $a_pname)
283  {
284  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
285  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname];
286  }
287 
291  function getActivePluginsForSlot($a_ctype, $a_cname, $a_slot_id)
292  {
293  // cache the list of active plugins
294  if (!isset(self::$active_plugins[$a_ctype][$a_cname][$a_slot_id]))
295  {
296  include_once "./Services/Component/classes/class.ilPlugin.php";
297 
298  self::$active_plugins[$a_ctype][$a_cname][$a_slot_id] =
299  ilPlugin::getActivePluginsForSlot($a_ctype, $a_cname, $a_slot_id);
300  }
301  return self::$active_plugins[$a_ctype][$a_cname][$a_slot_id];
302  }
303 
313  static function getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
314  {
315  // cache the plugin objects
316  if (!isset(self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname]))
317  {
318  self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname] =
319  ilPlugin::getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname);
320  }
321  return self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname];
322  }
323 
333  static function includeClass($a_ctype, $a_cname, $a_slot_id, $a_pname,
334  $a_class_file_name)
335  {
336  // cache the plugin objects
337  if (!isset(self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname]))
338  {
339  self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname] =
340  ilPlugin::getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname);
341  }
342  $pl = self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname];
343  $pl->includeClass($a_class_file_name);
344  }
345 
354  function hasLearningProgress($a_ctype, $a_cname, $a_slot_id, $a_pname)
355  {
356  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
357  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["learning_progress"];
358  }
359 }
360 
361 ?>