[Mapbender-commits] r8535 - in trunk/mapbender: http/javascripts http/php lib
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed Dec 19 03:31:13 PST 2012
Author: verenadiewald
Date: 2012-12-19 03:31:12 -0800 (Wed, 19 Dec 2012)
New Revision: 8535
Modified:
trunk/mapbender/http/javascripts/user.js
trunk/mapbender/http/php/mod_filteredGroup_User.php
trunk/mapbender/http/php/mod_filteredGroup_filteredUser.php
trunk/mapbender/http/php/mod_filteredGui_User.php
trunk/mapbender/http/php/mod_filteredGui_filteredUser.php
trunk/mapbender/http/php/mod_filteredUser_Group.php
trunk/mapbender/http/php/mod_filteredUser_Gui.php
trunk/mapbender/http/php/mod_filteredUser_filteredGroup.php
trunk/mapbender/http/php/mod_filteredUser_filteredGui.php
trunk/mapbender/http/php/mod_group_filteredUser.php
trunk/mapbender/http/php/mod_group_user.php
trunk/mapbender/http/php/mod_group_user_role.php
trunk/mapbender/http/php/mod_gui_filteredUser.php
trunk/mapbender/http/php/mod_gui_owner.php
trunk/mapbender/http/php/mod_gui_user.php
trunk/mapbender/http/php/mod_user_filteredGroup.php
trunk/mapbender/http/php/mod_user_filteredGui.php
trunk/mapbender/http/php/mod_user_group.php
trunk/mapbender/http/php/mod_user_gui.php
trunk/mapbender/http/php/user.php
trunk/mapbender/lib/editUser.php
Log:
prepared statements for user.php, new param owner-check on/off
Modified: trunk/mapbender/http/javascripts/user.js
===================================================================
--- trunk/mapbender/http/javascripts/user.js 2012-12-18 15:12:37 UTC (rev 8534)
+++ trunk/mapbender/http/javascripts/user.js 2012-12-19 11:31:12 UTC (rev 8535)
@@ -5,6 +5,7 @@
var input = $(this);
var target = $('#' + input.attr('data-target'));
var targetType = input.attr('data-target-type');
+ var ownerCheck = input.attr('owner-check');
if(typeof timeoutId !== 'undefined') {
window.clearTimeout(timeoutId);
@@ -20,7 +21,8 @@
$.ajax({
url: "../php/user.php",
data: {
- "searchterm" : input.val()
+ "searchterm" : input.val(),
+ "userCheck" : ownerCheck
},
type: "post",
dataType: "json",
Modified: trunk/mapbender/http/php/mod_filteredGroup_User.php
===================================================================
--- trunk/mapbender/http/php/mod_filteredGroup_User.php 2012-12-18 15:12:37 UTC (rev 8534)
+++ trunk/mapbender/http/php/mod_filteredGroup_User.php 2012-12-19 11:31:12 UTC (rev 8535)
@@ -224,7 +224,7 @@
echo "</select>";
/*filterbox****************************************************************************************/
-echo "<input type='text' value='' class='filter2' name='filter2' id='find_user' data-target='selecteduser' data-target-type='select' autocomplete='off'/>";
+echo "<input type='text' value='' class='filter2' name='filter2' id='find_user' data-target='selecteduser' owner-check='off' data-target-type='select' autocomplete='off'/>";
//echo "<input type='text' value='' class='filter2' id='filter2' name='filter2' onkeyup='filterUser(document.getElementById(\"selecteduser\"),user,this.value);'/>";
/*insert all profiles in selectbox*****************************************************************/
echo "<div class='text2'>USER:</div>";
Modified: trunk/mapbender/http/php/mod_filteredGroup_filteredUser.php
===================================================================
--- trunk/mapbender/http/php/mod_filteredGroup_filteredUser.php 2012-12-18 15:12:37 UTC (rev 8534)
+++ trunk/mapbender/http/php/mod_filteredGroup_filteredUser.php 2012-12-19 11:31:12 UTC (rev 8535)
@@ -234,7 +234,7 @@
echo "</select>";
/*filterbox****************************************************************************************/
- echo "<input type='text' value='' class='filter2' name='filter2' id='find_user' data-target='selecteduser' data-target-type='select' autocomplete='off'/>";
+ echo "<input type='text' value='' class='filter2' name='filter2' id='find_user' data-target='selecteduser' owner-check='on' data-target-type='select' autocomplete='off'/>";
//echo "<input type='text' value='' class='filter2' id='filter2' name='filter2' onkeyup='filterUser(document.getElementById(\"selecteduser\"),user,this.value);'/>";
/*insert all profiles in selectbox*****************************************************************/
echo "<div class='text2'>USER:</div>";
Modified: trunk/mapbender/http/php/mod_filteredGui_User.php
===================================================================
--- trunk/mapbender/http/php/mod_filteredGui_User.php 2012-12-18 15:12:37 UTC (rev 8534)
+++ trunk/mapbender/http/php/mod_filteredGui_User.php 2012-12-19 11:31:12 UTC (rev 8535)
@@ -234,7 +234,7 @@
echo "</select>";
/*filterbox****************************************************************************************/
-echo "<input type='text' value='' class='filter2' name='filter2' id='find_user' data-target='selecteduser' data-target-type='select' autocomplete='off'/>";
+echo "<input type='text' value='' class='filter2' name='filter2' id='find_user' data-target='selecteduser' owner-check='off' data-target-type='select' autocomplete='off'/>";
//echo "<input type='text' value='' class='filter2' id='filter2' name='filter2' onkeyup='filterUser(document.getElementById(\"selecteduser\"),user,this.value);'/>";
/*insert all profiles in selectbox*****************************************************************/
echo "<div class='text2'>USER:</div>";
Modified: trunk/mapbender/http/php/mod_filteredGui_filteredUser.php
===================================================================
--- trunk/mapbender/http/php/mod_filteredGui_filteredUser.php 2012-12-18 15:12:37 UTC (rev 8534)
+++ trunk/mapbender/http/php/mod_filteredGui_filteredUser.php 2012-12-19 11:31:12 UTC (rev 8535)
@@ -244,7 +244,7 @@
echo "</select>";
/*filterbox****************************************************************************************/
-echo "<input type='text' value='' class='filter2' name='filter2' id='find_user' data-target='selecteduser' data-target-type='select' autocomplete='off'/>";
+echo "<input type='text' value='' class='filter2' name='filter2' id='find_user' data-target='selecteduser' owner-check='on' data-target-type='select' autocomplete='off'/>";
//echo "<input type='text' value='' class='filter2' id='filter2' name='filter2' onkeyup='filterUser(document.getElementById(\"selecteduser\"),user,this.value);'/>";
/*insert all profiles in selectbox*****************************************************************/
echo "<div class='text2'>USER:</div>";
Modified: trunk/mapbender/http/php/mod_filteredUser_Group.php
===================================================================
--- trunk/mapbender/http/php/mod_filteredUser_Group.php 2012-12-18 15:12:37 UTC (rev 8534)
+++ trunk/mapbender/http/php/mod_filteredUser_Group.php 2012-12-19 11:31:12 UTC (rev 8535)
@@ -210,7 +210,7 @@
echo "<form name='form1' action='" . $self ."' method='post'>";
/*filterbox****************************************************************************************/
-echo "<input type='text' value='' class='filter1' name='filter1' id='find_user' data-target='selecteduser' data-target-type='select' autocomplete='off'/>";
+echo "<input type='text' value='' class='filter1' name='filter1' id='find_user' data-target='selecteduser' owner-check='on' data-target-type='select' autocomplete='off'/>";
//echo "<input type='text' value='' class='filter1' id='filter1' name='filter1' onkeyup='filterUser(document.getElementById(\"selecteduser\"),user,this.value);'/>";
/*insert all user in selectbox*************************************************************************************/
echo "<div class='text1'>USER: </div>";
Modified: trunk/mapbender/http/php/mod_filteredUser_Gui.php
===================================================================
--- trunk/mapbender/http/php/mod_filteredUser_Gui.php 2012-12-18 15:12:37 UTC (rev 8534)
+++ trunk/mapbender/http/php/mod_filteredUser_Gui.php 2012-12-19 11:31:12 UTC (rev 8535)
@@ -219,7 +219,7 @@
echo "<form name='form1' action='" . $self ."' method='post'>";
/*filterbox****************************************************************************************/
-echo "<input type='text' value='' class='filter1' name='filter1' id='find_user' data-target='selecteduser' data-target-type='select' autocomplete='off'/>";
+echo "<input type='text' value='' class='filter1' name='filter1' id='find_user' data-target='selecteduser' owner-check='on' data-target-type='select' autocomplete='off'/>";
//echo "<input type='text' value='' class='filter1' id='filter1' name='filter1' onkeyup='filterUser(document.getElementById(\"selecteduser\"),user,this.value);'/>";
/*insert all user in selectbox*************************************************************************************/
echo "<div class='text1'>USER: </div>";
Modified: trunk/mapbender/http/php/mod_filteredUser_filteredGroup.php
===================================================================
--- trunk/mapbender/http/php/mod_filteredUser_filteredGroup.php 2012-12-18 15:12:37 UTC (rev 8534)
+++ trunk/mapbender/http/php/mod_filteredUser_filteredGroup.php 2012-12-19 11:31:12 UTC (rev 8535)
@@ -217,7 +217,7 @@
echo "<form name='form1' action='" . $self ."' method='post'>";
/*filterbox****************************************************************************************/
-echo "<input type='text' value='' class='filter1' name='filter1' id='find_user' data-target='selecteduser' data-target-type='select' autocomplete='off'/>";
+echo "<input type='text' value='' class='filter1' name='filter1' id='find_user' data-target='selecteduser' owner-check='on' data-target-type='select' autocomplete='off'/>";
//echo "<input type='text' value='' class='filter1' id='filter1' name='filter1' onkeyup='filterUser(document.getElementById(\"selecteduser\"),user,this.value);'/>";
/*insert all user in selectbox*************************************************************************************/
echo "<div class='text1'>USER: </div>";
Modified: trunk/mapbender/http/php/mod_filteredUser_filteredGui.php
===================================================================
--- trunk/mapbender/http/php/mod_filteredUser_filteredGui.php 2012-12-18 15:12:37 UTC (rev 8534)
+++ trunk/mapbender/http/php/mod_filteredUser_filteredGui.php 2012-12-19 11:31:12 UTC (rev 8535)
@@ -258,7 +258,7 @@
/*filterbox****************************************************************************************/
-echo "<input type='text' value='' class='filter1' name='filter1' id='find_user' data-target='selecteduser' data-target-type='select' autocomplete='off'/>";
+echo "<input type='text' value='' class='filter1' name='filter1' id='find_user' data-target='selecteduser' owner-check='on' data-target-type='select' autocomplete='off'/>";
//echo "<input type='text' value='' class='filter1' id='filter1' name='filter1' onkeyup='filterUser(document.getElementById(\"selecteduser\"),user,this.value);'/>";
/*insert all user in selectbox*************************************************************************************/
echo "<div class='text1'>USER: </div>";
Modified: trunk/mapbender/http/php/mod_group_filteredUser.php
===================================================================
--- trunk/mapbender/http/php/mod_group_filteredUser.php 2012-12-18 15:12:37 UTC (rev 8534)
+++ trunk/mapbender/http/php/mod_group_filteredUser.php 2012-12-19 11:31:12 UTC (rev 8535)
@@ -220,7 +220,7 @@
echo "</select>";
/*filterbox****************************************************************************************/
-echo "<input type='text' value='' class='filter2' name='filter2' id='find_user' data-target='selecteduser' data-target-type='select' autocomplete='off'/>";
+echo "<input type='text' value='' class='filter2' name='filter2' id='find_user' data-target='selecteduser' owner-check='on' data-target-type='select' autocomplete='off'/>";
//echo "<input type='text' value='' class='filter2' id='filter2' name='filter2' onkeyup='filterUser(document.getElementById(\"selecteduser\"),user,this.value);'/>";
/*insert all profiles in selectbox*****************************************************************/
echo "<div class='text2'>USER:</div>";
Modified: trunk/mapbender/http/php/mod_group_user.php
===================================================================
--- trunk/mapbender/http/php/mod_group_user.php 2012-12-18 15:12:37 UTC (rev 8534)
+++ trunk/mapbender/http/php/mod_group_user.php 2012-12-19 11:31:12 UTC (rev 8535)
@@ -218,7 +218,7 @@
echo "</select>";
/*filterbox****************************************************************************************/
-echo "<input type='text' value='' class='filter2' name='filter2' id='find_user' data-target='selecteduser' data-target-type='select' autocomplete='off'/>";
+echo "<input type='text' value='' class='filter2' name='filter2' id='find_user' data-target='selecteduser' owner-check='off' data-target-type='select' autocomplete='off'/>";
//echo "<input type='text' value='' class='filter2' id='filter2' name='filter2' onkeyup='filterUser(document.getElementById(\"selecteduser\"),user,this.value);'/>";
/*insert all profiles in selectbox*****************************************************************/
echo "<div class='text2'>USER:</div>";
Modified: trunk/mapbender/http/php/mod_group_user_role.php
===================================================================
--- trunk/mapbender/http/php/mod_group_user_role.php 2012-12-18 15:12:37 UTC (rev 8534)
+++ trunk/mapbender/http/php/mod_group_user_role.php 2012-12-19 11:31:12 UTC (rev 8535)
@@ -295,7 +295,7 @@
echo "</select>";
/*filterbox****************************************************************************************/
-echo "<input type='text' value='' class='filter2' name='filter2' id='find_user' data-target='selecteduser' data-target-type='select' autocomplete='off'/>";
+echo "<input type='text' value='' class='filter2' name='filter2' id='find_user' data-target='selecteduser' owner-check='off' data-target-type='select' autocomplete='off'/>";
//echo "<input type='text' value='' class='filter2' id='filter2' name='filter2' onkeyup='filterUser(document.getElementById(\"selecteduser\"),user,this.value);'/>";
/*insert all profiles in selectbox*****************************************************************/
echo "<div class='text2'>USER:</div>";
Modified: trunk/mapbender/http/php/mod_gui_filteredUser.php
===================================================================
--- trunk/mapbender/http/php/mod_gui_filteredUser.php 2012-12-18 15:12:37 UTC (rev 8534)
+++ trunk/mapbender/http/php/mod_gui_filteredUser.php 2012-12-19 11:31:12 UTC (rev 8535)
@@ -225,7 +225,7 @@
echo "</select>";
/*filterbox****************************************************************************************/
-echo "<input type='text' value='' class='filter2' name='filter2' id='find_user' data-target='selecteduser' data-target-type='select' autocomplete='off'/>";
+echo "<input type='text' value='' class='filter2' name='filter2' id='find_user' data-target='selecteduser' owner-check='on' data-target-type='select' autocomplete='off'/>";
//echo "<input type='text' value='' class='filter2' id='filter2' name='filter2' onkeyup='filterUser(document.getElementById(\"selecteduser\"),user,this.value);'/>";
/*insert all profiles in selectbox*****************************************************************/
echo "<div class='text2'>USER:</div>";
Modified: trunk/mapbender/http/php/mod_gui_owner.php
===================================================================
--- trunk/mapbender/http/php/mod_gui_owner.php 2012-12-18 15:12:37 UTC (rev 8534)
+++ trunk/mapbender/http/php/mod_gui_owner.php 2012-12-19 11:31:12 UTC (rev 8535)
@@ -237,7 +237,7 @@
echo "</select>";
/*filterbox****************************************************************************************/
-echo "<input type='text' value='' class='filter2' name='filter2' id='find_user' data-target='selecteduser' data-target-type='select' autocomplete='off'/>";
+echo "<input type='text' value='' class='filter2' name='filter2' id='find_user' data-target='selecteduser' owner-check='on' data-target-type='select' autocomplete='off'/>";
//echo "<input type='text' value='' class='filter2' id='filter2' name='filter2' onkeyup='filterUser(document.getElementById(\"selecteduser\"),user,this.value);'/>";
/*insert all profiles in selectbox*****************************************************************/
echo "<div class='text2'>USER:</div>";
Modified: trunk/mapbender/http/php/mod_gui_user.php
===================================================================
--- trunk/mapbender/http/php/mod_gui_user.php 2012-12-18 15:12:37 UTC (rev 8534)
+++ trunk/mapbender/http/php/mod_gui_user.php 2012-12-19 11:31:12 UTC (rev 8535)
@@ -215,7 +215,7 @@
echo "</select>";
/*filterbox****************************************************************************************/
-echo "<input type='text' value='' class='filter2' name='filter2' id='find_user' data-target='selecteduser' data-target-type='select' autocomplete='off'/>";
+echo "<input type='text' value='' class='filter2' name='filter2' id='find_user' data-target='selecteduser' owner-check='off' data-target-type='select' autocomplete='off'/>";
//echo "<input type='text' value='' class='filter2' id='filter2' name='filter2' onkeyup='filterUser(document.getElementById(\"selecteduser\"),user,this.value);'/>";
/*insert all profiles in selectbox*****************************************************************/
echo "<div class='text2'>USER:</div>";
Modified: trunk/mapbender/http/php/mod_user_filteredGroup.php
===================================================================
--- trunk/mapbender/http/php/mod_user_filteredGroup.php 2012-12-18 15:12:37 UTC (rev 8534)
+++ trunk/mapbender/http/php/mod_user_filteredGroup.php 2012-12-19 11:31:12 UTC (rev 8535)
@@ -209,7 +209,7 @@
echo "<form name='form1' action='" . $self ."' method='post'>";
/*filterbox****************************************************************************************/
-echo "<input type='text' value='' class='filter1' name='filter1' id='find_user' data-target='selecteduser' data-target-type='select' autocomplete='off'/>";
+echo "<input type='text' value='' class='filter1' name='filter1' id='find_user' data-target='selecteduser' owner-check='off' data-target-type='select' autocomplete='off'/>";
//echo "<input type='text' value='' class='filter1' id='filter1' name='filter1' onkeyup='filterUser(document.getElementById(\"selecteduser\"),user,this.value);'/>";
/*insert all user in selectbox*************************************************************************************/
echo "<div class='text1'>USER: </div>";
Modified: trunk/mapbender/http/php/mod_user_filteredGui.php
===================================================================
--- trunk/mapbender/http/php/mod_user_filteredGui.php 2012-12-18 15:12:37 UTC (rev 8534)
+++ trunk/mapbender/http/php/mod_user_filteredGui.php 2012-12-19 11:31:12 UTC (rev 8535)
@@ -254,7 +254,7 @@
echo "<form name='form1' action='" . $self ."' method='post'>";
/*filterbox****************************************************************************************/
-echo "<input type='text' value='' class='filter1' name='filter1' id='find_user' data-target='selecteduser' data-target-type='select' autocomplete='off'/>";
+echo "<input type='text' value='' class='filter1' name='filter1' id='find_user' data-target='selecteduser' owner-check='off' data-target-type='select' autocomplete='off'/>";
//echo "<input type='text' value='' class='filter1' id='filter1' name='filter1' onkeyup='filterUser(document.getElementById(\"selecteduser\"),user,this.value);'/>";
/*insert all user in selectbox*************************************************************************************/
echo "<div class='text1'>USER: </div>";
Modified: trunk/mapbender/http/php/mod_user_group.php
===================================================================
--- trunk/mapbender/http/php/mod_user_group.php 2012-12-18 15:12:37 UTC (rev 8534)
+++ trunk/mapbender/http/php/mod_user_group.php 2012-12-19 11:31:12 UTC (rev 8535)
@@ -201,7 +201,7 @@
echo "<form name='form1' action='" . $self ."' method='post'>";
/*filterbox****************************************************************************************/
-echo "<input type='text' value='' class='filter1' name='filter1' id='find_user' data-target='selecteduser' data-target-type='select' autocomplete='off'/>";
+echo "<input type='text' value='' class='filter1' name='filter1' id='find_user' data-target='selecteduser' owner-check='off' data-target-type='select' autocomplete='off'/>";
//echo "<input type='text' value='' class='filter1' id='filter1' name='filter1' onkeyup='filterUser(document.getElementById(\"selecteduser\"),user,this.value);'/>";
/*insert all user in selectbox*************************************************************************************/
echo "<div class='text1'>USER: </div>";
Modified: trunk/mapbender/http/php/mod_user_gui.php
===================================================================
--- trunk/mapbender/http/php/mod_user_gui.php 2012-12-18 15:12:37 UTC (rev 8534)
+++ trunk/mapbender/http/php/mod_user_gui.php 2012-12-19 11:31:12 UTC (rev 8535)
@@ -205,7 +205,7 @@
echo "<form name='form1' action='" . $self ."&e_id_css=".$_REQUEST["e_id_css"]."' method='post'>";
/*filterbox****************************************************************************************/
-echo "<input type='text' value='' class='filter1' name='filter1' id='find_user' data-target='selecteduser' data-target-type='select' autocomplete='off'/>";
+echo "<input type='text' value='' class='filter1' name='filter1' id='find_user' data-target='selecteduser' owner-check='off' data-target-type='select' autocomplete='off'/>";
//echo "<input type='text' value='' class='filter1' id='filter1' name='filter1' onkeyup='filterUser(document.getElementById(\"selecteduser\"),user,this.value);'/>";
/*insert all user in selectbox*************************************************************************************/
echo "<div class='text1'>USER: </div>";
Modified: trunk/mapbender/http/php/user.php
===================================================================
--- trunk/mapbender/http/php/user.php 2012-12-18 15:12:37 UTC (rev 8534)
+++ trunk/mapbender/http/php/user.php 2012-12-19 11:31:12 UTC (rev 8535)
@@ -3,8 +3,7 @@
*
*******************************************************************************/
//$e_id="user";
-require_once(dirname(__FILE__) . "/../classes/class_administration.php");
-require_once dirname(__FILE__) . '/../../conf/mapbender.conf';
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
$user = (int)Mapbender::session()->get("mb_user_id");
@@ -20,45 +19,75 @@
die('SEARCH_COLUMN1, SEARCH_COLUMN2 or SEARCH_LIMIT not found in mapbender.conf');
}
-$conn = pg_connect('host='.DBSERVER.' port='.PORT.' dbname='.DB.' user='.OWNER.' password='.PW);
+if($_POST['userCheck'] == "on") {
+ if(SEARCH_COLUMN2 != "") {
+ $sql = "SELECT * FROM mb_user WHERE mb_user_owner = $1 AND (" . SEARCH_COLUMN1 . " LIKE '%' || $2 || '%' OR " . SEARCH_COLUMN2 . " LIKE '%' || $3 || '%') " .
+ "ORDER BY " . SEARCH_COLUMN1 ."," . SEARCH_COLUMN2 . " LIMIT " . SEARCH_LIMIT;
+
+ $sqlCnt = "SELECT count(*) as cnt FROM mb_user WHERE mb_user_owner = $1 AND (" . SEARCH_COLUMN1 . " LIKE '%' || $2 || '%' OR " . SEARCH_COLUMN2 . " LIKE '%' || $3 || '%')";
-if($conn) {
- $whereCondition = SEARCH_COLUMN1 . " LIKE '%" . pg_escape_string($_POST['searchterm']). "%'";
- $orderBy = "ORDER BY ". SEARCH_COLUMN1;
- if(SEARCH_COLUMN2 != "") {
- $whereCondition .= " OR ". SEARCH_COLUMN2 . " LIKE '%" . pg_escape_string($_POST['searchterm']). "%'";
- $orderBy .= ", ". SEARCH_COLUMN2;
+ $v = array($user, $_POST['searchterm'], $_POST['searchterm']);
+ $t = array("i", "s", "s");
}
- $sql = "SELECT * FROM mb_user WHERE ("
- . $whereCondition .
- ") AND mb_user_owner = '" . pg_escape_string($user) . "' ". $orderBy ." LIMIT " . SEARCH_LIMIT;
- $result = pg_query($conn, $sql);
+ else {
+ $sql = "SELECT * FROM mb_user WHERE mb_user_owner = $1 AND " . SEARCH_COLUMN1 . " LIKE '%' || $2 || '%' " .
+ "ORDER BY " . SEARCH_COLUMN1 ." LIMIT " . SEARCH_LIMIT;
- if($result) {
- $userArray = array();
+ $sqlCnt = "SELECT count(*) as cnt FROM mb_user WHERE mb_user_owner = $1 AND " . SEARCH_COLUMN1 . " LIKE '%' || $2 || '%' ";
- while($users = pg_fetch_assoc($result)) {
- $userArray[] = array(
- 'id' => $users['mb_user_id'],
- 'login' => $users['mb_user_name'],
- 'firstname' => $users['mb_user_firstname'],
- 'lastname' => $users['mb_user_lastname'],
- 'name' => $users['mb_user_name'],
- 'email' => $users['mb_user_email']
- );
- }
+ $v = array($user, $_POST['searchterm']);
+ $t = array("i", "s");
+ }
+}
+else {
+ if(SEARCH_COLUMN2 != "") {
+ $sql = "SELECT * FROM mb_user WHERE " . SEARCH_COLUMN1 . " LIKE '%' || $1 || '%' OR " . SEARCH_COLUMN2 . " LIKE '%' || $2 || '%' " .
+ "ORDER BY " . SEARCH_COLUMN1 ."," . SEARCH_COLUMN2 . " LIMIT " . SEARCH_LIMIT;
- $sqlCnt = "SELECT count(*) as cnt FROM mb_user WHERE ("
- . $whereCondition .
- ") AND mb_user_owner = '" . pg_escape_string($user) . "'";
- $resultCnt = pg_query($conn, $sqlCnt);
- $userCnt = pg_fetch_assoc($resultCnt);
- $resultArray = array("hits" => $userCnt['cnt'], "limit" => SEARCH_LIMIT, "users" => $userArray);
+ $sqlCnt = "SELECT count(*) as cnt FROM mb_user WHERE " . SEARCH_COLUMN1 . " LIKE '%' || $1 || '%' OR " . SEARCH_COLUMN2 . " LIKE '%' || $2 || '%' ";
- #$resultArray = array($userArray, $userInfoArray);
+ $v = array($_POST['searchterm'], $_POST['searchterm']);
+ $t = array("s", "s");
+ }
+ else {
+ $sql = "SELECT * FROM mb_user WHERE " . SEARCH_COLUMN1 . " LIKE '%' || $1 || '%' " .
+ "ORDER BY " . SEARCH_COLUMN1 ." LIMIT " . SEARCH_LIMIT;
- die(json_encode($resultArray));
+ $sqlCnt = "SELECT count(*) as cnt FROM mb_user WHERE " . SEARCH_COLUMN1 . " LIKE '%' || $1 || '%' ";
- } else die('Error: Searchresult.');
+ $v = array($_POST['searchterm']);
+ $t = array("s");
+ }
+}
+
+$result = db_prep_query($sql,$v,$t);
+$resultCnt = db_prep_query($sqlCnt,$v,$t);
+
+if($result) {
+ $userArray = array();
-} else die('Error: DB-Connection.');
\ No newline at end of file
+ while($users = db_fetch_assoc($result)) {
+ $userArray[] = array(
+ 'id' => $users['mb_user_id'],
+ 'login' => $users['mb_user_name'],
+ 'firstname' => $users['mb_user_firstname'],
+ 'lastname' => $users['mb_user_lastname'],
+ 'name' => $users['mb_user_name'],
+ 'email' => $users['mb_user_email']
+ );
+ }
+
+ $userCnt = db_fetch_assoc($resultCnt);
+ if($userCnt['cnt'] < SEARCH_LIMIT) {
+ $limit = $userCnt['cnt'];
+ }
+ else {
+ $limit = SEARCH_LIMIT;
+ }
+ $resultArray = array("hits" => $userCnt['cnt'], "limit" => $limit, "users" => $userArray);
+
+ #$resultArray = array($userArray, $userInfoArray);
+
+ die(json_encode($resultArray));
+
+} else die('Error: Searchresult.');
\ No newline at end of file
Modified: trunk/mapbender/lib/editUser.php
===================================================================
--- trunk/mapbender/lib/editUser.php 2012-12-18 15:12:37 UTC (rev 8534)
+++ trunk/mapbender/lib/editUser.php 2012-12-19 11:31:12 UTC (rev 8535)
@@ -274,7 +274,7 @@
echo _mb("User").": ";
echo "</td>";
echo "<td>";
- echo "<input type='text' value='' id='find_user' data-target='selecteduser' data-target-type='select' data-target-new='true' />";
+ echo "<input type='text' value='' id='find_user' data-target='selecteduser' owner-check='off' data-target-type='select' data-target-new='true' />";
// 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'>"._mb("NEW")."...</option>";
More information about the Mapbender_commits
mailing list