check and increment app_id, or set random value if api version >= 0.9.13.015

This commit is contained in:
Miles Lott 2001-10-17 18:42:18 +00:00
parent 09602fec0c
commit 39bd4f6318

View File

@ -223,6 +223,10 @@
else else
{ {
$appstbl = 'phpgw_applications'; $appstbl = 'phpgw_applications';
if($this->amorethanb($setup_info['phpgwapi']['currentver'],'0.9.13.014'))
{
$use_appid = True;
}
} }
if($DEBUG) if($DEBUG)
@ -237,9 +241,26 @@
{ {
$tables = implode(',',$setup_info[$appname]['tables']); $tables = implode(',',$setup_info[$appname]['tables']);
} }
if($use_appid)
{
$this->db->query("SELECT MAX(app_id) FROM $appstbl");
$this->db->next_record();
if($this->db->f(0))
{
$app_id = ($this->db->f(0) + 1) . ',';
$app_idstr = 'app_id,';
}
else
{
srand(100000);
$app_id = rand(1,100000) . ',';
$app_idstr = 'app_id,';
}
}
$this->db->query("INSERT INTO $appstbl " $this->db->query("INSERT INTO $appstbl "
. "(app_name,app_title,app_enabled,app_order,app_tables,app_version) " . "($app_idstr app_name,app_title,app_enabled,app_order,app_tables,app_version) "
. "VALUES (" . "VALUES ("
. $app_id
. "'" . $setup_info[$appname]['name'] . "'," . "'" . $setup_info[$appname]['name'] . "',"
. "'" . $setup_info[$appname]['title'] . "'," . "'" . $setup_info[$appname]['title'] . "',"
. $enable . "," . $enable . ","