#!/bin/bash
# set -x
+set -e
#
# Defaults
#
if ($user->is_auth()) {
$model = '{ "listen": { "__type": "radio" } }';
- $content = '{ "listen": {"val": "' . ($user->flags & USER_FLAG_ISOLAUTH ? "2" :
- ($user->flags & USER_FLAG_LISTAUTH ? "1" : "0")) .
- '" } }';
+ $content = array('listen' => array('val' => ($user->flags & USER_FLAG_ISOLAUTH ? "2" :
+ ($user->flags & USER_FLAG_LISTAUTH ? "1" : "0")),
+ 'cur' => ($user->flags_cur & USER_FLAG_ISOLAUTH ? "2" :
+ ($user->flags_cur & USER_FLAG_LISTAUTH ? "1" : "0"))));
+
$ret .= sprintf('g_prefsf.fields_descr_set(JSON.parse(\'%s\'));', $model);
- $ret .= sprintf('g_prefsf.json2dom(JSON.parse(\'%s\'));', $content);
+ $ret .= sprintf('g_prefsf.json2dom(JSON.parse(\'%s\'));', json_encode($content));
}
if ($user->subst == 'standup')
$this->user[$idx]->flags |= ($authenticate != FALSE ? USER_FLAG_AUTH : 0x00);
$this->user[$idx]->flags |= ( ($pass != FALSE && $bdb == FALSE) ? USER_FLAG_DBFAILED : 0x00);
log_auth("XXX", sprintf("FLAGS: [%x]", $this->user[$idx]->flags));
-
+ $this->user[$idx]->flags_cur = $this->user[$idx]->flags;
if ($authenticate != FALSE) {
$this->user[$idx]->code = $authenticate->code_get();
- if (0 == 1) {
- // all this part is included in the db server
- $this->user[$idx]->flags |= USER_FLAG_LISTAUTH;
-
- if (isset($cookie['CO_list'])) {
- fprintf(STDERR, "QQ: %s CO_list: [%s]\n", __FUNCTION__, $cookie['CO_list']);
- if (strcmp($cookie['CO_list'], "auth") == 0) {
- $this->user[$idx]->flags &= ~USER_FLAG_MAP_AUTH;
- $this->user[$idx]->flags |= USER_FLAG_LISTAUTH;
- }
- if (strcmp($cookie['CO_list'], "isolation") == 0) {
- $this->user[$idx]->flags &= ~USER_FLAG_MAP_AUTH;
- $this->user[$idx]->flags |= USER_FLAG_ISOLAUTH;
- }
- else {
- $this->user[$idx]->flags &= ~USER_FLAG_MAP_AUTH;
- }
- }
- }
- else {
- fprintf(STDERR, "QQ: CO_list not set flags: %x\n", __FUNCTION__, $this->user[$idx]->flags);
- }
}
fprintf(STDERR, "QQ %s: flag %x\n", __FUNCTION__, $this->user[$idx]->flags);
if ($ghost > -1) {
$thiz->exitislock = TRUE;
$thiz->flags = 0x00;
+ $thiz->flags_cur = 0x00;
$thiz->rec = FALSE;
$thiz->chattime = array_fill(0, CHAT_N, 0);
$this->exitislock = $from->exitislock;
$this->flags = $from->flags;
+ $this->flags_cur = $from->flags_cur;
$this->rec = $from->rec;
$this->chattime = array();
$thiz->the_end = $from->the_end;
$thiz->flags = $from->flags;
+ $thiz->flags_cur = $from->flags_cur;
$thiz->rec = $from->rec;
$thiz->chattime = array_fill(0, CHAT_N, 0);
return ($flags_old);
}
+ function flags_cur_set($flags_cur, $mask)
+ {
+ $flags_cur_old = $this->flags_cur & (~$mask);
+ $this->flags_cur = ($flags_cur_old | ($flags_cur & $mask));
+
+ return ($flags_cur_old);
+ }
+
function prefs_store()
{
if (($bdb = BriskDB::create()) == FALSE) {
}
}
else if ($argz[0] == 'prefsf') {
- fprintf(STDERR, "INFO: prefsf case\n");
+ fprintf(STDERR, "INFO: prefsf case [%s]\n", $post['F_act']);
+ if (!isset($post['model_name']) || !isset($post['json']))
+ return FALSE;
+
+ /* [F_act] => update
+ [model_name] => prefsf
+ [counter] => 1
+ [json] => {"listen":{"act":"1"}}
+ */
+ if ($post['model_name'] == 'prefsf') {
+ fprintf(STDERR, "INFO: prefsf preset [%x]\n", $user->flags_cur);
+ $cont = json_decode($post['json']);
+ $new_flags_cur = $user->flags_cur & ~(USER_FLAG_ISOLAUTH | USER_FLAG_LISTAUTH);
+ if ($cont->listen->cur == '1') {
+ $new_flags_cur |= USER_FLAG_LISTAUTH;
+ }
+ else if ($cont->listen->cur == '2') {
+ $new_flags_cur |= USER_FLAG_ISOLAUTH;
+ }
+ $user->flags_cur = $new_flags_cur;
+ fprintf(STDERR, "INFO: prefsf postset [%x]\n", $user->flags_cur);
+ }
}
else if ($argz[0] == 'prefs') {
if ($argz[1] == 'save') {
$prefs = Client_prefs::from_user($user);
}
$user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
- $user->comm[$user->step % COMM_N] .= sprintf('prefs_load(\'%s\', true, %s);', json_encode($prefs),
- 'false');
+ $user->comm[$user->step % COMM_N] .= sprintf('prefs_load(\'%s\', true, %s);', json_encode($prefs),
+ 'false');
$user->step_inc();
if ($argz[1] == 'save') {