full 'listen' prefs management completed and partial 'comps' prefs implemented
[brisk.git] / web / index_wr.php
index cf41230..001b51f 100644 (file)
@@ -391,17 +391,26 @@ function index_wr_main(&$brisk, $remote_addr_full, $get, $post, $cookie)
            [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;
+            if ($post['F_act'] == 'update' || $post['F_act'] == 'store') {
+                $cont = json_decode($post['json']);
+                $leaf = ($post['F_act'] == 'update' ? 'cur' : 'val');
+
+                $listen_flags = (($cont->listen->$leaf == '1' ? USER_FLAG_LISTAUTH : 0) |
+                                 ($cont->listen->$leaf == '2' ? USER_FLAG_ISOLAUTH : 0));
+                $user->flags_set($listen_flags, USER_FLAG_MAP_AUTH);
+                if ($post['F_act'] == 'store'
+                    && $user->flags_db_get(USER_FLAG_MAP_AUTH) != $user->flags_get(USER_FLAG_MAP_AUTH)) {
+                    $user->prefs_store();
+                }
+            }
+            if ($user->stat == 'room' && $user->subst == 'standup') {
+                $brisk->standup_update($user);
             }
-            else if ($cont->listen->cur == '2') {
-                $new_flags_cur |= USER_FLAG_ISOLAUTH;
+            else if ($user->stat == 'room' && $user->subst == 'sitdown') {
+                $brisk->table_update($user);
             }
-            $user->flags_cur = $new_flags_cur;
-            fprintf(STDERR, "INFO: prefsf postset [%x]\n", $user->flags_cur);
+            echo "1";
+            return TRUE;
         }
     }
     else if ($argz[0] == 'prefs') {