NEW FEATURE: automatically accept new games
authorArun Persaud <arun@nubati.net>
Sat, 24 May 2008 20:33:55 +0000 (13:33 -0700)
committerArun Persaud <arun@nubati.net>
Sat, 24 May 2008 20:33:55 +0000 (13:33 -0700)
user can set this in the preferences now and won't be asked during a game setup

Signed-off-by: Arun Persaud <arun@nubati.net>
include/db.php
include/game.php
include/preferences.php

index 208334f7772b93049dc1c7328e268758ca09eeec..c8750b49d88264a966863103a2b71e0142636d8d 100644 (file)
@@ -705,6 +705,19 @@ function DB_get_PREF($myid)
   else
     $PREF["email"]="emailnonaddict";
 
+  /* Autosetup */
+  $r = DB_query_array("SELECT value FROM User_Prefs".
+                     " WHERE user_id='$myid' AND pref_key='autosetup'" );
+  if($r)
+    {
+      if($r[0]=='yes')
+       $PREF['autosetup']='yes';
+      else
+       $PREF['autosetup']='no';
+    }
+  else
+    $PREF['autosetup']='no';
+
   return $PREF;
 }
 
index 4dbf68f0a6e291dd194c485d8844a4c8aa49bc2b..3540be4592c052f77ba5b791482939e4d9d01ce5 100644 (file)
@@ -142,7 +142,11 @@ display_table();
 switch($mystatus)
   {
   case 'start':
-    if( !myisset("in") )
+    /* don't ask if user has autosetup set to yest */
+    $skip = 0;
+    if($PREF['autosetup']=='yes') $skip = 1;
+
+    if( !myisset("in") && !$skip)
       {
        /* asks the player, if he wants to join the game */
        output_check_want_to_play($me);
@@ -151,7 +155,7 @@ switch($mystatus)
     else
       {
        /* check the result, if player wants to join, got next stage, else cancel game */
-       if($_REQUEST["in"] == "no")
+       if($_REQUEST["in"] == "no" && !$skip)
          {
            /* cancel the game */
            $message = "Hello, \n\n".
index 3e25d316e95378067af136b70ca2dfc36f985e97..8a6050d0f70106831ca4502728d4e282c569a71d 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-/* make sure that we are not called from outside the scripts, 
+/* make sure that we are not called from outside the scripts,
  * use a variable defined in config.php to check this
  */
 if(!isset($HOST))
@@ -12,10 +12,11 @@ if(!$myid)
   return;
 
 /* track what got changed */
-$changed_notify          = 0;
-$changed_password = 0;
-$changed_cards   = 0;
-$changed_timezone = 0;
+$changed_notify           = 0;
+$changed_password  = 0;
+$changed_cards    = 0;
+$changed_timezone  = 0;
+$changed_autosetup = 0;
 
 output_status();
 display_user_menu();
@@ -74,6 +75,25 @@ if(myisset("notify"))
       }
   }
 
+if(myisset("autosetup"))
+  {
+    $autosetup = $_REQUEST['autosetup'];
+    if($autosetup != $PREF['autosetup'])
+      {
+       /* check if we already have an entry for the user, if so change it, if not create new one */
+       $result = DB_query("SELECT * from User_Prefs".
+                          " WHERE user_id='$myid' AND pref_key='autosetup'" );
+       if( DB_fetch_array($result))
+         $result = DB_query("UPDATE User_Prefs SET value=".DB_quote_smart($autosetup).
+                            " WHERE user_id='$myid' AND pref_key='autosetup'" );
+       else
+         $result = DB_query("INSERT INTO User_Prefs VALUES(NULL,'$myid','autosetup',".
+                            DB_quote_smart($autosetup).")");
+       $changed_autosetup=1;
+      }
+  }
+
+
 if(myisset("password0") &&  $_REQUEST["password0"]!="" )
   {
     $changed_password = 1;
@@ -87,7 +107,7 @@ if(myisset("password0") &&  $_REQUEST["password0"]!="" )
     /* check if new passwords are types the same twice */
     if($_REQUEST["password1"] != $_REQUEST["password2"] )
       $changed_password = -2;
-    
+
     if($changed_password==1)
       {
        DB_query("UPDATE User SET password='".md5($_REQUEST["password1"]).
@@ -126,7 +146,23 @@ echo "  <select id=\"notify\" name=\"notify\" size=\"1\">\n";
        }
   echo "  </select>\n";
 if($changed_notify) echo "changed";
-echo " </td></tr>\n";    
+echo " </td></tr>\n";
+echo "    <tr><td>Autosetup:          </td><td>";
+
+echo "  <select id=\"autosetup\" name=\"autosetup\" size=\"1\">\n";
+      if($PREF['autosetup']=="yes")
+       {
+         echo "   <option value=\"yes\" selected=\"selected\">accept every game</option>\n";
+         echo "   <option value=\"no\">ask for games</option>\n";
+       }
+      else
+       {
+         echo "   <option value=\"yes\">accept every game</option>\n";
+         echo "   <option value=\"no\" selected=\"selected\">ask for games</option>\n";
+       }
+  echo "  </select>\n";
+if($changed_autosetup) echo "changed";
+echo " </td></tr>\n";
 echo "    <tr><td>Card set:              </td><td>";
 
 echo "  <select id=\"cards\" name=\"cards\" size=\"1\">\n";
@@ -142,7 +178,7 @@ echo "  <select id=\"cards\" name=\"cards\" size=\"1\">\n";
        }
   echo "  </select>\n";
 if($changed_cards) echo "changed";
-echo " </td></tr>\n";    
+echo " </td></tr>\n";
 echo "    <tr><td>Password(old):         </td><td>",
   "<input type=\"password\" id=\"password0\" name=\"password0\" size=\"20\" maxlength=\"30\" />";
 switch($changed_password)
@@ -168,7 +204,7 @@ echo "    <tr><td><input type=\"submit\" class=\"submitbutton\" name=\"passwd\"
   "<td></td></tr>\n";
 echo "    </table>\n";
 echo "  </form>\n";
-echo "</div>\n";    
+echo "</div>\n";
 
 output_footer();
 DB_close();