--- /dev/null
+--
+-- Table to manage users trust network
+--
+DROP TABLE IF EXISTS #PFX#usersnet;
+CREATE TABLE #PFX#usersnet (
+ owner integer REFERENCES #PFX#users (code)
+ ON DELETE cascade ON UPDATE cascade, -- network owner
+ target integer REFERENCES #PFX#users (code)
+ ON DELETE cascade ON UPDATE cascade, -- evaluated user
+ friend integer, -- friendship level
+ skill integer, -- skill level
+ trust integer, -- auth
+ ctime timestamp DEFAULT now(), -- creation time
+ mtime timestamp DEFAULT to_timestamp(0) -- modification time
+ );
+
+DROP INDEX IF EXISTS #PFX#usersnet_owner_idx;
+DROP INDEX IF EXISTS #PFX#usersnet_target_idx;
+DROP INDEX IF EXISTS #PFX#usersnet_owner_target_idx;
+CREATE INDEX #PFX#usersnet_owner_idx ON #PFX#usersnet (owner);
+CREATE INDEX #PFX#usersnet_target_idx ON #PFX#usersnet (target);
+CREATE UNIQUE INDEX #PFX#usersnet_owner_target_idx ON #PFX#usersnet (owner,target);
+
+
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;
+DELETE FROM #PFX#users WHERE code = 10107;
+INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10107, E'"/\\''|', md5('sev'), 'sev@pluto.com', CAST (X'00210000' as integer), 10103);
+ALTER SEQUENCE #PFX#users_code_seq RESTART WITH 10108;
--- /dev/null
+DELETE FROM #PFX#usersnet WHERE owner = 10101 AND friend = 10102;
+INSERT INTO #PFX#usersnet (owner, target, friend, skill, trust) VALUES (10101, 10102, 3, 2, 3);
+DELETE FROM #PFX#usersnet WHERE owner = 10101 AND friend = 10107;
+INSERT INTO #PFX#usersnet (owner, target, friend, skill, trust) VALUES (10101, 10107, 3, 3, 4);
+
} while (0);
} // nick chat command
else if (strncmp($msg, "/info ", 6) == 0) {
- $guar_user = substr($msg, 6);
+ $info_user = substr($msg, 6);
- error_log("here [" . $guar_user."]");
- echo $this->info_show($user, $guar_user, $dt);
+ error_log("here [" . $info_user."][".escsql(urldecode($info_user)). "]");
+ echo $this->info_show($user, urldecode($info_user), $dt);
}
else if (strncmp($msg, "/st ", 4) == 0) {
log_main("chatt_send BEGIN");
},
// { 'name': 'value' }
- populate: function(field_values)
+ json2dom: function(field_values)
{
for (k in this.field) {
if (this.field[k].type == 'value') {
}
},
+ dom2json: function()
+ {
+ var ret = {};
+ for (k in this.field) {
+ if (this.field[k].perms == 'ro')
+ continue;
+ if (this.field[k].type == 'value') {
+ ret[k] = this.fld_value_get(k);
+ }
+ else if (this.field[k].type == 'radio') {
+ ret[k] = this.fld_radio_get(k);
+ }
+ }
+ return ret;
+ },
+
fld_value_set: function(name, value)
{
this.ancestor.getElementsByClassName(name + '_id')[0].innerHTML = value;
},
+ fld_value_get: function(name)
+ {
+ return this.ancestor.getElementsByClassName(name + '_id')[0].innerHTML;
+ },
+
fld_radio_set: function(name, value)
{
var arr = this.ancestor.getElementsByClassName(name + '_id');
arr[k].checked = false;
}
},
+
+ fld_radio_get: function(name)
+ {
+ var arr = this.ancestor.getElementsByClassName(name + '_id');
+ ret = null;
+
+ for (k in arr) {
+ if (arr[k].checked == true) {
+ ret = arr[k].value;
+ break;
+ }
+ }
+ return ret;
+ },
+
tap: null
}
<script type="text/javascript" src="commons.js"></script>
<script type="text/javascript" src="fieldify.js"></script>
<script type="text/javascript" src="prefs.js"></script>
+<script type="text/javascript" src="info.js"></script>
<!-- <script type="text/javascript" src="myconsole.js"></script> -->
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript" src="heartbit.js"></script>
<script type="text/javascript" src="commons.js"></script>
<script type="text/javascript" src="fieldify.js"></script>
<script type="text/javascript" src="prefs.js"></script>
+<script type="text/javascript" src="info.js"></script>
<!-- <script type="text/javascript" src="myconsole.js"></script> -->
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript" src="ticker.js"></script>
</table>
<div style="position: absolute; bottom: 8px; margin: auto; width: 100%;">
<input type="submit" class="input_sub" style="bottom: 4px;" onclick="$('info').style.visibility = 'hidden';" value="<?php echo $mlang_room['btn_close'][$G_lang]; ?>"/>
-<!-- <input type="submit" class="input_sub" style="bottom: 4px;" onclick="prefs_reset();" value="<?php echo $mlang_room['btn_reset'][$G_lang]; ?>"/>
-<input type="submit" class="input_sub" style="bottom: 4px;" onclick="prefs_save();" value="<?php echo $mlang_room['btn_save'][$G_lang]; ?>"/> -->
+<input type="submit" class="input_sub" style="bottom: 4px;" onclick="info_reset();" value="<?php echo $mlang_room['btn_reset'][$G_lang]; ?>"/>
+<input type="submit" class="input_sub" style="bottom: 4px;" onclick="info_save();" value="<?php echo $mlang_room['btn_save'][$G_lang]; ?>"/>
</div>
</div>
--- /dev/null
+/*
+ * brisk - info.js
+ *
+ * Copyright (C) 2015 Matteo Nastasi
+ * mailto: nastasi@alternativeoutput.it
+ * matteo.nastasi@milug.org
+ * web: http://www.alternativeoutput.it
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details. You should have received a
+ * copy of the GNU General Public License along with this program; if
+ * not, write to the Free Software Foundation, Inc, 59 Temple Place -
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+function info_fld(dobj)
+{
+ var fields = { login: { type: 'value' },
+ state: { type: 'value', perms: 'ro' },
+ guar: { type: 'value', perms: 'ro' },
+ match: { type: 'value', perms: 'ro' },
+ game: { type: 'value', perms: 'ro' },
+ friend: { type: 'radio' },
+ skill: { type: 'radio' },
+ trust: { type: 'radio' }
+ };
+
+ return (new Fieldify(dobj, fields));
+ }
+
+function info_show(username)
+{
+ var info_in_in = server_request('mesg', 'chatt|/info ' +
+ encodeURIComponent(username));
+ var info_in = JSON.parse(info_in_in);
+ var info = null;
+
+ if (info_in.ret == 0) {
+ info = info_fld($('info'));
+ info.json2dom(info_in);
+ info.visible(true);
+ }
+ else {
+ alert("error: open info window failed");
+ }
+}
+
+var g__info_show_target = "";
+function info_show_cb(e)
+{
+ if (g__info_show_target == e.target.innerHTML) {
+ g__info_show_target = "";
+ info_show(e.target.innerHTML);
+ }
+ else {
+ g__info_show_target = e.target.innerHTML;
+ }
+}
+
+function info_save()
+{
+ var ret;
+
+ info = info_fld($('info'));
+ ret = info.dom2json();
+
+ console.log(ret);
+
+ if (0 == 1) {
+ if (typeof(g_prefs) == 'undefined')
+ return false;
+
+ ret = server_request('mesg', 'info|save','__POST__', 'prefs', JSON.stringify(g_prefs));
+
+ if (ret == 1)
+ $('preferences').style.visibility = 'hidden';
+ }
+}
+
+function info_reset()
+{
+ var ret;
+
+ ret = server_request('mesg', 'prefs|reset');
+}
var usr = $("standup").getElementsByClassName("id_usr");
for (i = 0 ; i < usr.length ; i++) {
- addEvent(usr[i], "click", click_update_cb);
+ addEvent(usr[i], "click", info_show_cb);
}
}
act_logout(0);
};
-var g_user_info_target = "";
-
-function info_show(username)
-{
- // ret = server_request('mesg', 'prefs|save','__POST__', 'prefs', JSON.stringify(g_prefs));
- var info_in = JSON.parse(server_request('mesg', 'chatt|/info ' + username));
- var info = null;
-
- if (info_in.ret == 0) {
- var fields = { login: { type: 'value' },
- state: { type: 'value' },
- guar: { type: 'value' },
- match: { type: 'value' },
- game: { type: 'value' },
- friend: { type: 'radio' },
- skill: { type: 'radio' },
- trust: { type: 'radio' }
- };
-
- info = new Fieldify($('info'), fields);
- info.populate(info_in);
- info.visible(true);
- }
- else {
- console.log("some error: open a dialog");
- }
- // FIXME: just to be finished
- console.log(info);
-}
-
-function click_update_cb(e)
-{
- if (g_user_info_target == e.target.innerHTML) {
- g_user_info_target = "";
- info_show(e.target.innerHTML);
- }
- else {
- g_user_info_target = e.target.innerHTML;
- }
-}
-
function j_tab_cont(table_idx, data)
{
var i;
$("table"+table_idx).innerHTML = content;
var usr = $("table"+table_idx).getElementsByClassName("id_usr");
for (i = 0 ; i < usr.length ; i++) {
- addEvent(usr[i], "click", click_update_cb);
+ addEvent(usr[i], "click", info_show_cb);
}
}