Updates to install system

This commit is contained in:
Ice
2008-01-27 21:36:06 +00:00
parent 4b60b175e0
commit 1531697f31
2 changed files with 696 additions and 622 deletions

View File

@@ -23,23 +23,29 @@ $user->session_begin();
$auth->acl($user->data);
$user->setup('mods/portal_install');
$version_array = array('0.1.0', 'p3p1.2.2', 'p3p1.2.1', 'p3p1.2.0', 'p3p1.1.0b');
$mode = request_var('mode', '');
$old_version = 0;
$phpbb3portal = false;
$installed = $updated = $uninstalled =false;
$page_title = 'Board3portal v' . $current_version;
$sql = 'SELECT config_value as version
if( $user->data['is_registered'] && $user->data['user_type'] == USER_FOUNDER )
{
$version_array = array('0.1.0', 'p3p1.2.2', 'p3p1.2.1', 'p3p1.2.0', 'p3p1.1.0b');
$old_version = 0;
$phpbb3portal = false;
$installed = $updated = $uninstalled =false;
$sql = 'SELECT config_value as version
FROM ' . PORTAL_CONFIG_TABLE . "
WHERE config_name = 'portal_version'";
$result = @$db->sql_query_limit( $sql, 1 );
if( $db->sql_affectedrows($result) > 0 )
{
$result = @$db->sql_query_limit( $sql, 1 );
if( $db->sql_affectedrows($result) > 0 )
{
$version = $db->sql_fetchrow( $result );
$old_version = $version['version'];
}
else
{
}
else
{
$db->sql_freeresult( $result );
$sql = 'SELECT config_value as version
FROM ' . CONFIG_TABLE . "
@@ -51,29 +57,26 @@ else
$phpbb3portal = true;
$old_version = ( strtolower($version['version']) == '1.1.0.b' ) ? '1.1.0b' : $version['version'] ;
}
}
$db->sql_freeresult( $result );
}
$db->sql_freeresult( $result );
$check_mode = 'none';
$check_mode = 'none';
if( $old_version == 0 )
{
if( $old_version == 0 )
{
$check_mode = 'install';
}
elseif( $phpbb3portal === TRUE || version_compare( $old_version, $current_version, "<" ) === TRUE )
{
}
elseif( $phpbb3portal === TRUE || version_compare( $old_version, $current_version, "<" ) === TRUE )
{
$check_mode = 'update';
}
}
$page_title = 'Board3portal v' . $current_version;
$confirm = request_var('confirm', 0);
$mode = request_var('mode', '');
$confirm = request_var('confirm', 0);
$error_array = array();
$error_array = array();
function split_sql_file($sql, $delimiter)
{
function split_sql_file($sql, $delimiter)
{
$sql = str_replace("\r" , '', $sql);
$data = preg_split('/' . preg_quote($delimiter, '/') . '$/m', $sql);
@@ -88,10 +91,10 @@ function split_sql_file($sql, $delimiter)
}
return $data;
}
}
function db_error( $error, $sql, $line, $file, $skip = false )
{
function db_error( $error, $sql, $line, $file, $skip = false )
{
global $error, $lang, $db;
if( $skip )
@@ -109,10 +112,10 @@ function db_error( $error, $sql, $line, $file, $skip = false )
include $phpbb_root_path . 'install_portal/style/layout_footer.php';
exit;
}
}
}
function remove_comments(&$output)
{
function remove_comments(&$output)
{
$lines = explode("\n", $output);
$output = '';
@@ -140,16 +143,16 @@ function remove_comments(&$output)
unset($lines);
return $output;
}
}
function remove_remarks(&$sql)
{
function remove_remarks(&$sql)
{
$sql = preg_replace('/\n{2,}/', "\n", preg_replace('/^#.*$/m', "\n", $sql));
}
}
// What sql_layer should we use?
switch ($db->sql_layer)
{
// What sql_layer should we use?
switch ($db->sql_layer)
{
case 'mysql':
$db_schema = 'mysql_40';
$delimiter = ';';
@@ -208,14 +211,14 @@ switch ($db->sql_layer)
default:
trigger_error('Sorry, unsupported DBMS found.');
break;
}
}
// Get old version if it is installed.
// Get old version if it is installed.
switch ($mode)
{
// Installing from scratch
case 'install':
switch ($mode)
{
// Installing from scratch
case 'install':
if( $check_mode == 'install' )
{
if( $confirm == 1)
@@ -471,9 +474,9 @@ case 'install':
{
include($phpbb_root_path . 'install_portal/style/layout_menu.'.$phpEx);
}
break;
// Updating
case 'update':
break;
// Updating
case 'update':
if( $check_mode == 'update' )
{
$confirm = request_var('confirm', '');
@@ -840,9 +843,9 @@ case 'update':
include($phpbb_root_path . 'install_portal/style/layout_menu.'.$phpEx);
}
break;
// Uninstalling
case 'uninstall':
break;
// Uninstalling
case 'uninstall':
if( $old_version != 0 )
{
if( $confirm == 1)
@@ -884,13 +887,69 @@ case 'uninstall':
$db->sql_freeresult($result);
break;
}
$sql = 'SELECT right_id, module_id FROM ' . MODULES_TABLE . "
WHERE module_langname = 'ACP_PORTAL_GENERAL_INFO'
OR module_langname = 'ACP_PORTAL_NEWS_INFO'
OR module_langname = 'ACP_PORTAL_ANNOUNCE_INFO'
OR module_langname = 'ACP_PORTAL_WELCOME_INFO'
OR module_langname = 'ACP_PORTAL_RECENT_INFO'
OR module_langname = 'ACP_PORTAL_WORDGRAPH_INFO'
OR module_langname = 'ACP_PORTAL_PAYPAL_INFO'
OR module_langname = 'ACP_PORTAL_ADS_INFO'
OR module_langname = 'ACP_PORTAL_ATTACHMENTS_NUMBER_INFO'
OR module_langname = 'ACP_PORTAL_MEMBERS_INFO'
OR module_langname = 'ACP_PORTAL_POLLS_INFO'
OR module_langname = 'ACP_PORTAL_BOTS_INFO'
OR module_langname = 'ACP_PORTAL_MOST_POSTER_INFO'
OR module_langname = 'ACP_PORTAL_MINICALENDAR_INFO'";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$sql = 'DELETE FROM ' . MODULES_TABLE . " WHERE module_id = '{$row['module_id']}'";
$db->sql_query($sql);
$sql = 'UPDATE ' . MODULES_TABLE . "
SET left_id = left_id - 2
WHERE module_class = 'acp'
AND left_id > {$row['right_id']}";
$db->sql_query($sql);
$sql = 'UPDATE ' . MODULES_TABLE . "
SET right_id = right_id - 2
WHERE module_class = 'acp'
AND right_id > {$row['right_id']}";
$db->sql_query($sql);
}
$db->sql_freeresult($result);
$sql = 'SELECT right_id, module_id FROM ' . MODULES_TABLE . "
WHERE module_langname = 'ACP_PORTAL_INFO'";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$sql = 'DELETE FROM ' . MODULES_TABLE . " WHERE module_id = '{$row['module_id']}'";
$db->sql_query($sql);
$sql = 'UPDATE ' . MODULES_TABLE . "
SET left_id = left_id - 2
WHERE module_class = 'acp'
AND left_id > {$row['right_id']}";
$db->sql_query($sql);
$sql = 'UPDATE ' . MODULES_TABLE . "
SET right_id = right_id - 2
WHERE module_class = 'acp'
AND right_id > {$row['right_id']}";
$db->sql_query($sql);
}
$db->sql_freeresult($result);
$installed = true;
}
else
{
include($phpbb_root_path . 'install_portal/style/layout_header.'.$phpEx);
echo '<h1>' . $user->lang['INSTALLER_ERROR'] . '</h1>';
echo '<h1>' . $user->lang['INSTALLER_UNINSTALL_OLDVERSION'] . '</h1>';
echo '<p>' . $user->lang['INSTALLER_UNINSTALL_OLDVERSION'] . '</p>';
include($phpbb_root_path . 'install_portal/style/layout_footer.'.$phpEx);
}
}
@@ -899,13 +958,21 @@ case 'uninstall':
include($phpbb_root_path . 'install_portal/style/layout_menu.'.$phpEx);
}
break;
// Welcome page!
default:
break;
// Welcome page!
default:
include($phpbb_root_path . 'install_portal/style/layout_menu.'.$phpEx);
break;
break;
}
}
else
{
include($phpbb_root_path . 'install_portal/style/layout_header.'.$phpEx);
echo '<h1>' . $user->lang['INSTALLER_ERROR'] . '</h1>';
echo '<p>' . $user->lang['INSTALLER_NEEDS_FOUNDER'] . '</p>';
include($phpbb_root_path . 'install_portal/style/layout_footer.'.$phpEx);
}
?>

View File

@@ -29,6 +29,10 @@ if( !defined('IN_PHPBB') || !defined('IN_PORTAL_INSTALL') )
<div class="panel">
<span class="corners-top"><span></span></span>
<div id="content">
<?php
if( isset($mode) && isset($old_version) && isset($phpbb3portal) )
{
?>
<div id="menu">
<ul>
<li class="header"><?php echo $user->lang['INSTALLER_MENU']; ?></li>
@@ -43,5 +47,8 @@ if( $old_version != 0 && $phpbb3portal === false )
?>
</ul>
</div>
<?php
}
?>
<div id="main">
<a name="maincontent"></a>