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/04/08 20:39:52 UTC

svn commit: r932056 - in /incubator/vcl/trunk/web: .ht-inc/images.php .ht-inc/privileges.php .ht-inc/requests.php .ht-inc/userpreferences.php .ht-inc/utils.php shibauth/index.php

Author: jfthomps
Date: Thu Apr  8 18:39:51 2010
New Revision: 932056

URL: http://svn.apache.org/viewvc?rev=932056&view=rev
Log:
VCL-93

shibauth/index.php: if $row['shibonly'] is false, we now call getUserlistID with $noadd set; if it returns NULL, we call updateShibUser to get the user added to the db without using LDAP

requests.php: modified viewRequestInfo and confirmDeleteRequest to set $noupdate when calling getUserInfo

privileges.php: modified userLookup to try calling getUserInfo with $noupdate set if first call to it returns NULL

images.php: modified addImage to set $noupdate when calling getUserInfo

utils.php:
-modified initGlobals - try calling getUserInfo with $noupdate set if first call to it returns NULL
-modified checkAccess - try calling getUserInfo with $noupdate set if first call to it returns NULL
-modified addOwnedResourceGroups - set $noupdate when calling getUserInfo
-modified getUserInfo - added $noupdate as an optional argument that will return existing user data even if lastupdated is expired

userpreferences.php: modified submitUserPrefs - set $noupdate when calling getUserInfo


VCL-139

utils.php: modified main - there were 2 identical conditionals for the preferredname, changed the second one to be for firstname

Modified:
    incubator/vcl/trunk/web/.ht-inc/images.php
    incubator/vcl/trunk/web/.ht-inc/privileges.php
    incubator/vcl/trunk/web/.ht-inc/requests.php
    incubator/vcl/trunk/web/.ht-inc/userpreferences.php
    incubator/vcl/trunk/web/.ht-inc/utils.php
    incubator/vcl/trunk/web/shibauth/index.php

