From: <jhe...@us...> - 2002-11-28 14:27:27
|
Update of /cvsroot/upcase-project/UpCase/lib In directory sc8-pr-cvs1:/tmp/cvs-serv6468 Modified Files: uc_installer.php Log Message: big refactoring, added the possibility for a package to ask users input during installation. Index: uc_installer.php =================================================================== RCS file: /cvsroot/upcase-project/UpCase/lib/uc_installer.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** uc_installer.php 21 Nov 2002 15:16:13 -0000 1.7 --- uc_installer.php 28 Nov 2002 14:27:22 -0000 1.8 *************** *** 26,30 **** var $metaDataFile; ! function UcPackageInstance($name, $version, $path, $tblPrefix) { $cfg = $GLOBALS["ucConfig"]; --- 26,30 ---- var $metaDataFile; ! function UcPackageInstance($name, $version, $configData) { $cfg = $GLOBALS["ucConfig"]; *************** *** 38,44 **** $this->source = $source; $this->supported = $supported; ! $this->path = $path; ! $this->prefix = $tblPrefix; $this->tables = $tables; } --- 38,45 ---- $this->source = $source; $this->supported = $supported; ! $this->path = $configData["PACKAGE_PATH"]; $this->tables = $tables; + $this->prefix = $configData["TABLES_PREFIX"]; + $this->configData = $configData; } *************** *** 76,80 **** { $pkg = new UcPackageInstance($o->PKGNAME, $o->PKGVERSION, ! $o->PKGPATH, $o->TBLPREFIX); $pkg->setStatus($o->INSTALLED); $ret[] = $pkg; --- 77,82 ---- { $pkg = new UcPackageInstance($o->PKGNAME, $o->PKGVERSION, ! array("PACKAGE_PATH" => $o->PKGPATH, ! "TABLES_PREFIX" => $o->TBLPREFIX)); $pkg->setStatus($o->INSTALLED); $ret[] = $pkg; *************** *** 89,94 **** $dstFile = $this->metaBackup . "/" . $package->name . "-" . $package->version . ".inc"; ! if (!file_exists($dstFile)) ! copy($srcFile, $dstFile); } --- 91,95 ---- $dstFile = $this->metaBackup . "/" . $package->name . "-" . $package->version . ".inc"; ! copy($srcFile, $dstFile); } *************** *** 141,151 **** } ! function setupMySQL($package, $sqlPath, $tblPrefix) { ! if (!file_exists($sqlPath . MYSQL_QUERIES)) return false; ! $tblprefix = $tblPrefix . "_"; ! include($sqlPath . MYSQL_QUERIES); foreach($queries as $query) { --- 142,156 ---- } ! function setupMySQL($packageInstance) { ! $cfg = $GLOBALS["ucConfig"]; ! $sqlPath = $cfg->siteRoot . "/" . $packageInstance->path . "/" ! . MYSQL_QUERIES; ! ! if (!file_exists($sqlPath)) return false; ! $tblprefix = $packageInstance->prefix . "_"; ! include($sqlPath); foreach($queries as $query) { *************** *** 157,161 **** } ! function setupPackage($package, $relPath, $tblPrefix) { $cfg = $GLOBALS["ucConfig"]; --- 162,178 ---- } ! function getConfigInputs($package, $pkgPath) ! { ! $cfg = $GLOBALS["ucConfig"]; ! ! include_once($cfg->siteRoot . "/" ! . $pkgPath . PACKAGE_SETUP); ! if (!empty($config_input) || count($config_input) > 0) ! return $config_input; ! else ! return false; ! } ! ! function setupPackage($packageInstance) { $cfg = $GLOBALS["ucConfig"]; *************** *** 166,183 **** $dbinf->passwd = $cfg->dbPasswd; $dbinf->host = $cfg->dbHost; ! $dbinf->prefix = $tblPrefix . "_"; ! include_once($cfg->siteRoot . "/" . $relPath . PACKAGE_SETUP); ! setup($dbinf, $cfg->siteUrl . "/" . $relPath, ! $cfg->siteRoot . "/" .$relPath) or die("Unable to setup package"); return true; } ! function registerPackage($package, $relPath, $tblPrefix) { $query = sprintf($GLOBALS["ucsql_packageregister"], $package->name, $package->version, ! $relPath, $tblPrefix); $this->db->Execute($query) or die("Unable to register package: " . $this->db->ErrorMsg()); --- 183,200 ---- $dbinf->passwd = $cfg->dbPasswd; $dbinf->host = $cfg->dbHost; ! $dbinf->prefix = $packageInstance->prefix . "_"; ! include_once($cfg->siteRoot . "/" ! . $packageInstance->path . "/" . PACKAGE_SETUP); ! setup($dbinf, $cfg->siteUrl, $cfg->siteRoot, $packageInstance) or die("Unable to setup package"); return true; } ! function registerPackage($package, $destPath, $tblPrefix) { $query = sprintf($GLOBALS["ucsql_packageregister"], $package->name, $package->version, ! $destPath, $tblPrefix); $this->db->Execute($query) or die("Unable to register package: " . $this->db->ErrorMsg()); *************** *** 198,241 **** } ! function setInstallComplete($package, $relPath, $tblPrefix) { $query = sprintf($GLOBALS["ucsql_packageinstcomp"], ! $package->name, $package->version, ! $relPath, $tblPrefix); $this->db->Execute($query) or die("Unable to flag package as installed: " . $this->db->ErrorMsg()); } ! ! function install($package, $relPath, $tblPrefix) { $cfg = $GLOBALS["ucConfig"]; ! $pkgPath = $cfg->siteRoot . "/" . $relPath; ! $this->download($package) or die("Unable to get package archive"); ! $this->checkPathValidity($pkgPath) ! or die("Invalid URL"); ! $this->registerPackage($package, $relPath, $tblPrefix) ! or die("Unable to register package to be installed"); ! createDirectory($pkgPath) or die("Unable to create directory $pkgPath"); ! $this->unpack($package, $pkgPath) or die("Unable to unpack package"); if ($package->supported == 1) { ! $this->setupMySQL($package, $pkgPath, $tblPrefix) or die("Unable to set up MySQL"); ! $this->setupPackage($package, $relPath, $tblPrefix) or die("Unable to set up package"); ! $redirect = $cfg->siteUrl . "/" . $relPath; } else { ! $redirect = $cfg->siteUrl . "/" . $relPath ! . "/" . $package->setupScript ! . "?prefix=" . $tblPrefix; } ! $this->setInstallComplete($package, $relPath, $tblPrefix); return $redirect; } --- 215,265 ---- } ! function setInstallComplete($packageInstance) { $query = sprintf($GLOBALS["ucsql_packageinstcomp"], ! $packageInstance->name, $packageInstance->version, ! $packageInstance->path, $packageInstance->prefix); $this->db->Execute($query) or die("Unable to flag package as installed: " . $this->db->ErrorMsg()); } ! ! function preInstall($package, $destPath, $tblPrefix) { $cfg = $GLOBALS["ucConfig"]; ! $this->saveMetaData($package); $this->download($package) or die("Unable to get package archive"); ! $fullPath = $cfg->siteRoot . "/" .$destPath; ! $this->checkPathValidity($fullPath) ! or die("Invalid destination path"); ! $this->registerPackage($package, $destPath, $tblPrefix) ! or die("Unable to register package to be installed"); ! createDirectory($fullPath) or die("Unable to create directory $pkgPath"); ! $this->unpack($package, $fullPath) or die("Unable to unpack package"); + } + + function install($package, $configData) + { + $cfg = $GLOBALS["ucConfig"]; + $packageInstance = new UcPackageInstance($package->name, + $package->version, + $configData); if ($package->supported == 1) { ! $this->setupMySQL($packageInstance) or die("Unable to set up MySQL"); ! $this->setupPackage($packageInstance) or die("Unable to set up package"); ! $redirect = $cfg->siteUrl . "/" . $packageInstance->path; } else { ! $redirect = $cfg->siteUrl . "/" . $packageInstance->path ! . "/" . $package->setupScript; } ! $this->setInstallComplete($packageInstance); return $redirect; } |