added a modify line to groups for admin users
[gwvp.git] / gwvplib / gwvpuseradmin.php
index af44eb6..95b6a9c 100644 (file)
@@ -26,7 +26,219 @@ function gwvp_UserAdminPage()
 
 function gwvp_UserAdminPageBody()
 {
-       echo "I am a repo admin page body";
+       global $LOGIN_TYPE;
+       
+       $groups = gwvp_getGroups();
+       $users = gwvp_getUsers();
+       
+       echo "<h2>Users and Groups</h2>";
+       echo "On this page you can manage users, groups, group membership and update your profile<br>";
+       echo "<table>";
+       
+       echo "<tr><td colspan=\"2\"><hr></td></tr>";
+       
+       
+       // Header part of table
+       // user self-management bit
+       if($LOGIN_TYPE != "anon") {
+               echo "<tr><td valign=\"top\"><h3>My Profile</h3></td><td><h3>My Groups</h3></td></tr>";
+               
+               echo "<tr>";
+               // user profile bit
+               echo "<td valign=\"top\">";
+               echo "User profile bits go here";
+               echo "</td>";
+               
+               // now the group bit for the user
+               echo "<td valign=\"top\">";
+               echo "User owned groups, and groups their a member of go here";
+               echo "</td>";
+               echo "</tr>";
+               
+               echo "<tr><td colspan=\"2\"><hr></td></tr>";
+       }
+       
+       // admin only bit
+       if($LOGIN_TYPE == "admin") {
+               echo "<tr><td valign=\"top\"><h3>Create User</h3></td><td><h3>Create Group</h3></td></tr>";
+               
+               // create user bit
+               echo "<tr><td valign=\"top\">";
+               
+               echo "<form method=\"post\">";
+               echo "<table>";
+               echo "<tr><td>EMail</td><td><input type=\"text\" name=\"email\"></td>";
+               echo "<td>Full Name</td><td><input type=\"text\" name=\"fullname\"></td></tr>";
+               echo "<tr><td>Password</td><td><input type=\"text\" name=\"pass1\"></td>";
+               echo "<td>Password Confirm</td><td><input type=\"text\" name=\"pass2\"></td></tr>";
+               echo "<tr><td>Username</td><td><input type=\"text\" name=\"username\"></td>";
+               echo "<td>Description</td><td><input type=\"text\" name=\"desc\"></td></tr>";
+               echo "<tr><td><input type=\"submit\" name=\"Create\" value=\"Create\" class=\"buttons\"></td></tr>";
+               echo "</table>";
+               echo "</form>";
+               
+               echo "</td><td valign=\"top\">";
+               
+               // Create group
+               echo "<form method=\"post\">";
+               echo "<table>";
+               echo "<tr><td>Group Name</td><td><input type=\"text\" name=\"groupname\"><td></tr>";
+               echo "<tr><td>Admin Group?</td><td><input type=\"checkbox\" name=\"admingroup\" class=\"mycheckbox\"></td></tr>";
+               echo "<tr><td>Owner</td><td><div><select class=\"myselect\" name=\"groupowner\">";
+               foreach($users as $u_users) {
+                       $uid = $u_users["id"];
+                       $email = $u_users["email"];
+                       $username = $u_users["username"];
+                       $fullname = $u_users["fullname"];
+                       echo "<option value=\"$uid\">$username, $fullname ($email)</option>";
+               }
+               echo "</select></div></td></tr>";
+               
+               
+               
+               echo "<tr><td><input type=\"submit\" name=\"Create\" value=\"Create\" class=\"buttons\"></td></tr>";
+               echo "</table>";
+               echo "</form>";
+               
+               
+               echo "</td></tr>";
+               echo "<tr><td colspan=\"2\"><hr></td></tr>";
+       }
+       
+       
+       
+       // TODO: whats seen here will depend GREATLY on setting in config - need to fix this later
+       // user list
+       echo "<tr><td valign=\"top\"><h3>Users</h3></td><td><h3>Groups</h3></td></tr>";
+       
+       echo "<tr><td>";
+       echo "<table border=\"1\">";
+       switch($LOGIN_TYPE) {
+               case "anon":
+                       echo "<tr><th>Username</th><th>Groups</th><th>Description</th></tr>";
+                       break;
+               case "admin":
+                       echo "<tr><th>EMail</th><th>Username</th><th>Full Name</th><th>Groups</th><th>Description</th><th>Admin?</th><th>Status</th><th>Modify</th></tr>";
+                       break;
+               case "user":
+                       echo "<tr><th>Username</th><th>Groups</th><th>Description</th></tr>";
+                       break;
+       }
+               
+       /*
+        *              $returns[$rn]["id"] = $u_res["users_id"];
+               $returns[$rn]["fullname"] = $u_res["user_full_name"];
+               $returns[$rn]["password"] = $u_res["user_password"];
+               $returns[$rn]["username"] = $u_res["user_username"];
+               $returns[$rn]["email"] = $u_res["user_email"];
+               $returns[$rn]["desc"] = $u_res["user_desc"];
+               $returns[$rn]["status"] = $u_res["user_status"];
+
+        */
+       foreach($users as $u_users) {
+               $userid = $u_users["id"];
+               $email = $u_users["email"];
+               $fullname = $u_users["fullname"];
+               $username = $u_users["username"];
+               $desc = $u_users["desc"];
+               $status = $u_users["status"];
+               if(gwvp_IsUserAdmin($email) == 1) {
+                       $globaladmin = "Yes";
+               } else {
+                       $globaladmin = "No";
+               }
+               
+               
+               // TODO: sort out group prints here
+               $ingroups = gwvp_getGroupsForUser($email);
+               
+               $ownedgroups = gwvp_getGroupsOwnedByUser($email);
+               $ugroups = "";
+               if($ownedgroups == false) $ogroups = "-";
+               else {
+                       foreach($ownedgroups as $gr_u) {
+                               $ugroups .= "<font color=\"#3333ff\">$gr_u</font><br>";
+                       }
+               }
+               trim($ugroups);
+               
+               
+               foreach($ingroups as $grname) {
+                       $isownedgroup = false;
+                       foreach($ownedgroups as $gr_u) {
+                               if($grname == $gr_u) $isownedgroup = true;
+                       }
+                       if(!$isownedgroup) $ugroups .= "$grname<br>";
+               }
+               trim($ugroups);
+               
+               switch($LOGIN_TYPE) {
+                       case "anon":
+                               echo "<tr><td>$username</td><td>$ugroups</td><td>$desc</td></tr>";
+                               break;
+                       case "admin":
+                               echo "<tr><td>$email</td><td>$username</td><td>$fullname</td><td>$ugroups</td><td>$desc</td>";
+                               echo "<td>$globaladmin</td><td>$status</td><td><a href=\"$BASE_URL/users/modify?id=$userid\">Modify</a></td></tr>";
+                               break;
+                       case "user":
+                               echo "<tr><td>$username</td><td>$ugroups</td><td>$desc</td></tr>";
+                               break;
+               }
+               
+               
+       }
+       echo "</table>";
+       
+       echo "</td><td valign=\"top\">";
+       
+       // group part of table
+       
+       echo "<table border=\"1\">";
+       
+       switch($LOGIN_TYPE) {
+               case "anon":
+                       echo "<tr><th>Group Name</th><th>Owner</th></tr>";
+                       break;
+               case "admin":
+                       echo "<tr><th>Group Name</th><th>Owner</th><th>Admin Group?</th><th>Modify</th></tr>";
+                       break;
+               case "user":
+                       echo "<tr><th>Group Name</th><th>Owner</th><th>Admin Group?</th></tr>";
+                       break;
+       }
+       
+       foreach($groups as $u_groups) {
+               /*
+                *              $returns[$rn]["id"] = $u_res["groups_id"];
+               $returns[$rn]["name"] = $u_res["groups_name"];
+               if($u_res["groups_is_admin"]=="1") $return[$rn]["admin"] = true;
+               else $return[$rn]["admin"] = false;
+               $returns[$rn]["admin"] = $u_res["groups_is_admin"];
+               $returns[$rn]["ownerid"] = $u_res["groups_owner_id"];
+
+                */
+               $gname = $u_groups["name"];
+               $gid = $u_groups["id"];
+               $owner = gwvp_getUserEmail($u_groups["ownerid"]);
+               if($u_groups["admin"]) $gadmin = "Yes";
+               else $gadmin  = "No";
+
+               switch($LOGIN_TYPE) {
+                       case "anon":
+                               echo "<tr><td>$gname</td><td>$owner</td></tr>";
+                               break;
+                       case "admin":
+                               echo "<tr><td>$gname</td><td>$owner</td><td>$gadmin</td><td><a href=\"$BASE_URL/users/modifygroup?groupid=$gid\">Modify</a></td></tr>";
+                               break;
+                       case "user":
+                               echo "<tr><td>$gname</td><td>$owner</td><td>$gadmin</td></tr>";
+                               break;
+               }
+               
+               
+       }
+       echo "</table>";
+       echo "</td></tr></table>";
 }