[Mapbender-commits] r1755 - trunk/mapbender/http/php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Oct 26 10:24:50 EDT 2007


Author: christoph
Date: 2007-10-26 10:24:50 -0400 (Fri, 26 Oct 2007)
New Revision: 1755

Modified:
   trunk/mapbender/http/php/mod_editFilteredUser.php
   trunk/mapbender/http/php/mod_editUser.php
Log:
filter search results via AJAX-like text field

Modified: trunk/mapbender/http/php/mod_editFilteredUser.php
===================================================================
--- trunk/mapbender/http/php/mod_editFilteredUser.php	2007-10-26 14:15:56 UTC (rev 1754)
+++ trunk/mapbender/http/php/mod_editFilteredUser.php	2007-10-26 14:24:50 UTC (rev 1755)
@@ -90,7 +90,34 @@
   }
   return 'true';
 }
-
+/**
+ * filter the Userlist by str
+ */
+function filterUser(list, all, str){
+	str=str.toLowerCase();
+	var selection=[];
+	var i,j,selected;
+	for(i=0;i<list.options.length;i++){
+		if(list.options[i].selected)
+			selection[selection.length]=list.options[i].value;
+	}
+	
+	list.options.length = 1;
+	for(i=0; i<all.length; i++){
+		if(all[i]['name'].toLowerCase().indexOf(str)==-1)
+			continue;
+		selected=false;
+		for(j=0;j<selection.length;j++){
+			if(selection[j]==all[i]['id']){
+				selected=true;
+				break;
+			}
+		}
+		var newOption = new Option(all[i]['name'],all[i]['id'],false,selected);
+		newOption.setAttribute("title", all[i]['email']);
+		list.options[list.options.length] = newOption;
+	}	
+}
 </script>
 
 </head>
@@ -182,21 +209,26 @@
       echo "User: ";
    echo "</td>";
 echo "<td>";
-   echo "<select name='selected_user' onchange='submit()'>";
+   echo "<input type='text' value='' onkeyup='filterUser(document.getElementById(\"selecteduser\"),user,this.value);'/>";
+   echo "<br /><select id='selecteduser' name='selected_user' onchange='submit()'>";
    echo "<option value='new'>NEW...</option>";
-   $sql = "SELECT mb_user_name,mb_user_id FROM mb_user ";
+   $sql = "SELECT mb_user_name,mb_user_id,mb_user_email FROM mb_user ";
    if(isset($myUser)){ $sql .= "WHERE mb_user_owner = ".$_SESSION["mb_user_id"];}
    $sql .= " ORDER BY mb_user_name ";
    $res = db_query($sql);
    $count=0;
    while($row = db_fetch_array($res)){
-	 	echo "<option value='".$row["mb_user_id"]."' ";
-		if($selected_user && $selected_user == $row["mb_user_id"]){
+	 	echo "<option value='".$row["mb_user_id"]."' title='".$row["mb_user_email"]."'";
+   		if($selected_user && $selected_user == $row["mb_user_id"]){
          echo "selected";
       }
       echo ">".$row["mb_user_name"]."</option>";
-		$count++;
+	  $user_id[$count] = $row["mb_user_id"];
+	  $user_name[$count] = $row["mb_user_name"];
+	  $user_email[$count] = $row["mb_user_email"];      
+      $count++;
    }
+   $cnt_user=$count;
    echo "</select>";
    echo "</td>";
 echo "</tr>";
@@ -324,5 +356,18 @@
 ?>
 <input type='hidden' name='action' value=''>
 </form>
+<script type="text/javascript">
+<!--
+var user=[];
+<?php
+for($i=0; $i<$cnt_user; $i++){
+	echo "user[".($i)."]=[];\n";
+	echo "user[".($i)."]['id']='" . $user_id[$i]  . "';\n";
+	echo "user[".($i)."]['name']='" . $user_name[$i]  . "';\n";
+	echo "user[".($i)."]['email']='" . $user_email[$i]  . "';\n";
+}
+?>
+// -->
+</script>
 </body>
 </html>
\ No newline at end of file

Modified: trunk/mapbender/http/php/mod_editUser.php
===================================================================
--- trunk/mapbender/http/php/mod_editUser.php	2007-10-26 14:15:56 UTC (rev 1754)
+++ trunk/mapbender/http/php/mod_editUser.php	2007-10-26 14:24:50 UTC (rev 1755)
@@ -89,7 +89,34 @@
   }
   return 'true';
 }
