From: Matteo Nastasi (mop) Date: Thu, 5 Nov 2015 06:28:56 +0000 (+0100) Subject: load data from usernet table or create a default instance X-Git-Tag: v5.3.0~60 X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=a77cf3db1fbace39c49b030b9e144a316f007373;p=brisk.git load data from usernet table or create a default instance --- diff --git a/TODO.txt b/TODO.txt index 8de1e80..321039a 100644 --- a/TODO.txt +++ b/TODO.txt @@ -3,7 +3,35 @@ FEATURES | ----------+ + * Users Network construction + DONE - sql + - dbase API + - enhance info interface + . disable parts of interface + - minisplash at end of the match + + * Double click on chat to open preferences + + * APPRENTICE + Phase2 + DONE - match counters (part 2) + DONE . migration script for old users + - guarantee for apprentice + + BUGS | + ------+ - Global vars checker + - Remove books from chat + - Not triple chars between letters + - 10002 message when already clicked + + +--------- + - APPRENTICE + Phase2 + DONE - match counters (part 2) + DONE . migration script for old users + - APPRENTICE Phase1 DONE - correggere minuta giornaliera @@ -30,11 +58,6 @@ DONE - fix layout of tables DONE - aggiungere books.png - Phase2 - - match counters (part 2) - . migration script for old users - - guarantee for apprentice - - MENTORS - listen all diff --git a/sql/sql.d/100-anagr.sql.devel b/sql/sql.d/100-anagr.sql.devel deleted file mode 100644 index 9de8924..0000000 --- a/sql/sql.d/100-anagr.sql.devel +++ /dev/null @@ -1,28 +0,0 @@ --- --- Populate users db. --- - --- macro for user_flag bit-field --- define('USER_FLAG_TY_ALL', 0xff0000); // done --- define('USER_FLAG_TY_NORM', 0x010000); // done --- define('USER_FLAG_TY_SUPER', 0x020000); // done --- define('USER_FLAG_TY_CERT', 0x040000); // done --- define('USER_FLAG_TY_FIRONLY', 0x200000); // done --- define('USER_FLAG_TY_ADMIN', 0x400000); // done --- define('USER_FLAG_TY_DISABLE', 0x800000); // done - - -DELETE FROM #PFX#users WHERE code = 10101; -DELETE FROM #PFX#users WHERE guar_code = 10101 AND code != 10101; -INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10101, 'uno', md5('one'), 'uno@pluto.com', CAST (X'00450000' as integer), 10101); -DELETE FROM #PFX#users WHERE code = 10102; -INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10102, 'due', md5('two'), 'due@pluto.com', CAST (X'00010000' as integer), 10101); -DELETE FROM #PFX#users WHERE code = 10103; -INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10103, 'tre', md5('thr'), 'tre@pluto.com', CAST (X'00010000' as integer), 10102); -DELETE FROM #PFX#users WHERE code = 10104; -INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10104, 'qua', md5('for'), 'qua@pluto.com', CAST (X'00010000' as integer), 10102); -DELETE FROM #PFX#users WHERE code = 10105; -INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10105, 'cin', md5('fiv'), 'cin@pluto.com', CAST (X'00010000' as integer), 10103); -DELETE FROM #PFX#users WHERE code = 10106; -INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10106, 'sei', md5('six'), 'sei@pluto.com', CAST (X'00210000' as integer), 10103); -ALTER SEQUENCE #PFX#users_code_seq RESTART WITH 10107; diff --git a/sql/sql.d/900-anagr.sql.devel b/sql/sql.d/900-anagr.sql.devel new file mode 100644 index 0000000..9de8924 --- /dev/null +++ b/sql/sql.d/900-anagr.sql.devel @@ -0,0 +1,28 @@ +-- +-- Populate users db. +-- + +-- macro for user_flag bit-field +-- define('USER_FLAG_TY_ALL', 0xff0000); // done +-- define('USER_FLAG_TY_NORM', 0x010000); // done +-- define('USER_FLAG_TY_SUPER', 0x020000); // done +-- define('USER_FLAG_TY_CERT', 0x040000); // done +-- define('USER_FLAG_TY_FIRONLY', 0x200000); // done +-- define('USER_FLAG_TY_ADMIN', 0x400000); // done +-- define('USER_FLAG_TY_DISABLE', 0x800000); // done + + +DELETE FROM #PFX#users WHERE code = 10101; +DELETE FROM #PFX#users WHERE guar_code = 10101 AND code != 10101; +INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10101, 'uno', md5('one'), 'uno@pluto.com', CAST (X'00450000' as integer), 10101); +DELETE FROM #PFX#users WHERE code = 10102; +INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10102, 'due', md5('two'), 'due@pluto.com', CAST (X'00010000' as integer), 10101); +DELETE FROM #PFX#users WHERE code = 10103; +INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10103, 'tre', md5('thr'), 'tre@pluto.com', CAST (X'00010000' as integer), 10102); +DELETE FROM #PFX#users WHERE code = 10104; +INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10104, 'qua', md5('for'), 'qua@pluto.com', CAST (X'00010000' as integer), 10102); +DELETE FROM #PFX#users WHERE code = 10105; +INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10105, 'cin', md5('fiv'), 'cin@pluto.com', CAST (X'00010000' as integer), 10103); +DELETE FROM #PFX#users WHERE code = 10106; +INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10106, 'sei', md5('six'), 'sei@pluto.com', CAST (X'00210000' as integer), 10103); +ALTER SEQUENCE #PFX#users_code_seq RESTART WITH 10107; diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 1eb6f94..760e377 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -1660,13 +1660,13 @@ class Brisk $ret = 2; break; } - if (($user_item = $bdb->getitem_bylogin($user_login, $user_code)) == FALSE) { + if ($user_login == $user->name) { $ret = 3; + $mesg = sprintf($mlang_brisk['inf_self'][$G_lang]); break; } - if ($user_login == $user->name) { + if (($user_item = $bdb->getitem_bylogin($user_login, $user_code)) == FALSE) { $ret = 4; - $mesg = sprintf($mlang_brisk['inf_self'][$G_lang]); break; } if (($guar_item = $bdb->getitem_bycode($user_item->guar_code_get())) != FALSE) { @@ -1677,6 +1677,10 @@ class Brisk } $user_tos_vers = $user_item->tos_vers_get(); + if (($usernet_item = $bdb->usernet_bycode($user->code, $user_item->code)) == FALSE) { + $usernet_item = $bdb->usernet_default($user->code, $user_item->code); + } + if (versions_cmp($user_tos_vers, "1.2") < 0) { $mesg = sprintf($mlang_brisk['tos_old'][$G_lang], xcape($user_login)); } diff --git a/web/Obj/dbase_base.phh b/web/Obj/dbase_base.phh index 1e7a19a..5e65ec8 100644 --- a/web/Obj/dbase_base.phh +++ b/web/Obj/dbase_base.phh @@ -3,7 +3,7 @@ * brisk - dbase_base.phh * * Copyright (C) 2011-2012 Matteo Nastasi - * mailto: nastasi@alternativeoutput.it + * mailto: nastasi@alternativeoutput.it * matteo.nastasi@milug.org * web: http://www.alternativeoutput.it * @@ -56,7 +56,7 @@ class LoginDBItem { static function LoginDBItemFromRecord($rec) { - $ret = new LoginDBItem($rec->code, $rec->login, $rec->pass, + $ret = new LoginDBItem($rec->code, $rec->login, $rec->pass, $rec->email, $rec->type, $rec->last_dona, $rec->supp_comp, $rec->tos_vers, $rec->disa_reas, $rec->guar_code, $rec->match_cnt, $rec->game_cnt); @@ -73,7 +73,7 @@ class LoginDBItem { { return $this->login; } - + function pass_get() { return $this->pass; @@ -181,4 +181,47 @@ class MailDBItem { return $bdb->mail_add_fromitem($this); } } + +define('USERNET_FRIEND', 0); +define('USERNET_CLEVER', 1); +define('USERNET_TRUST', 2); +class UserNetItem { + var $owner; + var $target; + var $friend; + var $clever; + var $trust; + + var $from_db; + + function UserNetItem($owner, $target, $friend, $clever, $trust, $from_db) + { + $this->owner = $owner; + $this->target = $target; + $this->friend = $friend; + $this->clever = $clever; + $this->trust = $trust; + + $this->from_db = $from_db; + } + + static function UserNetItemFromRecord($rec) + { + $ret = new UserNetItem($rec->owner, $rec->target, $rec->friend, + $rec->clever, $rec->trust, TRUE); + + return ($ret); + } + + static function UserNetItemDefaults($owner, $target) + { + $ret = new UserNetItem($owner, $target, USERNET_FRIEND, + USERNET_CLEVER, USERNET_TRUST, FALSE); + + return ($ret); + } + + +} + ?> \ No newline at end of file diff --git a/web/Obj/dbase_pgsql.phh b/web/Obj/dbase_pgsql.phh index 77c215f..e3e1551 100644 --- a/web/Obj/dbase_pgsql.phh +++ b/web/Obj/dbase_pgsql.phh @@ -855,6 +855,28 @@ INSERT INTO %smails (code, ucode, type, tstamp, subj, body_txt, body_htm, hash) return (TRUE); } + function usernet_bycode($owner, $target) + { + GLOBAL $G_dbpfx; + $ret = FALSE; + + $net_sql = sprintf("SELECT * FROM %susers_net WHERE owner = %d AND target = %d;", + $G_dbpfx, $owner, $target); + if (($net_pg = $this->query($net_sql)) == FALSE) { + return FALSE; + } + if (pg_numrows($net_pg) != 1) + return FALSE; + + $net_obj = pg_fetch_object($net_pg, 0); + + return (UserNetItem::UserNetItemFromRecord($net_obj)); + } + + function usernet_default($owner, $target) + { + return (UserNetItem::UserNetItemDefaults($owner, $target)); + } } // End class BriskDB