[pLog-svn] r4334 - plog/branches/lifetype-1.1.3/class/gallery/dao
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Sun Nov 26 20:06:52 GMT 2006
Author: oscar
Date: 2006-11-26 20:06:51 +0000 (Sun, 26 Nov 2006)
New Revision: 4334
Modified:
plog/branches/lifetype-1.1.3/class/gallery/dao/galleryresources.class.php
Log:
fixed issue 1131 (http://bugs.lifetype.net/view.php?id=1131) -- the search feature for resources not working in the summary page
Modified: plog/branches/lifetype-1.1.3/class/gallery/dao/galleryresources.class.php
===================================================================
--- plog/branches/lifetype-1.1.3/class/gallery/dao/galleryresources.class.php 2006-11-26 18:54:07 UTC (rev 4333)
+++ plog/branches/lifetype-1.1.3/class/gallery/dao/galleryresources.class.php 2006-11-26 20:06:51 UTC (rev 4334)
@@ -173,7 +173,7 @@
/**
* Returns all the resources that belong to a blog
*
- * @param blogId The blog to which the resources belong
+ * @param blogId The blog to which the resources belong, use -1 to indicate any blog/owner
* @param albumId Filters by album
* @param page
* @param itemsPerPage
@@ -190,14 +190,21 @@
$itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
{
$resources = Array();
- $query = "SELECT id FROM ".$this->getPrefix()."gallery_resources WHERE owner_id = '".Db::qstr($ownerId)."'";
+ $query = "SELECT id FROM ".$this->getPrefix()."gallery_resources WHERE ";
+ if( $ownerId != -1 )
+ $query .= " owner_id = '".Db::qstr($ownerId)."' AND";
if( $albumId != GALLERY_NO_ALBUM )
- $query .= " AND album_id = '".Db::qstr($albumId)."'";
+ $query .= " album_id = '".Db::qstr($albumId)."' AND";
if( $resourceType != GALLERY_RESOURCE_ANY )
- $query .= " AND resource_type = '".Db::qstr($resourceType)."'";
+ $query .= " resource_type = '".Db::qstr($resourceType)."' AND";
if( $searchTerms != "" )
- $query .= " AND (".$this->getSearchConditions( $searchTerms ).")";
+ $query .= " (".$this->getSearchConditions( $searchTerms ).")";
+ // just in case if for any reason the string ends with "AND"
+ $query = trim( $query );
+ if( substr( $query, -3, 3 ) == "AND" )
+ $query = substr( $query, 0, strlen( $query ) - 3 );
+
$result = $this->Execute( $query, $page, $itemsPerPage );
if( !$result )
return $resources;
More information about the pLog-svn
mailing list