Annotation of /mambo/branches/4.6/mambots/search/contacts.searchbot.php
Parent Directory
|
Revision Log
Revision 1 -
(view)
(download)
Original Path: mambo/trunk/mambots/search/contacts.searchbot.php
| 1 : | root | 1 | <?php |
| 2 : | /** | ||
| 3 : | * @version $Id: contacts.searchbot.php,v 1.1 2005/07/22 01:58:25 eddieajau Exp $ | ||
| 4 : | * @package Mambo | ||
| 5 : | * @copyright (C) 2000 - 2005 Miro International Pty Ltd | ||
| 6 : | * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL | ||
| 7 : | * Mambo is Free Software | ||
| 8 : | */ | ||
| 9 : | |||
| 10 : | /** ensure this file is being included by a parent file */ | ||
| 11 : | defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); | ||
| 12 : | |||
| 13 : | $_MAMBOTS->registerFunction( 'onSearch', 'botSearchContacts' ); | ||
| 14 : | |||
| 15 : | /** | ||
| 16 : | * Contacts Search method | ||
| 17 : | * | ||
| 18 : | * The sql must return the following fields that are used in a common display | ||
| 19 : | * routine: href, title, section, created, text, browsernav | ||
| 20 : | * @param string Target search string | ||
| 21 : | * @param string mathcing option, exact|any|all | ||
| 22 : | * @param string ordering option, newest|oldest|popular|alpha|category | ||
| 23 : | */ | ||
| 24 : | function botSearchContacts( $text, $phrase='', $ordering='' ) { | ||
| 25 : | global $database, $my; | ||
| 26 : | |||
| 27 : | $text = trim( $text ); | ||
| 28 : | if ($text == '') { | ||
| 29 : | return array(); | ||
| 30 : | } | ||
| 31 : | |||
| 32 : | $section = _CONTACT_TITLE; | ||
| 33 : | |||
| 34 : | switch ( $ordering ) { | ||
| 35 : | case 'alpha': | ||
| 36 : | $order = 'a.name ASC'; | ||
| 37 : | break; | ||
| 38 : | case 'category': | ||
| 39 : | $order = 'b.title ASC, a.name ASC'; | ||
| 40 : | break; | ||
| 41 : | case 'popular': | ||
| 42 : | case 'newest': | ||
| 43 : | case 'oldest': | ||
| 44 : | default: | ||
| 45 : | $order = 'a.name DESC'; | ||
| 46 : | } | ||
| 47 : | |||
| 48 : | $query = "SELECT a.name AS title," | ||
| 49 : | . "\n CONCAT_WS( ', ', a.name, a.con_position, a.misc ) AS text," | ||
| 50 : | . "\n '' AS created," | ||
| 51 : | . "\n CONCAT_WS( ' / ', '$section', b.title ) AS section," | ||
| 52 : | . "\n '2' AS browsernav," | ||
| 53 : | . "\n CONCAT( 'index.php?option=com_contact&task=view&&contact_id=', a.id ) AS href" | ||
| 54 : | . "\n FROM #__contact_details AS a" | ||
| 55 : | . "\n INNER JOIN #__categories AS b ON b.id = a.catid AND b.access <= '$my->gid'" | ||
| 56 : | . "\n WHERE ( a.name LIKE '%$text%'" | ||
| 57 : | . "\n OR a.misc LIKE '%$text%'" | ||
| 58 : | . "\n OR a.con_position LIKE '%$text%'" | ||
| 59 : | . "\n OR a.address LIKE '%$text%'" | ||
| 60 : | . "\n OR a.suburb LIKE '%$text%'" | ||
| 61 : | . "\n OR a.state LIKE '%$text%'" | ||
| 62 : | . "\n OR a.country LIKE '%$text%'" | ||
| 63 : | . "\n OR a.postcode LIKE '%$text%'" | ||
| 64 : | . "\n OR a.telephone LIKE '%$text%'" | ||
| 65 : | . "\n OR a.fax LIKE '%$text%' )" | ||
| 66 : | . "\n AND a.published = '1'" | ||
| 67 : | . "\n ORDER BY $order" | ||
| 68 : | ; | ||
| 69 : | $database->setQuery( $query ); | ||
| 70 : | $rows = $database->loadObjectList(); | ||
| 71 : | return $rows; | ||
| 72 : | } | ||
| 73 : | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

