summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kremmel <xing@synapse.plus.com>2007-08-25 10:30:50 +0000
committerMax Kremmel <xing@synapse.plus.com>2007-08-25 10:30:50 +0000
commit6ee13487f257cb98b477c0d622e114c7be339e72 (patch)
tree571132074d5feb12f384cbdeccb6f10eaa9de180
parent1a20e052c92b93c836165dd1e3afd0e630668e03 (diff)
downloadpigeonholes-6ee13487f257cb98b477c0d622e114c7be339e72.tar.gz
pigeonholes-6ee13487f257cb98b477c0d622e114c7be339e72.tar.bz2
pigeonholes-6ee13487f257cb98b477c0d622e114c7be339e72.zip
add option to return members in subcategories when filtering data
-rw-r--r--Pigeonholes.php71
-rw-r--r--templates/service_list_options_inc.tpl5
2 files changed, 62 insertions, 14 deletions
diff --git a/Pigeonholes.php b/Pigeonholes.php
index 1842cf0..9613ed8 100644
--- a/Pigeonholes.php
+++ b/Pigeonholes.php
@@ -1,6 +1,6 @@
<?php
/**
- * @version $Header: /cvsroot/bitweaver/_bit_pigeonholes/Pigeonholes.php,v 1.103 2007/08/25 08:26:02 squareing Exp $
+ * @version $Header: /cvsroot/bitweaver/_bit_pigeonholes/Pigeonholes.php,v 1.104 2007/08/25 10:30:49 squareing Exp $
*
* +----------------------------------------------------------------------+
* | Copyright ( c ) 2004, bitweaver.org
@@ -17,7 +17,7 @@
* Pigeonholes class
*
* @author xing <xing@synapse.plus.com>
- * @version $Revision: 1.103 $
+ * @version $Revision: 1.104 $
* @package pigeonholes
*/
@@ -910,6 +910,35 @@ class Pigeonholes extends LibertyAttachable {
return $ret;
}
+
+ function getSubPigeonholes( $pContentId = NULL, $pStructureId = NULL ) {
+ global $gStructure;
+ $ret = array();
+
+ if( empty( $gStructure )) {
+ $struct = new LibertyStructure();
+ } else {
+ $struct = &$gStructure;
+ }
+
+ if( @BitBase::verifyId( $pContentId ) && !@BitBase::verifyId( $pStructureId )) {
+ $pigeon = $struct->getNode( NULL, $pContentId );
+ $pStructureId = $pigeon['structure_id'];
+ }
+
+ if( @BitBase::verifyId( $pStructureId )) {
+ $tree = $struct->getSubTree( $pStructureId );
+
+ // weed out duplicates
+ foreach( $tree as $pigeon ) {
+ if( !in_array( $pigeon['content_id'], array_keys( $ret ))) {
+ $ret[$pigeon['content_id']] = $pigeon;
+ }
+ }
+ }
+
+ return $ret;
+ }
}
function pigeonholes_alphabetiser( $a, $b ) {
@@ -1146,18 +1175,34 @@ function pigeonholes_content_list_sql( &$pObject, $pParamHash = NULL ) {
global $gBitSystem;
$ret = array();
- if( !empty( $pParamHash['pigeonholes']['filter'] )) {
- $pParamHash['liberty_categories'] = $pParamHash['pigeonholes']['filter'];
- }
+ if( !empty( $pParamHash['pigeonholes']['no_filter'] )) {
+ $_REQUEST['pigeonholes']['filter'] = array();
+ } else {
+ if( !empty( $pParamHash['pigeonholes']['filter'] )) {
+ $pParamHash['liberty_categories'] = $pParamHash['pigeonholes']['filter'];
+ }
- if( !empty( $pParamHash['liberty_categories'] )) {
- $ret['join_sql'] = "LEFT OUTER JOIN `".BIT_DB_PREFIX."pigeonhole_members` pm ON (lc.`content_id`=pm.`content_id`)";
- if( is_array( $pParamHash['liberty_categories'] )) {
- $ret['where_sql'] = ' AND pm.`parent_id` in ('.implode( ',', array_fill( 0, count( $pParamHash['liberty_categories'] ), '?' )).')';
- $ret['bind_vars'] = $pParamHash['liberty_categories'];
- } else {
- $ret['where_sql'] = " AND pm.`parent_id`=? ";
- $ret['bind_vars'][] = $pParamHash['liberty_categories'];
+ if( !empty( $pParamHash['liberty_categories'] )) {
+ if( !is_array( $pParamHash['liberty_categories'] )) {
+ $pParamHash['liberty_categories'][] = $pParamHash['liberty_categories'];
+ }
+
+ // if we want to allow items in subcategories, we get those and include them in the query
+ if( !empty( $pParamHash['pigeonholes']['sub_holes'] )) {
+ $pigeonholes = new Pigeonholes();
+ $contentIds = array();
+ foreach( $pParamHash['liberty_categories'] as $pigeonhole ) {
+ $pigeons = $pigeonholes->getSubPigeonholes( $pigeonhole );
+ $contentIds = array_merge( $contentIds, array_keys( $pigeons ));
+ }
+ $contentIds = array_unique( array_merge( $pParamHash['liberty_categories'], $contentIds ));
+ } else {
+ $contentIds = $pParamHash['liberty_categories'];
+ }
+
+ $ret['join_sql'] = "LEFT OUTER 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( $contentIds ), '?' )).')';
+ $ret['bind_vars'] = $_REQUEST['pigeonholes']['filter'] = $contentIds;
}
}
diff --git a/templates/service_list_options_inc.tpl b/templates/service_list_options_inc.tpl
index fefd839..f097a09 100644
--- a/templates/service_list_options_inc.tpl
+++ b/templates/service_list_options_inc.tpl
@@ -1,10 +1,13 @@
{strip}
{if $pigeonList}
{form legend="Only view entries in the following Categories"}
- {html_checkboxes options=$pigeonList values=$pigeonList selected=$smarty.request.pigeonholes.filter name="pigeonholes[filter]" id=pigeonholes_filter separator=" &nbsp; "}
+ {html_checkboxes options=$pigeonList values=$pigeonList selected=$smarty.request.pigeonholes.filter name="pigeonholes[filter]" separator=" &nbsp; "}
<div class="submit">
<input type="submit" name="apply" value="{tr}Apply Filter{/tr}" />
+ <input type="submit" name="pigeonholes[no_filter]" value="{tr}No Filter{/tr}" />
+ <br />
+ <label><input type="checkbox" {if $smarty.request.pigeonholes.sub_holes}checked="checked"{/if} name="pigeonholes[sub_holes]" /> {tr}Include subcategories{/tr}</label>
</div>
{/form}
{/if}