manage refuse answer to licence manager
authorMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Tue, 3 Dec 2013 18:48:16 +0000 (19:48 +0100)
committerMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Tue, 3 Dec 2013 18:48:16 +0000 (19:48 +0100)
web/Obj/dbase_base.phh
web/Obj/dbase_pgsql.phh
web/Obj/sac-a-push.phh
web/Obj/user.phh
web/index_wr.php

index a01ce52..938a277 100644 (file)
@@ -108,6 +108,10 @@ class LoginDBItem {
     {
         return $this->disa_reas;
     }
+    function disa_reas_set($disa_reas)
+    {
+        $this->disa_reas = $disa_reas;
+    }
 
 }
 
index 2b1d4d5..d923fb9 100644 (file)
@@ -185,6 +185,21 @@ class BriskDB
         return TRUE;
     }
 
+    function user_state_update($code, $flags, $disa_reas)
+    {
+        GLOBAL $G_dbpfx;
+
+        $user_sql = sprintf("UPDATE %susers SET (type, disa_reas) = (%d, %d) WHERE code = %d;",
+                            $G_dbpfx, $flags, $disa_reas, $code);
+        fprintf(STDERR, "REQUEST [%s]\n", $user_sql);
+        if ( ! (($user_pg  = $this->query($user_sql)) != FALSE && pg_affected_rows($user_pg) == 1) ) {
+             return FALSE;
+        }
+        fprintf(STDERR, "REQUEST GOOD [%s]\n", $user_sql);
+
+        return TRUE;
+    }
+
     function user_licence_update($code, $lice_vers)
     {
         GLOBAL $G_dbpfx;
index 973e012..b2efb61 100644 (file)
@@ -611,6 +611,7 @@ class Sac_a_push {
         GLOBAL $G_splash_w, $G_topbanner, $G_with_donors, $G_with_poll;
         GLOBAL $G_with_sidebanner, $G_with_sidebanner2, $G_with_splash;
         GLOBAL $G_with_topbanner;
+        GLOBAL $G_lice_vers, $G_lice_fname, $G_lice_dtsoft, $G_lice_dthard, $G_lice_idx;
 
         if ($this->main_loop) {
             return (FALSE);
index a7d9357..69842e8 100644 (file)
@@ -63,6 +63,7 @@ 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);
@@ -314,6 +315,8 @@ class User {
   {
       $flags_old = $this->flags & (~$mask);
       $this->flags = ($flags_old | ($flags & $mask));
+
+      return ($flags_old);
   }
 
   function prefs_store()
@@ -333,6 +336,15 @@ class User {
       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)
   {
       $this->rd_endtime = $curtime + RD_ENDTIME_DELTA;
index 3ccfd24..75fed15 100644 (file)
@@ -554,11 +554,6 @@ function index_wr_main(&$room, $remote_addr_full, $get, $post, $cookie)
                 $f_type = $argz[1];      $f_code = $argz[2];
                 $f_lice_curr = $argz[3]; $f_lice_vers = $argz[4];
 
-                $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
-                $user->comm[$user->step % COMM_N] .=  show_notify(xcape("FIN QUIZ |"."${argz[1]}"."|"."${argz[2]}"."|"."${argz[3]}"."|"."${argz[4]}"."|".$res), 0, $mlang_indwr['btn_backtotab'][$G_lang], 400, 200);
-                log_wr($user->comm[$user->step % COMM_N]);
-                $user->step_inc();
-
                 if ("$f_lice_curr" == $user->rec->lice_vers_get()  &&
                     "$f_lice_vers" == "$G_lice_vers") {
                     if ("$f_type" == "soft" || "$f_type" == "hard") {
@@ -569,6 +564,13 @@ function index_wr_main(&$room, $remote_addr_full, $get, $post, $cookie)
                             $res = $user->licence_store();
                             break;
                         case LICMGR_CHO_REFUSE:
+                            $user->flags_set(USER_FLAG_TY_DISABLE, USER_FLAG_TY_ALL);
+                            $user->rec->disa_reas_set(USER_DIS_REA_LICENCE);
+                            $res = $user->state_store();
+
+                            $user->comm[$user->step % COMM_N] = $user->blocking_error(TRUE);
+                            $user->the_end = TRUE;
+                            $user->step_inc();
                             break;
                         }
                     }