read terms-of-service from file
[brisk.git] / web / Obj / user.phh
index 0661c38..9554cc0 100644 (file)
@@ -63,6 +63,11 @@ define('USER_FLAG_TY_FIRONLY', 0x200000); // done
 define('USER_FLAG_TY_SUSPEND', 0x400000); // done
 define('USER_FLAG_TY_DISABLE', 0x800000); // done
 
+// ... reasons for disabling account ...
+define('USER_DIS_REA_INVMAIL', 1);
+define('USER_DIS_REA_LICENCE', 2);
+define('USER_DIS_REA_BANNED',  3);
+
 // 240 is the right value, 600 is for fwrite error test
 define('RD_ENDTIME_DELTA',  240);
 define('RD_KEEPALIVE_TOUT',   4);
@@ -310,15 +315,34 @@ class User {
   {
       $flags_old = $this->flags & (~$mask);
       $this->flags = ($flags_old | ($flags & $mask));
+
+      return ($flags_old);
   }
 
-  function store_set()
+  function prefs_store()
   {
       if (($bdb = BriskDB::create()) == FALSE) {
           return FALSE;
       }
       return ($bdb->user_prefs_update($this->code, ($this->flags & (USER_FLAG_TY_ALL | USER_FLAG_MAP_AUTH)),
-                                      $this->rec->supp_comp));
+                                      $this->rec->supp_comp_get()));
+  }
+
+  function licence_store()
+  {
+      if (($bdb = BriskDB::create()) == FALSE) {
+          return FALSE;
+      }
+      return ($bdb->user_licence_update($this->code, $this->rec->lice_vers_get()));
+  }
+
+  function state_store()
+  {
+   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->rec->disa_reas_get()));
   }
 
   function rd_data_set($curtime, $transp, $enc, $stat, $subst, $step, $from)
@@ -533,7 +557,7 @@ class User {
 
   protected function maincheck($get, $post, $cookie)
   {
-      GLOBAL $G_lang, $mlang_indrd;
+      GLOBAL $G_lang, $G_base, $mlang_indrd;
       // GLOBAL $first_loop;
       GLOBAL $G_with_splash, $G_splash_content, $G_splash_interval, $G_splash_idx;
       GLOBAL $G_splash_w, $G_splash_h, $G_splash_timeout;
@@ -586,7 +610,40 @@ class User {
           if ($this->stat == 'room') {
               log_rd("roomma ".$this->step);
               $curtime = time();
-              
+              if ($this->rec !== FALSE) {
+                  if ($curtime > $G_lice_dtsoft || $curtime > $G_lice_dthard) {
+                      if (versions_cmp($this->rec->lice_vers_get(), $G_lice_vers) < 0) { // comparison between user version and current version
+                          if ($curtime > $G_lice_dtsoft) {
+                              // call notify soft
+                              // FIXME: manage translations
+                              $ret .=  show_notify_document(esclfhtml(file_get_contents($G_base.sprintf($G_lice_fname, $G_lice_vers, $G_lang))),
+                                       0, array("Accetto.", "Rifiuto.", "Leggo poi.",  /* , "Scarico." */),
+                                       "lice_confirm", 600, 600, TRUE, 0);
+                              $ret .= sprintf("act_licencemgr('soft', g_nd.ret_get(), '%s', '%s');", 
+                                              xcape($this->rec->lice_vers_get()), xcape($G_lice_vers));
+                          }
+                          else if ($curtime > $G_lice_dthard) {
+                              // call notify hard
+                              $ret .=  show_notify_document(esclfhtml(file_get_contents($G_base.sprintf($G_lice_fname, $G_lice_vers, $G_lang))),
+                                       0, array("Accetto.", "Rifiuto." /* , "Scarico." */),
+                                       "lice_confirm", 600, 600, TRUE, 0);
+                              $ret .= sprintf("act_licencemgr('hard', g_nd.ret_get(), '%s', '%s');", 
+                                              xcape($this->rec->lice_vers_get()), xcape($G_lice_vers));
+                          }
+
+
+                          /* $ret .=  show_notify_ex(str_replace("\n", " ", "Versione corrente: [".$this->rec->lice_vers_get()."] Versione sito: ".$G_lice_vers), */
+                          /*     ($is_super ? 0 : $G_splash_timeout), */
+                          /*     // $mlang_indrd[($is_super ? 'btn_btotabsup' : 'btn_backtotab')][$G_lang], */
+                          /*     $mlang_indrd['btn_backtotab'][$G_lang], */
+                          /*     $G_splash_w, $G_splash_h, true, */
+                          /*     ($is_super ? 0 : $G_splash_timeout)); */
+                          /* $ret .= sprintf('|createCookie("CO_lice_date%d", %d, 24*365, cookiepath);', $G_lice_idx, $curtime); */
+
+
+                      }
+                  }
+              }
               if ($G_with_splash &&
                   ($splashdate < $curtime - $G_splash_interval ||
                    $splashdate > $curtime)) {
@@ -782,7 +839,7 @@ function is_supp_custom()
             return (TRUE);
         }
         /*
-          if ($this->rec->last_dona > 1356994800) {
+          if ($this->rec->last_dona_get() > 1356994800) {
               return (TRUE);
           }
         */