User page code for user/group admin
[gwvp.git] / gwvplib / gwvpuseradmin.php
index af44eb6..63b3cd8 100644 (file)
@@ -26,7 +26,140 @@ function gwvp_UserAdminPage()
 
 function gwvp_UserAdminPageBody()
 {
-       echo "I am a repo admin page body";
+       $groups = gwvp_getGroups();
+       $users = gwvp_getUsers();
+       
+       echo "<h2>User/Group Administration</h2>";
+       echo "On this page you can manage users, groups, group membership and update your profile<br>";
+       echo "<table>";
+       
+       // Header part of table
+       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 valign=\"top\"><h3>Users</h3></td><td><h3>Groups</h3></td></tr>";
+       
+       // create user bit
+       echo "<tr><td valign=\"top\">";
+       
+       echo "Create User<br>";
+       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>Nickname</td><td><input type=\"text\" name=\"nick\"></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"];
+               $nickname = $u_users["nickname"];
+               $fullname = $u_users["fullname"];
+               echo "<option value=\"$uid\">$nickname, $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>";
+       
+       // user list
+       echo "<tr><td>";
+       echo "<table border=\"1\">";
+       echo "<tr><th>EMail</th><th>Nick Name</th><th>Full Name</th><th>In Groups</th><th>Owns Groups</th><th>Description</th><th>Is Global Admin?</th><th>Status</th></tr>";
+       /*
+        *              $returns[$rn]["id"] = $u_res["users_id"];
+               $returns[$rn]["fullname"] = $u_res["user_full_name"];
+               $returns[$rn]["password"] = $u_res["user_password"];
+               $returns[$rn]["nickname"] = $u_res["user_nickname"];
+               $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) {
+               $email = $u_users["email"];
+               $fullname = $u_users["fullname"];
+               $nickname = $u_users["nickname"];
+               $desc = $u_users["desc"];
+               $status = $u_users["status"];
+               if(gwvp_IsUserAdmin($email) == 1) {
+                       $globaladmin = "Yes";
+               } else {
+                       $globaladmin = "No";
+               }
+               
+               $ingroups = gwvp_getGroupsForUser($email);
+               $ugroups = "";
+               foreach($ingroups as $grname) {
+                       $ugroups .= "$grname ";
+               }
+               trim($ugroups);
+               
+               $ownedgroups = gwvp_getGroupsOwnedByUser($email);
+               $ogroups = "";
+               if($ownedgroups == false) $ogroups = "-";
+               else {
+                       foreach($ownedgroups as $gr_u) {
+                               $ogroups .= "$gr_u ";
+                       }
+               }
+               
+               echo "<tr><td>$email</td><td>$nickname</td><td>$fullname</td><td>$ugroups</td><td>$ogroups</td><td>$desc</td><td>$globaladmin</td><td>$status</td></tr>";
+       }
+       echo "</table>";
+       
+       echo "</td><td valign=\"top\">";
+       
+       // group part of table
+       
+       echo "<table border=\"1\">";
+       echo "<tr><th>Group Name</th><th>Owner</th><th>Global Admin Group?</th></tr>";
+       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"];
+               $owner = gwvp_getUserEmail($u_groups["ownerid"]);
+               if($u_groups["admin"]) $gadmin = "Yes";
+               else $gadmin  = "No";
+               echo "<tr><td>$gname</td><td>$owner</td><td>$gadmin</td></tr>";
+       }
+       echo "</table>";
+       echo "</td></tr></table>";
 }