From: Philippe M. <phi...@us...> - 2001-10-11 07:53:51
|
Update of /cvsroot/squirrelmail/sm2-api In directory usw-pr-cvs1:/tmp/cvs-serv25527 Modified Files: ZkConstants.php ZkLoader.php Log Message: Captain Partridge reporting: * Testing auth module now works. * Some cosmethic changes in the code. * Beware of the return-fields. Index: ZkConstants.php =================================================================== RCS file: /cvsroot/squirrelmail/sm2-api/ZkConstants.php,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -r1.1 -r1.2 --- ZkConstants.php 2001/09/08 02:10:03 1.1 +++ ZkConstants.php 2001/10/11 07:53:47 1.2 @@ -15,6 +15,7 @@ * Adapted from apache log level values found on: * http://www.administeringapache.com/Figures/loglevel.php3 */ + define('ZKLOG_DEBUG', 0); /* Debug-level messages */ define('ZKLOG_INFO', 1); /* Informational */ define('ZKLOG_UNKNOWN', 2); /* Error level unknown */ Index: ZkLoader.php =================================================================== RCS file: /cvsroot/squirrelmail/sm2-api/ZkLoader.php,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -r1.6 -r1.7 --- ZkLoader.php 2001/10/10 16:51:32 1.6 +++ ZkLoader.php 2001/10/11 07:53:47 1.7 @@ -40,21 +40,20 @@ /** * Attempt to load the requested service. * - * @param string $username username with which to authenticate - * @param string $password password with which to authenticate - * @return bool indicates correct or incorrect password + * @param string $svcname + * @param string $options + * @param string $modname + * + * @return bool/string */ function &loadService($svcname, $options, $modname = '') { $svcfile = "$this->libhome/$svcname/load.php"; $svcfunc = "zkload_$svcname"; $svcclass = "ZkSvc_$svcname"; + $ret = FALSE; /* Do some checks on the service name, then load the service file. */ - if (!zkCheckName($svcname)) { - return (false); - } else if (!file_exists($svcfile)) { - return (false); - } else { + if( zkCheckName($svcname) && file_exists($svcfile) ) { require_once($svcfile); $code_preload = "\$svcfile_result = $svcfunc('$this->zkhome');"; @@ -62,10 +61,7 @@ eval($code_preload); /* Evaluate the result. */ - if (!$svcfile_result) { - return (false); - } - } + if ($svcfile_result) { /* Run the service load code string. */ $code_loadservice = "\$service = new $svcclass(\$options);"; @@ -75,9 +71,11 @@ if ($modname != '') { $this->loadModule($service, $options, $modname); } - + $ret = $service; + } + } /* Return the newly created Zookeeper service. */ - return ($service); + return ($ret); } /** @@ -85,21 +83,21 @@ * * @param object $service service to which to add the new module * @param array $options array of options for the module + * @param string $modname module name + * + * @return bool TRUE if succesfully loaded or FALSE if not */ function loadModule(&$service, $options, $modname) { + $svcname = $service->getServiceName(); $modfile = "$this->modhome/$svcname/$modname.php"; $modclass = "ZkMod_$svcname" . "_$modname"; + $ret = FALSE; /* Do some checks on the module name, then load the module file. */ - if (!zkCheckName($modname)) { - return (false); - } else if (!file_exists($modfile)) { - return (false); - } else { + if( zkCheckName($modname) && file_exists($modfile) ) { require_once($modfile); - } - + $ret = TRUE; /* Run the module load code string. */ $code_loadmodule = "\$module = new $modclass(\$options);"; eval($code_loadmodule); @@ -114,6 +112,8 @@ /* Load the newly created module into this service. */ $service->loadModule($module, $options); } + return( $ret ); + } } ?> |