Modified: incubator/vcl/trunk/web/.ht-inc/images.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/images.php?rev=932056&r1=932055&r2=932056&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/images.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/images.php Thu Apr  8 18:39:51 2010
@@ -2508,7 +2508,7 @@ function addImage($data) {
 	$data['description'] = mysql_escape_string($data['description']);
 	$data['usage'] = mysql_escape_string($data['usage']);
 
-	$ownerdata = getUserInfo($data['owner']);
+	$ownerdata = getUserInfo($data['owner'], 1);
 	$ownerid = $ownerdata['id'];
 	if(empty($data['maxconcurrent']) || ! is_numeric($data['maxconcurrent']))
 		$data['maxconcurrent'] = 'NULL';

Modified: incubator/vcl/trunk/web/.ht-inc/privileges.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/privileges.php?rev=932056&r1=932055&r2=932056&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/privileges.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/privileges.php Thu Apr  8 18:39:51 2010
@@ -1113,8 +1113,11 @@ function userLookup() {
 
 		$userdata = getUserInfo($userid);
 		if(is_null($userdata)) {
-			print "<font color=red>$userid not found in any known systems</font><br>\n";
-			return;
+			$userdata = getUserInfo($userid, 1);
+			if(is_null($userdata)) {
+				print "<font color=red>$userid not found in any known systems</font><br>\n";
+				return;
+			}
 		}
 		print "<TABLE>\n";
 		if(! empty($userdata['firstname'])) {

Modified: incubator/vcl/trunk/web/.ht-inc/requests.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/requests.php?rev=932056&r1=932055&r2=932056&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/requests.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/requests.php Thu Apr  8 18:39:51 2010
@@ -2547,7 +2547,7 @@ function viewRequestInfo() {
 		}
 	}
 	$states = getStates();
-	$userinfo = getUserInfo($request["userid"]);
+	$userinfo = getUserInfo($request["userid"], 1);
 	print "<DIV align=center>\n";
 	print "<H2>View Reservation</H2>\n";
 	print "<table summary=\"\">\n";
@@ -3202,7 +3202,7 @@ function confirmDeleteRequest() {
 						. $reservation["prettyimage"] . "</strong> that started ";
 			}
 			else {
-				$userinfo = getUserInfo($request["userid"]);
+				$userinfo = getUserInfo($request["userid"], 1);
 				$text = "Delete reservation by {$userinfo['unityid']}@"
 				      . "{$userinfo['affiliation']} for <strong>"
 				      . "{$reservation["prettyimage"]}</strong> that started ";

Modified: incubator/vcl/trunk/web/.ht-inc/userpreferences.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/userpreferences.php?rev=932056&r1=932055&r2=932056&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/userpreferences.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/userpreferences.php Thu Apr  8 18:39:51 2010
@@ -502,7 +502,7 @@ function submitUserPrefs() {
 		       . "WHERE userid = {$user['id']}";
 		doQuery($query, 101);
 	}
-	$user = getUserInfo($user["id"]);
+	$user = getUserInfo($user["id"], 1);
 	$_SESSION['user'] = $user;
 	userpreferences();
 }

Modified: incubator/vcl/trunk/web/.ht-inc/utils.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/utils.php?rev=932056&r1=932055&r2=932056&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/utils.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/utils.php Thu Apr  8 18:39:51 2010
@@ -211,14 +211,17 @@ function initGlobals() {
 	else {
 		# get info about user
 		if(! $user = getUserInfo($userid)) {
-			$ERRORS[1] = "Failed to get user info from database.  userid was $userid";
-			abort(1);
+			// if first call to getUserInfo fails, try calling with $noupdate set
+			if(! $user = getUserInfo($userid, 1)) {
+				$ERRORS[1] = "Failed to get user info from database.  userid was $userid";
+				abort(1);
+			}
 		}
 		if($user['adminlevel'] == 'developer' &&
 			array_key_exists('VCLTESTUSER', $_COOKIE)) {
 			$userid = $_COOKIE['VCLTESTUSER'];
 			if($userid != "{$user['unityid']}@{$user['affiliation']}") {
-				if($testuser = getUserInfo($userid))
+				if($testuser = getUserInfo($userid, 1))
 					$user = $testuser;
 			}
 		}
@@ -333,9 +336,12 @@ function checkAccess() {
 		}
 		$xmluser = processInputData($_SERVER['HTTP_X_USER'], ARG_STRING, 1);
 		if(! $user = getUserInfo($xmluser)) {
-			printXMLRPCerror(3);   # access denied
-			dbDisconnect();
-			exit;
+			// if first call to getUserInfo fails, try calling with $noupdate set
+			if(! $user = getUserInfo($xmluser, 1)) {
+				printXMLRPCerror(3);   # access denied
+				dbDisconnect();
+				exit;
+			}
 		}
 		$xmlpass = $_SERVER['HTTP_X_PASS'];
 		if(get_magic_quotes_gpc())
@@ -670,7 +676,7 @@ function main() {
 	if($authed) {
 		if(! empty($user['lastname']) && ! empty($user['preferredname']))
 			print "Hello {$user["preferredname"]} {$user['lastname']}<br><br>\n";
-		elseif(! empty($user['lastname']) && ! empty($user['preferredname']))
+		elseif(! empty($user['lastname']) && ! empty($user['firstname']))
 			print "Hello {$user["firstname"]} {$user['lastname']}<br><br>\n";
 		$tmp = array_values($user['groups']);
 		if(count($tmp) == 1 && $tmp[0] == 'nodemo') {
@@ -1675,7 +1681,7 @@ function addOwnedResources(&$resources, 
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function addOwnedResourceGroups(&$resourcegroups, $userid) {
-	$user = getUserInfo($userid);
+	$user = getUserInfo($userid, 1);
 	$userid = $user["id"];
 	$groupids = implode(',', array_keys($user["groups"]));
 	if(empty($groupids))
@@ -2761,9 +2767,11 @@ function processInputData($data, $type, 
 
 ////////////////////////////////////////////////////////////////////////////////
 ///
-/// \fn getUserInfo($id)
+/// \fn getUserInfo($id, $noupdate)
 ///
 /// \param $id - unity ID for the user or user's id from database
+/// \param $noupdate - (optional, default=0) specify 1 to skip updating user's
+/// data if lastupdated timestamp is expired
 ///
 /// \return 0 if fail to fetch data or $user - an array with these elements:\n
 /// \b unityid - unity ID for the user\n
@@ -2799,7 +2807,7 @@ function processInputData($data, $type, 
 /// their name and unity id; fix information in db based on numeric unity id
 ///
 ////////////////////////////////////////////////////////////////////////////////
-function getUserInfo($id) {
+function getUserInfo($id, $noupdate=0) {
 	$affilid = DEFAULT_AFFILID;
 	if(! is_numeric($id))
 		getAffilidAndLogin($id, $affilid);
@@ -2845,7 +2853,8 @@ function getUserInfo($id) {
 		if((datetimeToUnix($user["lastupdated"]) > time() - SECINDAY) ||
 		   $user['unityid'] == 'vclreload' ||
 		   $user['affiliation'] == 'Local' ||
-		   $user['shibonly']) {
+		   $user['shibonly'] ||
+		   $noupdate) {
 			# get user's groups
 			$user["groups"] = getUsersGroups($user["id"], 1);
 

Modified: incubator/vcl/trunk/web/shibauth/index.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/shibauth/index.php?rev=932056&r1=932055&r2=932056&view=diff
==============================================================================
--- incubator/vcl/trunk/web/shibauth/index.php (original)
+++ incubator/vcl/trunk/web/shibauth/index.php Thu Apr  8 18:39:51 2010
@@ -177,8 +177,11 @@ if($row['shibonly']) {
 	updateShibGroups($userdata['id'], $_SERVER['affiliation']);
 	$usernid = $userdata['id'];
 }
-else
-	$usernid = getUserlistID($userid);
+else {
+	$usernid = getUserlistID($userid, 1);
+	if(is_null($usernid))
+		$usernid = updateShibUser($userid);
+}
 
 $affilid = getAffiliationID($affil);
 addLoginLog($userid, 'shibboleth', $affilid, 1);