full 'listen' prefs management completed and partial 'comps' prefs implemented
[brisk.git] / web / Obj / dbase_base.phh
index 5e65ec8..d7d8068 100644 (file)
@@ -98,6 +98,38 @@ class LoginDBItem {
     {
         return $this->supp_comp;
     }
+    function supp_comp_get_array()
+    {
+        $ret = array();
+        $group_id = array("fg", "bg");
+        $comp_id = array("r", "g", "b");
+        $ret_arr = array();
+        $supp_comp = $this->supp_comp;
+
+        for ($i = 0 ; $i < 2 ; $i++) {
+            $group_cur = $group_id[$i];
+            $ret_arr[$group_cur] = array();
+            for ($e = 0 ; $e < 3 ; $e++) {
+                $ret_arr[$group_cur][$comp_id[$e]] = base_convert(substr($supp_comp, $i*6 + $e*2, 2), 16, 10);
+            }
+        }
+        return ($ret_arr);
+    }
+
+    function supp_comp_set_array($supp_comp_in)
+    {
+        $group_id = array("fg", "bg");
+        $comp_id = array("r", "g", "b");
+        $supp_comp = "";
+
+        for ($i = 0 ; $i < 2 ; $i++) {
+            for ($e = 0 ; $e < 3 ; $e++) {
+                $supp_comp += sprintf("%02x", $supp_comp_in[$group_id[$i]][$comp_id[$e]]);
+            }
+        }
+        $this->supp_comp = $supp_comp;
+    }
+
     function supp_comp_set($supp_comp)
     {
         $this->supp_comp = $supp_comp;
@@ -182,41 +214,47 @@ class MailDBItem {
     }
 }
 
-define('USERNET_FRIEND', 0);
-define('USERNET_CLEVER', 1);
-define('USERNET_TRUST', 2);
-class UserNetItem {
+define('USERSNET_DEF_FRIEND', 2);
+define('USERSNET_DEF_SKILL', 2);
+define('USERSNET_DEF_TRUST', 2);
+
+class UsersNetItem {
     var $owner;
     var $target;
     var $friend;
-    var $clever;
+    var $skill;
     var $trust;
 
     var $from_db;
 
-    function UserNetItem($owner, $target, $friend, $clever, $trust, $from_db)
+    function UsersNetItem($owner, $target, $friend, $skill, $trust,
+                          $widefriend, $narrowfriend, $from_db)
     {
         $this->owner = $owner;
         $this->target = $target;
         $this->friend = $friend;
-        $this->clever = $clever;
+        $this->skill = $skill;
         $this->trust = $trust;
+        $this->widefriend = $widefriend;
+        $this->narrowfriend = $narrowfriend;
 
         $this->from_db = $from_db;
     }
 
-    static function UserNetItemFromRecord($rec)
+    static function UsersNetItemFromRecord($rec, $widefriend, $narrowfriend)
     {
-        $ret = new UserNetItem($rec->owner, $rec->target, $rec->friend,
-                               $rec->clever, $rec->trust, TRUE);
+        $ret = new UsersNetItem($rec->owner, $rec->target, $rec->friend,
+                               $rec->skill, $rec->trust,
+                                $widefriend, $narrowfriend, TRUE);
 
         return ($ret);
     }
 
-    static function UserNetItemDefaults($owner, $target)
+    static function UsersNetItemDefaults($owner, $target, $widefriend, $narrowfriend)
     {
-        $ret = new UserNetItem($owner, $target, USERNET_FRIEND,
-                               USERNET_CLEVER, USERNET_TRUST, FALSE);
+        $ret = new UsersNetItem($owner, $target, USERSNET_DEF_FRIEND,
+                                USERSNET_DEF_SKILL, USERSNET_DEF_TRUST,
+                                $widefriend, $narrowfriend, FALSE);
 
         return ($ret);
     }