]> git.mjollnir.org Git - moodle.git/commitdiff
Added function get_first_string to better handle multi-valued attributes
authorexe-cutor <exe-cutor>
Mon, 15 May 2006 06:55:08 +0000 (06:55 +0000)
committerexe-cutor <exe-cutor>
Mon, 15 May 2006 06:55:08 +0000 (06:55 +0000)
auth/shibboleth/lib.php

index 37f04b9e0f46b5a97c711e242348b6d2c4c8cd67..62d9bd02c26565f3c3b371a5ff4be35693ad438a 100755 (executable)
@@ -1,7 +1,11 @@
 <?PHP  // $Id$
 //CHANGELOG:
-//28.10.2004 SHIBBOLETH Authentication functions v.0.1
-//Distributed under GPL (c)Markus Hagman 2004-
+//10.2004 SHIBBOLETH Authentication functions v.0.1
+//05.2005 Various extensions and fixes by Lukas Haemmerle
+//10.2005 Added better error messags
+//05.2006 Added better handling of mutli-valued attributes
+//
+//Distributed under GPL (c)Markus Hagman 2004-2006
 
 function auth_user_login($username, $password) {
     global $CFG;
@@ -41,9 +45,9 @@ function auth_get_userinfo($username) {
   
     foreach ($attrmap as $key=>$value) {
         if (!empty($CFG->unicodedb)) {
-            $result[$key]=$_SERVER[$value];
+            $result[$key]= get_first_string($_SERVER[$value]);
         } else {
-            $result[$key]=utf8_decode($_SERVER[$value]);
+            $result[$key]=get_first_string(utf8_decode($_SERVER[$value]));
         }
     }
 
@@ -84,4 +88,14 @@ function auth_shib_attributes(){
 
        return $moodleattributes;
 }
+
+function get_first_string($string){
+// Cleans and returns first of potential many values (multi-valued attributes)
+       
+       $list = split( ';', $string);
+       $clean_string = rtrim($list[0]);
+       
+       return $clean_string;
+       
+}
 ?>