[Mapbender-commits] r8533 - in trunk/mapbender: conf http/javascripts http/php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Dec 18 06:34:20 PST 2012
Author: verenadiewald
Date: 2012-12-18 06:34:20 -0800 (Tue, 18 Dec 2012)
New Revision: 8533
Modified:
trunk/mapbender/conf/mapbender.conf-dist
trunk/mapbender/http/javascripts/user.js
trunk/mapbender/http/php/user.php
Log:
number of hits, mouseover info and second search field for user selectbox
Modified: trunk/mapbender/conf/mapbender.conf-dist
===================================================================
--- trunk/mapbender/conf/mapbender.conf-dist 2012-12-18 10:46:33 UTC (rev 8532)
+++ trunk/mapbender/conf/mapbender.conf-dist 2012-12-18 14:34:20 UTC (rev 8533)
@@ -250,7 +250,8 @@
# user autocomplete
# --------------------------------------------
define('SEARCH_LIMIT', 50);
-define('SEARCH_COLUMN', 'mb_user_name');
+define('SEARCH_COLUMN1', 'mb_user_name');
+define('SEARCH_COLUMN2', 'mb_user_email');
###HACK for GLOBALS
$DBSERVER=DBSERVER;
Modified: trunk/mapbender/http/javascripts/user.js
===================================================================
--- trunk/mapbender/http/javascripts/user.js 2012-12-18 10:46:33 UTC (rev 8532)
+++ trunk/mapbender/http/javascripts/user.js 2012-12-18 14:34:20 UTC (rev 8533)
@@ -37,15 +37,17 @@
.text('NEW...')
);
}
-
- for(var i=0; i<data.length; i++) {
+
+ for(var i=0; i<data.users.length; i++) {
target.append(
$('<option>')
- .attr('value', data[i].id)
- .attr('title', data[i].firstname + ' ' + data.lastname)
- .text(data[i].login)
+ .attr('value', data.users[i].id)
+ .attr('title', data.users[i].id + ": " + data.users[i].name + ' (' + data.users[i].email + ")")
+ .text(data.users[i].login)
);
}
+ target.prev().text("USER (" + data.limit + " von " + data.hits + "):");
+
}
}
Modified: trunk/mapbender/http/php/user.php
===================================================================
--- trunk/mapbender/http/php/user.php 2012-12-18 10:46:33 UTC (rev 8532)
+++ trunk/mapbender/http/php/user.php 2012-12-18 14:34:20 UTC (rev 8533)
@@ -16,35 +16,49 @@
die('Error: Searchterm not found.');
}
-if(!defined('SEARCH_COLUMN') || !defined('SEARCH_LIMIT')) {
- die('SEARCH_COLUMN or SEARCH_LIMIT not found in mapbender.conf');
+if(!defined('SEARCH_COLUMN1') || !defined('SEARCH_COLUMN2') || !defined('SEARCH_LIMIT')) {
+ 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($conn) {
-
- $result = pg_query($conn,
- "SELECT * FROM mb_user WHERE "
- . SEARCH_COLUMN . " LIKE '%"
- . pg_escape_string($_POST['searchterm'])
- . "%' AND mb_user_owner = '" . pg_escape_string($user) . "' ORDER BY ". SEARCH_COLUMN ." LIMIT " . SEARCH_LIMIT
- );
-
+ $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;
+ }
+ $sql = "SELECT * FROM mb_user WHERE ("
+ . $whereCondition .
+ ") AND mb_user_owner = '" . pg_escape_string($user) . "' ". $orderBy ." LIMIT " . SEARCH_LIMIT;
+ $result = pg_query($conn, $sql);
+
if($result) {
$userArray = array();
- while($user = pg_fetch_assoc($result)) {
+ while($users = pg_fetch_assoc($result)) {
$userArray[] = array(
- 'id' => $user['mb_user_id'],
- 'login' => $user['mb_user_name'],
- 'firstname' => $user['mb_user_firstname'],
- 'lastname' => $user['mb_user_lastname']
+ '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']
);
}
- die(json_encode($userArray));
+ $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);
+ #$resultArray = array($userArray, $userInfoArray);
+
+ die(json_encode($resultArray));
+
} else die('Error: Searchresult.');
} else die('Error: DB-Connection.');
\ No newline at end of file
More information about the Mapbender_commits
mailing list