bug 1192: changes for find CCA agreement
authorINOPIAE <inopiae@cacert.org>
Fri, 20 Sep 2013 09:09:58 +0000 (11:09 +0200)
committerINOPIAE <inopiae@cacert.org>
Fri, 20 Sep 2013 09:09:58 +0000 (11:09 +0200)
www/index.php

index 08ed57f..161dadd 100644 (file)
@@ -27,7 +27,7 @@ require_once('../includes/notary.inc.php');
                 $id = 0;
 
         $_SESSION['_config']['errmsg'] = "";
-        $ccatest=FALSE;
+        $ccatest=0;
 
        if($id == 17 || $id == 20)
        {
@@ -161,6 +161,7 @@ require_once('../includes/notary.inc.php');
                        $_SESSION['profile'] = mysql_fetch_assoc(mysql_query(
                                "select * from `users` where
                                `id`='$user_id' and `deleted`=0 and `locked`=0"));
+                       $ccatest=get_user_agreement_status($user_id,'CCA');
 
                        if($_SESSION['profile']['id'] != 0)
                        {
@@ -185,6 +186,7 @@ require_once('../includes/notary.inc.php');
        if($id == 4 && array_key_exists('profile',$_SESSION) && array_key_exists('loggedin',array($_SESSION['profile'])) && $_SESSION['profile']['loggedin'] == 1)
        {
                header("location: https://".$_SERVER['HTTP_HOST']."/account.php");
+                                       echo '###2###'.$cca['active'];
                exit;
        }
 
@@ -344,10 +346,17 @@ require_once('../includes/notary.inc.php');
                        }
                        if (checkpwlight($pword) < 3)
                                $_SESSION['_config']['oldlocation'] = "account.php?id=14&force=1";
-                       if($_SESSION['_config']['oldlocation'] != "")
+                       $ccatest=get_user_agreement_status($_SESSION['profile']['id'],'CCA');
+                       if($_SESSION['_config']['oldlocation'] != ""){
                                header("location: https://".$_SERVER['HTTP_HOST']."/".$_SESSION['_config']['oldlocation']);
-                       else
-                               header("location: https://".$_SERVER['HTTP_HOST']."/account.php");
+                       }else{
+                               if (0==$ccatest) {
+                                       $id=52;
+                                       header("location: https://".$_SERVER['HTTP_HOST']."/index.php?id=52");
+                               }else{
+                                       header("location: https://".$_SERVER['HTTP_HOST']."/account.php");
+                               }
+                       }
                        exit;
                }
 
@@ -360,18 +369,12 @@ require_once('../includes/notary.inc.php');
                } else {
                        $_SESSION['_config']['errmsg'] = _("Your account has not been verified yet, please check your email account for the signup messages.");
                }
-
-               $cca=get_last_user_agreement($_SESSION['profile']['id']);
-               echo '###'.$cca['active'];
-               if (!isset($cca['active'])){
-                       $id=52;
-                       $ccatest=TRUE;
-               }
        }
 
 // check for CCA acceptance prior to login
-if ($id == 52 && $ccatest==FALSE)
+if ($id == 52 )
 {
+       $ccatest=get_user_agreement_status($_SESSION['profile']['id'],'CCA');
        $agree = ""; if(array_key_exists('agree',$_REQUEST)) $agree=$_REQUEST['agree'];
        if (!$agree) {
                $_SESSION['profile']['loggedin'] = 0;