ILIAS  Release_4_0_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  +-----------------------------------------------------------------------------+
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 {
40  function __construct()
41  {
42  }
43 
52  private final function getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname)
53  {
54  global $ilDB, $lng;
55 
56  if (!$this->got_data[$a_ctype][$a_cname][$a_slot_id][$a_pname])
57  {
58  include_once "./Services/Component/classes/class.ilPluginSlot.php";
59  $slot_name = ilPluginSlot::lookupSlotName($a_ctype, $a_cname, $a_slot_id);
60 
61  $plugin_php_file = "./Customizing/global/plugins/".$a_ctype."/".
62  $a_cname."/".$slot_name."/".$a_pname."/plugin.php";
63 
64  $rec = ilPlugin::getPluginRecord($a_ctype, $a_cname, $a_slot_id, $a_pname);
65 
66  if (is_file($plugin_php_file))
67  {
68  include_once($plugin_php_file);
69  $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname] =
70  array("version" => $version, "id" => $id,
71  "ilias_min_version" => $ilias_min_version,
72  "ilias_max_version" => $ilias_max_version,
73  "responsible" => $responsible,
74  "responsible_mail" => $responsible_mail);
75  }
76 
77  $active = $rec["active"];
78  $needs_update = false;
79  $activation_possible = !$active;
80 
81  // version checks
83  {
84  $active = false;
85  if (is_object($lng))
86  {
87  $inactive_reason = $lng->txt("cmps_needs_newer_ilias_version");
88  }
89  else
90  {
91  $inactive_reason = "Plugin needs a newer version of ILIAS.";
92  }
93  $activation_possible = false;
94  }
95  else if (ilComponent::isVersionGreaterString(ILIAS_VERSION_NUMERIC, $ilias_max_version))
96  {
97  $active = false;
98  if (is_object($lng))
99  {
100  $inactive_reason = $lng->txt("cmps_needs_newer_plugin_version");
101  }
102  else
103  {
104  $inactive_reason = "Plugin does not support current version of ILIAS. Newer version of plugin needed.";
105  }
106  $activation_possible = false;
107  }
108  else if ($rec["last_update_version"] == "")
109  {
110  $active = false;
111  if (is_object($lng))
112  {
113  $inactive_reason = $lng->txt("cmps_needs_update");
114  }
115  else
116  {
117  $inactive_reason = "Update needed.";
118  }
119  $needs_update = true;
120  $activation_possible = false;
121  }
122  else if (ilComponent::isVersionGreaterString($rec["last_update_version"], $version))
123  {
124  $active = false;
125  if (is_object($lng))
126  {
127  $inactive_reason = $lng->txt("cmps_needs_upgrade");
128  }
129  else
130  {
131  $inactive_reason = "Upgrade needed.";
132  }
133  $activation_possible = false;
134  }
135  else if ($rec["last_update_version"] != $version)
136  {
137  $active = false;
138  if (is_object($lng))
139  {
140  $inactive_reason = $lng->txt("cmps_needs_update");
141  }
142  else
143  {
144  $inactive_reason = "Update needed.";
145  }
146  $needs_update = true;
147  $activation_possible = false;
148  }
149 
150  $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["is_active"] = $active;
151  $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["inactive_reason"] = $inactive_reason;
152  $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["needs_update"] = $needs_update;
153  $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["activation_possible"] = $activation_possible;
154 
155  $this->got_data[$a_ctype][$a_cname][$a_slot_id][$a_pname] = true;
156  }
157  }
158 
167  function getVersion($a_ctype, $a_cname, $a_slot_id, $a_pname)
168  {
169  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
170  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["version"];
171  }
172 
181  function getIliasMinVersion($a_ctype, $a_cname, $a_slot_id, $a_pname)
182  {
183  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
184  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["ilias_min_version"];
185  }
186 
195  function getIliasMaxVersion($a_ctype, $a_cname, $a_slot_id, $a_pname)
196  {
197  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
198  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["ilias_max_version"];
199  }
200 
209  function getId($a_ctype, $a_cname, $a_slot_id, $a_pname)
210  {
211  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
212  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["id"];
213  }
214 
223  function isActive($a_ctype, $a_cname, $a_slot_id, $a_pname)
224  {
225  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
226  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["is_active"];
227  }
228 
237  function exists($a_ctype, $a_cname, $a_slot_id, $a_pname)
238  {
239  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
240  return isset($this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]);
241  }
242 
251  function needsUpdate($a_ctype, $a_cname, $a_slot_id, $a_pname)
252  {
253  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
254  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["needs_update"];
255  }
256 
265  function getAllData($a_ctype, $a_cname, $a_slot_id, $a_pname)
266  {
267  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
268  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname];
269  }
270 
274  function getActivePluginsForSlot($a_ctype, $a_cname, $a_slot_id)
275  {
276  include_once "./Services/Component/classes/class.ilPlugin.php";
277  return ilPlugin::getActivePluginsForSlot($a_ctype, $a_cname, $a_slot_id);
278  }
279 
288  static function getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
289  {
290  return ilPlugin::getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname);
291  }
292 }
293 
294 ?>