Enable app upgrade status for admins (of all applications)

This commit is contained in:
Miles Lott 2001-09-08 16:02:59 +00:00
parent 3459f050ba
commit 7c7d5ba480
2 changed files with 81 additions and 30 deletions

View File

@ -109,25 +109,6 @@
echo parse_navbar();
}
$GLOBALS['phpgw']->db->query("select app_version from phpgw_applications where app_name='phpgwapi'",__LINE__,__FILE__);
if($GLOBALS['phpgw']->db->next_record())
{
$apiversion = $GLOBALS['phpgw']->db->f('app_version');
}
else
{
$GLOBALS['phpgw']->db->query("select app_version from phpgw_applications where app_name='admin'",__LINE__,__FILE__);
$GLOBALS['phpgw']->db->next_record();
$apiversion = $GLOBALS['phpgw']->db->f('app_version');
}
if ($GLOBALS['phpgw_info']['server']['versions']['phpgwapi'] > $apiversion)
{
echo '<p><b>' . lang('You are running a newer version of phpGroupWare than your database is setup for') . '.'
. '<br>' . lang('It is recommended that you run setup to upgrade your tables to the current version') . '.'
. '</b>';
}
$GLOBALS['phpgw']->translation->add_app('mainscreen');
if (lang('mainscreen_message') != 'mainscreen_message*')
{
@ -143,9 +124,9 @@
$lines = $GLOBALS['phpgw']->network->gethttpsocketfile('http://www.phpgroupware.org/currentversion');
for ($i=0; $i<count($lines); $i++)
{
if (ereg("currentversion",$lines[$i]))
if (ereg('currentversion',$lines[$i]))
{
$line_found = explode(":",chop($lines[$i]));
$line_found = explode(':',chop($lines[$i]));
}
}
if($GLOBALS['phpgw']->common->cmp_version($GLOBALS['phpgw_info']['server']['versions']['phpgwapi'],$line_found[1]))
@ -153,6 +134,39 @@
echo '<p>There is a new version of phpGroupWare available. <a href="'
. 'http://www.phpgroupware.org">http://www.phpgroupware.org</a>';
}
$_found = False;
$GLOBALS['phpgw']->db->query("select app_name,app_version from phpgw_applications",__LINE__,__FILE__);
while($GLOBALS['phpgw']->db->next_record())
{
$_found = True;
$_db_version = $GLOBALS['phpgw']->db->f('app_version');
$_app_name = $GLOBALS['phpgw']->db->f('app_name');
$_versionfile = $GLOBALS['phpgw']->common->get_app_dir($_app_name) . '/setup/setup.inc.php';
if(file_exists($_versionfile))
{
include($_versionfile);
$_file_version = $setup_info[$_app_name]['version'];
$_app_title = $setup_info[$_app_name]['title'];
unset($setup_info);
if($GLOBALS['phpgw']->common->cmp_version_long($_db_version,$_file_version))
{
$_app_string .= '<br>' . lang($_app_title);
}
unset($_file_version);
unset($_app_title);
}
unset($_db_version);
unset($_versionfile);
}
if($_found)
{
echo '<br>' . lang('The following applications require upgrades') . ':' . "\n";
echo $_app_string . "\n";
echo '<br>' . lang('Please run setup to become current') . '.' . "\n";
unset($_app_string);
}
}
?>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">

View File

@ -47,26 +47,63 @@
var $crypto;
var $debug_info; // An array with debugging info from the API
// Compares two Version strings
/*!
@functionn cmp_version
@@abstract Compares two Version strings and return 1 if str2 is newest (bigger version number) than str1
@@param $str1
@@param $str2
@function cmp_version
@abstract Compares two Version strings and return 1 if str2 is newest (bigger version number) than str1
@discussion This function checks for major version only.
@param $str1
@param $str2
*/
function cmp_version($str1,$str2)
{
ereg("([0-9]+)\.([0-9]+)\.([0-9]+)[a-zA-Z]*([0-9]*)",$str1,$regs);
ereg("([0-9]+)\.([0-9]+)\.([0-9]+)[a-zA-Z]*([0-9]*)",$str2,$regs2);
//echo "$regs[0] - $regs2[0]";
for($i=1;$i<5;$i++) {
for($i=1;$i<5;$i++)
{
//echo "<br>$regs[$i] - $regs2[$i]";
if($regs2[$i] == $regs[$i])
{
continue;
}
if($regs2[$i] > $regs[$i])
{
return 1;
else
if($regs2[$i] < $regs[$i])
return 0;
}
elseif($regs2[$i] < $regs[$i])
{
return 0;
}
}
}
/*!
@function cmp_version_long
@abstract Compares two Version strings and return 1 if str2 is newest (bigger version number) than str1
@discussion This function checks all fields. cmp_version() checks release version only.
@param $str1
@param $str2
*/
function cmp_version_long($str1,$str2)
{
ereg("([0-9]+)\.([0-9]+)\.([0-9]+)[a-zA-Z]*([0-9]*)\.([0-9]*)",$str1,$regs);
ereg("([0-9]+)\.([0-9]+)\.([0-9]+)[a-zA-Z]*([0-9]*)\.([0-9]*)",$str2,$regs2);
//echo "$regs[0] - $regs2[0]";
for($i=1;$i<6;$i++)
{
//echo "<br>$regs[$i] - $regs2[$i]";
if($regs2[$i] == $regs[$i])
{
continue;
}
if($regs2[$i] > $regs[$i])
{
return 1;
}
elseif($regs2[$i] < $regs[$i])
{
return 0;
}
}
}