Search by Owner Name
|
kehlers
Joined: 2007-08-03
Posts: 15 |
Posted: Thu, 2007-09-20 01:19
|
|
Can anyone give me a road map to adding a "search by owner name" to the Gallery Search? Basically, I want to be able to type an owner id (ex: kehlers) in the 'Search the Gallery' box, then have all times which are owned by kehlers to show as search results. I've looked at the GalleryCoreSearch.class, but the things I tried haven't worked so far. Gallery version = 2.2.2 core 1.2.0.4 |
|
| Login or register to post comments |

Posts: 15
Okey-dokey - I did figure this out, and it was simple when I finally figured it out. So, I'll post the code I used. Cautionary note: this does require altering source code, and thus when you apply upgrades, your changes may be overwritten. I couldn't find another way to do this, so I went ahead. The result of these modifications is that when a user types a keyword in Gallery Search, the item owner field will be searched also. Thus, you can search for all gallery items owned by x, where 'x' is what the user types.
In the file /gallery/modules/core/classes/GalleryCoreSearch.class, you must add/alter two sections.
1) Just before the $storage =& $gallery->getStorage(); at around line 85, ADD
$whereList[] = "[GalleryUser::userName] LIKE ?";
$whereData[]= '%' . $criteria . '%';
2) Modify the $countquery, around line 104, as shown below:
$countQuery = sprintf('
SELECT
COUNT([GalleryItem::id])
FROM
[GalleryItem], [GalleryAccessSubscriberMap], [GalleryUser]
WHERE
(' . implode(' OR ', $whereList) . ')
AND
[GalleryItem::id] = [GalleryAccessSubscriberMap::itemId]
AND
[GalleryUser::id] = [GalleryItem::ownerId]
AND
[GalleryAccessSubscriberMap::accessListId] IN (%s)
', $aclMarkers);
Posts: 44
Thanks kehlers!!!
To search by Id, just do the following:
In the file /gallery/modules/core/classes/GalleryCoreSearch.class, you must add, just before the $storage =& $gallery->getStorage(); at around line 90:
$whereList[] = "[GalleryItem::Id] LIKE ?";
$whereData[]= '%' . $criteria . '%';
Posts: 34
I used this mod but I needed to limit my searches to only image owners. Kehlers code above includes the owner field in every search. So I replaced the "Search Summaries" check box with a "Search Photographers" check box. Here's what I changed in GalleryCoreSearch.class
Line 51 Changed
to
Line 70 Changed
to
Added to the $acountQuery (Kehler's second step) around line 104
Finally replaced 'summary' call on line 173 to 'owner' listed in bold
It will now search the last name of the owner when "Search Photographers" is checked. Enjoy.
Posts: 15
Great addition! Thx.