From: Matteo Nastasi (mop) Date: Thu, 28 Nov 2013 16:47:35 +0000 (+0100) Subject: add methods to store users::lice_vers and renamed store_set to prefs_store to be... X-Git-Tag: v4.11.0~17 X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=8e29e6c5f6919cdf37bed7f6782ac549c14e6210;p=brisk.git add methods to store users::lice_vers and renamed store_set to prefs_store to be more consistent --- diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 20e6e3a..e88f1db 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -814,7 +814,7 @@ class Client_prefs { $user->rec->supp_comp_set($this->supp_comp); } if ($is_save) - $user->store_set(); + $user->prefs_store(); } } diff --git a/web/Obj/dbase_base.phh b/web/Obj/dbase_base.phh index ab20e6c..a01ce52 100644 --- a/web/Obj/dbase_base.phh +++ b/web/Obj/dbase_base.phh @@ -99,6 +99,10 @@ class LoginDBItem { { return $this->lice_vers; } + function lice_vers_set($lice_vers) + { + $this->lice_vers = $lice_vers; + } function disa_reas_get() { diff --git a/web/Obj/dbase_pgsql.phh b/web/Obj/dbase_pgsql.phh index f7f67cd..2b1d4d5 100644 --- a/web/Obj/dbase_pgsql.phh +++ b/web/Obj/dbase_pgsql.phh @@ -163,9 +163,6 @@ class BriskDB $user_sql = sprintf("UPDATE %susers SET (lintm) = (date 'epoch' + %d * INTERVAL '1 second') WHERE code = %d;", $G_dbpfx, $lintm, $code); - // $user_pg = $this->query($user_sql); - // $row_n = pg_affected_rows($user_pg); - // fprintf(STDERR, "query: %s NUM: %d\n", ($user_pg == FALSE ? "FALSE" : "TRUE"), $row_n); if ( ! (($user_pg = $this->query($user_sql)) != FALSE && pg_affected_rows($user_pg) == 1) ) { return FALSE; } @@ -178,7 +175,22 @@ class BriskDB GLOBAL $G_dbpfx; $user_sql = sprintf("UPDATE %susers SET (type, supp_comp) = (%d, '%s') WHERE code = %d;", - $G_dbpfx, $flags, $supp_comp, $code); + $G_dbpfx, $flags, escsql($supp_comp), $code); + fprintf(STDERR, "REQUEST [%s]\n", $user_sql); + if ( ! (($user_pg = $this->query($user_sql)) != FALSE && pg_affected_rows($user_pg) == 1) ) { + return FALSE; + } + fprintf(STDERR, "REQUEST GOOD [%s]\n", $user_sql); + + return TRUE; + } + + function user_licence_update($code, $lice_vers) + { + GLOBAL $G_dbpfx; + + $user_sql = sprintf("UPDATE %susers SET (lice_vers) = ('%s') WHERE code = %d;", + $G_dbpfx, escsql($lice_vers), $code); fprintf(STDERR, "REQUEST [%s]\n", $user_sql); if ( ! (($user_pg = $this->query($user_sql)) != FALSE && pg_affected_rows($user_pg) == 1) ) { return FALSE; diff --git a/web/Obj/user.phh b/web/Obj/user.phh index 8ae6b32..6235759 100644 --- a/web/Obj/user.phh +++ b/web/Obj/user.phh @@ -316,7 +316,7 @@ class User { $this->flags = ($flags_old | ($flags & $mask)); } - function store_set() + function prefs_store() { if (($bdb = BriskDB::create()) == FALSE) { return FALSE; @@ -325,6 +325,14 @@ class User { $this->rec->supp_comp_get())); } + function licence_store() + { + if (($bdb = BriskDB::create()) == FALSE) { + return FALSE; + } + return ($bdb->user_licence_update($this->code, $this->rec->lice_vers_get())); + } + function rd_data_set($curtime, $transp, $enc, $stat, $subst, $step, $from) { $this->rd_endtime = $curtime + RD_ENDTIME_DELTA;