|
From: <jhe...@us...> - 2002-12-05 10:00:45
|
Update of /cvsroot/upcase-project/UpCase/admin
In directory sc8-pr-cvs1:/tmp/cvs-serv12921
Added Files:
pkg_configure.php pkg_install.php pkg_preinstall.php
pkg_uninstall.php
Log Message:
splitted big installer.php in smaller units
--- NEW FILE: pkg_configure.php ---
<?php
// input : pkgpath = relative path of the package
// tblprefix = tables prefix for the package
// session : get package = package to install
// set packageInstance = specialized instance of the package
// (with a path and a tables prefix)
// unset package
// output : array with config data created from package description file
include_once("../config/uc_config.inc");
include_once("lib/uc_utils.php");
include_once("lib/uc_repository.php");
include_once("lib/uc_installer.php");
include_once("lib/uc_page.php");
$p = new UcPage("installer");
$p->open();
$pkgPath = checkVar("pkgpath", false)
or die("No destination path defined");
$tblPrefix = checkVar("tblprefix", false)
or die("No tables prefix defined");
$pkg = $_SESSION["package"];
$inst = new UcInstaller();
include("config/uc_templates.inc");
$pkgInst = $inst->preinstall($package, $pkgPath, $tblPrefix);
$_SESSION["packageInstance"] = $pkgInst;
unset($_SESSION["package"]);
if ($pkgInst->supported == 0)
{
header("Location: " . $ucConfig->upcaseUrl . "/admin/pkg_install.php");
exit();
}
$inputs = $inst->getConfigInputs($pkgInst);
if ($inputs)
{
$tmpl = new ModeliXe($uc_tmpl["CONFIGURE"]);
$tmpl->SetModeliXe();
$tmpl->MxAttribut("installer",
$ucConfig->upcaseUrl . "/admin/pkg_install.php");
$tmpl->MxText("pkgname", $pkgInst->name);
foreach ($inputs as $inputVar => $inputInfo)
{
$tmpl->MxText("inputs.label", $inputInfo[2]);
if ($inputInfo[0] == "text")
{
$tmpl->MxBloc("inputs.enums", "delete");
$tmpl->MxBloc("inputs.booleans", "delete");
$tmpl->MxFormField("inputs.fields.field", "text",
$inputVar, $inputInfo[1]);
}
else if ($inputInfo[0] == "password")
{
$tmpl->MxBloc("inputs.enums", "delete");
$tmpl->MxBloc("inputs.booleans", "delete");
$tmpl->MxFormField("inputs.fields.field", "password",
$inputVar, "");
}
else if ($inputInfo[0] == "boolean")
{
$tmpl->MxBloc("inputs.fields", "delete");
$tmpl->MxBloc("inputs.enums", "delete");
$tmpl->MxCheckerField("inputs.booleans.boolean", "checkbox",
$inputVar, $inputInfo[1]);
}
else if ($inputInfo[0] == "enum")
{
$tmpl->MxBloc("inputs.fields", "delete");
$tmpl->MxBloc("inputs.booleans", "delete");
$tmpl->MxSelect("inputs.enums.enum", $inputVar, $inputInfo[1],
$inputInfo[3]);
}
$tmpl->MxBloc("inputs", "loop");
}
$tmpl->MxWrite();
}
else
{
header("Location: " . $ucConfig->upcaseUrl . "/admin/pkg_install.php");
}
?>
--- NEW FILE: pkg_install.php ---
<?php
// input : array of the data from the configure step (from the package file
// description)
// session : get packageInstance
// unset packageInstance
include_once("../config/uc_config.inc");
include_once("lib/uc_utils.php");
include_once("lib/uc_installer.php");
include_once("lib/uc_repository.php");
include_once("lib/uc_page.php");
$p = new UcPage("installer");
$p->open();
$inst = new UcInstaller();
include("config/uc_templates.inc");
$configData = array();
$pkgInst = $_SESSION["packageInstance"];
unset($_SESSION["packageInstance"]);
if ($pkgInst->supported == 1)
{
$configInputs = $inst->getConfigInputs($pkgInst);
if ($configInputs)
{
foreach (array_keys($configInputs) as $key)
{
if (checkVar($key, false))
{
$configData[$key] = checkVar($key);
}
}
}
}
$redirect = $inst->install($pkgInst, $configData);
header("Location: " . $redirect);
?>
--- NEW FILE: pkg_preinstall.php ---
<?php
// Ask the user a relative path for the package installation and a prefix
// for the tables.
// input : cat = name of the category
// pkg = name of the package
// to session : package = new package object
// output : pkgpath = relative path of the package
// tblprefix = talbes prefix for the package
include_once("../config/uc_config.inc");
include_once("lib/uc_utils.php");
include_once("lib/uc_repository.php");
include_once("lib/uc_installer.php");
include_once("lib/uc_page.php");
$p = new UcPage("installer");
$p->open();
$rep = new UcLocalRepository();
$inst = new UcInstaller();
// Check HTTP input vars
$catname = checkVarIn("cat", $rep->categories, false)
or die("Invalid category");
$category = $rep->getCategory($catname);
if (!$category)
die("Invalid category");
$pkgname = checkVarIn("pkg", $category->packages, false)
or die("Invalid package1");
$pkg = $category->getPackage($pkgname);
if (!$pkg)
die("Invalid package2");
$_SESSION["package"] = $pkg;
// don't use the include_once directive unless you want
// to always display this page in the default language
include("config/uc_templates.inc");
$tmpl = new ModeliXe($uc_tmpl["PREINSTALL"]);
$tmpl->SetModeliXe();
$tmpl->MxAttribut("configure",
$ucConfig->upcaseUrl . "/admin/pkg_configure.php");
$tmpl->MxText("siteurl", $ucConfig->siteUrl);
$tmpl->MxText("pkgname", $package->name);
$tmpl->MxWrite();
?>
--- NEW FILE: pkg_uninstall.php ---
<?php
include_once("../config/uc_config.inc");
include_once("uc_page.php");
include_once("uc_utils.php");
include_once("uc_accounts.php");
include_once("uc_installer.php");
$page = new UcPage("unInstall");
$page->open();
$packageId = checkVar("appid", false)
or die("No package id given");
$user = $page->session->getUser();
include("uc_templates.php");
$userName = checkVar("username", false);
$userPassword = checkVar("password", false);
if (!$userName || !$userPassword)
{
$tmpl = new ModeliXe($uc_tmpl["FORCE_LOGIN"]);
$tmpl->SetModeliXe();
$tmpl->MxHidden("params", "appid=$packageId");
$tmpl->MxWrite();
}
else
{
if ($userName != $user->name)
{
die("Go out !");
}
$accountMgr = new UcAccountManager($page->session->db);
if (!$accountMgr->checkUserPassword($userName, $userPassword))
{
die("Go out 2nd time !");
}
$inst = new UcInstaller();
$inst->unInstall($packageId);
header("Location: " . $ucConfig->upcaseUrl . "/admin/repository.php");
}
?>
|