Added some form validation bits, with the ability to return posts back
[gwvp.git] / gwvplib / gwvpdatabase.php
index 7338e68..172ffbb 100644 (file)
@@ -19,7 +19,7 @@ function gwvp_dbCreateSQLiteStructure($dbloc)
            "user_username" TEXT,
            "user_email" TEXT,
            "user_desc" TEXT,
-           "user_status" INTEGER
+           "user_status" TEXT
                )';
 
        $groupsql = '
@@ -79,6 +79,51 @@ function gwvp_dbCreateSQLiteStructure($dbloc)
        $DB_CONNECTION->query($groupmemsql);
 }
 
+function gwvp_GetUserStatus($userid)
+{
+       $conn = gwvp_ConnectDB();
+       
+       $sql = "select user_status from users where users_id='$userid'";
+       
+       $res = $conn->query($sql);
+       
+       $return = null;
+       foreach($res as $val) {
+               $spl = explode(";", $val);
+               
+               $return["statusid"] = $spl[0];
+               $return["extstatus"] = $spl[1];
+       }
+       
+}
+
+function gwvp_SetUserStatus($userid, $status, $extendedstatus=null)
+{
+       /*
+        * user statues
+        * 0 - all good
+        * 1 - locked
+        * 2 - password locked
+        * 3 - awaiting registration completion
+        * 4 - awaiting password reset
+        * where use status = 3,4 the key for unlock is set as the extended status
+        * i.e. if a user goes thru registration, when the validation email gets to
+        * them they'll have a key in their email (128 or 256 bit), thats what
+        * the extended status field is used for
+        */
+       
+       $conn = gwvp_ConnectDB();
+       
+       if($extendedstatus != null) {
+               $sql = "update users set user_status='$status;$extendedstatus' where users_id='$userid'";
+       } else {
+               $sql = "update users set user_status='$status;0' where users_id='$userid'";
+       }
+       
+       return $conn->query($sql);
+       
+}
+
 function gwvp_forceDisconnect()
 {
        
@@ -426,7 +471,7 @@ function gwvp_getGroupId($groupname)
        return $return;
 }
 
-function gwvp_getGroup($gid)
+function gwvp_getGroup($gid = null, $gname = null)
 {
        /* 
         *      $groupsql = '
@@ -440,7 +485,11 @@ function gwvp_getGroup($gid)
         */
        $conn = gwvp_ConnectDB();
        
-       $sql = "select * from groups where groups_id='$gid'";
+       if($gid != null) {
+               $sql = "select * from groups where groups_id='$gid'";
+       } else if ($gname != null) {
+               $sql = "select * from groups where groups_name='$gname'";
+       } else return false;
        
        $res = $conn->query($sql);
        $return = false;