From: Banana Date: Thu, 16 Feb 2012 12:41:52 +0000 (+0100) Subject: new options and it is now possible to arrange the option entries X-Git-Tag: 2.1-alpha-2019-0-29~91 X-Git-Url: http://91.132.146.200/gitweb/?a=commitdiff_plain;h=b2c5dc13911261148aa8c827960452417f416648;p=insipid.git new options and it is now possible to arrange the option entries --- diff --git a/ChangeLog b/ChangeLog index b10131e..b1bfdd2 100755 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ version 1.1 * older and newer link at the top no working * bug with path to the jquery.js file * some statistics + * options can be ordered now version 1.0 () + jumpin.banana diff --git a/lib/Insipid/Database.pm b/lib/Insipid/Database.pm index 0815a7f..28c239b 100755 --- a/lib/Insipid/Database.pm +++ b/lib/Insipid/Database.pm @@ -70,32 +70,37 @@ sub export_options { $writer->endTag('options'); } +# this function is special for every version. +# there is no generic function for upgrades +# so changes to the DB needs to be saved here too +# in the next version change this sub dbupgrade { - my $sql = "update $tbl_options set value = ? where (name = ?)"; + + + my $sql = "ALTER TABLE `$tbl_options` ADD COLUMN `pos` int(10) NOT NULL AFTER `value`;"; my $sth = $dbh->prepare($sql); - $sth->execute($version, 'version'); + $sth->execute; - $sql = "insert into $tbl_options(name, value, description) - values(?, ?, ?)"; - $sth = $dbh->prepare($sql); - $sth->execute('version', $version, 'Internal Insipid version'); - $sth->execute('use_rewrite', 'yes', 'Use mod_rewrite - disable this if you do not want to use mod_rewrite.'); + my $sql = "UPDATE $tbl_options SET pos = ? where (name = ?)"; + my $sth = $dbh->prepare($sql); + $sth->execute(3, 'feed_name'); + $sth->execute(1, 'site_name'); + $sth->execute(20, 'proxy_host'); + $sth->execute(21, 'proxy_port'); + $sth->execute(2, 'public_searches'); + $sth->execute(90, 'use_rewrite'); + $sth->execute(9999, 'version'); - # Delete the old sessions table - $sql = 'drop table sessions'; - $sth = $dbh->prepare($sql); - $sth->execute(); - # Create the new session table if it's not there. - $sql = "create table $tbl_authentication ( - session_id varchar(32), - create_time int, - primary key(session_id))"; - $sth = $dbh->prepare($sql); - $sth->execute(); - if($dbh->errstr) { - print STDERR $dbh->errstr; - } + $sql = "INSERT INTO `$tbl_options` ( `name`, `value`, `description`, `pos`) + VALUES ( 'feed_num', '10', 'How many feed entries per default (0 = all)', '4')"; + my $sth = $dbh->prepare($sql); + $sth->execute; + + + my $sql = "update $tbl_options set value = ? where (name = ?)"; + my $sth = $dbh->prepare($sql); + $sth->execute($version, 'version'); return; } diff --git a/lib/Insipid/Main.pm b/lib/Insipid/Main.pm index 7557d69..e9a0b82 100755 --- a/lib/Insipid/Main.pm +++ b/lib/Insipid/Main.pm @@ -524,7 +524,9 @@ sub show_options { } # Now show em - my $sql = "select name, description, value from $tbl_options"; + my $sql = "SELECT name, description, value + FROM $tbl_options + ORDER BY `pos`"; my $sth = $dbh->prepare($sql); $sth->execute(); diff --git a/lib/Insipid/Schemas.pm b/lib/Insipid/Schemas.pm index 4c3c293..26f05cb 100755 --- a/lib/Insipid/Schemas.pm +++ b/lib/Insipid/Schemas.pm @@ -42,7 +42,7 @@ $createMySQL # Insipid will check the database version number on each initialization of # the options table (every hit essentially) and upgrade the tables if there's # any mismatch. -our $version = "1.0"; +our $version = "1.1"; our $createMySQL = <