ILIAS  eassessment Revision 61809
 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 
42  function __construct()
43  {
44  }
45 
54  private final function getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname)
55  {
56  global $ilDB, $lng;
57 
58  if (!isset($this->got_data[$a_ctype][$a_cname][$a_slot_id][$a_pname]))
59  {
60  include_once "./Services/Component/classes/class.ilPluginSlot.php";
61  $slot_name = ilPluginSlot::lookupSlotName($a_ctype, $a_cname, $a_slot_id);
62 
63  $plugin_php_file = "./Customizing/global/plugins/".$a_ctype."/".
64  $a_cname."/".$slot_name."/".$a_pname."/plugin.php";
65 
66  $rec = ilPlugin::getPluginRecord($a_ctype, $a_cname, $a_slot_id, $a_pname);
67 
68  if (is_file($plugin_php_file))
69  {
70  include_once($plugin_php_file);
71  $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname] =
72  array("version" => $version, "id" => $id,
73  "ilias_min_version" => $ilias_min_version,
74  "ilias_max_version" => $ilias_max_version,
75  "responsible" => $responsible,
76  "responsible_mail" => $responsible_mail);
77  }
78 
79  $active = $rec["active"];
80  $needs_update = false;
81  $activation_possible = !$active;
82  $inactive_reason = "";
83 
84  // version checks
86  {
87  $active = false;
88  if (is_object($lng))
89  {
90  $inactive_reason = $lng->txt("cmps_needs_newer_ilias_version");
91  }
92  else
93  {
94  $inactive_reason = "Plugin needs a newer version of ILIAS.";
95  }
96  $activation_possible = false;
97  }
98  else if (ilComponent::isVersionGreaterString(ILIAS_VERSION_NUMERIC, $ilias_max_version))
99  {
100  $active = false;
101  if (is_object($lng))
102  {
103  $inactive_reason = $lng->txt("cmps_needs_newer_plugin_version");
104  }
105  else
106  {
107  $inactive_reason = "Plugin does not support current version of ILIAS. Newer version of plugin needed.";
108  }
109  $activation_possible = false;
110  }
111  else if ($rec["last_update_version"] == "")
112  {
113  $active = false;
114  if (is_object($lng))
115  {
116  $inactive_reason = $lng->txt("cmps_needs_update");
117  }
118  else
119  {
120  $inactive_reason = "Update needed.";
121  }
122  $needs_update = true;
123  $activation_possible = false;
124  }
125  else if (ilComponent::isVersionGreaterString($rec["last_update_version"], $version))
126  {
127  $active = false;
128  if (is_object($lng))
129  {
130  $inactive_reason = $lng->txt("cmps_needs_upgrade");
131  }
132  else
133  {
134  $inactive_reason = "Upgrade needed.";
135  }
136  $activation_possible = false;
137  }
138  else if ($rec["last_update_version"] != $version)
139  {
140  $active = false;
141  if (is_object($lng))
142  {
143  $inactive_reason = $lng->txt("cmps_needs_update");
144  }
145  else
146  {
147  $inactive_reason = "Update needed.";
148  }
149  $needs_update = true;
150  $activation_possible = false;
151  }
152 
153  $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["is_active"] = $active;
154  $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["inactive_reason"] = $inactive_reason;
155  $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["needs_update"] = $needs_update;
156  $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["activation_possible"] = $activation_possible;
157 
158  $this->got_data[$a_ctype][$a_cname][$a_slot_id][$a_pname] = true;
159  }
160  }
161 
170  function getVersion($a_ctype, $a_cname, $a_slot_id, $a_pname)
171  {
172  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
173  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["version"];
174  }
175 
184  function getIliasMinVersion($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]["ilias_min_version"];
188  }
189 
198  function getIliasMaxVersion($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_max_version"];
202  }
203 
212  function getId($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]["id"];
216  }
217 
226  function isActive($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]["is_active"];
230  }
231 
240  function exists($a_ctype, $a_cname, $a_slot_id, $a_pname)
241  {
242  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
243  return isset($this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]);
244  }
245 
254  function needsUpdate($a_ctype, $a_cname, $a_slot_id, $a_pname)
255  {
256  $this->getPluginData($a_ctype, $a_cname, $a_slot_id, $a_pname);
257  return $this->data[$a_ctype][$a_cname][$a_slot_id][$a_pname]["needs_update"];
258  }
259 
268  function getAllData($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];
272  }
273 
277  function getActivePluginsForSlot($a_ctype, $a_cname, $a_slot_id)
278  {
279  include_once "./Services/Component/classes/class.ilPlugin.php";
280  return ilPlugin::getActivePluginsForSlot($a_ctype, $a_cname, $a_slot_id);
281  }
282 
291  static function getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
292  {
293  return ilPlugin::getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname);
294  }
295 }
296 
297 ?>