$DB_CONNECTION->query($groupmemsql);
}
+function gwvp_forceDisconnect()
+{
+
+ global $DB_CONNECTION;
+
+ $DB_CONNECTION = false;
+}
+
function gwvp_isDBSetup()
{
// for sqlite, we just check if the db exists, for everyone else, we check for a conneciton and go yay or nay
return $return;
}
+function gwvp_deleteGroupMemberByID($uid, $gid)
+{
+ $conn = gwvp_ConnectDB();
+
+ /*
+ * CREATE TABLE "group_membership" (
+ "groupmember_id" INTEGER PRIMARY KEY AUTOINCREMENT,
+ "groupmember_groupid" INTEGER,
+ "groupmember_userid" INTEGER
+
+ */
+ $sql = "delete from group_membership where groupmember_groupid='$gid' and groupmember_userid='$uid'";
+
+ $conn->query($sql);
+
+ return true;
+}
+
+
+function gwvp_addGroupMemberByID($uid, $gid)
+{
+ $conn = gwvp_ConnectDB();
+
+ /*
+ * CREATE TABLE "group_membership" (
+ "groupmember_id" INTEGER PRIMARY KEY AUTOINCREMENT,
+ "groupmember_groupid" INTEGER,
+ "groupmember_userid" INTEGER
+
+ */
+ $sql = "insert into group_membership values (null, '$gid', '$uid')";
+
+ $conn->query($sql);
+
+ return true;
+}
+
+
function gwvp_addGroupMember($email, $groupname)
{
$conn = gwvp_ConnectDB();
"groupmember_userid" INTEGER
*/
- if($uid!=false&&$gid!=false) $sql = "insert into group_membership values (null, '$gid', '$uid')";
+ if($uid!=false&&$gid!=false) gwvp_addGroupMemberByID($uid, $gid);
else return false;
$conn->query($sql);
break;
case "recreatedb":
global $db_name;
- unlink("$db_name");
+ gwvp_forceDisconnect();
+ rename("$db_name", "$db_name.tmp");
gwvp_dbCreateSQLiteStructure("$db_name");
//gwvp_createGroup($group_name, $is_admin, $owner_id)
//gwvp_createUser($email, $fullname, $password, $username, $desc, $status)
case "adduser":
return "gwvp_AddUserPage";
break;
+ case "groupmember":
+ return "gwvp_groupMemberChange";
+ break;
case "addgroup":
return "gwvp_AddGroupPage";
break;
// gwvp_createGroup($group_name, $is_admin, $owner_id)
gwvp_createGroup("$gname", $gdesc, $isadmin, $owner);
+ // we also need to add the owner to the group
+ gwvp_addGroupMember(gwvp_getUserName($owner), $gname);
header("Location: $BASE_URL/admin/users");
echo "modify user $uid";
}
+function gwvp_groupMemberChange()
+{
+ global $LOGIN_TYPE, $BASE_URL;
+
+ $gid = -1;
+
+ if(isset($_REQUEST["q"])) {
+ $query = $_REQUEST["q"];
+ $qspl = explode("/", $query);
+ $gid = $qspl[3];
+ }
+ error_log("into groupmemberchange with $gid");
+ if($gid!= -1) {
+
+ }
+
+ if(isset($_REQUEST["add"])) {
+ error_log("$gid add set to ".$_REQUEST["add"]);
+ // this is an add op
+ if(isset($_REQUEST["membersout"])) {
+ foreach($_REQUEST["membersout"] as $uid) {
+ error_log("would add $uid from $gid");
+ gwvp_addGroupMemberByID($uid, $gid);
+
+ }
+ }
+ }
+ if(isset($_REQUEST["remove"])) {
+ error_log("$gid remove set to ".$_REQUEST["remove"]);
+ // this is a remove op
+ if(isset($_REQUEST["membersin"])) {
+ foreach($_REQUEST["membersin"] as $uid) {
+ error_log("would remote $uid from $gid");
+ gwvp_deleteGroupMemberByID($uid, $gid);
+ }
+ }
+ }
+
+ error_log("redirect to $BASE_URL/admin/users/modifygroup/$gid");
+ header("Location: $BASE_URL/admin/users/modifygroup/$gid");
+ //gwvp_goMainPage("gwvp_ModifyGroupPageBody");
+
+ return;
+}
+
function gwvp_ModifyGroupPageBody()
{
global $LOGIN_TYPE, $BASE_URL;
// members
- echo "<select name=\"members\" size=\"20\" multiple>";
+ echo "<select name=\"membersin[]\" size=\"20\" multiple=\"true\">";
foreach($users as $u_users) {
$uid = $u_users["id"];
$email = $u_users["email"];
// all users
- echo "<select name=\"members\" size=\"20\" multiple>";
+ echo "<select name=\"membersout[]\" size=\"20\" multiple=\"true\">";
foreach($users as $u_users) {
$uid = $u_users["id"];
$email = $u_users["email"];