"user_username" TEXT,
"user_email" TEXT,
"user_desc" TEXT,
- "user_status" INTEGER
+ "user_status" TEXT
)';
$groupsql = '
$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()
{
}
+function gwvp_getOwnedRepos($userid = null, $username = null)
+{
+ $conn = gwvp_ConnectDB();
+
+ if($username != null) {
+ $details = gwvp_getUser($username);
+ $uid = $details["id"];
+ $sql = "select * from repos where repos_owner='$uid'";
+ $res = $conn->query($sql);
+ error_log("sql: $sql");
+ } else if($userid != null) {
+ $sql = "select * from repos where repos_owner='$userid'";
+ $res = $conn->query($sql);
+ error_log("sql: $sql");
+ } else return false;
+
+ /*
+ * CREATE TABLE "repos" (
+ "repos_id" INTEGER PRIMARY KEY AUTOINCREMENT,
+ "repos_name" TEXT,
+ "repos_description" TEXT,
+ "repos_owner" INTEGER
+ )';
+
+ */
+
+ $returns = false;
+ $rn = 0;
+ foreach($res as $u_res) {
+ $returns[$rn]["id"] = $u_res["repos_id"];
+ $returns[$rn]["name"] = $u_res["repos_name"];
+ $returns[$rn]["description"] = $u_res["repos_description"];
+ $rn++;
+ }
+
+ return $returns;
+}
+
function gwvp_getUsers()
{
$conn = gwvp_ConnectDB();
return $return;
}
-function gwvp_getGroup($gid)
+function gwvp_getGroup($gid = null, $gname = null)
{
/*
* $groupsql = '
*/
$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;