From cdf98c1577327be466cd2c08df76108086b4fd73 Mon Sep 17 00:00:00 2001
From: Martin Haase <martin.haase@daasi.de>
Date: Wed, 15 Jun 2011 17:38:48 +0000
Subject: [PATCH] resolved TG-1169 and TG-1423

git-svn-id: https://textgridlab.org/svn/textgrid/trunk/middleware/tgauth@10197 7c539038-3410-0410-b1ec-0f2a7bf1c452
---
 .../WebAuthN/PutAttributes.php                        | 11 +++++++----
 .../tglib/LDAP.class.php                              |  2 +-
 .../tglib/WebUtils.class.php                          |  2 +-
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/info.textgrid.middleware.tgauth.webauth/WebAuthN/PutAttributes.php b/info.textgrid.middleware.tgauth.webauth/WebAuthN/PutAttributes.php
index 18c8b66..a6eb82c 100755
--- a/info.textgrid.middleware.tgauth.webauth/WebAuthN/PutAttributes.php
+++ b/info.textgrid.middleware.tgauth.webauth/WebAuthN/PutAttributes.php
@@ -37,18 +37,21 @@ $rbac = new RBAC ( $configfile, $authZinstance );
 $Sid = $_REQUEST["Sid"];
 
 $attributes = $rbac->getUserAttributes( $Sid );
-$newattributes = array();
+// we always need one more argument, as PHP'S SOAP lib simplifies structures 
+// s.t. if we only want to modify exactly one attr, 
+// (it turns a:1{o:2{name,n,value,v}} into a:2{name,n,value,v})
+$newattributes = array("gnuelpfix"); 
 $thedisplayname = "anonymous";
 
 //phpinfo(); 
 foreach ($attributes as $a) {
   if ($util->isBoolean($a)) {
-    if (isset ( $_REQUEST[$a->name]) && $_REQUEST[$a->name] == TRUE) {
+    if (isset ( $_REQUEST[$a->name] ) && $_REQUEST[$a->name] === "on" && $a->value !== "TRUE") {
       $na = new StdClass();
       $na->name = $a->name;
       $na->value = "TRUE";
       $newattributes[] = $na;
-    } else {
+    } else if ($a->value === "TRUE" && !isset ( $_REQUEST[$a->name])) {
       $na = new StdClass();
       $na->name = $a->name;
       $na->value = "FALSE";
@@ -69,7 +72,7 @@ foreach ($attributes as $a) {
   }
 }
 
-//$file = fopen ("/tmp/xxxUR.log", "w+");
+//$file = fopen ("/tmp/xxxPut.log", "w+");
 //fwrite ($file, "putting these attrs: ". serialize ($newattributes) ."\n");
 //fclose ($file); 
 
diff --git a/info.textgrid.middleware.tgauth.webauth/tglib/LDAP.class.php b/info.textgrid.middleware.tgauth.webauth/tglib/LDAP.class.php
index 64646c1..d19f5a7 100644
--- a/info.textgrid.middleware.tgauth.webauth/tglib/LDAP.class.php
+++ b/info.textgrid.middleware.tgauth.webauth/tglib/LDAP.class.php
@@ -93,7 +93,7 @@ class LDAP {
     $sendOutMail = FALSE;
 
     foreach ($attrHash as $a) {
-      if (in_array($a->name, array_keys ($this->AttributeMap))) {
+      if (is_object($a) && in_array($a->name, array_keys ($this->AttributeMap))) {
 	$arrModify[$this->AttributeMap[$a->name]][] = $a->value;
 	$needsModification = TRUE;
 	if ($a->name === "mail") {
diff --git a/info.textgrid.middleware.tgauth.webauth/tglib/WebUtils.class.php b/info.textgrid.middleware.tgauth.webauth/tglib/WebUtils.class.php
index 41284c2..e65db13 100644
--- a/info.textgrid.middleware.tgauth.webauth/tglib/WebUtils.class.php
+++ b/info.textgrid.middleware.tgauth.webauth/tglib/WebUtils.class.php
@@ -244,7 +244,7 @@ class WebUtils {
 
       echo "<tr><td>".$a->displayname." ${mandatory}</td>";
       if ($this->isBoolean ($a)) {
-	echo "<td><input type=\"checkbox\" name=\"". $a->name . "\" value=\"yes\" ${checked}/></td>\n";
+	echo "<td><input type=\"checkbox\" name=\"". $a->name . "\" value=\"on\" ${checked}/></td>\n";
       } else if ($this->isISO3166format ($a)) { 
 	if ($oldval === "") {$oldval = "DE";} // pre-assume German Scholars
 	echo "<td>";	
-- 
GitLab