You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vcl.apache.org by jf...@apache.org on 2010/12/15 14:43:32 UTC

svn commit: r1049551 [1/2] - in /incubator/vcl/trunk/web: ./ .ht-inc/ .ht-inc/authmethods/ css/ js/

Author: jfthomps
Date: Wed Dec 15 13:43:31 2010
New Revision: 1049551

URL: http://svn.apache.org/viewvc?rev=1049551&view=rev
Log:
VCL-312
remove View Mode and any uses of user.adminlevelid

I added a new tab to the privileges section where additional user group permissions can be assigned. Now we have user privileges, resource attributes, and user permissions. The user permissions are assigned in the new section found at the new tab. The permissions are things that don't make sense to have granted related to a node in the privilege tree.

VCL-399
add a dashboard where admins can see current state of VCL system

I updated the dashboard to be able to view only by affiliation.


statistics.php: replaced all references to $viewmode with checkUserHasPerm

vcldocs.php: removed all references to $viewmode and left only dependance on $doceditors

authmethods/itecsauth.php:
-removed all references to adminlevel/adminlevelid
-added call to getUsersGroupPerms in updateITECSUser

authmethods/ldapauth.php:
-removed all references to adminlevel/adminlevelid
-added call to getUsersGroupPerms in updateLDAPUser

userpreferences.php:
-removed all references to VIEWASUSERERR
-removed all references to viewmode and submitviewmode
-removed all code wrapped in $adminleveldeveloper blocks

states.php:
-added AJpermSelectUserGroup
-added AJcopyUserGroupPrivs
-added AJsaveUserGroupPrivs

images.php:
-removed all references to $viewmode and adminlevel
-removed code that allowed the "User group allowed to log in" to be set for an image - no longer supported on the backend

managementnodes.php: removed one (all) reference to $viewmode

privileges.php:
-replaced all uses of $viewmode with calls to checkUserHasPerm
-modified viewNodes - added section that allows additional user group permissions to be managed
-modified userLookup - removed display of adminlevel, added display of user group permissions
-added AJpermSelectUserGroup
-added AJsaveUserGroupPrivs

requests.php: replaced all references to $viewmode with checkUserHasPerm

errors.php: modified errorHandler - replaced adminlevel check with check for ONLINEDEBUG and checkUserHasPerm

groups.php: replaced all references to $viewmode with checkUserHasPerm

computers.php:
-replaced all references to $viewmode with checkUserHasPerm
-fixed typo in confirmAddBulkComputers that kept private addresses from being displayed
-modified processBulkComputerInput to allow all users to set the private IP address range

vm.php:
-replaced all references to $viewmode with checkUserHasPerm
-modified editVMInfo to clear displayed data when selected VM host or VM profile is changed to help make it clear what is being modified because a user could select a different item but not click the submit button and it would appear as though the wrong item is being modified

blockallocations.php: replaced reference to $viewmode with checkUserHasPerm

dashboard.php:
-added ability to view information based on affiliation
-added box for viewing top 5 images from past 24 hours

utils.php:
-removed definition of ADMIN_*
-replaced all references to $viewmode with checkUserHasPerm
-removed getViewMode
-added session caching to getUserGroups
-added getUserGroupPrivs
-added getUserGroupPrivTypes
-modified getUserInfo - removed adminlevel/adminlevelid, added call to getUserGroupPerms
-added getUsersGroupPerms
-added checkUserHasPerm
-modified getContinuationsData to return noHTMLwrappers as part of the array if continuation is expired and tomode is in $noHTMLwrappers
-modified continuationsError to not print the HTML header/footer if noHTMLwrappers is in $contdata and is true
-modified sendHeaders - removed block that handled $mode == submitviewmode
-modified printHTMLHeader to not print HTML header if $contdata contains noHTMLwrappers set to 1

index.php:
-removed $viewmode
-changed reference to $viewmode to call to checkUserHasPerm

css/privileges.css: aded groupprivhelpcell, hlperm, statusfailed, statussuccess, groupprivshidden

js/dashboard.js:
-added ability to view information based on affiliation
-added updateTopPastImages

js/privileges.js:
-added selectUserGroup
-added selectUserGroupCB
-added showUserGroupPrivHelp
-added clearUserGroupPrivHelp
-added copyUserGroupPrivs
-added copyUserGroupPrivsCB
-added saveUserGroupPrivs
-added saveUserGroupPrivsCB
-added clearUserPrivStatus
-added hideUserGroupPrivs

Modified:
    incubator/vcl/trunk/web/.ht-inc/authmethods/itecsauth.php
    incubator/vcl/trunk/web/.ht-inc/authmethods/ldapauth.php
    incubator/vcl/trunk/web/.ht-inc/blockallocations.php
    incubator/vcl/trunk/web/.ht-inc/computers.php
    incubator/vcl/trunk/web/.ht-inc/dashboard.php
    incubator/vcl/trunk/web/.ht-inc/errors.php
    incubator/vcl/trunk/web/.ht-inc/groups.php
    incubator/vcl/trunk/web/.ht-inc/images.php
    incubator/vcl/trunk/web/.ht-inc/managementnodes.php
    incubator/vcl/trunk/web/.ht-inc/privileges.php
    incubator/vcl/trunk/web/.ht-inc/requests.php
    incubator/vcl/trunk/web/.ht-inc/states.php
    incubator/vcl/trunk/web/.ht-inc/statistics.php
    incubator/vcl/trunk/web/.ht-inc/userpreferences.php
    incubator/vcl/trunk/web/.ht-inc/utils.php
    incubator/vcl/trunk/web/.ht-inc/vcldocs.php
    incubator/vcl/trunk/web/.ht-inc/vm.php
    incubator/vcl/trunk/web/css/privileges.css
    incubator/vcl/trunk/web/index.php
    incubator/vcl/trunk/web/js/dashboard.js
    incubator/vcl/trunk/web/js/privileges.js

