-
Côme Chilliet authored
Resolve "Non-existing classes in pluglist::$info" Closes #5700 See merge request !22
6e7dd729
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2003-2010 Cajus Pollmeier
Copyright (C) 2011-2016 FusionDirectory
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*!
* \file class_pluglist.inc
* Source code for the class pluglist
*/
/*!
* \brief This class contains all the function needed to make list
* of plugin and manage them
*
* \see class_plugin
*/
class pluglist {
var $menu = "";
var $iconmenu = "";
var $current = "";
/*!
* \brief The plInfo result for all plugin, using class as key.
* Contains the plugin index in 'INDEX' and the path in 'PATH'
*/
var $info = array();
/*!
* \brief Using the plugin index as a key, the class of the plugin.
*/
var $dirlist = array();
/*!
* \brief List plugin indexes of all plugin that the user have acl for
*/
var $allowed_plugins = array();
var $silly_cache = array();
/*!
* \brief List the plugins
*/
function __construct()
{
global $class_mapping;
/* Fill info part of pluglist */
$classes = get_declared_classes();
/* To avoid plugins changing index when reloading */
sort($classes);
$index = 0;
$depends_infos = array();
$conflicts_infos = array();
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
$foreign_refs = array();
foreach ($classes as $cname) {
$cmethods = get_class_methods($cname);
if (in_array_ics('plInfo', $cmethods)) {
$infos = call_user_func(array($cname, 'plInfo'));
if (is_subclass_of($cname, 'simpleService')) {
$infos['plSelfModify'] = FALSE;
/* services are not part of any objectType */
unset($infos['plObjectType']);
$infos['plCategory'] = array('server');
} else {
if (!isset($infos['plSelfModify'])) {
$infos['plSelfModify'] = FALSE;
}
}
if (isset($class_mapping[$cname])) {
$infos['PATH'] = dirname($class_mapping[$cname]);
}
if (isset($infos['plDepends'])) {
$depends_infos[] = $cname;
}
if (isset($infos['plConflicts'])) {
$conflicts_infos[] = $cname;
}
if (isset($infos['plForeignKeys'])) {
foreach ($infos['plForeignKeys'] as $ofield => &$pfks) {
if (!is_array($pfks)) {
$pfks = array($pfks);
}
if (!is_array($pfks[0])) {
$pfks = array($pfks);
}
foreach ($pfks as &$pfk) {
$class = $pfk[0];
if (isset($pfk[1])) {
$field = $pfk[1];
} else {
$field = 'dn';
$pfk[1] = $field;
}
$filter = NULL;
if (isset($pfk[2])) {
$filter = $pfk[2];
}
if ($filter === NULL) {
$filter = "$ofield=%oldvalue%";
}
$pfk[2] = $filter;
if (!isset($foreign_refs[$class])) {
$foreign_refs[$class] = array();
}
if (!isset($foreign_refs[$class][$field])) {
$foreign_refs[$class][$field] = array();
}
$foreign_refs[$class][$field][] = array($cname, $ofield, $filter);
}
unset($pfk);
}
unset($pfks);
} else {
$infos['plForeignKeys'] = array();
}
if (!isset($infos['plProvidedAcls'])) {
$infos['plProvidedAcls'] = array();
}
if (!isset($infos['plCategory'])) {
$infos['plCategory'] = array();
}
if (!isset($infos['plTitle']) && isset($infos['plShortName'])) {
$infos['plTitle'] = $infos['plShortName'];