First step in integrating application setup with core setup.

What was in setup/index.php is now in setup/inc/core_setup.inc.php
This commit is contained in:
sjb4891 2000-11-06 03:22:52 +00:00
parent 75d5efa114
commit 7b1d3ff865
2 changed files with 545 additions and 217 deletions

View File

@ -0,0 +1,225 @@
<?php
/**************************************************************************\
* phpGroupWare - Core Setup *
* http://www.phpgroupware.org *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
* -------------------------------------------- *
* This file handles the setup for the core of phpGroupWare, *
* it DOES NOT currently follow the Setup class' model because it wants *
* to interct with the user. This will be fixed at some point in the *
* (hopefully) near future. *
* An upgrade or install of the core will _always_ happen before *
* any of the additional applications are dealt with. *
* *
\**************************************************************************/
/* $Id$ */
// $ok is chacked after including this file,
// if false then no additional work is performed.
// if true, ../index.php falls through to app setup
$ok = true;
if (!isset($oldversion)){
@$db->query("select app_version from applications where app_name='admin'");
@$db->next_record();
$oldversion = $db->f("app_version");
}
if (PHP_VERSION < "3.0.16") {
echo "You appear to be running an old version of PHP. It its recommend that you upgrade "
. "to a new version. Older version of PHP might not run phpGroupWare correctly, if at all.";
}
/* Database setup */
switch($action){
case "regularversion":
echo "<html><head><title>phpGroupWare Setup</title></head>\n";
echo "<body bgcolor='#ffffff'>\n";
echo "<table border=\"0\" align=\"center\">\n";
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Analysis</b></font></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>You appear to be running version $oldversion of phpGroupWare.<br>\n";
echo " We will automaticly update your tables/records to ".$phpgw_info["server"]["version"].", but we highly recommend backing up your tables incase the script causes damage to your data.\n";
echo " These automated scripts can easily destroy your data. Please backup before going any further!</td>\n";
echo " </tr>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>";
echo " <form method=\"POST\" action=\"$PHP_SELF\">\n";
echo " <input type=\"hidden\" name=\"oldversion\" value=\"".$oldversion."\">\n";
echo " <input type=\"hidden\" name=\"useglobalconfigsettings\">\n";
echo " <input type=\"submit\" name=\"action\" value=\"Upgrade\">\n";
echo " <input type=\"submit\" name=\"action\" value=\"Delete my old tables\">\n";
echo " </form>\n";
echo " <form method=\"POST\" action=\"config.php\">\n";
echo " <input type=\"submit\" name=\"action\" value=\"Dont touch my data\">\n";
echo " </form>\n";
echo " </td>";
echo " </tr>\n";
echo "</table>\n";
echo "</body></html>\n";
// Prevent app setup from running
$ok = false;
break;
case "prebetaversion":
echo "<html><head><title>phpGroupWare Setup</title></head>\n";
echo "<body bgcolor='#ffffff'>\n";
echo "<body bgcolor='#ffffff'>\n";
echo "<table border=\"0\" align=\"center\">\n";
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Analysis</b></font></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>You appear to be running a pre-beta version of phpGroupWare<br>\n";
echo " We are providing an automated upgrade system, but we highly recommend backing up your tables incase the script causes damage to your data.<br>\n";
echo " These automated scripts can easily destroy your data. Please backup before going any further!</td>\n";
echo " </tr>\n";
echo "</table>\n";
?>
<form method="POST" action="<?php $PHP_SELF?>">
<table border="0" align="center">
<tr bgcolor="486591">
<td colspan="2"><font color="fefefe">&nbsp;<b>Upgrade information</b></font></td>
</tr>
<tr bgcolor="e6e6e6">
<td>Select your old version:</td>
<td>
<select name="oldversion">
<option value="7122000">7122000</option>
<option value="8032000">8032000</option>
<option value="8072000">8072000</option>
<option value="8212000">8212000</option>
<option value="9052000">9052000</option>
<option value="9072000">9072000</option>
<option value="9262000">9262000</option>
<option value="0_9_1">0.9.1</option>
<option value="0_9_2">0.9.2</option>
</select>
</td>
</tr>
<tr bgcolor="e6e6e6">
<td>Port old globalconfig settings.</td>
<td><input type="checkbox" name="useglobalconfigsettings"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="action" value="Upgrade"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="action" value="Delete my old tables"></td>
</tr>
</table>
</form>
<?php
// Prevent app setup from running
$ok = false;
break;
case "Delete my old tables":
echo "<html><head><title>phpGroupWare Setup</title></head>\n";
echo "<body bgcolor='#ffffff'>\n";
echo "<table border=\"0\" align=\"center\">\n";
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Information</b></font></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>At your request, this script is going to take the evil action of deleting your existing tables and re-creating them in the new format.</td>\n";
echo " </tr>\n";
$db->Halt_On_Error = "report";
$currentver = "drop";
include ("../sql/common_main.inc.php");
$db->Halt_On_Error = "no";
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Status</b></font></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>If you did not recieve any serious errors, your tables have been created.</td>\n";
echo " </tr>\n";
echo "</table>\n";
break;
case "Upgrade":
echo "<html><head><title>phpGroupWare Setup</title></head>\n";
echo "<body bgcolor='#ffffff'>\n";
echo "<table border=\"0\" align=\"center\">\n";
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Information</b></font></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>At your request, this script is going to attempt to upgrade your old tables to the new format.</td>\n";
echo " </tr>\n";
echo "</table>\n";
$currentver = $oldversion;
$db->Halt_On_Error = "report";
include ("../sql/common_main.inc.php");
$db->Halt_On_Error = "no";
echo "<table border=\"0\" align=\"center\">\n";
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Status</b></font></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>If you did not recieve any serious errors, your tables *should* have been ";
echo " updated (no warranty on data integrity).</td>\n";
echo " </tr>\n";
echo "</table>\n";
break;
default:
if (isset($oldversion)){
if ($phpgw_info["server"]["version"] != $oldversion){
Header("Location: $PHP_SELF?action=regularversion");
$ok = false;
}
}else{
@$db->query("select * from config");
if (@$db->num_rows() == 0){
@$db->query("select * from accounts");
if (@$db->num_rows() == 0){
echo "<html><head><title>phpGroupWare Setup</title></head>\n";
echo "<body bgcolor='#ffffff'>\n";
echo "<table border=\"0\" align=\"center\">\n";
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Analysis</b></font></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>You appear to be running a new install of phpGroupWare, so the tables will be created for you.</td>\n";
echo " </tr>\n";
$db->Halt_On_Error = "report";
$currentver = "new";
include ("../sql/common_main.inc.php");
$db->Halt_On_Error = "no";
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Status</b></font></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>If you did not recieve any errors, your tables have been created.<br>\n";
echo " </tr>\n";
echo "</table>\n";
}else{
Header("Location: $PHP_SELF?action=prebetaversion");
$ok = false;
}
}else{
echo "<table border=\"0\" align=\"center\">\n";
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b> phpGroupware Core Analysis</b></font></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>Your database seems to be current.</td>\n";
echo " </tr>\n";
echo "</table>\n";
}
}
}
if (!$ok) {
echo "</body></html>";
}
// Leave php close tag off, don't want to mess up later Header() calls

