full 'listen' prefs management completed and partial 'comps' prefs implemented
[brisk.git] / web / Obj / user.phh
index 3d09ceb..1d693d5 100644 (file)
@@ -209,6 +209,7 @@ class User {
     $thiz->handpt     = -1;
     $thiz->exitislock = TRUE;
 
+    $thiz->flags_db   = 0x00;
     $thiz->flags      = 0x00;
     $thiz->rec        = FALSE;
 
@@ -258,6 +259,7 @@ class User {
     $this->handpt     = $from->handpt;
     $this->exitislock = $from->exitislock;
 
+    $this->flags_db   = $from->flags_db;
     $this->flags      = $from->flags;
     $this->rec        = $from->rec;
 
@@ -326,6 +328,7 @@ class User {
     $thiz->exitislock = $from->exitislock;
     $thiz->the_end    = $from->the_end;
 
+    $thiz->flags_db   = $from->flags_db;
     $thiz->flags      = $from->flags;
     $thiz->rec        = $from->rec;
 
@@ -372,6 +375,24 @@ class User {
       return FALSE;
   }
 
+  function flags_db_get($mask)
+  {
+      return ($this->flags_db & $mask);
+  }
+
+  function flags_db_set($flags_db, $mask)
+  {
+      $flags_db_old = $this->flags_db & (~$mask);
+      $this->flags_db = ($flags_db_old | ($flags_db & $mask));
+
+      return ($flags_db_old);
+  }
+
+  function flags_get($mask)
+  {
+      return ($this->flags & $mask);
+  }
+
   function flags_set($flags, $mask)
   {
       $flags_old = $this->flags & (~$mask);
@@ -385,7 +406,11 @@ class User {
       if (($bdb = BriskDB::create()) == FALSE) {
           return FALSE;
       }
-      return ($bdb->user_prefs_update($this->code, ($this->flags & (USER_FLAG_TY_ALL | USER_FLAG_MAP_AUTH)),
+      if ($this->flags_db == $this->flags)
+          return TRUE;
+
+      $this->flags_db = $this->flags;
+      return ($bdb->user_prefs_update($this->code, ($this->flags_db & (USER_FLAG_TY_ALL | USER_FLAG_MAP_AUTH)),
                                       $this->rec->supp_comp_get()));
   }
 
@@ -399,10 +424,11 @@ class User {
 
   function state_store()
   {
-   if (($bdb = BriskDB::create()) == FALSE) {
+      if (($bdb = BriskDB::create()) == FALSE) {
           return FALSE;
       }
-      return ($bdb->user_state_update($this->code, ($this->flags & (USER_FLAG_TY_ALL | USER_FLAG_MAP_AUTH)),
+      $this->flags_db = $this->flags;
+      return ($bdb->user_state_update($this->code, ($this->flags_db & (USER_FLAG_TY_ALL | USER_FLAG_MAP_AUTH)),
                                       $this->rec->disa_reas_get()));
   }