-
+/**
+ * filter the Userlist by str
+ */
+function filterUser(list, all, str){
+	str=str.toLowerCase();
+	var selection=[];
+	var i,j,selected;
+	for(i=0;i<list.options.length;i++){
+		if(list.options[i].selected)
+			selection[selection.length]=list.options[i].value;
+	}
+	
+	list.options.length = 1;
+	for(i=0; i<all.length; i++){
+		if(all[i]['name'].toLowerCase().indexOf(str)==-1)
+			continue;
+		selected=false;
+		for(j=0;j<selection.length;j++){
+			if(selection[j]==all[i]['id']){
+				selected=true;
+				break;
+			}
+		}
+		var newOption = new Option(all[i]['name'],all[i]['id'],false,selected);
+		newOption.setAttribute("title", all[i]['email']);
+		list.options[list.options.length] = newOption;
+	}	
+}
 </script>
 
 </head>
@@ -103,7 +130,7 @@
 			if (MD5 == 'false'){
 				$pw = $password;
 			}else{
-				$pw = md5($password);
+				$pw = "md5('".$password."')";
 			}
 		}
 		return $pw;
@@ -197,21 +224,26 @@
       echo "User: ";
    echo "</td>";
 echo "<td>";
-   echo "<select name='selected_user' onchange='submit()'>";
+   echo "<input type='text' value='' onkeyup='filterUser(document.getElementById(\"selecteduser\"),user,this.value);'/>";
+   echo "<br /><select id='selecteduser' name='selected_user' onchange='submit()'>";
    echo "<option value='new'>NEW...</option>";
-   $sql = "SELECT mb_user_name,mb_user_id FROM mb_user ";
+   $sql = "SELECT mb_user_name,mb_user_id,mb_user_email FROM mb_user ";
    if(isset($myUser)){ $sql .= "WHERE mb_user_owner = ".$_SESSION["mb_user_id"];}
    $sql .= " ORDER BY mb_user_name ";
    $res = db_query($sql);
    $count=0;
    while($row = db_fetch_array($res)){
-	 	echo "<option value='".$row["mb_user_id"]."' ";
+	 	echo "<option value='".$row["mb_user_id"]."' title='".$row["mb_user_email"]."'";
 		if($selected_user && $selected_user == $row["mb_user_id"]){
          echo "selected";
       }
       echo ">".$row["mb_user_name"]."</option>";
+	  $user_id[$count] = $row["mb_user_id"];
+	  $user_name[$count] = $row["mb_user_name"];
+	  $user_email[$count] = $row["mb_user_email"];      
 		$count++;
    }
+   $cnt_user=$count;
    echo "</select>";
    echo "</td>";
 echo "</tr>";
@@ -339,5 +371,18 @@
 ?>
 <input type='hidden' name='action' value=''>
 </form>
+<script type="text/javascript">
+<!--
+var user=[];
+<?php
+for($i=0; $i<$cnt_user; $i++){
+	echo "user[".($i)."]=[];\n";
+	echo "user[".($i)."]['id']='" . $user_id[$i]  . "';\n";
+	echo "user[".($i)."]['name']='" . $user_name[$i]  . "';\n";
+	echo "user[".($i)."]['email']='" . $user_email[$i]  . "';\n";
+}
+?>
+// -->
+</script>
 </body>
 </html>
\ No newline at end of file



More information about the Mapbender_commits mailing list