ILIAS  Release_4_2_x_branch Revision 61807
 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  }
91 
92  $active = $rec["active"];
93  $needs_update = false;
94  $activation_possible = !$active;
95  $inactive_reason = "";
96 
97  // version checks
99  {
100  $active = false;
101  if (is_object($lng))
102  {
103  $inactive_reason = $lng->txt("cmps_needs_newer_ilias_version");
104  }
105  else
106  {
107  $inactive_reason = "Plugin needs a newer version of ILIAS.";
108  }
109  $activation_possible = false;
110  }
111  else if (ilComponent::isVersionGreaterString(ILIAS_VERSION_NUMERIC, $ilias_max_version))
112  {
113  $active = false;
114  if (is_object($lng))
115  {
116  $inactive_reason = $lng->txt("cmps_needs_newer_plugin_version");
117  }
118  else
119  {
120  $inactive_reason = "Plugin does not support current version of ILIAS. Newer version of plugin needed.";
121  }
122  $activation_possible = false;
123  }
124  else if ($rec["last_update_version"] == "")
125  {
126  $active = false;
127  if (is_object($lng))
128  {
129  $inactive_reason = $lng->txt("cmps_needs_update");
130  }
131  else
132  {
133  $inactive_reason = "Update needed.";
134  }
135  $needs_update = true;
136  $activation_possible = false;
137  }
138  else if (ilComponent::isVersionGreaterString($rec["last_update_version"], $version))
139  {
140  $active = false;
141  if (is_object($lng))
142  {
143  $inactive_reason = $lng->txt("cmps_needs_upgrade");
144  }
145  else
146  {
147  $inactive_reason = "Upgrade needed.";
148  }
149  $activation_possible = false;
150  }
151  else if ($rec["last_update_version"] != $version)
152  {
153  $active = false;
154  if (is_object($lng))
155  {
156  $inactive_reason = $lng->txt("cmps_needs_update");
157  }
158  else
159  {
160  $inactive_reason = "Update needed.";
161  }
162  $needs_update = true;
163  $activation_possible = false;
164  }
165 
166  $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["is_active"] = $active;
167  $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["inactive_reason"] = $inactive_reason;
168  $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["needs_update"] = $needs_update;
169  $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["activation_possible"] = $activation_possible;
170 
171  $this->got_data[$a_ctype][$a_cname][$a_slot_id][$a_pname] = true;
172  }
173  }
174 
183  function getVersion($a_ctype, $a_cname, $a_slot_id, $a_pname)
184  {
185  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
186  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["version"];
187  }
188 
197  function getIliasMinVersion($a_ctype, $a_cname, $a_slot_id, $a_pname)
198  {
199  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
200  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["ilias_min_version"];
201  }
202 
211  function getIliasMaxVersion($a_ctype, $a_cname, $a_slot_id, $a_pname)
212  {
213  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
214  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["ilias_max_version"];
215  }
216 
225  function getId($a_ctype, $a_cname, $a_slot_id, $a_pname)
226  {
227  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
228  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["id"];
229  }
230 
239  function isActive($a_ctype, $a_cname, $a_slot_id, $a_pname)
240  {
241  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
242  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["is_active"];
243  }
244 
253  function exists($a_ctype, $a_cname, $a_slot_id, $a_pname)
254  {
255  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
256  return isset($this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]);
257  }
258 
267  function needsUpdate($a_ctype, $a_cname, $a_slot_id, $a_pname)
268  {
269  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
270  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["needs_update"];
271  }
272 
281  function getAllData($a_ctype, $a_cname, $a_slot_id, $a_pname)
282  {
283  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
284  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname];
285  }
286 
290  function getActivePluginsForSlot($a_ctype, $a_cname, $a_slot_id)
291  {
292  // cache the list of active plugins
293  if (!isset(self::$active_plugins[$a_ctype][$a_cname][$a_slot_id]))
294  {
295  include_once "./Services/Component/classes/class.ilPlugin.php";
296 
297  self::$active_plugins[$a_ctype][$a_cname][$a_slot_id] =
298  ilPlugin::getActivePluginsForSlot($a_ctype, $a_cname, $a_slot_id);
299  }
300  return self::$active_plugins[$a_ctype][$a_cname][$a_slot_id];
301  }
302 
312  static function getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
313  {
314  // cache the plugin objects
315  if (!isset(self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname]))
316  {
317  self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname] =
318  ilPlugin::getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname);
319  }
320  return self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname];
321  }
322 
332  static function includeClass($a_ctype, $a_cname, $a_slot_id, $a_pname,
333  $a_class_file_name)
334  {
335  // cache the plugin objects
336  if (!isset(self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname]))
337  {
338  self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname] =
339  ilPlugin::getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname);
340  }
341  $pl = self::$plugin_objects[$a_ctype][$a_cname][$a_slot_id][$a_pname];
342  $pl->includeClass($a_class_file_name);
343  }
344 
345 }
346 
347 ?>