Modified: incubator/vcl/trunk/web/.ht-inc/authmethods/itecsauth.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/authmethods/itecsauth.php?rev=1049551&r1=1049550&r2=1049551&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/authmethods/itecsauth.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/authmethods/itecsauth.php Wed Dec 15 13:43:31 2010
@@ -130,8 +130,6 @@ function validateITECSUser($loginid) {
 /// \b email - user's preferred email address\n
 /// \b IMtype - user's preferred IM protocol\n
 /// \b IMid - user's IM id\n
-/// \b adminlevel - user's admin level (= 'none' if no admin access)\n
-/// \b adminlevelid - id of adminlevel\n
 /// \b width - rdp file width\n
 /// \b height - rdp file height\n
 /// \b bpp - rdp file bpp\n
@@ -168,8 +166,6 @@ function updateITECSUser($userid) {
 	       .        "u.IMid AS IMid, "
 	       .        "u.affiliationid, "
 	       .        "af.name AS affiliation, "
-	       .        "a.name AS adminlevel, "
-	       .        "a.id AS adminlevelid, "
 	       .        "u.preferredname AS preferredname, "
 	       .        "u.uid AS uid, "
 	       .        "u.id AS id, "
@@ -183,10 +179,8 @@ function updateITECSUser($userid) {
 	       .        "u.showallgroups "
 	       . "FROM user u, "
 	       .      "IMtype i, "
-	       .      "affiliation af, "
-	       .      "adminlevel a "
+	       .      "affiliation af "
 	       . "WHERE u.IMtypeid = i.id AND "
-	       .       "u.adminlevelid = a.id AND "
 	       .       "u.affiliationid = af.id AND "
 		    .       "u.uid = " . $userData["uid"];
 	$qh = doQuery($query, 255);
@@ -226,8 +220,6 @@ function updateITECSUser($userid) {
 		       .        "u.IMid AS IMid, "
 		       .        "u.uid AS uid, "
 		       .        "u.id AS id, "
-		       .        "a.name AS adminlevel, "
-		       .        "a.id AS adminlevelid, "
 		       .        "u.width AS width, "
 		       .        "u.height AS height, "
 		       .        "u.bpp AS bpp, "
@@ -239,10 +231,8 @@ function updateITECSUser($userid) {
 		       .        "u.lastupdated AS lastupdated "
 		       . "FROM user u, "
 		       .      "IMtype i, "
-		       .      "affiliation af, "
-		       .      "adminlevel a "
+		       .      "affiliation af "
 		       . "WHERE u.IMtypeid = i.id AND "
-		       .       "u.adminlevelid = a.id AND "
 		       .       "u.affiliationid = af.id AND "
 		       .       "u.id = $id";
 		$qh = doQuery($query, 101);
@@ -254,6 +244,7 @@ function updateITECSUser($userid) {
 	}
 
 	$user["groups"] = getUsersGroups($user["id"], 1);
+	$user["groupperms"] = getUsersGroupPerms(array_keys($user['groups']));
 
 	checkExpiredDemoUser($user['id'], $user['groups']);
 

Modified: incubator/vcl/trunk/web/.ht-inc/authmethods/ldapauth.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/authmethods/ldapauth.php?rev=1049551&r1=1049550&r2=1049551&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/authmethods/ldapauth.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/authmethods/ldapauth.php Wed Dec 15 13:43:31 2010
@@ -177,8 +177,6 @@ function updateLDAPUser($authtype, $user
 	       .        "af.name AS affiliation, "
 	       .        "af.shibonly, "
 	       .        "u.emailnotices, "
-	       .        "a.name AS adminlevel, "
-	       .        "a.id AS adminlevelid, "
 	       .        "u.preferredname AS preferredname, "
 	       .        "u.uid AS uid, "
 	       .        "u.id AS id, "
@@ -192,10 +190,8 @@ function updateLDAPUser($authtype, $user
 	       .        "u.showallgroups "
 	       . "FROM user u, "
 	       .      "IMtype i, "
-	       .      "adminlevel a, "
 	       .      "affiliation af "
 	       . "WHERE u.IMtypeid = i.id AND "
-	       .       "u.adminlevelid = a.id AND "
 	       .       "af.id = $affilid AND ";
 	if(array_key_exists('numericid', $userData) &&
 	   is_numeric($userData['numericid']))
@@ -242,8 +238,6 @@ function updateLDAPUser($authtype, $user
 		       .        "u.IMid AS IMid, "
 		       .        "u.uid AS uid, "
 		       .        "u.id AS id, "
-		       .        "a.name AS adminlevel, "
-		       .        "a.id AS adminlevelid, "
 		       .        "u.width AS width, "
 		       .        "u.height AS height, "
 		       .        "u.bpp AS bpp, "
@@ -255,10 +249,8 @@ function updateLDAPUser($authtype, $user
 		       .        "u.lastupdated AS lastupdated "
 		       . "FROM user u, "
 		       .      "IMtype i, "
-		       .      "affiliation af, "
-		       .      "adminlevel a "
+		       .      "affiliation af "
 		       . "WHERE u.IMtypeid = i.id AND "
-		       .       "u.adminlevelid = a.id AND "
 		       .       "u.affiliationid = af.id AND "
 		       .       "u.id = $id";
 		$qh = doQuery($query, 101);
@@ -275,6 +267,7 @@ function updateLDAPUser($authtype, $user
 			//TODO possibly add to a default group
 	}
 	$user["groups"] = getUsersGroups($user["id"], 1);
+	$user["groupperms"] = getUsersGroupPerms(array_keys($user['groups']));
 	$user["privileges"] = getOverallUserPrivs($user["id"]);
 	$user['login'] = $user['unityid'];
 	return $user;

Modified: incubator/vcl/trunk/web/.ht-inc/blockallocations.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/blockallocations.php?rev=1049551&r1=1049550&r2=1049551&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/blockallocations.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/blockallocations.php Wed Dec 15 13:43:31 2010
@@ -30,8 +30,8 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function blockAllocations() {
-	global $viewmode, $user;
-	if($viewmode != ADMIN_DEVELOPER) {
+	global $user;
+	if(! checkUserHasPerm('Manage Block Allocations')) {
 		print "<H2>Block Allocations</H2>\n";
 		print "Block Allocations are a way to have a set of machines preloaded with a particular environment at specified times and made available to a specific group of users. This is very useful for classroom use and for workshops. They can be made available on a repeating schedule such as when a course meets each week. Block Allocations only allocate machines for the group of users - they do not create the actual, end user reservations for the machines. All users still must log in to the VCL web site and make their own reservations DURING the period a block allocation is active.<br><br>\n";
 		print "<button dojoType=\"dijit.form.Button\" type=\"button\">\n";

Modified: incubator/vcl/trunk/web/.ht-inc/computers.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/computers.php?rev=1049551&r1=1049550&r2=1049551&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/computers.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/computers.php Wed Dec 15 13:43:31 2010
@@ -53,7 +53,7 @@ define("VMAVAILERR", 1 << 11);
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function selectComputers() {
-	global $viewmode, $user;
+	global $user;
 	$test = getComputers();
 	if(empty($test)) {
 		addComputerPrompt();
@@ -1135,7 +1135,7 @@ function submitDeleteComputer() {
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function bulkAddComputer() {
-	global $submitErr, $viewmode;
+	global $submitErr;
 
 	$data = processBulkComputerInput(0);
 	$data2 = processComputerInput2(); //yes, this is somewhat redundant, but it
@@ -1378,7 +1378,7 @@ function confirmAddBulkComputers() {
 	print "    <TD>" . $data["startipaddress"] . " - ";
 	print $data["endipaddress"] . "</TD>\n";
 	print "  </TR>\n";
-	if(! empty($data['startpraddress'])) {
+	if(! empty($data['startpripaddress'])) {
 		print "  <TR>\n";
 		print "    <TH align=right nowrap>Private IP Addresses:</TH>\n";
 		print "    <TD>" . $data["startpripaddress"] . " - ";
@@ -3227,7 +3227,7 @@ function processComputerInput3() {
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function processBulkComputerInput($checks=1) {
-	global $submitErr, $submitErrMsg, $viewmode;
+	global $submitErr, $submitErrMsg;
 	$return = processComputerInput2();
 	$ipaddress = getContinuationVar("ipaddress", processInputVar("ipaddress", ARG_STRING));
 	if(! empty($ipaddress)) {
@@ -3377,8 +3377,7 @@ function processBulkComputerInput($check
 	   $submitErrMsg[ENDHOSTVALERR] = "The number of IP addresses ($numipaddrs) "
 		      . "does not match the number of hostnames ($numhostnames).";
 	}
-	if($viewmode == ADMIN_DEVELOPER &&
-	   ! empty($return['startpripaddress']) && ! empty($return['endpripaddress']) &&
+	if(! empty($return['startpripaddress']) && ! empty($return['endpripaddress']) &&
 	   (! ($submitErr & IPADDRERR2 || $submitErr & IPADDRERR4) && 
 	   ! empty($endpraddrArr) &&
 		($endaddrArr[3] - $startaddrArr[3] != $endpraddrArr[3] - $startpraddrArr[3]))) {

Modified: incubator/vcl/trunk/web/.ht-inc/dashboard.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/dashboard.php?rev=1049551&r1=1049550&r2=1049551&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/dashboard.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/dashboard.php Wed Dec 15 13:43:31 2010
@@ -29,7 +29,15 @@
 ////////////////////////////////////////////////////////////////////////////////
 function dashboard() {
 	print "<h2>VCL Dashboard</h2>\n";
-	print "<table summary=\"\">\n";
+	if(checkUserHasPerm('View Dashboard (global)')) {
+		print "View data for:";
+		$affils = getAffiliations();
+		$affils = array_reverse($affils, TRUE);
+		$affils[0] = "All Affiliations";
+		$affils = array_reverse($affils, TRUE);
+		printSelectInput('affilid', $affils, -1, 0, 0, 'affilid', 'onChange="updateDashboard();"');
+	}
+	print "<table summary=\"\" id=dashboard>\n";
 	print "<tr>\n";
 
 	# -------- left column ---------
@@ -37,6 +45,7 @@ function dashboard() {
 	print addWidget('status', 'Current Status');
 	print addWidget('topimages', 'Top 5 Images in Use', '(Reservations &lt; 24 hours long)');
 	print addWidget('toplongimages', 'Top 5 Long Term Images in Use', '(Reservations &gt; 24 hours long)');
+	print addWidget('toppastimages', 'Top 5 Images From Past Day', '(Reservations with a start<br>time within past 24 hours)');
 	print addWidget('topfailedcomputers', 'Top Recent Computer Failures', '(Failed in the last 5 days)');
 	print "</td>\n";
 	# -------- end left column ---------
@@ -51,7 +60,7 @@ function dashboard() {
 
 	print "</tr>\n";
 	print "</table>\n";
-	$cont = addContinuationsEntry('AJupdateDashboard', array('val' => 0), 60, 1, 0);
+	$cont = addContinuationsEntry('AJupdateDashboard', array('val' => 0), 90, 1, 0);
 	print "<input type=\"hidden\" id=\"updatecont\" value=\"$cont\">\n";
 }
 
@@ -64,10 +73,11 @@ function dashboard() {
 ////////////////////////////////////////////////////////////////////////////////
 function AJupdateDashboard() {
 	$data = array();
-	$data['cont'] = addContinuationsEntry('AJupdateDashboard', array(), 60, 1, 0);
+	$data['cont'] = addContinuationsEntry('AJupdateDashboard', array(), 90, 1, 0);
 	$data['status'] = getStatusData();
 	$data['topimages'] = getTopImageData();
 	$data['toplongimages'] = getTopLongImageData();
+	$data['toppastimages'] = getTopPastImageData();
 	$data['topfailed'] = getTopFailedData();
 	$data['topfailedcomputers'] = getTopFailedComputersData();
 	$data['reschart'] = getActiveResChartData();
@@ -150,17 +160,31 @@ function addLineChart($id, $title) {
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function getStatusData() {
+	$affilid = getDashboardAffilID();
 	$data = array();
 	$data[] = array('key' => 'Active Reservations', 'val' => 0);
 	$data[] = array('key' => 'Online Computers', 'val' => 0, 'tooltip' => 'Computers in states available, reserved,<br>reloading, inuse, or timeout');
 	$data[] = array('key' => 'Failed Computers', 'val' => 0);
 	$reloadid = getUserlistID('vclreload@Local');
-	$query = "SELECT COUNT(id) "
-	       . "FROM request "
-	       . "WHERE userid != $reloadid AND "
-	       .       "stateid NOT IN (1, 5, 12) AND "
-	       .       "start < NOW() AND "
-			 .       "end > NOW()";
+	if($affilid == 0) {
+		$query = "SELECT COUNT(id) "
+		       . "FROM request "
+		       . "WHERE userid != $reloadid AND "
+		       .       "stateid NOT IN (1, 5, 12) AND "
+		       .       "start < NOW() AND "
+				 .       "end > NOW()";
+	}
+	else {
+		$query = "SELECT COUNT(rq.id) "
+		       . "FROM request rq, "
+		       .      "user u "
+		       . "WHERE rq.userid != $reloadid AND "
+		       .       "rq.userid = u.id AND "
+		       .       "u.affiliationid = $affilid AND "
+		       .       "rq.stateid NOT IN (1, 5, 12) AND "
+		       .       "rq.start < NOW() AND "
+				 .       "rq.end > NOW()";
+	}
 	$qh = doQuery($query, 101);
 	if($row = mysql_fetch_row($qh))
 		$data[0]['val'] = $row[0];
@@ -189,18 +213,38 @@ function getStatusData() {
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function getTopImageData() {
-	$query = "SELECT COUNT(rs.imageid) AS count, "
-	       .        "i.prettyname "
-	       . "FROM reservation rs, "
-	       .      "request rq, "
-	       .      "image i "
-	       . "WHERE rs.imageid = i.id AND "
-			 .       "rq.stateid = 8 AND "
-			 .       "rs.requestid = rq.id AND "
-			 .       "TIMESTAMPDIFF(HOUR, rq.start, rq.end) <= 24 "
-	       . "GROUP BY rs.imageid "
-	       . "ORDER BY count DESC "
-	       . "LIMIT 5";
+	$affilid = getDashboardAffilID();
+	if($affilid == 0) {
+		$query = "SELECT COUNT(rs.imageid) AS count, "
+		       .        "i.prettyname "
+		       . "FROM reservation rs, "
+		       .      "request rq, "
+		       .      "image i "
+		       . "WHERE rs.imageid = i.id AND "
+				 .       "rq.stateid = 8 AND "
+				 .       "rs.requestid = rq.id AND "
+				 .       "TIMESTAMPDIFF(HOUR, rq.start, rq.end) <= 24 "
+		       . "GROUP BY rs.imageid "
+		       . "ORDER BY count DESC "
+		       . "LIMIT 5";
+	}
+	else {
+		$query = "SELECT COUNT(rs.imageid) AS count, "
+		       .        "i.prettyname "
+		       . "FROM reservation rs, "
+		       .      "request rq, "
+		       .      "image i, "
+		       .      "user u "
+		       . "WHERE rq.userid = u.id AND "
+		       .       "u.affiliationid = $affilid AND "
+		       .       "rs.imageid = i.id AND "
+				 .       "rq.stateid = 8 AND "
+				 .       "rs.requestid = rq.id AND "
+				 .       "TIMESTAMPDIFF(HOUR, rq.start, rq.end) <= 24 "
+		       . "GROUP BY rs.imageid "
+		       . "ORDER BY count DESC "
+		       . "LIMIT 5";
+	}
 	$data = array();
 	$qh = doQuery($query, 101);
 	while($row = mysql_fetch_assoc($qh))
@@ -220,31 +264,88 @@ function getTopImageData() {
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function getTopLongImageData() {
-	$query = "SELECT COUNT(rs.imageid) AS count, "
-	       .        "i.prettyname, "
-	       .        "TIMESTAMPDIFF(HOUR, rq.start, rq.end) AS reslen "
-	       . "FROM reservation rs, "
-	       .      "request rq, "
-	       .      "image i "
-	       . "WHERE rs.imageid = i.id AND "
-			 .       "rq.stateid = 8 AND "
-			 .       "rs.requestid = rq.id "
-	       . "GROUP BY rs.imageid "
-	       . "HAVING reslen > 24 "
-	       . "ORDER BY count DESC "
-	       . "LIMIT 5";
-	$query = "SELECT COUNT(rs.imageid) AS count, "
-	       .        "i.prettyname "
-	       . "FROM reservation rs, "
-	       .      "request rq, "
-	       .      "image i "
-	       . "WHERE rs.imageid = i.id AND "
-			 .       "rq.stateid = 8 AND "
-			 .       "rs.requestid = rq.id AND "
-			 .       "TIMESTAMPDIFF(HOUR, rq.start, rq.end) > 24 "
-	       . "GROUP BY rs.imageid "
-	       . "ORDER BY count DESC "
-	       . "LIMIT 5";
+	$affilid = getDashboardAffilID();
+	if($affilid == 0) {
+		$query = "SELECT COUNT(rs.imageid) AS count, "
+		       .        "i.prettyname "
+		       . "FROM reservation rs, "
+		       .      "request rq, "
+		       .      "image i "
+		       . "WHERE rs.imageid = i.id AND "
+				 .       "rq.stateid = 8 AND "
+				 .       "rs.requestid = rq.id AND "
+				 .       "TIMESTAMPDIFF(HOUR, rq.start, rq.end) > 24 "
+		       . "GROUP BY rs.imageid "
+		       . "ORDER BY count DESC "
+		       . "LIMIT 5";
+	}
+	else {
+		$query = "SELECT COUNT(rs.imageid) AS count, "
+		       .        "i.prettyname "
+		       . "FROM reservation rs, "
+		       .      "request rq, "
+		       .      "image i, "
+		       .      "user u "
+		       . "WHERE rq.userid = u.id AND "
+		       .       "u.affiliationid = $affilid AND "
+		       .       "rs.imageid = i.id AND "
+				 .       "rq.stateid = 8 AND "
+				 .       "rs.requestid = rq.id AND "
+				 .       "TIMESTAMPDIFF(HOUR, rq.start, rq.end) > 24 "
+		       . "GROUP BY rs.imageid "
+		       . "ORDER BY count DESC "
+		       . "LIMIT 5";
+	}
+	$data = array();
+	$qh = doQuery($query, 101);
+	while($row = mysql_fetch_assoc($qh))
+		$data[] = $row;
+	return $data;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn getTopPastImageData()
+///
+/// \return array of data with these keys:\n
+/// \b prettyname - name of image\n
+/// \b count - number of reservations for this image
+///
+/// \brief gets data about top reserved images over past day
+///
+////////////////////////////////////////////////////////////////////////////////
+function getTopPastImageData() {
+	$affilid = getDashboardAffilID();
+	$reloadid = getUserlistID('vclreload@Local');
+	if($affilid == 0) {
+		$query = "SELECT COUNT(l.imageid) AS count, "
+		       .        "i.prettyname "
+		       . "FROM log l, "
+		       .      "image i "
+		       . "WHERE l.imageid = i.id AND "
+				 .       "l.wasavailable = 1 AND "
+				 .       "l.userid != $reloadid AND "
+				 .       "l.start > DATE_SUB(NOW(), INTERVAL 1 DAY) "
+		       . "GROUP BY l.imageid "
+		       . "ORDER BY count DESC "
+		       . "LIMIT 5";
+	}
+	else {
+		$query = "SELECT COUNT(l.imageid) AS count, "
+		       .        "i.prettyname "
+		       . "FROM log l, "
+		       .      "image i, "
+		       .      "user u "
+		       . "WHERE l.userid = u.id AND "
+		       .       "u.affiliationid = $affilid AND "
+		       .       "l.imageid = i.id AND "
+				 .       "l.wasavailable = 1 AND "
+				 .       "l.userid != $reloadid AND "
+				 .       "l.start > DATE_SUB(NOW(), INTERVAL 1 DAY) "
+		       . "GROUP BY l.imageid "
+		       . "ORDER BY count DESC "
+		       . "LIMIT 5";
+	}
 	$data = array();
 	$qh = doQuery($query, 101);
 	while($row = mysql_fetch_assoc($qh))
@@ -264,16 +365,34 @@ function getTopLongImageData() {
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function getTopFailedData() {
-	$query = "SELECT COUNT(l.imageid) AS count, "
-	       .        "i.prettyname "
-	       . "FROM log l, "
-	       .      "image i "
-	       . "WHERE l.imageid = i.id AND "
-	       .       "l.ending = 'failed' AND "
-	       .       "l.start > DATE_SUB(NOW(), INTERVAL 5 DAY) "
-	       . "GROUP BY l.imageid "
-	       . "ORDER BY count DESC "
-	       . "LIMIT 5";
+	$affilid = getDashboardAffilID();
+	if($affilid == 0) {
+		$query = "SELECT COUNT(l.imageid) AS count, "
+		       .        "i.prettyname "
+		       . "FROM log l, "
+		       .      "image i "
+		       . "WHERE l.imageid = i.id AND "
+		       .       "l.ending = 'failed' AND "
+		       .       "l.start > DATE_SUB(NOW(), INTERVAL 5 DAY) "
+		       . "GROUP BY l.imageid "
+		       . "ORDER BY count DESC "
+		       . "LIMIT 5";
+	}
+	else {
+		$query = "SELECT COUNT(l.imageid) AS count, "
+		       .        "i.prettyname "
+		       . "FROM log l, "
+		       .      "image i, "
+		       .      "user u "
+		       . "WHERE l.userid = u.id AND "
+		       .       "u.affiliationid = $affilid AND "
+		       .       "l.imageid = i.id AND "
+		       .       "l.ending = 'failed' AND "
+		       .       "l.start > DATE_SUB(NOW(), INTERVAL 5 DAY) "
+		       . "GROUP BY l.imageid "
+		       . "ORDER BY count DESC "
+		       . "LIMIT 5";
+	}
 	$data = array();
 	$qh = doQuery($query, 101);
 	while($row = mysql_fetch_assoc($qh))
@@ -293,18 +412,38 @@ function getTopFailedData() {
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function getTopFailedComputersData() {
-	$query = "SELECT COUNT(s.computerid) AS count, "
-	       .        "c.hostname "
-	       . "FROM log l, "
-	       .      "sublog s, "
-	       .      "computer c "
-	       . "WHERE s.logid = l.id AND "
-	       .       "s.computerid = c.id AND "
-	       .       "l.ending = 'failed' AND "
-	       .       "l.start > DATE_SUB(NOW(), INTERVAL 5 DAY) "
-	       . "GROUP BY s.computerid "
-	       . "ORDER BY count DESC "
-	       . "LIMIT 5";
+	$affilid = getDashboardAffilID();
+	if($affilid == 0) {
+		$query = "SELECT COUNT(s.computerid) AS count, "
+		       .        "c.hostname "
+		       . "FROM log l, "
+		       .      "sublog s, "
+		       .      "computer c "
+		       . "WHERE s.logid = l.id AND "
+		       .       "s.computerid = c.id AND "
+		       .       "l.ending = 'failed' AND "
+		       .       "l.start > DATE_SUB(NOW(), INTERVAL 5 DAY) "
+		       . "GROUP BY s.computerid "
+		       . "ORDER BY count DESC "
+		       . "LIMIT 5";
+	}
+	else {
+		$query = "SELECT COUNT(s.computerid) AS count, "
+		       .        "c.hostname "
+		       . "FROM log l, "
+		       .      "sublog s, "
+		       .      "computer c, "
+		       .      "user u "
+		       . "WHERE l.userid = u.id AND "
+		       .       "u.affiliationid = $affilid AND "
+		       .       "s.logid = l.id AND "
+		       .       "s.computerid = c.id AND "
+		       .       "l.ending = 'failed' AND "
+		       .       "l.start > DATE_SUB(NOW(), INTERVAL 5 DAY) "
+		       . "GROUP BY s.computerid "
+		       . "ORDER BY count DESC "
+		       . "LIMIT 5";
+	}
 	$data = array();
 	$qh = doQuery($query, 101);
 	while($row = mysql_fetch_assoc($qh))
@@ -338,15 +477,32 @@ function getActiveResChartData() {
 	}
 	$data['maxy'] = 0;
 	$reloadid = getUserlistID('vclreload@Local');
-	$query = "SELECT id, "
-	       .        "UNIX_TIMESTAMP(start) AS start, "
-	       .        "UNIX_TIMESTAMP(finalend) AS end "
-	       . "FROM log "
-	       . "WHERE start < NOW() AND "
-	       .       "finalend > DATE_SUB(NOW(), INTERVAL 12 HOUR) AND "
-	       .       "ending NOT IN ('failed', 'failedtest') AND "
-	       .       "wasavailable = 1 AND "
-	       .       "userid != $reloadid";
+	$affilid = getDashboardAffilID();
+	if($affilid == 0) {
+		$query = "SELECT id, "
+		       .        "UNIX_TIMESTAMP(start) AS start, "
+		       .        "UNIX_TIMESTAMP(finalend) AS end "
+		       . "FROM log "
+		       . "WHERE start < NOW() AND "
+		       .       "finalend > DATE_SUB(NOW(), INTERVAL 12 HOUR) AND "
+		       .       "ending NOT IN ('failed', 'failedtest') AND "
+		       .       "wasavailable = 1 AND "
+		       .       "userid != $reloadid";
+	}
+	else {
+		$query = "SELECT l.id, "
+		       .        "UNIX_TIMESTAMP(l.start) AS start, "
+		       .        "UNIX_TIMESTAMP(l.finalend) AS end "
+		       . "FROM log l, "
+		       .      "user u "
+		       . "WHERE l.userid = u.id AND "
+		       .       "u.affiliationid = $affilid AND "
+		       .       "l.start < NOW() AND "
+		       .       "l.finalend > DATE_SUB(NOW(), INTERVAL 12 HOUR) AND "
+		       .       "l.ending NOT IN ('failed', 'failedtest') AND "
+		       .       "l.wasavailable = 1 AND "
+		       .       "l.userid != $reloadid";
+	}
 	$qh = doQuery($query, 101);
 	while($row = mysql_fetch_assoc($qh)) {
 		for($binstart = $chartstart, $binend = $chartstart + 900, $binindex = 0; 
@@ -382,24 +538,54 @@ function getActiveResChartData() {
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function getBlockAllocationData() {
+	$affilid = getDashboardAffilID();
 	# active block allocation
-	$query = "SELECT COUNT(id) "
-	       . "FROM blockTimes "
-	       . "WHERE skip = 0 AND "
-	       .       "start < NOW() AND "
-			 .       "end > NOW()";
+	if($affilid == 0) {
+		$query = "SELECT COUNT(id) "
+		       . "FROM blockTimes "
+		       . "WHERE skip = 0 AND "
+		       .       "start < NOW() AND "
+				 .       "end > NOW()";
+	}
+	else {
+		$query = "SELECT COUNT(bt.id) "
+		       . "FROM blockTimes bt, "
+		       .      "blockRequest br, "
+		       .      "user u "
+		       . "WHERE bt.blockRequestid = br.id AND "
+		       .       "br.ownerid = u.id AND "
+		       .       "u.affiliationid = $affilid AND "
+		       .       "bt.skip = 0 AND "
+		       .       "bt.start < NOW() AND "
+				 .       "bt.end > NOW()";
+	}
 	$qh = doQuery($query, 101);
 	$row = mysql_fetch_row($qh);
 	$blockcount = $row[0];
 	# computers in blockComputers for active allocations
-	$query = "SELECT bc.computerid, "
-	       .        "c.stateid "
-	       . "FROM blockComputers bc "
-	       . "LEFT JOIN computer c ON (c.id = bc.computerid) "
-	       . "LEFT JOIN blockTimes bt ON (bt.id = bc.blockTimeid) "
-	       . "WHERE c.stateid IN (2, 3, 6, 8, 19) AND "
-	       .       "bt.start < NOW() AND "
-	       .       "bt.end > NOW()";
+	if($affilid == 0) {
+		$query = "SELECT bc.computerid, "
+		       .        "c.stateid "
+		       . "FROM blockComputers bc "
+		       . "LEFT JOIN computer c ON (c.id = bc.computerid) "
+		       . "LEFT JOIN blockTimes bt ON (bt.id = bc.blockTimeid) "
+		       . "WHERE c.stateid IN (2, 3, 6, 8, 19) AND "
+		       .       "bt.start < NOW() AND "
+		       .       "bt.end > NOW()";
+	}
+	else {
+		$query = "SELECT bc.computerid, "
+		       .        "c.stateid "
+		       . "FROM blockComputers bc "
+		       . "LEFT JOIN computer c ON (c.id = bc.computerid) "
+		       . "LEFT JOIN blockTimes bt ON (bt.id = bc.blockTimeid) "
+		       . "LEFT JOIN blockRequest br ON (bt.blockRequestid = br.id) "
+		       . "LEFT JOIN user u ON (br.ownerid = u.id) "
+		       . "WHERE u.affiliationid = $affilid AND "
+		       .       "c.stateid IN (2, 3, 6, 8, 19) AND "
+		       .       "bt.start < NOW() AND "
+		       .       "bt.end > NOW()";
+	}
 	$qh = doQuery($query, 101);
 	$total = 0;
 	$used = 0;
@@ -413,12 +599,24 @@ function getBlockAllocationData() {
 	else
 		$compused = 0;
 	# number of computers that should be allocated
-	$query = "SELECT br.numMachines "
-	       . "FROM blockRequest br "
-	       . "LEFT JOIN blockTimes bt ON (bt.blockRequestid = br.id) "
-	       . "WHERE bt.start < NOW() AND "
-	       .       "bt.end > NOW() AND "
-	       .       "bt.skip = 0";
+	if($affilid == 0) {
+		$query = "SELECT br.numMachines "
+		       . "FROM blockRequest br "
+		       . "LEFT JOIN blockTimes bt ON (bt.blockRequestid = br.id) "
+		       . "WHERE bt.start < NOW() AND "
+		       .       "bt.end > NOW() AND "
+		       .       "bt.skip = 0";
+	}
+	else {
+		$query = "SELECT br.numMachines "
+		       . "FROM blockRequest br "
+		       . "LEFT JOIN blockTimes bt ON (bt.blockRequestid = br.id) "
+		       . "LEFT JOIN user u ON (br.ownerid = u.id) "
+		       . "WHERE u.affiliationid = $affilid AND "
+		       .       "bt.start < NOW() AND "
+		       .       "bt.end > NOW() AND "
+		       .       "bt.skip = 0";
+	}
 	$alloc = 0;
 	$qh = doQuery($query, 101);
 	while($row = mysql_fetch_assoc($qh))
@@ -433,4 +631,25 @@ function getBlockAllocationData() {
 	$data[] = array('title' => 'Failed Block Computers', 'val' => $failed);
 	return $data;
 }
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn getDashboardAffilID()
+///
+/// \return an affiliation id
+///
+/// \brief if user has access to view the dashboard for any affiliation, returns
+/// selected affiliationid; otherwise, returns user's affiliationid
+///
+////////////////////////////////////////////////////////////////////////////////
+function getDashboardAffilID() {
+	global $user;
+	if(! checkUserHasPerm('View Dashboard (global)'))
+		return $user['affiliationid'];
+	$affilid = processInputVar('affilid', ARG_NUMERIC);
+	$affils = getAffiliations();
+	if($affilid != 0 && ! array_key_exists($affilid, $affils))
+		return 0;
+	return $affilid;
+}
 ?>

Modified: incubator/vcl/trunk/web/.ht-inc/errors.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/errors.php?rev=1049551&r1=1049550&r2=1049551&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/errors.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/errors.php Wed Dec 15 13:43:31 2010
@@ -120,8 +120,8 @@ $ERRORS = array (
 	"227" => "Failed to execute query 3 in acknowledgeRequest",
 	"228" => "Failed to execute query 4 in acknowledgeRequest",
 	"229" => "Failed to execute query 5 in acknowledgeRequest",
-	"235" => "Failed to execute query 1 in submitBulkAddComputers",
-	"238" => "Failed to execute query 3 in submitBulkAddComputers",
+	"235" => "Failed to execute query 1 in submitAddBulkComputers",
+	"238" => "Failed to execute query 3 in submitAddBulkComputers",
 	"240" => "Failed to execute query 1 in addUser",
 	"241" => "Failed to execute query 2 in addUser",
 	"242" => "Failed to fetch last insert id in addUser",
@@ -223,7 +223,7 @@ $XMLRPCERRORS = array(
 ////////////////////////////////////////////////////////////////////////////////
 function errorHandler($errno, $errstr, $errfile=NULL, $errline=NULL, $errcontext=NULL) {
 	global $user;
-	if($user["adminlevel"] != "developer") {
+	if(! ONLINEDEBUG || ! checkUserHasPerm('View Debug Information')) {
 		dbDisconnect();
 		printHTMLFooter();
 		semUnlock();

Modified: incubator/vcl/trunk/web/.ht-inc/groups.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/groups.php?rev=1049551&r1=1049550&r2=1049551&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/groups.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/groups.php Wed Dec 15 13:43:31 2010
@@ -43,7 +43,7 @@ define("MAXOVERLAPERR", 1 << 6);
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function viewGroups() {
-	global $viewmode, $user, $mode;
+	global $user, $mode;
 	$modetype = getContinuationVar("type");
 
 	$usergroups = getUserGroups(1);
@@ -92,7 +92,7 @@ function viewGroups() {
 	print "    <TH>Initial Max Time (minutes)</TH>\n";
 	print "    <TH>Total Max Time (minutes)</TH>\n";
 	print "    <TH>Max Extend Time (minutes)</TH>\n";
-	if($viewmode == ADMIN_DEVELOPER)
+	if(checkUserHasPerm('Set Overlapping Reservation Count'))
 		print "    <TH>Max Overlapping Reservations</TH>\n";
 	print "  </TR>\n";
 	print "  <TR>\n";
@@ -118,7 +118,7 @@ function viewGroups() {
 	print "</TD>\n";
 	print "    <TD><INPUT type=text name=maxextend maxlength=4 size=4 value=30>";
 	print "</TD>\n";
-	if($viewmode == ADMIN_DEVELOPER) {
+	if(checkUserHasPerm('Set Overlapping Reservation Count')) {
 		print "    <TD><INPUT type=text name=overlap maxlength=4 size=4 value=0>";
 		print "</TD>\n";
 	}
@@ -174,7 +174,7 @@ function viewGroups() {
 		print "    <TD align=center>{$usergroups[$id]["initialmaxtime"]}</TD>\n";
 		print "    <TD align=center>{$usergroups[$id]["totalmaxtime"]}</TD>\n";
 		print "    <TD align=center>{$usergroups[$id]["maxextendtime"]}</TD>\n";
-		if($viewmode == ADMIN_DEVELOPER)
+		if(checkUserHasPerm('Set Overlapping Reservation Count'))
 			print "    <TD align=center>{$usergroups[$id]["overlapResCount"]}</TD>\n";
 		print "  </TR>\n";
 	}
@@ -280,7 +280,7 @@ function viewGroups() {
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function editOrAddGroup($state) {
-	global $submitErr, $user, $mode, $viewmode;
+	global $submitErr, $user, $mode;
 
 	$usergroups = getUserGroups(1);
 	if($user['showallgroups'])
@@ -446,7 +446,7 @@ function editOrAddGroup($state) {
 			printSubmitErr(MAXEXTENDERR);
 			print "</TD>\n";
 			print "  </TR>\n";
-			if($viewmode == ADMIN_DEVELOPER) {
+			if(checkUserHasPerm('Set Overlapping Reservation Count')) {
 				print "  <TR>\n";
 				print "    <TH align=right>Max Overlapping Reservations:</TH>\n";
 				print "    <TD><INPUT type=text name=overlap value=\"";
@@ -568,7 +568,7 @@ function editOrAddGroup($state) {
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function processGroupInput($checks=1) {
-	global $submitErr, $submitErrMsg, $user, $viewmode;
+	global $submitErr, $submitErrMsg, $user;
 	$return = array();
 	$return["groupid"] = getContinuationVar("groupid");
 	$return["type"] = getContinuationVar("type");
@@ -628,7 +628,7 @@ function processGroupInput($checks=1) {
 		$submitErrMsg[MAXEXTENDERR] = "Max extend time must be at least 15 "
 		                            . "minutes";
 	}
-	if($viewmode == ADMIN_DEVELOPER &&
+	if(checkUserHasPerm('Set Overlapping Reservation Count') &&
 	   $return["type"] == "user" &&
 	   ($return["overlap"] < 0 ||
 	   $return["overlap"] == 1)) {
@@ -685,7 +685,6 @@ function checkForGroupName($name, $type,
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function updateGroup($data) {
-	global $viewmode;
 	if($data["type"] == "user") {
 		$ownerid = getUserlistID($data["owner"]);
 		$query = "UPDATE usergroup "
@@ -695,7 +694,7 @@ function updateGroup($data) {
 		       .     "editusergroupid = {$data["editgroupid"]}, "
 		       .     "initialmaxtime = {$data["initialmax"]}, "
 		       .     "totalmaxtime = {$data["totalmax"]}, ";
-		if($viewmode == ADMIN_DEVELOPER)
+		if(checkUserHasPerm('Set Overlapping Reservation Count'))
 			$query .= "overlapResCount = {$data["overlap"]}, ";
 		$query .=    "maxextendtime = {$data["maxextend"]} "
 		       . "WHERE id = {$data["groupid"]}";
@@ -722,7 +721,6 @@ function updateGroup($data) {
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function addGroup($data) {
-	global $viewmode;
 	if($data["type"] == "user") {
 		if(! array_key_exists('custom', $data))
 			$data['custom'] = 1;
@@ -740,7 +738,7 @@ function addGroup($data) {
 		       .         "custom, "
 		       .         "initialmaxtime, "
 		       .         "totalmaxtime, ";
-		if($viewmode == ADMIN_DEVELOPER)
+		if(checkUserHasPerm('Set Overlapping Reservation Count'))
 			$query .=     "overlapResCount, ";
 		$query .=        "maxextendtime) "
 				 . "VALUES ('{$data["name"]}', "
@@ -750,7 +748,7 @@ function addGroup($data) {
 		       .        "{$data['custom']}, "
 		       .        "{$data["initialmax"]}, "
 		       .        "{$data["totalmax"]}, ";
-		if($viewmode == ADMIN_DEVELOPER)
+		if(checkUserHasPerm('Set Overlapping Reservation Count'))
 			$query .=    "{$data["overlap"]}, ";
 		$query .=       "{$data["maxextend"]})";
 	}
@@ -824,7 +822,7 @@ function checkForGroupUsage($groupid, $t
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function confirmEditOrAddGroup($state) {
-	global $submitErr, $user, $viewmode;
+	global $submitErr, $user;
 
 	$data = processGroupInput(1);
 
@@ -908,7 +906,7 @@ function confirmEditOrAddGroup($state) {
 		print "    <TH align=right>Max Extend Time (minutes):</TH>\n";
 		print "    <TD>{$data["maxextend"]}</TD>\n";
 		print "  </TR>\n";
-		if($viewmode == ADMIN_DEVELOPER) {
+		if(checkUserHasPerm('Set Overlapping Reservation Count')) {
 			print "  <TR>\n";
 			print "    <TH align=right>Max Overlapping Reservations:</TH>\n";
 			print "    <TD>{$data["overlap"]}</TD>\n";
@@ -1125,7 +1123,7 @@ function deleteGroupUser() {
 ///
 /// \fn jsonGetGroupInfo()
 ///
-/// \brief 
+/// \brief gets members of submitted resource group and returns in JSON format
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function jsonGetGroupInfo() {

Modified: incubator/vcl/trunk/web/.ht-inc/images.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/images.php?rev=1049551&r1=1049550&r2=1049551&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/images.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/images.php Wed Dec 15 13:43:31 2010
@@ -109,7 +109,7 @@ function selectImageOption() {
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function viewImages() {
-	global $viewmode, $user, $mode;
+	global $user, $mode;
 	$showdeleted = getContinuationVar("showdeleted", 0);
 	$deleted = getContinuationVar("deleted");
 	$details = processInputVar("details", ARG_NUMERIC);
@@ -945,30 +945,6 @@ function editOrAddImage($state) {
 	printSelectInput("rootaccess", $yesno, $default);
 	print "    </TD>\n";
 	print "  </TR>\n";
-	# finally just limited access so only high level access people see this
-	# because it confused too many people
-	if($user["adminlevel"] == "developer") {
-		print "  <TR>\n";
-		print "    <TH align=right>User group allowed to log in:<br>\n";
-		print "    <small>(This does not grant permission to<br>\n";
-		print "make a reservation for the image)</small></TH>\n";
-		print "    <TD>\n";
-		if(! empty($data["usergroupid"])) {
-			$default = $data["usergroupid"];
-			if(! array_key_exists($default, $groups)) {
-				if($submitErr || $mode == 'submitEditImageButtons')
-					$groups[$data['usergroupid']] = array('name' => $images[$data['imageid']]['usergroup']);
-				else
-					$groups[$data['usergroupid']] = array('name' => $data['usergroup']);
-				uasort($groups, 'sortKeepIndex');
-			}
-		}
-		else
-			$default = 0;
-		printSelectInput("usergroupid", $groups, $default);
-		print "    </TD>\n";
-		print "  </TR>\n";
-	}
 	if($state) {
 		if(array_key_exists("sysprep", $data) && ! $data["sysprep"])
 			$default = 0;
@@ -1488,16 +1464,6 @@ function confirmEditOrAddImage($state) {
 	else
 		print "    <TD>No</TD>\n";
 	print "  </TR>\n";
-	if($user["adminlevel"] == "developer" || $user['adminlevel'] == 'full') {
-		print "  <TR>\n";
-		print "    <TH align=right>User group allowed to log in:</TH>\n";
-		$tmp = explode('@', $groups[$data["usergroupid"]]["name"]);
-		if(array_key_exists(1, $tmp) && $tmp[1] != $user['affiliation'])
-			print "    <TD>" . $groups[$data["usergroupid"]]["name"] . "</TD>\n";
-		else
-			print "    <TD>{$tmp[0]}</TD>\n";
-		print "  </TR>\n";
-	}
 	if(! $state) {
 		print "  <TR>\n";
 		print "    <TH style=\"vertical-align:top; text-align:right;\">Subimages:</TH>\n";
@@ -2164,12 +2130,6 @@ function viewImageDetails() {
 	else
 		print "    <TD>yes</TD>\n";
 	print "  </TR>\n";
-	if(! empty($images[$imageid]["usergroupid"])) {
-		print "  <TR>\n";
-		print "    <TH align=right>User group allowed to log in:</TH>\n";
-		print "    <TD>{$images[$imageid]["usergroup"]}</TD>\n";
-		print "  </TR>\n";
-	}
 	if($oslist[$images[$imageid]["osid"]]["type"] == 'windows') {
 		print "  <TR>\n";
 		print "    <TH align=right>Use sysprep:</TH>\n";
@@ -2424,7 +2384,6 @@ function processImageInput($checks=1) {
 	$return["forcheckout"] = processInputVar("forcheckout", ARG_NUMERIC, 1);
 	$return["checkuser"] = processInputVar("checkuser", ARG_NUMERIC, 1);
 	$return["rootaccess"] = processInputVar("rootaccess", ARG_NUMERIC, 1);
-	$return["usergroupid"] = processInputVar("usergroupid", ARG_NUMERIC);
 	$return["sysprep"] = processInputVar("sysprep", ARG_NUMERIC, 1);
 	$return["description"] = processInputVar("description", ARG_STRING);
 	$return["usage"] = processInputVar("usage", ARG_STRING);
@@ -2562,16 +2521,11 @@ function updateImage($data) {
 	$return = mysql_affected_rows($GLOBALS["mysql_link_vcl"]);
 	if(empty($imgdata[$data["imageid"]]["imagemetaid"]) &&
 	   ($data["checkuser"] == 0 ||
-	   $data["usergroupid"] != 0 ||
 	   $data['rootaccess'] == 0)) {
-		if($data["usergroupid"] == 0)
-			$data["usergroupid"] = "NULL";
 		$query = "INSERT INTO imagemeta "
 		       .        "(checkuser, "
-		       .        "usergroupid, "
 		       .        "rootaccess) "
 		       . "VALUES ({$data["checkuser"]}, "
-		       .        "{$data["usergroupid"]}, "
 		       .        "{$data["rootaccess"]})";
 		doQuery($query, 101);
 		$qh = doQuery("SELECT LAST_INSERT_ID() FROM imagemeta", 101);
@@ -2585,14 +2539,10 @@ function updateImage($data) {
 	}
 	elseif(! empty($imgdata[$data["imageid"]]["imagemetaid"])) {
 	  if($data["checkuser"] != $imgdata[$data["imageid"]]["checkuser"] ||
-	   $data["rootaccess"] != $imgdata[$data["imageid"]]["rootaccess"] ||
-	   $data["usergroupid"] != $imgdata[$data["imageid"]]["usergroupid"]) {
-			if($data["usergroupid"] == 0)
-				$data["usergroupid"] = "NULL";
+	   $data["rootaccess"] != $imgdata[$data["imageid"]]["rootaccess"]) {
 			$query = "UPDATE imagemeta "
 			       . "SET checkuser = {$data["checkuser"]}, "
-			       .     "rootaccess = {$data["rootaccess"]}, "
-			       .     "usergroupid = {$data["usergroupid"]} "
+			       .     "rootaccess = {$data["rootaccess"]} "
 			       . "WHERE id = {$imgdata[$data["imageid"]]["imagemetaid"]}";
 			doQuery($query, 101);
 		}
@@ -2669,23 +2619,18 @@ function addImage($data) {
 		$data['checkuser'] = 1;
 	if($data['rootaccess'] != 0 && $data['rootaccess'] != 1)
 		$data['rootaccess'] = 1;
-	if(! is_numeric($data['usergroupid']) || $data['usergroupid'] <= 0)
-		$data['usergroupid'] = "NULL";
 	if($data['sysprep'] != 0 && $data['sysprep'] != 1)
 		$data['sysprep'] = 1;
 	if($data['checkuser'] == 0 ||
 	   $data['rootaccess'] == 0 ||
-	   (is_numeric($data['usergroupid']) && $data['usergroupid'] > 0) ||
 	   $data['sysprep'] == 0) {
 		$query = "INSERT INTO imagemeta "
 		       .        "(checkuser, "
 		       .        "rootaccess, "
-		       .        "usergroupid, "
 		       .        "sysprep) "
 		       . "VALUES "
 		       .        "({$data['checkuser']}, "
 		       .        "{$data['rootaccess']}, "
-		       .        "{$data['usergroupid']}, "
 		       .        "{$data['sysprep']})";
 		doQuery($query, 101);
 

Modified: incubator/vcl/trunk/web/.ht-inc/managementnodes.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/managementnodes.php?rev=1049551&r1=1049550&r2=1049551&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/managementnodes.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/managementnodes.php Wed Dec 15 13:43:31 2010
@@ -114,7 +114,7 @@ function selectMgmtnodeOption() {
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function viewMgmtnodes() {
-	global $viewmode, $user, $mode;
+	global $user, $mode;
 
 	$mgmtnodes = getManagementNodes();
 	$resources = getUserResources(array("mgmtNodeAdmin"), array("administer"));

Modified: incubator/vcl/trunk/web/.ht-inc/privileges.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/privileges.php?rev=1049551&r1=1049550&r2=1049551&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/privileges.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/privileges.php Wed Dec 15 13:43:31 2010
@@ -49,8 +49,14 @@ function viewNodes() {
 	}
 
 	$hasNodeAdmin = checkUserHasPriv("nodeAdmin", $user["id"], $activeNode);
+	$hasManagePerms = checkUserHasPerm('Manage Additional User Group Permissions');
 
 	# tree
+	if($hasManagePerms) {
+		print "<div id=\"mainTabContainer\" dojoType=\"dijit.layout.TabContainer\"\n";
+		print "     style=\"width:800px;height:600px\">\n";
+		print "<div id=\"privtreetab\" dojoType=\"dijit.layout.ContentPane\" title=\"Privilege Tree\">\n";
+	}
 	print "<H2>Privilege Tree</H2>\n";
 	$cont = addContinuationsEntry('JSONprivnodelist');
 	print "<div dojoType=\"dojo.data.ItemFileWriteStore\" url=\"" . BASEURL . SCRIPT . "?continuation=$cont\" jsid=\"nodestore\" id=\"nodestore\"></div>\n";
@@ -632,6 +638,67 @@ function viewNodes() {
 	print "    dojo.addClass(dijit.byId('workingDialog').titleBar, 'hidden');\n";
 	print "  </script>\n";
 	print "</div>\n";
+	if(! $hasManagePerms)
+		return;
+	print "</div>\n"; # end privtree tab
+
+	print "<div id=\"userpermtab\" dojoType=\"dijit.layout.ContentPane\" title=\"Additional User Permissions\">\n";
+	print "<h2>Additional User Group Permissions</h2>\n";
+	print "There are additional permisssions that can be assigned to user<br>\n";
+	print "groups that are not specific to any nodes in the privilege tree.<br>\n";
+	print "Use this portion of the site to manage those permissions.<br><br>\n";
+	printSelectInput("editusergroupid", $groups, -1, 0, 0, 'editusergroupid', 'onChange="hideUserGroupPrivs();"');
+	$cont = addContinuationsEntry('AJpermSelectUserGroup');
+	print "<button dojoType=\"dijit.form.Button\">\n";
+	print "	Manage User Group Permissions\n";
+	print "	<script type=\"dojo/method\" event=onClick>\n";
+	print "		selectUserGroup('$cont');\n";
+	print "	</script>\n";
+	print "</button>\n";
+	print "<div id=\"extrapermsdiv\">\n";
+	print "<table summary=\"\">\n";
+	print "<tr>\n";
+	print "<td nowrap>\n";
+	print "<div id=\"usergroupprivs\" class=\"groupprivshidden\">\n";
+	$privtypes = getUserGroupPrivTypes();
+	foreach($privtypes as $id => $type) {
+		print "<span onMouseOver=\"showUserGroupPrivHelp('{$type['help']}', $id);\" \n";
+		print "onMouseOut=\"clearUserGroupPrivHelp($id);\" id=\"grouptypespan$id\">\n";
+		print "<input id=\"grouptype$id\" dojoType=\"dijit.form.CheckBox\" ";
+		print "value=\"1\" name=\"$id\"><label for=\"grouptype$id\">{$type['name']}";
+		print "</label></span><br>\n";
+	}
+	print "</div>\n";
+	print "</td>\n";
+	print "<td id=\"groupprivhelpcell\">\n";
+	print "<fieldset style=\"height: 100%\";>\n";
+	print "<legend>Permission Description</legend>\n";
+	print "<div id=\"groupprivhelp\"></div>\n";
+	print "</fieldset>\n";
+	print "</td>\n";
+	print "</tr>\n";
+	print "</table><br><br>\n";
+	print "Copy permissions from user group: ";
+	printSelectInput("copyusergroupid", $groups, -1, 0, 0, 'copyusergroupid');
+	$cont = addContinuationsEntry('AJpermSelectUserGroup');
+	print "<button dojoType=\"dijit.form.Button\" id=\"usergroupcopyprivsbtn\" disabled>\n";
+	print "	Copy Permissions\n";
+	print "	<script type=\"dojo/method\" event=onClick>\n";
+	print "		copyUserGroupPrivs('$cont');\n";
+	print "	</script>\n";
+	print "</button><br><br>\n";
+	$cont = addContinuationsEntry('AJsaveUserGroupPrivs');
+	print "<button dojoType=\"dijit.form.Button\" id=\"usergroupsaveprivsbtn\" disabled>\n";
+	print "	Save Selected Permissions\n";
+	print "	<script type=\"dojo/method\" event=onClick>\n";
+	print "		saveUserGroupPrivs('$cont');\n";
+	print "	</script>\n";
+	print "</button><br>\n";
+	print "<span id=\"userpermsubmitstatus\"></span>\n";
+	print "</div>\n";
+	print "</div>\n"; # end userperm tab
+
+	print "</div>\n"; # end tab container
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -1075,7 +1142,7 @@ function AJsubmitRenameNode() {
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function userLookup() {
-	global $user, $viewmode;
+	global $user;
 	$userid = processInputVar("userid", ARG_STRING);
 	$force = processInputVar('force', ARG_NUMERIC, 0);
 	print "<div align=center>\n";
@@ -1107,7 +1174,7 @@ function userLookup() {
 			print "specified affiliation is unknown<br>\n";
 			return;
 		}
-		if($viewmode != ADMIN_DEVELOPER &&
+		if(! checkUserHasPerm('User Lookup (global)') &&
 		   $user['affiliationid'] != $affilid) {
 			print "You are only allowed to look up users from your own affiliation.<br>\n";
 			return;
@@ -1160,10 +1227,6 @@ function userLookup() {
 			print "  </TR>\n";
 		}
 		print "  <TR>\n";
-		print "    <TH align=right>Admin Level:</TH>\n";
-		print "    <TD>{$userdata["adminlevel"]}</TD>\n";
-		print "  </TR>\n";
-		print "  <TR>\n";
 		print "    <TH align=right style=\"vertical-align: top\">Groups:</TH>\n";
 		print "    <TD>\n";
 		uasort($userdata["groups"], "sortKeepIndex");
@@ -1173,6 +1236,17 @@ function userLookup() {
 		print "    </TD>\n";
 		print "  </TR>\n";
 		print "  <TR>\n";
+		print "    <TH align=right style=\"vertical-align: top\">User Group Permissions:</TH>\n";
+		print "    <TD>\n";
+		if(count($userdata['groupperms'])) {
+			foreach($userdata['groupperms'] as $perm)
+				print "      $perm<br>\n";
+		}
+		else
+			print "      No additional user group permissions\n";
+		print "    </TD>\n";
+		print "  </TR>\n";
+		print "  <TR>\n";
 		print "    <TH align=right style=\"vertical-align: top\">Privileges (found somewhere in the tree):</TH>\n";
 		print "    <TD>\n";
 		uasort($userdata["privileges"], "sortKeepIndex");
@@ -1773,6 +1847,8 @@ function getResourcePrivRowHTML($privnam
 		   ! array_key_exists($resourcegroups[$id]["ownerid"], $user["groups"])) {
 			$text .= "<TD><img src=images/blank.gif></TD>\n";
 		}
+		// if group type is schedule, don't print available or manageMapping checkboxes
+		// if group type is managementnode, don't print available checkbox
 		elseif(($grptype == 'schedule' && ($type == 'available' || $type == 'manageMapping')) ||
 		      ($grptype == 'managementnode' && $type == 'available')) {
 			$text .= "<TD><img src=images/blank.gif></TD>\n";
@@ -2532,4 +2608,66 @@ function checkUserHasPriv($priv, $uid, $
 	return 0;
 }
 
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn AJpermSelectUserGroup()
+///
+/// \brief gets permissions granted to a user group and sends it in JSON format
+///
+////////////////////////////////////////////////////////////////////////////////
+function AJpermSelectUserGroup() {
+	global $user;
+	$groups = getUserGroups(0, $user['affiliationid']);
+	$groupid = processInputVar('groupid', ARG_NUMERIC);
+	if(! array_key_exists($groupid, $groups)) {
+		sendJSON(array('failed' => 'noaccess'));
+		return;
+	}
+	$permdata = getUserGroupPrivs($groupid);
+	$perms = array();
+	foreach($permdata as $perm)
+		$perms[] = $perm['permid'];
+	sendJSON(array('perms' => $perms));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// \fn AJsaveUserGroupPrivs()
+///
+/// \brief saves submitted permissions for user group
+///
+////////////////////////////////////////////////////////////////////////////////
+function AJsaveUserGroupPrivs() {
+	global $user;
+	$groups = getUserGroups(0, $user['affiliationid']);
+	$groupid = processInputVar('groupid', ARG_NUMERIC);
+	if(! array_key_exists($groupid, $groups)) {
+		sendJSON(array('failed' => 'noaccess'));
+		return;
+	}
+	$permids = processInputVar('permids', ARG_STRING);
+	if(! preg_match('/^[0-9,]*$/', $permids)) {
+		sendJSON(array('failed' => 'invalid input'));
+		return;
+	}
+	$perms = explode(',', $permids);
+	$query = "DELETE FROM usergrouppriv WHERE usergroupid = $groupid";
+	doQuery($query, 101);
+	if(empty($perms[0])) {
+		sendJSON(array('success' => 1));
+		return;
+	}
+	$values = array();
+	foreach($perms as $permid)
+		$values[] = "($groupid, $permid)";
+	$allvals = implode(',', $values);
+	$query = "INSERT INTO usergrouppriv "
+	       .        "(usergroupid, "
+	       .        "userprivtypeid) "
+	       . "VALUES $allvals";
+	doQuery($query, 101);
+	sendJSON(array('success' => 1));
+	$_SESSION['user']["groupperms"] = getUsersGroupPerms(array_keys($user['groups']));
+}
+
 ?>

Modified: incubator/vcl/trunk/web/.ht-inc/requests.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/requests.php?rev=1049551&r1=1049550&r2=1049551&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/requests.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/requests.php Wed Dec 15 13:43:31 2010
@@ -291,7 +291,7 @@ function AJupdateWaitTime() {
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function submitRequest() {
-	global $submitErr, $user, $viewmode, $HTMLheader, $mode, $printedHTMLheader;
+	global $submitErr, $user, $HTMLheader, $mode, $printedHTMLheader;
 
 	if($mode == 'submitTestProd') {
 		$data = getContinuationVar();
@@ -596,7 +596,7 @@ function submitRequest() {
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function viewRequests() {
-	global $user, $viewmode, $inContinuation, $mode;
+	global $user, $inContinuation, $mode;
 	if($inContinuation)
 		$lengthchanged = getContinuationVar('lengthchanged', 0);
 	else
@@ -617,7 +617,7 @@ function viewRequests() {
 	$normal = '';
 	$imaging = '';
 	$long = '';
-	if($viewmode == ADMIN_DEVELOPER)
+	if(checkUserHasPerm('View Debug Information'))
 		$nodes = getManagementNodes();
 	if($count = count($requests)) {
 		$now = time();
@@ -810,7 +810,7 @@ function viewRequests() {
 			# print date requested
 			$text .= "    <TD>" . prettyDatetime($requests[$i]["daterequested"]) . "</TD>\n";
 
-			if($viewmode == ADMIN_DEVELOPER) {
+			if(checkUserHasPerm('View Debug Information')) {
 				$text .= "    <TD align=center>" . $requests[$i]["id"] . "</TD>\n";
 				$text .= "    <TD align=center>" . $requests[$i]["computerid"] . "</TD>\n";
 				$text .= "    <TD align=center>" . $nodes[$requests[$i]["managementnodeid"]]['hostname'] . "</TD>\n";
@@ -851,7 +851,7 @@ function viewRequests() {
 		$text .= "    <TH>Starting</TH>\n";
 		$text .= "    <TH>Ending</TH>\n";
 		$text .= "    <TH>Initially requested</TH>\n";
-		if($viewmode == ADMIN_DEVELOPER) {
+		if(checkUserHasPerm('View Debug Information')) {
 			$text .= "    <TH>Req ID</TH>\n";
 			$text .= "    <TH>Comp ID</TH>\n";
 			$text .= "    <TH>Management Node</TH>\n";
@@ -876,7 +876,7 @@ function viewRequests() {
 		$text .= "    <TH>Ending</TH>\n";
 		$text .= "    <TH>Initially requested</TH>\n";
 		$computers = getComputers();
-		if($viewmode == ADMIN_DEVELOPER) {
+		if(checkUserHasPerm('View Debug Information')) {
 			$text .= "    <TH>Req ID</TH>\n";
 			$text .= "    <TH>Comp ID</TH>\n";
 			$text .= "    <TH>Management Node</TH>\n";
@@ -901,7 +901,7 @@ function viewRequests() {
 		$text .= "    <TH>Ending</TH>\n";
 		$text .= "    <TH>Initially requested</TH>\n";
 		$computers = getComputers();
-		if($viewmode == ADMIN_DEVELOPER) {
+		if(checkUserHasPerm('View Debug Information')) {
 			$text .= "    <TH>Req ID</TH>\n";
 			$text .= "    <TH>Comp ID</TH>\n";
 			$text .= "    <TH>Management Node</TH>\n";
@@ -1757,7 +1757,7 @@ function confirmEditRequest() {
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function submitEditRequest() {
-	global $user, $submitErr, $viewmode, $mode;
+	global $user, $submitErr, $mode;
 	$data = getContinuationVar();
 	$request = getRequestInfo($data["requestid"]);
 

Modified: incubator/vcl/trunk/web/.ht-inc/states.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/states.php?rev=1049551&r1=1049550&r2=1049551&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/states.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/states.php Wed Dec 15 13:43:31 2010
@@ -146,6 +146,9 @@ $noHTMLwrappers = array('sendRDPfile',
                         'AJupdateDashboard',
                         'AJgetStatData',
                         'AJgetBlockAllocatedMachineData',
+                        'AJpermSelectUserGroup',
+                        'AJcopyUserGroupPrivs',
+                        'AJsaveUserGroupPrivs',
 );
 
 # main
@@ -529,6 +532,9 @@ $actions['mode']['AJchangeResourcePrivs'
 $actions['mode']['JSONprivnodelist'] = "JSONprivnodelist";
 $actions['mode']['jsonGetUserGroupMembers'] = "jsonGetUserGroupMembers";
 $actions['mode']['jsonGetResourceGroupMembers'] = "jsonGetResourceGroupMembers";
+$actions['mode']['AJpermSelectUserGroup'] = "AJpermSelectUserGroup";
+$actions['mode']['AJcopyUserGroupPrivs'] = "AJcopyUserGroupPrivs";
+$actions['mode']['AJsaveUserGroupPrivs'] = "AJsaveUserGroupPrivs";
 $actions['pages']['viewNodes'] = "privileges";
 $actions['pages']['submitAddChildNode'] = "privileges";
 $actions['pages']['AJsubmitAddChildNode'] = "privileges";
@@ -555,6 +561,9 @@ $actions['pages']['AJchangeResourcePrivs
 $actions['pages']['JSONprivnodelist'] = "privileges";
 $actions['pages']['jsonGetUserGroupMembers'] = "privileges";
 $actions['pages']['jsonGetResourceGroupMembers'] = "privileges";
+$actions['pages']['AJpermSelectUserGroup'] = "privileges";
+$actions['pages']['AJcopyUserGroupPrivs'] = "privileges";
+$actions['pages']['AJsaveUserGroupPrivs'] = "privileges";
 
 # user lookup
 $actions['mode']['userLookup'] = "userLookup"; # entry

Modified: incubator/vcl/trunk/web/.ht-inc/statistics.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/statistics.php?rev=1049551&r1=1049550&r2=1049551&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/statistics.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/statistics.php Wed Dec 15 13:43:31 2010
@@ -37,7 +37,7 @@ define("ORDERERR", 1 << 2);
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function selectStatistics() {
-	global $submitErr, $viewmode, $user;
+	global $submitErr, $user;
 	list($month1, $day1, $year1) = explode(',', date('F,j,Y', time() - 
 	                                    (SECINDAY * 6)));
 	list($month2, $day2, $year2) = explode(',', date('F,j,Y', time()));
@@ -100,7 +100,7 @@ function selectStatistics() {
 	printSelectInput("day2", $days, $daykey2);
 	printSelectInput("year2", $years, $yearkey2);
 	print "<br>\n";
-	if($viewmode >= ADMIN_FULL) {
+	if(checkUserHasPerm('View Statistics by Affiliation')) {
 		print "Select an affiliation:<br>\n";
 		$affils = getAffiliations();
 		if(! array_key_exists($affilid, $affils))
@@ -125,7 +125,7 @@ function selectStatistics() {
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function viewStatistics() {
-	global $submitErr, $submitErrMsg, $user, $viewmode;
+	global $submitErr, $submitErrMsg, $user;
 	define("30MIN", 1800);
 	define("1HOUR", 3600);
 	define("2HOURS", 7200);
@@ -139,7 +139,7 @@ function viewStatistics() {
 	$affilid = processInputVar("affilid", ARG_NUMERIC, $user['affiliationid']);
 
 	$affils = getAffiliations();
-	if($viewmode < ADMIN_FULL ||
+	if(! checkUserHasPerm('View Statistics by Affiliation') ||
 	   ($affilid != 0 && ! array_key_exists($affilid, $affils)))
 		$affilid = $user['affiliationid'];
 
@@ -327,16 +327,14 @@ function viewStatistics() {
 	print "    <TH align=right>Unavailable:</TH>\n";
 	print "    <TD>$notavailable</TD>\n";
 	print "  </TR>\n";
-	if($viewmode >= ADMIN_FULL) {
-		print "  <TR>\n";
-		print "    <TH align=right>Load times &lt; 2 minutes:</TH>\n";
-		print "    <TD>{$loadtimes['2less']}</TD>\n";
-		print "  </TR>\n";
-		print "  <TR>\n";
-		print "    <TH align=right>Load times &gt;= 2 minutes:</TH>\n";
-		print "    <TD>{$loadtimes['2more']}</TD>\n";
-		print "  </TR>\n";
-	}
+	print "  <TR>\n";
+	print "    <TH align=right>Load times &lt; 2 minutes:</TH>\n";
+	print "    <TD>{$loadtimes['2less']}</TD>\n";
+	print "  </TR>\n";
+	print "  <TR>\n";
+	print "    <TH align=right>Load times &gt;= 2 minutes:</TH>\n";
+	print "    <TD>{$loadtimes['2more']}</TD>\n";
+	print "  </TR>\n";
 	print "  <TR>\n";
 	print "    <TH align=right>Total Unique Users:</TH>\n";
 	print "    <TD>" . count($users) . "</TD>\n";
@@ -355,11 +353,9 @@ function viewStatistics() {
 	print "    <TH>Reservations</TH>\n";
 	print "    <TH>Unique Users</TH>\n";
 	print "    <TH>Hours Used</TH>\n";
-	if($viewmode >= ADMIN_FULL) {
-		print "    <TH>&lt; 2 min load time</TH>\n";
-		print "    <TH>&gt;= 2 min load time</TH>\n";
-		print "    <TH>Failures</TH>\n";
-	}
+	print "    <TH>&lt; 2 min load time</TH>\n";
+	print "    <TH>&gt;= 2 min load time</TH>\n";
+	print "    <TH>Failures</TH>\n";
 	print "  </TR>\n";
 	foreach($imagecount as $key => $value) {
 		print "  <TR>\n";
@@ -370,21 +366,19 @@ function viewStatistics() {
 			print "    <TD align=center>1</TD>\n";
 		else
 			print "    <TD align=center>" . (int)$imagehours[$key] . "</TD>\n";
-		if($viewmode >= ADMIN_FULL) {
-			print "    <TD align=center>{$imageload2less[$key]}</TD>\n";
-			print "    <TD align=center>{$imageload2more[$key]}</TD>\n";
-			if($imagefails[$key]) {
-				$percent = $imagefails[$key] * 100 / $value;
-				if($percent < 1)
-					$percent = sprintf('%.1f%%', $percent);
-				else
-					$percent = sprintf('%d%%', $percent);
-				print "    <TD align=center><font color=red>{$imagefails[$key]} ";
-				print "($percent)</font></TD>\n";
-			}
+		print "    <TD align=center>{$imageload2less[$key]}</TD>\n";
+		print "    <TD align=center>{$imageload2more[$key]}</TD>\n";
+		if($imagefails[$key]) {
+			$percent = $imagefails[$key] * 100 / $value;
+			if($percent < 1)
+				$percent = sprintf('%.1f%%', $percent);
 			else
-				print "    <TD align=center>{$imagefails[$key]}</TD>\n";
+				$percent = sprintf('%d%%', $percent);
+			print "    <TD align=center><font color=red>{$imagefails[$key]} ";
+			print "($percent)</font></TD>\n";
 		}
+		else
+			print "    <TD align=center>{$imagefails[$key]}</TD>\n";
 		print "  </TR>\n";
 	}
 	print "</TABLE>\n";

Modified: incubator/vcl/trunk/web/.ht-inc/userpreferences.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/userpreferences.php?rev=1049551&r1=1049550&r2=1049551&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/userpreferences.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/userpreferences.php Wed Dec 15 13:43:31 2010
@@ -26,10 +26,8 @@ define("PREFNAMEERR", 1);
 define("WIDTHERR", 1 << 1);
 /// signifies an error with submitted height
 define("HEIGHTERR", 1 << 2);
-/// signifies an error with submitted viewasuser id
-define("VIEWASUSERERR", 1 << 3);
 /// signifies an error with submitted new password
-define("LOCALPASSWORDERR", 1 << 4);
+define("LOCALPASSWORDERR", 1 << 3);
 
 ////////////////////////////////////////////////////////////////////////////////
 ///
@@ -39,7 +37,7 @@ define("LOCALPASSWORDERR", 1 << 4);
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function userpreferences() {
-	global $user, $submitErr, $viewmode, $mode;
+	global $user, $submitErr, $mode;
 	if($submitErr) {
 		$data = processUserPrefsInput(0);
 		$data['affiliation'] = $user['affiliation'];
@@ -52,11 +50,6 @@ function userpreferences() {
 			$data["resolution"] = $user["width"] . "x" . $user["height"];
 	}
 
-	$adminleveldeveloper = 0;
-	if($user['adminlevelid'] == ADMIN_DEVELOPER)
-		$adminleveldeveloper = 1;
-
-
 	print "<H2 align=center>User Preferences</H2>\n";
 	print "<div align=center id=status class=visible>\n";
 	if($mode == "submituserprefs") {
@@ -81,10 +74,6 @@ function userpreferences() {
 	print "</li>\n";
 	print "      <li><a href=#uiprefs onclick=\"javascript:show('uiprefs'); ";
 	print "return false\">General&nbsp;Preferences</a></li>\n";
-	if($adminleveldeveloper) {
-		print "      <li><a href=#viewmode onclick=\"javascript:";
-		print "show('viewmode'); return false\">View&nbsp;Mode</a></li>\n";
-	}
 	print "      </ul>\n";
 	print "      </div>\n";
 	print "    </TD>\n";
@@ -305,54 +294,6 @@ function userpreferences() {
 	print "      </FORM>\n";
 	print "      </fieldset>\n";
 	print "      </div>\n";
-	print "      <div id=viewmode class=visible>\n";
-	if($adminleveldeveloper) {
-		print "      <fieldset>\n";
-		print "      <legend>View Mode</legend>\n";
-		print "      <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
-		if($viewmode == ADMIN_FULL) {
-			$selected[ADMIN_NONE] = "";
-			$selected[ADMIN_FULL] = "checked";
-			$selected[ADMIN_DEVELOPER] = "";
-		}
-		elseif($viewmode == ADMIN_DEVELOPER) {
-			$selected[ADMIN_NONE] = "";
-			$selected[ADMIN_FULL] = "";
-			$selected[ADMIN_DEVELOPER] = "checked";
-		}
-		else {
-			$selected[ADMIN_NONE] = "checked";
-			$selected[ADMIN_FULL] = "";
-			$selected[ADMIN_DEVELOPER] = "";
-		}
-		if($user["adminlevelid"] != ADMIN_NONE) {
-			print "      <p>View site as:<br>\n";
-			print "      <INPUT type=radio name=viewmode value=" . ADMIN_NONE . " ";
-			print $selected[ADMIN_NONE] . ">Normal User<br>\n";
-			if($user["adminlevel"] == "full" || $user["adminlevel"] == "developer") {
-				print "      <INPUT type=radio name=viewmode value=" . ADMIN_FULL . " ";
-				print $selected[ADMIN_FULL] . ">Admin Level<br>\n";
-			}
-			if($user["adminlevel"] == "developer") {
-				print "      <INPUT type=radio name=viewmode value=" . ADMIN_DEVELOPER . " ";
-				print $selected[ADMIN_DEVELOPER] . ">Developer Level<br>\n";
-			}
-			print "      </p>\n";
-		}
-		print "      View As User: <INPUT type=text name=viewasuser  ";
-		if(! array_key_exists('unityid', $data))
-			print "size=20 value=\"{$user["unityid"]}@{$user['affiliation']}\">\n";
-		else
-			print "size=20 value=\"{$data["unityid"]}@{$data['affiliation']}\">\n";
-		printSubmitErr(VIEWASUSERERR);
-		print "<br>\n";
-		$cont = addContinuationsEntry('submitviewmode', array(), SECINDAY, 1, 0);
-		print "      <INPUT type=hidden name=continuation value=\"$cont\">\n";
-		print "      <INPUT type=submit value=\"Submit View Mode\">\n";
-		print "      </FORM>\n";
-		print "      </fieldset>\n";
-	}
-	print "      </div>\n";
 	print "    </TD>\n";
 	print "  </TR>\n";
 	print "</table>\n";
@@ -515,7 +456,7 @@ function submitUserPrefs() {
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function submitGeneralPreferences() {
-	global $user, $HTMLheader, $printedHTMLheader, $mode, $viewmode;
+	global $user, $HTMLheader, $printedHTMLheader, $mode;
 	$groupview = getContinuationVar('groupview', processInputVar('groupview', ARG_STRING));
 	$emailnotify = processInputVar('emailnotify', ARG_NUMERIC);
 	if($groupview != 'affiliation' && $groupview != 'allgroups') {
@@ -582,7 +523,6 @@ function processUserPrefsInput($checks=1
 	$return["mapdrives"] = processInputVar("mapdrives" , ARG_NUMERIC, $user["mapdrives"]);
 	$return["mapprinters"] = processInputVar("mapprinters" , ARG_NUMERIC, $user["mapprinters"]);
 	$return["mapserial"] = processInputVar("mapserial" , ARG_NUMERIC, $user["mapserial"]);
-	$return['unityid'] = "{$user['unityid']}@{$user['affiliation']}";
 
 	if(! $checks) {
 		return $return;
@@ -596,11 +536,6 @@ function processUserPrefsInput($checks=1
 	   $submitErr |= PREFNAMEERR;
 	   $submitErrMsg[PREFNAMEERR] = "Preferred name can only contain letters and spaces";
 	}
-	if(array_key_exists('unityid', $return) &&
-	   ! validateUserid($return['unityid'])) {
-	   $submitErr |= VIEWASUSERERR;
-	   $submitErrMsg[VIEWASUSERERR] = "Invalid user id";
-	}
 	if($user['affiliation'] == 'Local' && array_key_exists('newpassword', $_POST)) {
 		$return['newpassword'] = $_POST['newpassword'];
 		$confirmpwd = $_POST['confirmpassword'];
@@ -641,7 +576,6 @@ function show(id) {
 		obj.className = "hidden";
 	document.getElementById("rdpfile").className = "hidden";
 	document.getElementById("uiprefs").className = "hidden";
-	document.getElementById("viewmode").className = "hidden";
 	document.getElementById("status").className = "hidden";
 	if(id == 'personal' && ! obj)
 		id = 'rdpfile';