Hi anyOne.
Well I hope to explain my trouble in a
right way I've got this code:
class Plugins
{
var $__DB = FALSE;
var $__userPriv = 0;
var $__pluginList = array();
var $__count = 0;
function Plugins(&$db,$userPriv="")
{
if(!is_object($db))
{
exit("Could not connect");
}
$this->__DB = &$db;
$this->__userPriv = $userPriv;
if(empty($this->__userPriv) || is_null($this->__userPriv))
{
$this->__userPriv = 0; //if the site_id isn't overridden set it to the current site's id
}
$query = "SELECT * FROM _plugins WHERE priv_id = '".$this__userPriv."'";
$this->__DB->performQuery($query);
while ($row = $this->__DB->fetchObject())
{
$this->__count++;
$this->__pluginList['plugId'][]=$row->plugin_id; //add the current plug-in's ID to the plugin list
$this->__pluginList['plugName'][]=$row->plugin_name; //add the current plug-in's name to the plugin list
$this->__pluginList['plugDir'][]=$row->plugin_dir; //add the current plug-in's directory to the plugin list
$this->__pluginList['plugFile'][]=$row->plugin_file; //add the current plug-in's file to the plugin list
}
$this->load();
}
function load()
{
if(count($this->__pluginList) > 0)
{
for( $i=0; $i < $this->__count; $i++)
{
if(!file_exists($this->__pluginList['plugDir'][$i].$this->__pluginList['plugFile'][$i].".main.php"))
{
exit("The plug-in file: <b>".$this->__pluginList['plugDir'][$i].$this->__pluginList['plugFile'][$i].".php"."</b> Does not exist");
}
include($this->__pluginList['plugDir'][$i].$this->__pluginList['plugFile'][$i].".main.php");
}
}
}
}//
class Modules
{
var $__DB = FALSE;
var $__userPriv = 0;
var $__moduleList = array();
var $__count = 0;
function Modules(&$db,$userPriv="")
{
if(!is_object($db))
{
exit("Could not connect");
}
$this->__DB = &$db;
$this->__userPriv = $userPriv;
if(empty($this->__userPriv) || is_null($this->__userPriv))
{
$this->__userPriv = 0; //if the site_id isn't overridden set it to the current site's id
}
$query = "SELECT * FROM _modules WHERE priv_id = '".$this__userPriv."'";
$this->__DB->performQuery($query);
while ($row = $this->__DB->fetchObject())
{
$this->__count++;
$this->__moduleList['moduleId'][]=$row->module_id; //add the current plug-in's ID to the plugin list
$this->__moduleList['moduleName'][]=$row->module_name; //add the current plug-in's name to the plugin list
$this->__moduleList['moduleDir'][]=$row->module_dir; //add the current plug-in's directory to the plugin list
$this->__moduleList['moduleFile'][]=$row->module_file; //add the current plug-in's file to the plugin list
}
$this->load();
}
function load()
{
if(count($this->__moduleList) > 0)
{
for( $i=0; $i < $this->__count; $i++)
{
if(!file_exists($this->__moduleList['moduleDir'][$i].$this->__moduleList['moduleFile'][$i].".mod.php"))
{
exit("The plug-in file: <b>".$this->__moduleList['moduleDir'][$i].$this->__moduleList['moduleFile'][$i].".mod.php"."</b> Does not exist");
}
include($this->__moduleList['moduleDir'][$i].$this->__moduleList['moduleFile'][$i].".mod.php");
}
}
}
}//
?>
query apart
with the former I retrieve the main class file and include it
with the latter I retrieve for instance the file which instances the class .
In the index page I include this classes and a mysql abstraction library
and I instance it with
$db = new MySqlAbstract("localhost","user","pass","DB");
$plugins = new Plugins($db);
$modules = new Modules($db);
In the file I include (dynamic) there are an authentication class and his
instance but here is the trouble with the object ($db)
I use as parameters :
var_dump($db);
//it gives me NULL
$o = new Authentication($db);
but on the other hand if I use this simple
code no troubles !!!!!!!!!!!!!
include('plugins/authentication/authentication.main.php');
include('plugins/authentication/modules/getAuthentication.mod.php');
I don't understand why 😕
Could you help me ?
TKs