packages: lms/lms-quicksearch.php.patch (NEW) - fix from 'http://cvs.lms.or...
paszczus
paszczus at pld-linux.org
Wed Mar 30 12:49:49 CEST 2011
Author: paszczus Date: Wed Mar 30 10:49:49 2011 GMT
Module: packages Tag: HEAD
---- Log message:
- fix from 'http://cvs.lms.org.pl/viewvc/Development/lms/modules/quicksearch.php?r1=1.72&r2=1.73'
---- Files affected:
packages/lms:
lms-quicksearch.php.patch (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: packages/lms/lms-quicksearch.php.patch
diff -u /dev/null packages/lms/lms-quicksearch.php.patch:1.1
--- /dev/null Wed Mar 30 12:49:49 2011
+++ packages/lms/lms-quicksearch.php.patch Wed Mar 30 12:49:44 2011
@@ -0,0 +1,99 @@
+diff -ur lms/modules/quicksearch.php lms.new//modules/quicksearch.php
+--- lms/modules/quicksearch.php 2011-03-18 09:59:24.000000000 +0100
++++ lms.new//modules/quicksearch.php 2011-03-29 20:41:29.772258200 +0200
+@@ -1,7 +1,7 @@
+ <?php
+
+ /*
+- * LMS version 1.11.12 Aris
++ * LMS version 1.11-cvs
+ *
+ * (C) Copyright 2001-2011 LMS Developers
+ *
+@@ -21,7 +21,7 @@
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ *
+- * $Id$
++ * $Id$
+ */
+
+ function macformat($mac)
+@@ -75,12 +75,13 @@
+ case 'customer':
+ if(isset($_GET['ajax'])) // support for AutoSuggest
+ {
+- $candidates = $DB->GetAll('SELECT id, email, address, post_address, deleted,
++ $candidates = $DB->GetAll('SELECT id, email, address, post_name, post_address, deleted,
+ '.$DB->Concat('UPPER(lastname)',"' '",'name').' AS username
+ FROM customersview
+ WHERE '.(preg_match('/^[0-9]+$/', $search) ? 'id = '.intval($search).' OR ' : '').'
+ LOWER('.$DB->Concat('lastname',"' '",'name').') ?LIKE? LOWER(\'%'.$search.'%\')
+ OR LOWER(address) ?LIKE? LOWER(\'%'.$search.'%\')
++ OR LOWER(post_name) ?LIKE? LOWER(\'%'.$search.'%\')
+ OR LOWER(post_address) ?LIKE? LOWER(\'%'.$search.'%\')
+ OR LOWER(email) ?LIKE? LOWER(\'%'.$search.'%\')
+ ORDER by deleted, username, email, address
+@@ -105,6 +106,10 @@
+ $descriptions[$row['id']] = escape_js(trans('Address:').' '.$row['address']);
+ continue;
+ }
++ else if (preg_match("~$search~i",$row['post_name'])) {
++ $descriptions[$row['id']] = escape_js(trans('Name:').' '.$row['post_name']);
++ continue;
++ }
+ else if (preg_match("~$search~i",$row['post_address'])) {
+ $descriptions[$row['id']] = escape_js(trans('Address:').' '.$row['post_address']);
+ continue;
+@@ -156,20 +161,37 @@
+ case 'node':
+ if(isset($_GET['ajax'])) // support for AutoSuggest
+ {
+- $candidates = $DB->GetAll('SELECT n.id, n.name, INET_NTOA(ipaddr) as ip,
+- INET_NTOA(ipaddr_pub) AS ip_pub, mac
+- FROM vnodes n
+- WHERE ('.(preg_match('/^[0-9]+$/',$search) ? 'n.id = '.intval($search).' OR ' : '').'
+- LOWER(n.name) ?LIKE? LOWER(\'%'.$search.'%\')
+- OR INET_NTOA(ipaddr) ?LIKE? \'%'.$search.'%\'
+- OR INET_NTOA(ipaddr_pub) ?LIKE? \'%'.$search.'%\'
+- OR LOWER(mac) ?LIKE? LOWER(\'%'.macformat($search).'%\')
+- )
+- AND NOT EXISTS (
+- SELECT 1 FROM customerassignments a
+- JOIN excludedgroups e ON (a.customergroupid = e.customergroupid)
+- WHERE e.userid = lms_current_user() AND a.customerid = n.ownerid)
+- ORDER BY n.name LIMIT 15');
++ // Build different query for each database engine,
++ // MySQL is slow here when vnodes view is used
++ if ($CONFIG['database']['type'] == 'postgres')
++ $sql_query = 'SELECT n.id, n.name, INET_NTOA(ipaddr) as ip,
++ INET_NTOA(ipaddr_pub) AS ip_pub, mac
++ FROM vnodes n
++ WHERE %where
++ ORDER BY n.name LIMIT 15';
++ else
++ $sql_query = 'SELECT n.id, n.name, INET_NTOA(ipaddr) as ip,
++ INET_NTOA(ipaddr_pub) AS ip_pub, mac
++ FROM nodes n
++ JOIN (
++ SELECT nodeid, GROUP_CONCAT(mac SEPARATOR \',\') AS mac
++ FROM macs
++ GROUP BY nodeid
++ ) m ON (n.id = m.nodeid)
++ WHERE %where
++ ORDER BY n.name LIMIT 15';
++
++ $sql_where = '('.(preg_match('/^[0-9]+$/',$search) ? 'n.id = '.intval($search).' OR ' : '').'
++ LOWER(n.name) ?LIKE? LOWER(\'%'.$search.'%\')
++ OR INET_NTOA(ipaddr) ?LIKE? \'%'.$search.'%\'
++ OR INET_NTOA(ipaddr_pub) ?LIKE? \'%'.$search.'%\'
++ OR LOWER(mac) ?LIKE? LOWER(\'%'.macformat($search).'%\'))
++ AND NOT EXISTS (
++ SELECT 1 FROM customerassignments a
++ JOIN excludedgroups e ON (a.customergroupid = e.customergroupid)
++ WHERE e.userid = lms_current_user() AND a.customerid = n.ownerid)';
++
++ $candidates = $DB->GetAll(str_replace('%where', $sql_where, $sql_query));
+
+ $eglible=array(); $actions=array(); $descriptions=array();
+ if ($candidates)
================================================================
More information about the pld-cvs-commit
mailing list