Annotation of /mambo/branches/4.6/mambots/search/contacts.searchbot.php
Parent Directory
|
Revision Log
Revision 1756 - (view) (download)
| 1 : | root | 1 | <?php |
| 2 : | /** | ||
| 3 : | elpie | 964 | * @package Mambo |
| 4 : | elpie | 1756 | * @author Mambo Foundation Inc see README.php |
| 5 : | * @copyright (C) 2000 - 2009 Mambo Foundation Inc. | ||
| 6 : | * See COPYRIGHT.php for copyright notices and details. | ||
| 7 : | * @license GNU/GPL Version 2, see LICENSE.php | ||
| 8 : | * | ||
| 9 : | * Redistributions of files must retain the above copyright notice. | ||
| 10 : | * | ||
| 11 : | * Mambo is free software; you can redistribute it and/or | ||
| 12 : | * modify it under the terms of the GNU General Public License | ||
| 13 : | * as published by the Free Software Foundation; version 2 of the License. | ||
| 14 : | */ | ||
| 15 : | root | 1 | |
| 16 : | /** ensure this file is being included by a parent file */ | ||
| 17 : | defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); | ||
| 18 : | |||
| 19 : | $_MAMBOTS->registerFunction( 'onSearch', 'botSearchContacts' ); | ||
| 20 : | |||
| 21 : | /** | ||
| 22 : | * Contacts Search method | ||
| 23 : | * | ||
| 24 : | * The sql must return the following fields that are used in a common display | ||
| 25 : | * routine: href, title, section, created, text, browsernav | ||
| 26 : | * @param string Target search string | ||
| 27 : | * @param string mathcing option, exact|any|all | ||
| 28 : | * @param string ordering option, newest|oldest|popular|alpha|category | ||
| 29 : | */ | ||
| 30 : | function botSearchContacts( $text, $phrase='', $ordering='' ) { | ||
| 31 : | global $database, $my; | ||
| 32 : | |||
| 33 : | $text = trim( $text ); | ||
| 34 : | if ($text == '') { | ||
| 35 : | return array(); | ||
| 36 : | } | ||
| 37 : | |||
| 38 : | csouza | 183 | $section = T_('Contact'); |
| 39 : | root | 1 | |
| 40 : | switch ( $ordering ) { | ||
| 41 : | case 'alpha': | ||
| 42 : | $order = 'a.name ASC'; | ||
| 43 : | break; | ||
| 44 : | case 'category': | ||
| 45 : | $order = 'b.title ASC, a.name ASC'; | ||
| 46 : | break; | ||
| 47 : | case 'popular': | ||
| 48 : | case 'newest': | ||
| 49 : | case 'oldest': | ||
| 50 : | default: | ||
| 51 : | $order = 'a.name DESC'; | ||
| 52 : | } | ||
| 53 : | |||
| 54 : | mambo | 116 | $database->setQuery("SELECT id FROM #__menu WHERE link LIKE 'index.php?option=com_contact%' ORDER BY LENGTH(link)"); |
| 55 : | mambo | 112 | $citemid = $database->loadResult(); |
| 56 : | |||
| 57 : | root | 1 | $query = "SELECT a.name AS title," |
| 58 : | . "\n CONCAT_WS( ', ', a.name, a.con_position, a.misc ) AS text," | ||
| 59 : | . "\n '' AS created," | ||
| 60 : | . "\n CONCAT_WS( ' / ', '$section', b.title ) AS section," | ||
| 61 : | . "\n '2' AS browsernav," | ||
| 62 : | mambo | 112 | . "\n CONCAT( 'index.php?option=com_contact&task=view&Itemid=$citemid&contact_id=', a.id ) AS href" |
| 63 : | root | 1 | . "\n FROM #__contact_details AS a" |
| 64 : | . "\n INNER JOIN #__categories AS b ON b.id = a.catid AND b.access <= '$my->gid'" | ||
| 65 : | . "\n WHERE ( a.name LIKE '%$text%'" | ||
| 66 : | . "\n OR a.misc LIKE '%$text%'" | ||
| 67 : | . "\n OR a.con_position LIKE '%$text%'" | ||
| 68 : | . "\n OR a.address LIKE '%$text%'" | ||
| 69 : | . "\n OR a.suburb LIKE '%$text%'" | ||
| 70 : | . "\n OR a.state LIKE '%$text%'" | ||
| 71 : | . "\n OR a.country LIKE '%$text%'" | ||
| 72 : | . "\n OR a.postcode LIKE '%$text%'" | ||
| 73 : | . "\n OR a.telephone LIKE '%$text%'" | ||
| 74 : | . "\n OR a.fax LIKE '%$text%' )" | ||
| 75 : | . "\n AND a.published = '1'" | ||
| 76 : | . "\n ORDER BY $order" | ||
| 77 : | ; | ||
| 78 : | $database->setQuery( $query ); | ||
| 79 : | $rows = $database->loadObjectList(); | ||
| 80 : | return $rows; | ||
| 81 : | } | ||
| 82 : | mambo | 112 | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

