From 1c9cd208681808832762c5eacf5e19077ce237d9 Mon Sep 17 00:00:00 2001 From: Sylvie Greverend Date: Mon, 15 May 2006 08:36:46 +0000 Subject: be able to filter a getList on a list of pigeonholes by setting hash['pigeonholes'] --- Pigeonholes.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'Pigeonholes.php') diff --git a/Pigeonholes.php b/Pigeonholes.php index d0312d1..c76bf14 100644 --- a/Pigeonholes.php +++ b/Pigeonholes.php @@ -1,6 +1,6 @@ - * @version $Revision: 1.57 $ + * @version $Revision: 1.58 $ * @package pigeonholes */ @@ -931,4 +931,24 @@ function pigeonholes_content_store( $pObject, $pParamHash ) { } } } +/** + * filter the search with pigeonholes + * @param $pParamHash['pigeonholes'] - a pigeonhole or an array of pigeonhole content_id + **/ +function pigeonholes_content_list_sql ( &$pObject, $pParamHash = '') { + global $gBitSystem; + $ret = array(); + if( /*$gBitSystem->isFeatureActive( 'pigeonholes_categorize_'.$pObject->getContentType() ) && */ !empty( $pParamHash['pigeonholes'] ) ) { + if ( is_array( $pParamHash['pigeonholes'] ) ) { + $ret['join_sql'] = "LEFT JOIN `".BIT_DB_PREFIX."pigeonhole_members` pm ON (lc .`content_id`= pm.`content_id`)"; + $ret['where_sql'] = ' AND pm.`parent_id` in ('.implode( ',', array_fill(0, count( $pParamHash['pigeonholes'] ), '?' ) ).')'; + $ret['bind_vars'] = $pParamHash['pigeonholes']; + } else { + $ret['join_sql'] = "LEFT JOIN `".BIT_DB_PREFIX."pigeonhole_members` pm ON (lc .`content_id`= pm.`content_id`)"; + $ret['where_sql'] = " AND pm.`parent_id`=? "; + $ret['bind_vars'][] = $pParamHash['pigeonholes']; + } + } + return $ret; +} ?> -- cgit v1.3