ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPluginSlot.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.ilPlugin.php");
26 
40 {
41 
45  function __construct($a_c_type, $a_c_name, $a_slot_id)
46  {
47  $this->setComponentType($a_c_type);
48  $this->setComponentName($a_c_name);
49  $this->setSlotId($a_slot_id);
50 
51  if ($a_slot_id != "")
52  {
53  $this->read();
54  }
55  }
56 
60  function read()
61  {
62  global $ilDB;
63 
64  $q = "SELECT * FROM il_pluginslot WHERE component = ".
65  $ilDB->quote($this->getComponentType()."/".$this->getComponentName()).
66  " AND id = ".$ilDB->quote($this->getSlotId());
67  $set = $ilDB->query($q);
68  $rec = $set->fetchRow(DB_FETCHMODE_ASSOC);
69  $this->setSlotName($rec["name"]);
70  }
71 
77  function setComponentType($a_componenttype)
78  {
79  $this->componenttype = $a_componenttype;
80  }
81 
87  function getComponentType()
88  {
89  return $this->componenttype;
90  }
91 
97  function setComponentName($a_componentname)
98  {
99  $this->componentname = $a_componentname;
100  }
101 
107  function getComponentName()
108  {
109  return $this->componentname;
110  }
111 
117  function setSlotId($a_slotid)
118  {
119  $this->slotid = $a_slotid;
120  }
121 
127  function getSlotId()
128  {
129  return $this->slotid;
130  }
131 
137  function setSlotName($a_slotname)
138  {
139  $this->slotname = $a_slotname;
140  }
141 
147  function getSlotName()
148  {
149  return $this->slotname;
150  }
151 
156  {
157  return "./Customizing/global/plugins/".$this->getComponentType().
158  "/".$this->getComponentName()."/".$this->getSlotName();
159  }
160 
164  function getPluginPhpFileName($a_plugin_name)
165  {
166  return $this->getPluginsDirectory()."/".
167  $a_plugin_name."/plugin.php";
168  }
169 
173  function checkPluginPhpFileAvailability($a_plugin_name)
174  {
175  if (@is_file($this->getPluginPhpFileName($a_plugin_name)))
176  {
177  return true;
178  }
179 
180  return false;
181  }
182 
186  function getPluginClassFileName($a_plugin_name)
187  {
188  return $this->getPluginsDirectory()."/".
189  $a_plugin_name."/classes/class.il".$a_plugin_name."Plugin.php";
190  }
191 
195  function checkClassFileAvailability($a_plugin_name)
196  {
197  if (@is_file($this->getPluginClassFileName($a_plugin_name)))
198  {
199  return true;
200  }
201 
202  return false;
203  }
204 
209  function getPrefix()
210  {
211  if ($this->prefix == "")
212  {
213  $this->prefix =
215  $this->getComponentName())."_".$this->getSlotId();
216  }
217 
218  return $this->prefix;
219  }
220 
225  {
226  global $ilPluginAdmin;
227 
228  // read plugins directory
229  $pl_dir = $this->getPluginsDirectory();
230 
231  if (!@is_dir($pl_dir))
232  {
233  return array();
234  }
235 
236  $dir = opendir($pl_dir);
237 
238  $plugins = array();
239  while($file = readdir($dir))
240  {
241  if ($file != "." and
242  $file != "..")
243  {
244  // directories
245  if (@is_dir($pl_dir."/".$file))
246  {
247  $plugin = array();
248 
249  $plugin = ilPlugin::lookupStoredData($this->getComponentType(),
250  $this->getComponentName(), $this->getSlotId(), $file);
251 
252  $pdata = $ilPluginAdmin->getAllData($this->getComponentType(),
253  $this->getComponentName(), $this->getSlotId(), $file);
254 
255  $plugin["version"] = $pdata["version"];
256  $plugin["id"] = $pdata["id"];
257  $plugin["is_active"] = $pdata["is_active"];
258  $plugin["inactive_reason"] = $pdata["inactive_reason"];
259  $plugin["needs_update"] = $pdata["needs_update"];
260  $plugin["ilias_min_version"] = $pdata["ilias_min_version"];
261  $plugin["ilias_max_version"] = $pdata["ilias_max_version"];
262  $plugin["activation_possible"] = $pdata["activation_possible"];
263  $plugin["responsible"] = $pdata["responsible"];
264  $plugin["responsible_mail"] = $pdata["responsible_mail"];
265 
266  $plugin["name"] = $file;
267  $plugin["plugin_php_file_status"] = $this->checkPluginPhpFileAvailability($file);
268  $plugin["class_file_status"] = $this->checkClassFileAvailability($file);
269  $plugin["class_file"] = "class.il".$plugin["name"]."Plugin.php";
270 
271  $plugins[] = $plugin;
272  }
273  }
274  }
275 
276  return $plugins;
277  }
278 
282  function lookupSlotId($a_ctype, $a_cname, $a_slot_name)
283  {
284  global $ilDB;
285 
286  $q = "SELECT * FROM il_pluginslot WHERE component = ".
287  $ilDB->quote($a_ctype."/".$a_cname).
288  " AND name = ".$ilDB->quote($a_slot_name);
289  $set = $ilDB->query($q);
290  $rec = $set->fetchRow(DB_FETCHMODE_ASSOC);
291  return $rec["id"];
292  }
293 
297  function lookupSlotName($a_ctype, $a_cname, $a_slot_id)
298  {
299  global $ilDB;
300 
301  $q = "SELECT * FROM il_pluginslot WHERE component = ".
302  $ilDB->quote($a_ctype."/".$a_cname).
303  " AND id = ".$ilDB->quote($a_slot_id);
304  $set = $ilDB->query($q);
305  $rec = $set->fetchRow(DB_FETCHMODE_ASSOC);
306  return $rec["name"];
307  }
308 
312  function getActivePlugins()
313  {
314  global $ilPluginAdmin;
315 
316  return $ilPluginAdmin->getActivePluginsForSlot($this->getComponentType(),
317  $this->getComponentName(), $this->getSlotId());
318  }
319 
320 }
321 ?>