full 'listen' prefs management completed and partial 'comps' prefs implemented
[brisk.git] / web / Obj / dbase_base.phh
index d587352..d7d8068 100644 (file)
@@ -3,7 +3,7 @@
    *  brisk - dbase_base.phh
    *
    *  Copyright (C) 2011-2012 Matteo Nastasi
-   *                          mailto: nastasi@alternativeoutput.it 
+   *                          mailto: nastasi@alternativeoutput.it
    *                                  matteo.nastasi@milug.org
    *                          web: http://www.alternativeoutput.it
    *
@@ -34,8 +34,11 @@ class LoginDBItem {
     var $tos_vers;
     var $disa_reas;
     var $guar_code;
+    var $match_cnt;
+    var $game_cnt;
 
-    function LoginDBItem($code, $login, $pass, $email, $type, $last_dona, $supp_comp, $tos_vers, $disa_reas, $guar_code)
+    function LoginDBItem($code, $login, $pass, $email, $type, $last_dona, $supp_comp, $tos_vers,
+                         $disa_reas, $guar_code, $match_cnt, $game_cnt)
     {
         $this->code      = $code;
         $this->login     = $login;
@@ -47,13 +50,16 @@ class LoginDBItem {
         $this->tos_vers  = $tos_vers;
         $this->disa_reas = $disa_reas;
         $this->guar_code = $guar_code;
+        $this->match_cnt = $match_cnt;
+        $this->game_cnt  = $game_cnt;
     }
 
     static function LoginDBItemFromRecord($rec)
     {
-        $ret = new LoginDBItem($rec->code, $rec->login, $rec->pass, 
+        $ret = new LoginDBItem($rec->code, $rec->login, $rec->pass,
                                $rec->email, $rec->type, $rec->last_dona,
-                               $rec->supp_comp, $rec->tos_vers, $rec->disa_reas, $rec->guar_code);
+                               $rec->supp_comp, $rec->tos_vers, $rec->disa_reas, $rec->guar_code,
+                               $rec->match_cnt, $rec->game_cnt);
 
         return ($ret);
     }
@@ -67,7 +73,7 @@ class LoginDBItem {
     {
         return $this->login;
     }
-    
+
     function pass_get()
     {
         return $this->pass;
@@ -92,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;
@@ -119,6 +157,109 @@ class LoginDBItem {
         return $this->guar_code;
     }
 
+    function match_cnt_get()
+    {
+        return $this->match_cnt;
+    }
+    function match_cnt_add($v)
+    {
+        return $this->match_cnt += $v;
+    }
+
+    function game_cnt_get()
+    {
+        return $this->game_cnt;
+    }
+    function game_cnt_add($v)
+    {
+        return $this->game_cnt += $v;
+    }
+}
+
+define('MAIL_TYP_CHECK', 1);
+
+class MailDBItem {
+    var $code;
+    var $ucode;
+    var $type;
+    var $tstamp;
+    var $subj;
+    var $body_txt;
+    var $body_htm;
+    var $hash;
+
+    function MailDBItem($code, $ucode, $type, $tstamp, $subj, $body_txt, $body_htm, $hash=NULL)
+    {
+        $this->code = $code;
+        $this->ucode = $ucode;
+        $this->type = $type;
+        $this->tstamp = $tstamp;
+        $this->subj = $subj;
+        $this->body_txt = $body_txt;
+        $this->body_htm = $body_htm;
+        $this->hash = $hash;
+    }
+
+    static function MailDBItemFromRecord($rec)
+    {
+        $ret = new MailDBItem($rec->code, $rec->ucode, $rec->type, $rec->tstamp, $rec->subj,
+                              $rec->body_txt, $rec->body_htm, $rec->hash);
+
+        return ($ret);
+    }
+
+    function store($bdb)
+    {
+        return $bdb->mail_add_fromitem($this);
+    }
+}
+
+define('USERSNET_DEF_FRIEND', 2);
+define('USERSNET_DEF_SKILL', 2);
+define('USERSNET_DEF_TRUST', 2);
+
+class UsersNetItem {
+    var $owner;
+    var $target;
+    var $friend;
+    var $skill;
+    var $trust;
+
+    var $from_db;
+
+    function UsersNetItem($owner, $target, $friend, $skill, $trust,
+                          $widefriend, $narrowfriend, $from_db)
+    {
+        $this->owner = $owner;
+        $this->target = $target;
+        $this->friend = $friend;
+        $this->skill = $skill;
+        $this->trust = $trust;
+        $this->widefriend = $widefriend;
+        $this->narrowfriend = $narrowfriend;
+
+        $this->from_db = $from_db;
+    }
+
+    static function UsersNetItemFromRecord($rec, $widefriend, $narrowfriend)
+    {
+        $ret = new UsersNetItem($rec->owner, $rec->target, $rec->friend,
+                               $rec->skill, $rec->trust,
+                                $widefriend, $narrowfriend, TRUE);
+
+        return ($ret);
+    }
+
+    static function UsersNetItemDefaults($owner, $target, $widefriend, $narrowfriend)
+    {
+        $ret = new UsersNetItem($owner, $target, USERSNET_DEF_FRIEND,
+                                USERSNET_DEF_SKILL, USERSNET_DEF_TRUST,
+                                $widefriend, $narrowfriend, FALSE);
+
+        return ($ret);
+    }
+
+
 }
 
 ?>
\ No newline at end of file