diff --git a/phpgwapi/inc/class.common.inc.php b/phpgwapi/inc/class.common.inc.php index 58b4bb5793..807ddedc03 100644 --- a/phpgwapi/inc/class.common.inc.php +++ b/phpgwapi/inc/class.common.inc.php @@ -1258,4 +1258,34 @@ system("grep -r '^[ \t]*function' *"); echo ''; } + + // This will return a value for the next id an app may need to insert values into ldap. + /*! + @function next_id + @abstract return the next higher value for an integer, and increment it in the db. + */ + function next_id($appname) + { + global $phpgw; + + if (!$appname) { + return -1; + } + + $phpgw->db->query("SELECT id FROM phpgw_nextid WHERE appname='".$appname."'"); + while( $phpgw->db->next_record() ) { + $id = $phpgw->db->f("id"); + } + + if (empty($id) || !$id) { + $id = 1; + $phpgw->db->query("INSERT INTO phpgw_nextid (appname,id) VALUES ('".$appname."',".$id.")"); + $phpgw->db->query("UPDATE phpgw_nextid SET id=".$id." WHERE appname='".$appname."'"); + } else { + $id = $id + 1; + $phpgw->db->query("UPDATE phpgw_nextid SET id=".$id." WHERE appname='".$appname."'"); + } + + return intval($id); + } }//end common class diff --git a/setup/sql/mysql_newtables.inc.php b/setup/sql/mysql_newtables.inc.php index 90ba165af7..a2acb72d4b 100644 --- a/setup/sql/mysql_newtables.inc.php +++ b/setup/sql/mysql_newtables.inc.php @@ -321,7 +321,7 @@ note_id int(20) NOT NULL auto_increment, note_owner int(11), note_date int(11), - note_category int(9), + note_category int(9), note_content text, PRIMARY KEY (note_id) )"; @@ -336,7 +336,14 @@ );"; $phpgw_setup->db->query($sql); - $phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre18'; + $sql = "create table phpgw_nextid ( + appname varchar(25), + id int(8), + UNIQUE (appname) + )"; + $phpgw_setup->db->query($sql); + + $phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre19'; $phpgw_info['setup']['oldver']['phpgwapi'] = $phpgw_info['setup']['currentver']['phpgwapi']; update_version_table(); // $phpgw_setup->update_version_table(); diff --git a/setup/sql/mysql_upgrade_beta.inc.php b/setup/sql/mysql_upgrade_beta.inc.php index 41484745f0..6371594cc5 100644 --- a/setup/sql/mysql_upgrade_beta.inc.php +++ b/setup/sql/mysql_upgrade_beta.inc.php @@ -1322,6 +1322,20 @@ $phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre18'; } + $test[] = '0.9.10pre18'; + function upgrade0_9_10pre18() { + global $phpgw_info, $phpgw_setup; + + $sql = "create table phpgw_nextid ( + appname varchar(25), + id int(8), + UNIQUE (appname) + )"; + + $phpgw_setup->db->query($sql); + $phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre19'; + } + reset ($test); while (list ($key, $value) = each ($test)){ if ($phpgw_info["setup"]["currentver"]["phpgwapi"] == $value) { diff --git a/setup/sql/pgsql_newtables.inc.php b/setup/sql/pgsql_newtables.inc.php index de2bd8b63e..def26f20f6 100644 --- a/setup/sql/pgsql_newtables.inc.php +++ b/setup/sql/pgsql_newtables.inc.php @@ -291,7 +291,7 @@ note_id serial, note_owner int, note_date int, - note_category int, + note_category int, note_content text )"; $phpgw_setup->db->query($sql); @@ -304,7 +304,13 @@ )"; $phpgw_setup->db->query($sql); - $phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre18'; + $sql = "create table phpgw_nextid ( + appname varchar(25), + id int + )"; + $phpgw_setup->db->query($sql); + + $phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre19'; $phpgw_info['setup']['oldver']['phpgwapi'] = $phpgw_info['setup']['currentver']['phpgwapi']; update_version_table(); ?> diff --git a/setup/sql/pgsql_upgrade_beta.inc.php b/setup/sql/pgsql_upgrade_beta.inc.php index 22c9ee2bee..e493382bfe 100644 --- a/setup/sql/pgsql_upgrade_beta.inc.php +++ b/setup/sql/pgsql_upgrade_beta.inc.php @@ -1570,6 +1570,18 @@ $phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre18'; } + $test[] = '0.9.10pre18'; + function upgrade0_9_10pre18() { + global $phpgw_info, $phpgw_setup; + + $sql = "create table phpgw_nextid ( + appname varchar(25), + id int + )"; + + $phpgw_setup->db->query($sql); + $phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre19'; + } reset ($test); while (list ($key, $value) = each ($test)){ diff --git a/version.inc.php b/version.inc.php index cd3bdf9d95..48fc1186f5 100644 --- a/version.inc.php +++ b/version.inc.php @@ -11,5 +11,5 @@ /* $Id$ */ - $phpgw_info["server"]["versions"]["phpgwapi"] = "0.9.10pre18"; + $phpgw_info["server"]["versions"]["phpgwapi"] = "0.9.10pre19"; $phpgw_info["server"]["versions"]["current_header"] = "1.11";