Commit 2c64a8d1 authored by Mark Donohoe's avatar Mark Donohoe

Changes for fo-postinstall and friends.

fo-postinstall: added {$LIBEXECDIR} to invocations of fossinit and
fo_dbcheck.  Changed to call fossinit.php instead of fossinit.
Changed chgrp of Db.conf so it now works.  To get this to work added
PROJECTGROUP to fossology.conf.in.

Default user and fossy were not getting created in the db on an
install.  Issue was that code was removed from libschema that was
calling the install methods of every plugin.  This will not work in
fossinit as the plugins have not yet been loaded.  Core-auth's Install
method is where the default user and fossy get created.

Added function plugin_install to common-plugin, this is used in
index.php to call the install methods of all the plugins.  Modified index.php.

Removed adjustments for simple ui from core-auth.php, it was trying to
use simpleindex.php which is no longer available.

Added fo_dbcheck.php to svn.

Added installation of fo_dbcheck and fossinit to LIBEXECDIR in the
install/Makefile.  These modules should be there according to the
standard and where fo-postinstall expects them to be located.

Bob added -c paramater and it's processing to fossinit and refactored
some code.


git-svn-id: http://svn.code.sf.net/p/fossology/code/branches/fossology2.0/fossology@5150 a5643f74-2041-0410-a2b9-94ffef304a07
parent b53c2d19
......@@ -33,6 +33,8 @@ defconf/fossology.conf: defconf/fossology.conf-process
install: all
$(INSTALL_PROGRAM) fo-postinstall $(DESTDIR)$(LIBEXECDIR)/fo-postinstall
$(INSTALL_PROGRAM) fo_dbcheck.php $(DESTDIR)$(LIBEXECDIR)/fo_dbcheck.php
$(INSTALL_PROGRAM) fossinit.php $(DESTDIR)$(LIBEXECDIR)/fossinit.php
$(MAKE) -s -C db install
echo "Making configuration directories"; \
if [ ! -e $(DESTDIR)$(CONFPATH) ] ; then \
......
......@@ -36,10 +36,12 @@ localhost[] = * 00 ff
[DIRECTORIES]
; Project Name.
; Do not change after installation since PROJECT is used in installation directory names.
; Project Name and Group
; Do not change after installation since PROJECT and PROJECTGROUP is used in installation
; directory names and ownership.
; Use PREFIX to install multiple copies of FOSSology.
PROJECT={$PROJECT}
PROJECTGROUP={$PROJECTGROUP}
; base of the program data tree
PREFIX={$PREFIX}
......
#!/bin/bash
# FOSSology postinstall script
# Copyright (C) 2008 Hewlett-Packard Development Company, L.P.
# Copyright (C) 2008-2011 Hewlett-Packard Development Company, L.P.
#
# This script is for things that need to be done on the runtime system
# after we've installed the bits on the filesystem. It needs to be
......@@ -35,17 +35,17 @@ while true; do
-o|--overwrite) OVERWRITE=1; shift;;
-h|--help)
echo "Usage: fo-postinstall [options]";
echo " -a or --agent : agent specific actions"
echo " -d or --database : database specific actions"
echo " -w or --web : web interface specific actions"
echo " -s or --scheduler : scheduler specific actions"
echo " -e or --everything : all actions (default)"
echo " -o or --overwrite : overwrite config files with new versions"
echo " -h or --help : this help text"
echo " -a or --agent : agent specific actions"
echo " -d or --database : Create the FOSSology database"
echo " -w or --web : web interface specific actions"
echo " -s or --scheduler : scheduler specific actions"
echo " -e or --everything : all actions, default"
echo " -o or --overwrite : overwrite config files with new versions"
echo " -h or --help : this help text"
echo " Special options"
echo " --web-only : web, but exclude normal agent actions"
echo " --scheduler-only : scheduler, but exclude normal agent actions"
exit;;
exit;;
--) shift; break;;
*) echo "Error: option $1 not recognised"; exit 1;;
esac
......@@ -80,6 +80,9 @@ fi
if [ $DATABASE ]; then
{$LIBEXECDIR}/dbcreate
echo "*** Initializing database tables ***"
{$LIBEXECDIR}/fossinit.php -c {$SYSCONFDIR}
fi # end of DATABASE
########################################################################
......@@ -87,14 +90,14 @@ fi # end of DATABASE
if [ $AGENT ]; then
## get path to repo
if [ -e "{$SYSCONFDIR}/fossology/fossology.conf" ] ; then
if [ -e "{$SYSCONFDIR}/fossology.conf" ] ; then
while read line; do
if [[ $line =~ "path = " ]]; then
REPO=$\{line//'path = '/\}
fi
done < '{$SYSCONFDIR}/fossology/fossology.conf'
done < '{$SYSCONFDIR}/fossology.conf'
else
echo "ERROR: Cannot find {$SYSCONFDIR}/fossology/fossology.conf"
echo "ERROR: Cannot find {$SYSCONFDIR}/fossology.conf"
exit 1
fi
......@@ -179,60 +182,16 @@ if [ $AGENT ]; then
echo "NOTE: Repository already exists at $REPO"
fi
# ununpack before svn 1715 created it's directory with wrong permissions
# if the directory already exists ensure that it's permissions are correct
# this can be removed in the next release after 1.0.0, assuming we will
# require pre-1.0.0 users to upgrade to 1.0.0 first
if [ -d "$REPO/ununpack" ]; then
chmod 2770 $REPO/ununpack
fi
if [ -e "{$SYSCONFDIR}/fossology/Hosts.conf" ] ; then
# if we have a default Hosts.conf file, check if $REPO/localhost
# exists and if not then create it
grep -q "^localhost" {$SYSCONFDIR}/fossology/Hosts.conf
if [ $? == 0 ] ; then
if [ ! -d "$REPO/localhost" ] ; then
echo "NOTE: creating new $REPO/localhost directory"
mkdir $REPO/localhost
chown {$PROJECTUSER}:{$PROJECTGROUP} $REPO/localhost
chmod 2770 $REPO/localhost
else
echo "NOTE: $REPO/localhost directory already exists"
fi
fi
else
# if we don't have a default Hosts.conf file then it's a
# multi-machine install and the end user needs to setup
echo "NOTE: Hosts.conf indicates a multi-machine install. Please"
echo " make sure that the corresponding agents directories exist"
echo " in $REPO and are {$PROJECTUSER}:{$PROJECTGROUP} and 2770."
fi
## check that the db is accessable
echo "*** Checking database connectivity ***"
DBCONF="{$SYSCONFDIR}/fossology/Db.conf"
if [ ! -f $DBCONF ]; then
echo "ERROR: missing $DBCONF, cannot proceed."
fi
# make install sets Db.conf's mode to 660, but can't chgrp it because
# the group doesn't exist until we create it above. So chgrp now
chgrp {$PROJECTGROUP} $DBCONF || echo "ERROR: failed to chgrp $DBCONF"
chgrp {$PROJECTGROUP} {$SYSCONFDIR}/Db.conf || echo "ERROR: failed to chgrp {$SYSCONFDIR}/Db.conf"
## Check DataBase Connectivity, initialize the tables, License.bsam, and other
## setup done by fossinit
# In multi-system installs the database machine must be installed first
# in order for this to work on other machines.
echo "*** Initializing database tables ***"
{$BINDIR}/fossinit
{$LIBEXECDIR}/fo_dbcheck.php -c {$SYSCONFDIR}
if [ $? != 0 ] ; then
if [ $? = 2 ] ; then
echo "ERROR: unable to connect to database, please check {$SYSCONFDIR}/Db.conf"
fi
echo "ERROR: Unable to initialize."
echo "FATAL: unable to connect to database, please check {$SYSCONFDIR}/Db.conf"
exit 1
fi
echo "Database connectivity is good."
fi # end of AGENT
......@@ -241,23 +200,6 @@ fi # end of AGENT
if [ $SCHEDULERONLY ]; then
echo "*** Setting up scheduler ***"
# scheduler config file
# this has to be done after the database is setup
# BTW- mkschedconf seems to be hardcoded to use localhost, if that
# is ever fixed this code might need to be too
#echo "*** Checking Scheduler.conf ***"
#SCHEDCONF={$SYSCONFDIR}/fossology/Scheduler.conf
#if [ ! -f "$SCHEDCONF" -o "$OVERWRITE" ] ; then
# mkdir -p `dirname $SCHEDCONF`
# {$LIBEXECDIR}/mkschedconf -o $SCHEDCONF -L
# echo "NOTE: default $SCHEDCONF created."
# echo " Please check that is it correct for your environment or"
# echo " create a different one with mkschedconf."
#else
# echo "NOTE: $SCHEDCONF already exists,"
# echo " consider checking it or recreating with mkschedconf."
#fi
# Create the scheduler log directory.
if [ -f {$LOGDIR} ] ; then
# Must be a directory and not a file
......
#!/usr/bin/php
<?php
/***********************************************************
Copyright (C) 2011 Hewlett-Packard Development Company, L.P.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.
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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
***********************************************************/
/**
* @file fo_dbcheck.php
* @brief Check that you can connect to the db.
*
* @exit 0 for success, 1 for failure.
**/
/* Initialize the program configuration variables */
$SysConf = array(); // fo system configuration variables
$PG_CONN = 0; // Database connection
$Plugins = array();
/* Note: php 5 getopt() ignores options not specified in the function call, so add
* dummy options in order to catch invalid options.
*/
$AllPossibleOpts = "abc:defghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
/* defaults */
$Verbose = false;
$DatabaseName = "fossology";
$UpdateLiceneseRef = false;
$sysconfdir = '';
/* command-line options */
$Options = getopt($AllPossibleOpts);
foreach($Options as $Option => $OptVal)
{
switch($Option)
{
case 'c': /* set SYSCONFIDR */
$sysconfdir = $OptVal;
break;
default:
echo "Invalid Option \"$Option\".\n";
Usage();
}
}
/* Set SYSCONFDIR and set global (for backward compatibility) */
$SysConf = bootstrap($sysconfdir);
/* Initialize global system configuration variables $SysConfig[] */
ConfigInit($SYSCONFDIR, $SysConf);
$rv = DBconnect($sysconfdir, "", false);
if ($rv === false) exit(1);
exit(0);
/** \brief Print Usage statement.
* \return No return, this calls exit.
**/
function Usage()
{
global $argv;
$usage = "Usage: " . basename($argv[0]) . " [options]
Update FOSSology database. Options are:
-c fossology system configuration directory
-h this help usage";
print "$usage\n";
exit(0);
}
/************************************************/
/****** From src/lib/php/bootstrap.php ********/
/** Included here so that fossinit can run from any directory **/
/**
* \brief Bootstrap the fossology php library.
* - Determine SYSCONFDIR
* - parse fossology.conf
* - source template (require_once template-plugin.php)
* - source common files (require_once common.php)
*
* The following precedence is used to resolve SYSCONFDIR:
* - $SYSCONFDIR path passed in ($sysconfdir)
* - environment variable SYSCONFDIR
* - ./fossology.rc
*
* Any errors are fatal. A text message will be printed followed by an exit(1)
*
* \param $sysconfdir Typically from the caller's -c command line parameter
*
* \return the $SysConf array of values. The first array dimension
* is the group, the second is the variable name.
* For example:
* - $SysConf[DIRECTORIES][MODDIR] => "/mymoduledir/
*
* The global $SYSCONFDIR is also set for backward compatibility.
*
* \Note Since so many files expect directory paths that used to be in pathinclude.php
* to be global, this function will define the same globals (everything in the
* DIRECTORIES section of fossology.conf).
*/
function bootstrap($sysconfdir="")
{
$rcfile = "fossology.rc";
if (empty($sysconfdir))
{
$sysconfdir = getenv('SYSCONFDIR');
if ($sysconfdir === false)
{
if (file_exists($rcfile)) $sysconfdir = file_get_contents($rcfile);
if ($sysconfdir === false)
{
/* NO SYSCONFDIR specified */
$text = _("FATAL! System Configuration Error, no SYSCONFDIR.");
echo "$text\n";
exit(1);
}
}
}
$sysconfdir = trim($sysconfdir);
$GLOBALS['SYSCONFDIR'] = $sysconfdir;
/************* Parse fossology.conf *******************/
$ConfFile = "{$sysconfdir}/fossology.conf";
if (!file_exists($ConfFile))
{
$text = _("FATAL! Missing configuration file: $ConfFile");
echo "$text\n";
exit(1);
}
$SysConf = parse_ini_file($ConfFile, true);
if ($SysConf === false)
{
$text = _("FATAL! Invalid configuration file: $ConfFile");
echo "$text\n";
exit(1);
}
/* evaluate all the DIRECTORIES group for variable substitutions.
* For example, if PREFIX=/usr/local and BINDIR=$PREFIX/bin, we
* want BINDIR=/usr/local/bin
*/
foreach($SysConf['DIRECTORIES'] as $var=>$assign)
{
/* Evaluate the individual variables because they may be referenced
* in subsequent assignments.
*/
$toeval = "\$$var = \"$assign\";";
eval($toeval);
/* now reassign the array value with the evaluated result */
$SysConf['DIRECTORIES'][$var] = ${$var};
$GLOBALS[$var] = ${$var};
}
if (empty($MODDIR))
{
$text = _("FATAL! System initialization failure: MODDIR not defined in $SysConf");
echo $text. "\n";
exit(1);
}
//require("i18n.php"); DISABLED until i18n infrastructure is set-up.
require_once("$MODDIR/www/ui/template/template-plugin.php");
require_once("$MODDIR/lib/php/common.php");
return $SysConf;
}
?>
......@@ -23,7 +23,7 @@
* must exist) and updates the license_ref table.
*
* This should be used immediately after an install or update.
*
*
* @return 0 for success, 1 for failure.
**/
......@@ -42,23 +42,16 @@ $SysConf = array(); // fo system configuration variables
$PG_CONN = 0; // Database connection
$Plugins = array();
/* Set SYSCONFDIR and set global (for backward compatibility) */
$SysConf = bootstrap();
require_once("$MODDIR/lib/php/libschema.php");
/* Initialize global system configuration variables $SysConfig[] */
ConfigInit($SYSCONFDIR, $SysConf);
/* Note: php 5 getopt() ignores options not specified in the function call, so add
* dummy options in order to catch invalid options.
*/
$AllPossibleOpts = "abcd:ef:ghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$AllPossibleOpts = "abc:d:ef:ghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
/* defaults */
$Verbose = false;
$DatabaseName = "fossology";
$UpdateLiceneseRef = false;
$SchemaFilePath = "$MODDIR/www/ui/core-schema.dat";
$sysconfdir = '';
/* command-line options */
$Options = getopt($AllPossibleOpts);
......@@ -66,6 +59,9 @@ foreach($Options as $Option => $OptVal)
{
switch($Option)
{
case 'c': /* set SYSCONFIDR */
$sysconfdir = $OptVal;
break;
case 'd': /* optional database name */
$DatabaseName = $OptVal;
break;
......@@ -86,6 +82,17 @@ foreach($Options as $Option => $OptVal)
}
}
/* Set SYSCONFDIR and set global (for backward compatibility) */
$SysConf = bootstrap($sysconfdir);
require_once("$MODDIR/lib/php/libschema.php");
// don't think we want all the other common libs
require_once("$MODDIR/lib/php/common.php");
/* Initialize global system configuration variables $SysConfig[] */
ConfigInit($SYSCONFDIR, $SysConf);
if (empty($SchemaFilePath)) $SchemaFilePath = "$MODDIR/www/ui/core-schema.dat";
if (!file_exists($SchemaFilePath))
{
print "FAILED: Schema data file ($SchemaFilePath) not found.\n";
......@@ -135,6 +142,7 @@ function Usage()
$usage = "Usage: " . basename($argv[0]) . " [options]
Update FOSSology database. Options are:
-c path to fossology configuration files
-d {database name} default is 'fossology'
-f {file} update the schema with file generaged by schema-export.php
-l update the license_ref table with fossology supplied licenses
......@@ -144,93 +152,6 @@ function Usage()
exit(0);
}
/************************************************/
/****** From src/lib/php/bootstrap.php ********/
/** Included here so that fossinit can run from any directory **/
/**
* \file bootstrap.php
* \brief Fossology system bootstrap
* This file may be DUPLICATED in any php utility that needs to
* bootstrap itself.
*/
/**
* \brief Bootstrap the fossology php library.
* - Determine SYSCONFDIR
* - parse fossology.conf
* - source template (require_once template-plugin.php)
* - source common files (require_once common.php)
*
* The following precedence is used to resolve SYSCONFDIR:
* - $SYSCONFDIR path passed in
* - environment variable SYSCONFDIR
* - ./fossology.rc
*
* \return the $SysConf array of values. The first array dimension
* is the group, the second is the variable name.
* For example:
* - $SysConf[DIRECTORIES][MODDIR] => "/mymoduledir/
*
* The global $SYSCONFDIR is also set for backward compatibility.
*
* \Note Since so many files expect directory paths that used to be in pathinclude.php
* to be global, this function will define the same globals (everything in the
* DIRECTORIES section of fossology.conf).
*/
function bootstrap()
{
$rcfile = "fossology.rc";
$sysconfdir = getenv('SYSCONFDIR');
if ($sysconfdir === false)
{
if (file_exists($rcfile)) $sysconfdir = file_get_contents($rcfile);
if ($sysconfdir === false)
{
/* NO SYSCONFDIR specified */
$text = _("FATAL: System Configuration Error, no SYSCONFDIR.");
echo "<hr><h3>$text</h3><hr>";
exit(1);
}
}
$sysconfdir = trim($sysconfdir);
$GLOBALS['SYSCONFDIR'] = $sysconfdir;
/************* Parse fossology.conf *******************/
$ConfFile = "{$sysconfdir}/fossology.conf";
$SysConf = parse_ini_file($ConfFile, true);
/* evaluate all the DIRECTORIES group for variable substitutions.
* For example, if PREFIX=/usr/local and BINDIR=$PREFIX/bin, we
* want BINDIR=/usr/local/bin
*/
foreach($SysConf['DIRECTORIES'] as $var=>$assign)
{
/* Evaluate the individual variables because they may be referenced
* in subsequent assignments.
*/
$toeval = "\$$var = \"$assign\";";
eval($toeval);
/* now reassign the array value with the evaluated result */
$SysConf['DIRECTORIES'][$var] = ${$var};
$GLOBALS[$var] = ${$var};
}
if (empty($MODDIR))
{
$text = _("FATAL: System initialization failure: MODDIR not defined in fossology.conf");
echo $text. "\n";
exit;
}
//require("i18n.php"); DISABLED until i18n infrastructure is set-up.
require_once("$MODDIR/www/ui/template/template-plugin.php");
require_once("$MODDIR/lib/php/common.php");
return $SysConf;
}
/**
* \brief Load the license_ref table with licenses.
*
......@@ -302,4 +223,103 @@ function initLicenseRefTable($Verbose)
}
return (0);
} // initLicenseRefTable()
/************************************************/
/****** From src/lib/php/bootstrap.php ********/
/** Included here so that fossinit can run from any directory **/
/**
* \brief Bootstrap the fossology php library.
* - Determine SYSCONFDIR
* - parse fossology.conf
* - source template (require_once template-plugin.php)
* - source common files (require_once common.php)
*
* The following precedence is used to resolve SYSCONFDIR:
* - $SYSCONFDIR path passed in ($sysconfdir)
* - environment variable SYSCONFDIR
* - ./fossology.rc
*
* Any errors are fatal. A text message will be printed followed by an exit(1)
*
* \param $sysconfdir Typically from the caller's -c command line parameter
*
* \return the $SysConf array of values. The first array dimension
* is the group, the second is the variable name.
* For example:
* - $SysConf[DIRECTORIES][MODDIR] => "/mymoduledir/
*
* The global $SYSCONFDIR is also set for backward compatibility.
*
* \Note Since so many files expect directory paths that used to be in pathinclude.php
* to be global, this function will define the same globals (everything in the
* DIRECTORIES section of fossology.conf).
*/
function bootstrap($sysconfdir="")
{
$rcfile = "fossology.rc";
if (empty($sysconfdir))
{
$sysconfdir = getenv('SYSCONFDIR');
if ($sysconfdir === false)
{
if (file_exists($rcfile)) $sysconfdir = file_get_contents($rcfile);
if ($sysconfdir === false)
{
/* NO SYSCONFDIR specified */
$text = _("FATAL! System Configuration Error, no SYSCONFDIR.");
echo "$text\n";
exit(1);
}
}
}
$sysconfdir = trim($sysconfdir);
$GLOBALS['SYSCONFDIR'] = $sysconfdir;
/************* Parse fossology.conf *******************/
$ConfFile = "{$sysconfdir}/fossology.conf";
if (!file_exists($ConfFile))
{
$text = _("FATAL! Missing configuration file: $ConfFile");
echo "$text\n";
exit(1);
}
$SysConf = parse_ini_file($ConfFile, true);
if ($SysConf === false)
{
$text = _("FATAL! Invalid configuration file: $ConfFile");
echo "$text\n";
exit(1);
}
/* evaluate all the DIRECTORIES group for variable substitutions.
* For example, if PREFIX=/usr/local and BINDIR=$PREFIX/bin, we
* want BINDIR=/usr/local/bin
*/
foreach($SysConf['DIRECTORIES'] as $var=>$assign)
{
/* Evaluate the individual variables because they may be referenced
* in subsequent assignments.
*/
$toeval = "\$$var = \"$assign\";";
eval($toeval);
/* now reassign the array value with the evaluated result */
$SysConf['DIRECTORIES'][$var] = ${$var};
$GLOBALS[$var] = ${$var};
}
if (empty($MODDIR))
{
$text = _("FATAL! System initialization failure: MODDIR not defined in $SysConf");
echo $text. "\n";
exit(1);
}
//require("i18n.php"); DISABLED until i18n infrastructure is set-up.
require_once("$MODDIR/www/ui/template/template-plugin.php");
require_once("$MODDIR/lib/php/common.php");
return $SysConf;
}
?>
......@@ -14,7 +14,7 @@
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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
***********************************************************/
***********************************************************/
/**
* \file common-plugin.php
......@@ -27,48 +27,48 @@
$Plugins = array();
/**
\brief Sort compare function. Sorts by dependency
relationship. If a and b are at the same
dependency level, then sort by the plugin level.
\brief Sort compare function. Sorts by dependency
relationship. If a and b are at the same
dependency level, then sort by the plugin level.
\param Plugin a
\param Plugin b
\param Plugin a
\param Plugin b
\return -1, 0, 1 for plugin a being <, =, or > than b
\return -1, 0, 1 for plugin a being <, =, or > than b
**/
function plugin_cmp($a,$b)
{
/* Sort by plugin version only when the name is the same */
$rc = strcmp($a->Name,$b->Name);
if ($rc == 0)
{
{
/* Sort by plugin version (descending order) */
$rc = strcmp($a->Version,$b->Version);
if ($rc != 0) { return(-$rc); }
}
}
/* Sort by dependencies. */
/* check if $a is a dependency for $b */
// print "BEGIN Comparing $a->Name with $b->Name\n";
foreach($a->Dependency as $val)
{
{
// print "Comparing $a->Name :: $val with $b->Name\n";
if ($val == $b->Name) { return(1); }
}
}
/* check if $b is a dependency for $a */
foreach($b->Dependency as $val)
{
{
// print "Comparing $b->Name :: $val with $a->Name\n";
if ($val == $a->Name) { return(-1); }
}
}
// print "STILL Comparing $a->Name with $b->Name\n";
/* If same dependencies, then sort by plugin level (highest comes first) */
if ($a->PluginLevel != $b->PluginLevel)
{
{
if ($a->PluginLevel > $b->PluginLevel) { return(-1); }
else { return(1); }
}
}
/* Nothing else to sort by -- sort by number of dependencies */
$rc = count($a->Dependency) - count($b->Dependency);
......@@ -84,9 +84,9 @@ function plugin_cmp($a,$b)
function plugin_disable($Level)
{
global $Plugins;
if(empty($Level)) return(0);
/* Disable all plugins with >= $Level access */
//echo "<pre>COMP: starting to disable plugins\n</pre>";
$LoginFlag = empty($_SESSION['User']);
......@@ -117,86 +117,86 @@ function plugin_sort()
global $Plugins;
/* Ideally, I would like to use usort. However, there are
dependency issues. Specifically: usort only works where there are
direct comparisons. It does not work with indirect dependencies.
For example:
A depends on B (A->B).
B depends on C (B->C).
If I just use usort, then C may be sorted AFTER A since there is
no explicit link from A->C. The array (B,A,C) is a possible usort
return, and it is wrong.
Before I can sort, we must fill out the dependency arrays.
dependency issues. Specifically: usort only works where there are
direct comparisons. It does not work with indirect dependencies.
For example:
A depends on B (A->B).
B depends on C (B->C).
If I just use usort, then C may be sorted AFTER A since there is
no explicit link from A->C. The array (B,A,C) is a possible usort
return, and it is wrong.
Before I can sort, we must fill out the dependency arrays.
*/
/* for each plugin, store the dependencies in a matrix */
$DepArray=array();
for($i=0; $i < count($Plugins); $i++)
{
{
$P = &$Plugins[$i];
if (empty($P->Dependency[0])) continue; // ignore no dependencies
$DepArray[$P->Name] = array();
$D = &$DepArray[$P->Name];
for($j=0; $j < count($P->Dependency); $j++)
{
{
$D[$P->Dependency[$j]] = $P->PluginLevel;
}
}
}
/* Now iterate through the array.
This converts implied dependencies into direct dependencies. */
This converts implied dependencies into direct dependencies. */
foreach($DepArray as $A => $a)