X-Git-Url: http://git.pjr.cc/?p=gwvp.git;a=blobdiff_plain;f=gwvplib%2Fgwvpdatabase.php;fp=gwvplib%2Fgwvpdatabase.php;h=172ffbb3c7d20f11c214014cf2113519c11b0f15;hp=7338e686eab0efd8cc6ffa9991ce6af51b0439d4;hb=5a23c888fac7fa841467950e23e123afa1352024;hpb=f4fc778c9d25c9d04b9df4c87cd8e656d2a39019 diff --git a/gwvplib/gwvpdatabase.php b/gwvplib/gwvpdatabase.php index 7338e68..172ffbb 100644 --- a/gwvplib/gwvpdatabase.php +++ b/gwvplib/gwvpdatabase.php @@ -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;