View File

@ -1,6 +1,6 @@
<?php
/**************************************************************************\
* phpGroupWare - Setup *
* phpGroupWare *
* http://www.phpgroupware.org *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
@ -13,240 +13,343 @@
$phpgw_info["flags"] = array("noheader" => True, "nonavbar" => True, "currentapp" => "home", "noapi" => True);
include("../header.inc.php");
include("../version.inc.php"); // To set the current core version
$phpgw_info["server"]["api_dir"] = $phpgw_info["server"]["include_root"]."/phpgwapi";
// Authorize the user to use setup app
include("inc/setup_auth.inc.php");
// Does not return unless user is authorized
/* Database setup */
include($phpgw_info["server"]["api_dir"] . "/phpgw_db_".$phpgw_info["server"]["db_type"].".inc.php");
switch($phpgw_info["server"]["db_type"]){
case "postgresql":
include($phpgw_info["server"]["api_dir"] . "/phpgw_db_pgsql.inc.php");
break;
case "oracle":
include($phpgw_info["server"]["api_dir"] . "/phpgw_db_oracle.inc.php");
break;
case "mysql":
include($phpgw_info["server"]["api_dir"] . "/phpgw_db_mysql.inc.php");
break;
default:
echo("<h1>Please set db_type in your header.inc.php correctly</h1>\n");
exit;
}
$db = new db;
$db->Host = $phpgw_info["server"]["db_host"];
$db->Type = $phpgw_info["server"]["db_type"];
$db->Database = $phpgw_info["server"]["db_name"];
$db->User = $phpgw_info["server"]["db_user"];
$db->Password = $phpgw_info["server"]["db_pass"];
//$db->Halt_On_Error = "report";
$db = new db;
$db->Host = $phpgw_info["server"]["db_host"];
$db->Type = $phpgw_info["server"]["db_type"];
$db->Database = $phpgw_info["server"]["db_name"];
$db->User = $phpgw_info["server"]["db_user"];
$db->Password = $phpgw_info["server"]["db_pass"];
// $db->Halt_On_Error = "report";
$db->Halt_On_Error = "no";
if (!isset($oldversion)){
@$db->query("select app_version from applications where app_name='admin'");
@$db->next_record();
$db->query("select app_version from applications where app_name='admin'");
$db->next_record();
$oldversion = $db->f("app_version");
}
if (PHP_VERSION < "3.0.16") {
echo "You appear to be running an old version of PHP. It its recommend that you upgrade "
. "to a new version. Older version of PHP might not run phpGroupWare correctly, if at all.";
/**********************************************************************\
* First order of business is to upgrade or install the core. *
* if $ok is set to false after this include, the setup stops here *
* otherwise, we display the app setup form. *
* This is sorta kludgy still, but until I can figure out a clean way *
* for applications to inteact with the user, this is how it is. *
* *
\**********************************************************************/
$ok = true;
include("inc/core_setup.inc.php");
if (!$ok) {
exit;
} else {
echo "<table border='0' align='center' bgcolor='#e6e6e6' cellpadding='3' cellspacing='0'>\n";
echo "<tr bgcolor='#486591'>";
echo "<th><font color='#fefefe'>phpGroupWare Core Staus</font></th>";
echo "</tr>\n";
echo "<tr><td>Core version $oldversion. No updates needed.</td></tr>\n";
echo "</table>\n\n";
}
// Remove the appName from all users and groupws on the system
function removeAppPerms($appName) {
global $db;
}
switch($msg){
case "1":
return "You have been successfully logged out";
break;
case "2":
return "Your old tables were deleted";
break;
}
/**********************************************************************\
* See the Developers HOWTO and the example app in phpgwapps for more *
* info on how to integrate your application with this system. *
\**********************************************************************/
/* Database setup */
switch($action){
case "regularversion":
echo "<html><head><title>phpGroupWare Setup</title></head>\n";
echo "<body bgcolor='#ffffff'>\n";
echo "<table border=\"0\" align=\"center\">\n";
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Analysis</b></font></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>You appear to be running version $oldversion of phpGroupWare.<br>\n";
echo " We will automaticly update your tables/records to ".$phpgw_info["server"]["version"].", but we highly recommend backing up your tables incase the script causes damage to your data.\n";
echo " These automated scripts can easily destroy your data. Please backup before going any further!</td>\n";
echo " </tr>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>";
echo " <form method=\"POST\" action=\"$PHP_SELF\">\n";
echo " <input type=\"hidden\" name=\"oldversion\" value=\"".$oldversion."\">\n";
echo " <input type=\"hidden\" name=\"useglobalconfigsettings\">\n";
echo " <input type=\"submit\" name=\"action\" value=\"Upgrade\">\n";
echo " <input type=\"submit\" name=\"action\" value=\"Delete my old tables\">\n";
echo " </form>\n";
echo " <form method=\"POST\" action=\"config.php\">\n";
echo " <input type=\"submit\" name=\"action\" value=\"Dont touch my data\">\n";
echo " </form>\n";
echo " </td>";
echo " </tr>\n";
echo "</table>\n";
echo "</body></html>\n";
break;
case "prebetaversion":
echo "<html><head><title>phpGroupWare Setup</title></head>\n";
echo "<body bgcolor='#ffffff'>\n";
echo "<table border=\"0\" align=\"center\">\n";
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Analysis</b></font></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>You appear to be running a pre-beta version of phpGroupWare<br>\n";
echo " We are providing an automated upgrade system, but we highly recommend backing up your tables incase the script causes damage to your data.<br>\n";
echo " These automated scripts can easily destroy your data. Please backup before going any further!</td>\n";
echo " </tr>\n";
echo "</table>\n";
?>
<form method="POST" action="<?php $PHP_SELF?>">
<table border="0" align="center">
<tr bgcolor="486591">
<td colspan="2"><font color="fefefe">&nbsp;<b>Upgrade information</b></font></td>
</tr>
<tr bgcolor="e6e6e6">
<td>Select your old version:</td>
<td>
<select name="oldversion">
<option value="7122000">7122000</option>
<option value="8032000">8032000</option>
<option value="8072000">8072000</option>
<option value="8212000">8212000</option>
<option value="9052000">9052000</option>
<option value="9072000">9072000</option>
<option value="9262000">9262000</option>
<option value="0_9_1">0.9.1</option>
<option value="0_9_2">0.9.2</option>
</select>
</td>
</tr>
<tr bgcolor="e6e6e6">
<td>Port old globalconfig settings.</td>
<td><input type="checkbox" name="useglobalconfigsettings"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="action" value="Upgrade"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="action" value="Delete my old tables"></td>
</tr>
</table>
</form>
<?php
break;
case "Delete my old tables":
echo "<html><head><title>phpGroupWare Setup</title></head>\n";
echo "<body bgcolor='#ffffff'>\n";
echo "<table border=\"0\" align=\"center\">\n";
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Information</b></font></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>At your request, this script is going to take the evil action of deleting your existing tables and re-creating them in the new format.</td>\n";
echo " </tr>\n";
$db->Halt_On_Error = "report";
$currentver = "drop";
include ("sql/common_main.inc.php");
$db->Halt_On_Error = "no";
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Status</b></font></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>If you did not recieve any serious errors, your tables have been created.<br>\n";
echo " <a href=\"config.php\">Click here</a> to configure the environment.</td>\n";
echo " <a href=\"lang.php\">Click here</a> to configure multi-langague support.</td>\n";
echo " </tr>\n";
echo "</table>\n";
break;
case "Upgrade":
echo "<html><head><title>phpGroupWare Setup</title></head>\n";
echo "<body bgcolor='#ffffff'>\n";
echo "<table border=\"0\" align=\"center\">\n";
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Information</b></font></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>At your request, this script is going to attempt to upgrade your old tables to the new format.</td>\n";
echo " </tr>\n";
echo "</table>\n";
$currentver = $oldversion;
$db->Halt_On_Error = "report";
include ("sql/common_main.inc.php");
$db->Halt_On_Error = "no";
echo "<table border=\"0\" align=\"center\">\n";
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Status</b></font></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>If you did not recieve any serious errors, your tables *should* have been updated (no warranty on data integrity).<br>\n";
echo " <a href=\"config.php\">Click here</a> to configure the environment.\n";
echo " <br><a href=\"lang.php\">Click here</a> to configure multi-langague support.</td>\n";
echo " </tr>\n";
echo "</table>\n";
break;
default:
if (isset($oldversion)){
if ($phpgw_info["server"]["version"] == $oldversion){
echo "<html><head><title>phpGroupWare Setup</title></head>\n";
echo "<body bgcolor='#ffffff'>\n";
echo "<table border=\"0\" align=\"center\">\n";
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Analysis</b></font></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>Your database is up to date with version $oldversion.<br>\n";
echo " <a href=\"config.php\">Click here</a> to configure the environment.\n";
echo " <br><a href=\"lang.php\">Click here</a> to configure multi-langague support.</td>\n";
echo " </tr>\n";
echo "</table>\n";
}else{
Header("Location: $PHP_SELF?action=regularversion");
}
}else{
@$db->query("select * from config");
if (@$db->num_rows() == 0){
@$db->query("select * from accounts");
if (@$db->num_rows() == 0){
echo "<html><head><title>phpGroupWare Setup</title></head>\n";
echo "<body bgcolor='#ffffff'>\n";
echo "<table border=\"0\" align=\"center\">\n";
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Analysis</b></font></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>You appear to be running a new install of phpGroupWare, so the tables will be created for you.</td>\n";
echo " </tr>\n";
$db->Halt_On_Error = "report";
$currentver = "new";
include ("sql/common_main.inc.php");
$db->Halt_On_Error = "no";
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Status</b></font></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>If you did not recieve any errors, your tables have been created.<br>\n";
echo " <a href=\"config.php\">Click here</a> to configure the environment.\n";
echo " <br><a href=\"lang.php?newinstall=True\">Click here</a> to configure multi-langague support.</td>\n";
echo " </tr>\n";
echo "</table>\n";
}else{
Header("Location: $PHP_SELF?action=prebetaversion");
}
}else{
echo "<html><head><title>phpGroupWare Setup</title></head>\n";
echo "<body bgcolor='#ffffff'>\n";
echo "<table border=\"0\" align=\"center\">\n";
echo " <tr bgcolor=\"486591\">\n";
echo " <td colspan=\"2\"><font color=\"fefefe\">&nbsp;<b>Analysis</b></font></td>\n";
echo " </tr>\n";
echo " <tr bgcolor=\"e6e6e6\">\n";
echo " <td>Your database seems to be current.<br>\n";
echo " <a href=\"config.php\">Click here</a> to configure the environment.</td>\n";
echo " </tr>\n";
echo "</table>\n";
}
// Called by the app setup classes to add/remove lang records
// it acts correctly according to the current action,
// for an install/upgrade it removes the old record & installes the new one
// for an uninstall it removes the record (as long is as it NOT in common)
//
// TODO: This mechanism is VERY TEMPORARY until jengo and blinky can figure
// out a clean way to use transy for this!!!!!!!!!!!!!!!!!!!!!!!!!!!!
function do_lang($msg_id,$app,$lang,$content) {
global $db,$currentAction;
$msg_id = strtolower($msg_id);
$act = strtolower($currentAction);
//echo "Do Lang: $act, $msg_id, $app, $lang, $content<br>\n";
// Remove the old one
if ($act == "uninstall" || $act == "upgrade") {
if ($app == "common") {
echo "<!-- Not touching message_id '".$msg_id."' as it is in app common. -->\n";
} else {
$sql = "DELETE FROM lang WHERE message_id='" . $msg_id . "' AND app_name='". $app ."'";
$db->query($sql);
}
}
// Add the new one
// By setting $content == "", it allows you to prune old messages from the system
if ($content != "" && $act == "install") {
$sql = "INSERT INTO lang(message_id,app_name,lang,content) VALUES(";
$sql .= "'".$msg_id."',";
$sql .= "'".$app."',";
$sql .= "'".$lang."',";
$sql .= "'".$content."')";
$db->query($sql);
}
if ($content != "" && $act == "upgrade") {
$sql = "UPDATE lang SET ";
$sql .= "content='".$content."' WHERE";
$sql .= " message_id ='".$msg_id."'";
$sql .= " AND app_name = '".$app."'";
$sql .= " AND lang = '".$lang."'";
$db->query($sql);
}
}
echo "</body></html>";
//db->disconnect();
/**********************************************************************\
* *
\**********************************************************************/
/**********************************************************************\
* Apps should call this function to report errors if possible to *
* display them in a nice and controlled format *
\**********************************************************************/
function error($msg) {
global $error_count;
++$error_count;
echo "<tr><td><font color='#ff0000'>".$msg."</font></td></tr>\n";
}
/**********************************************************************\
* Apps should call this function to report warnings if possible to *
* display them in a nice and controlled format *
\**********************************************************************/
function warn($msg) {
echo "<tr><td><font color='#ff00ff'>".$msg."</font></td></tr>\n";
}
/**********************************************************************\
* Applications (and the core) inherit from this class which provides *
* all the hooks that setup needs to call for the app. *
* *
* Applications should call warn() or error() to communicate with *
* the user. *
\**********************************************************************/
// Template for the app-specific setup classes
class Setup {
// Is *ANY* version of the app currently installed ?
function is_installed() {
return false;
}
// Is the app installed and up to date?
function is_current() {
return true;
}
// Can the installed version be upgraded to the
// new one?
function can_upgrade() {
return false;
}
// If this application dpends on any other apps
// this shouldd return an array of the app names (the directory name)
// or return false if it can stand alone
function dependant_apps() {
return false;
}
// Called to actually upgrade the app
function upgrade() {
return true;
}
function install() {
return false;
}
// Called to uninstall the app
// You should remove all tables and files you created,
// and return the system to the state it was before upgrade/install was called
function uninstall() {
}
}
// Initial HTML output
echo "<html><head><title>Setup phpGroupWare</title></head>\n";
echo "<body bgcolor='#ffffff'>\n";
// Loop through all the directories looking for possible 3rd party apps
$baseDir = $phpgw_info["server"]["server_root"];
$setupFile = "/inc/setup.inc.php"; // File to look for to identify apps
$dh = opendir($baseDir);
while ($dir = readdir($dh)) {
$fp = $baseDir . "/" . $dir;
if ($dir[0] != '.' && is_dir($fp)) {
$fp .= $setupFile;
if (is_file($fp) && $dir != "setup") {
//echo "found a setup! in $fp<br>\n";
$detectedApps[$dir]["path"] = $fp;
$detectedApps[$dir]["name"] = $dir;
$detectedApps[$dir]["dir"] = $baseDir."/".$dir;
}
}
}
closedir($dh);
while ($detectedApps && list($name,$app) = each($detectedApps)) {
include($app["path"]);
$detectedApps[$name]["setup"] = new $classname($app["dir"]);
}
// If the user wanted to upgrade/install/remove an app, now is the time
if ($submit == "Perform Actions" && is_array($appAction)) {
echo "<p>\n";
echo "<table border='0' align='center' bgcolor='#e6e6e6' cellpadding='3' cellspacing='0'>\n";
echo "<tr bgcolor='#486591'>";
echo "<th><font color='#fefefe'>Making Application Changes</font></th>";
echo "</tr>\n";
reset($detectedApps);
$numAltered = 0;
while ($detectedApps && list($name,$a) = each($detectedApps)) {
$app = $a["setup"];
switch ($appAction[$name]) {
case "ignore":
break;
case "upgrade":
$currentAction = "upgrade";
if ($app->upgrade()) {
echo "<tr><td><b>$name</b> upgraded.</td></tr>\n";
} else {
echo "<tr bgcolor='#ff4444'><td><b>$name</b> - upgrade failed!</td></tr>\n";
}
++$numAltered;
break;
case "install":
$currentAction = "install";
if ($app->install()) {
echo "<tr><td><b>$name</b> installed.</td></tr>\n";
} else {
echo "<tr bgcolor='#ff4444'><td><b>$name</b> - install failed!</td></tr>\n";
}
++$numAltered;
break;
case "uninstall":
$currentAction = "uninstall";
if ($app->uninstall()) {
echo "<tr><td><b>$name</b> uninstalled.</td></tr>\n";
removeAppPerms($name);
} else {
echo "<tr bgcolor='#ff4444'><td><b>$name</b> - uninstall failed!</td></tr>\n";
}
++$numAltered;
break;
}
}
if ($numAltered == 0) {
echo "<tr><td>No applications altered.</td></tr>\n";
}
echo "</table>\n";
}
echo "<form action='".$PHP_SELF."' method='POST'>\n";
echo "<table border='0' align='center' bgcolor='#e6e6e6' cellpadding='3' cellspacing='1'>\n";
echo "<tr bgcolor='#486591'><th colspan='7'><font size='+1' color='#fefefe'>Application Setup</font></th></tr>\n";
echo "<tr bgcolor='#486591'>";
echo "<th><font color='#fefefe'>Application</font></th>";
echo "<th><font color='#fefefe'>Installed Version</font></th>";
echo "<th><font color='#fefefe'>Detected Version</font></th>";
echo "<th><font color='#fefefe'>Install</font></th>";
echo "<th><font color='#fefefe'>Upgrade</font></th>";
echo "<th><font color='#fefefe'>Remove</font></th>";
echo "<th><font color='#fefefe'>Do Nothing</font></th>";
echo "</tr>\n";
$numApps = 0;
if (isSet($detectedApps)) reset($detectedApps);
while ($detectedApps && list($name,$a) = each($detectedApps)) {
$app = $a["setup"];
echo "<tr>";
echo " <td>".$name."</td>\n";
if (is_object($a["setup"])) {
$installed = $app->is_installed();
$code = $app->code_version();
}
if (!$installed) {
echo " <td>-not yet installed-</td>\n";
} else if ($installed == "0.0.0" || $installed == "0.0") {
echo " <td>Pre-Beta</td>";
} else {
echo " <td>".$installed."</td>\n";
}
echo " <td>".$code."</td>\n";
if ($installed && $app->is_current()) {
echo " <td>N/A</td>"; // Can't install
echo " <td>N/A</td>"; // Can't upgrade
echo " <td><input type='radio' name='appAction[".$name."]' value='uninstall'>"; // Can remove
echo " <td><input type='radio' name='appAction[".$name."]' value='ignore' checked>"; // Can ignore
} else if ($installed) {
echo " <td>N/A</td>"; // Can't install
echo " <td><input type='radio' name='appAction[".$name."]' value='upgrade' checked>"; // Can upgrade
echo " <td><input type='radio' name='appAction[".$name."]' value='uninstall'>"; // Can remove
echo " <td><input type='radio' name='appAction[".$name."]' value='ignore'>"; // Can ignore
} else {
echo " <td><input type='radio' name='appAction[".$name."]' value='install' checked>"; // Can install
echo " <td>N/A</td>"; // Can't upgrade
echo " <td>N/A</td>"; // Can't remove
echo " <td><input type='radio' name='appAction[".$name."]' value='ignore'>"; // Can ignore
}
echo "</tr>\n";
++$numApps;
}
if ($numApps) {
echo "<tr><td colspan='7' align='right'><input type='submit' name='submit' value='Perform Actions'></td></tr>\n";
} else {
echo "<tr><td colspan='7' align='right'>Found no non-core applications. ";
echo "Visit <a href='http://phpgroupware.org/'>phpGroupWare.org</a> to obtain add-on applications.</td></tr>\n";
}
echo "</table>\n";
echo "</form>\n";
echo "Applications not in the table above are either part of the phpGroupWare core, or ";
echo "have not been upgraded to the new phpGroupWare application setup code.";
echo "<p>When you are done installing and upgrading applications, you should ";
echo "continue to the <a href='config.php'>Configuration Page</a>";
echo "<br>or skip to <a href='lang.php'>Configure multi-language support</a>.\n";
?>
</body>
</html>