I need to write a user page that shows all the images that a user owns, a sort of search by tags (clicking on the word) but by owner. I need it to collect every image a user uploads on my site.
The search form doesn't have a 'owner' option and I can't find a specific function in the documentation.
What function can I use to print them? Any suggestion?
Thanks
Probably there should be a search field for the owner as there is one for the author of Zenpage items.
You have two ways to get them instead:
a) Use the object model (recommended)
b) Use a MySQL query
c) Use the object model to assign a tag to each image based on the owner name and then search that one (we use a tag "author_" for credits for example we do that manually as 3rd party authors are no "users" on our site)
I cannot use the tag "author_bob" because I'm already using tags to classify images, that tag would appear among the other "true" tags.
uhm... I already use the object model to assign the owner to the image while uploading (using $image->setOwner('bob');), my idea was to recall that by $_zp_current_image->getOwner();, modifying somehow search.php... could be that a good idea?
I haven't clearly understood how a search is done yet, but I think I could clone the model of search by tag and substitute the control on tag with the control on the owner...
If you want to hide a tag, you can of course use custom tag display functions to filter that. (we have alway a get variant to each print one and of course the object model).
Modifying the search is surely an option but not recommended because of upgrade. The best would be to open a ticket so it is actually added. Probably it was just forgotten or something. My colleague will be able to answer this I guess.
Thank you for the replies, I partially solved with a $_GET['owner']: in my case all user images are in the same album; so when I call the album, if I use ?owner=bob then this variable is passed in the function
$personality->theme_content($map, $_GET['owner']);
and then used to skip image prints that don't have the requested owner
if ($_zp_current_image->getOwner() == $owner || $owner == '') { print the thumbnail }
This worked for me, but if you said Stephan could have a cleaner and more general way to get it, I'll wait. However, it will be a nice feature having it among the search fields, in a future release.
The simplest way to implent this is to add
$this->search_structure['owner'] = gettext('Owner');
To the constructor of the search class. Then the field shows up in the option list and can be checked to cause it to be included in on the search form.
I am sure that it is just an oversite that it is not already included. I will make sure it is part of 1.4.4
Thank you, now it seems to work! It was so simply...
uhm, I think there is a bug, or something.
I simply added $this->search_structure['owner'] = gettext('Owner'); to the class-search _constructor, but when I search by owner it shows me only 11 results, while that user (the admin) has uploaded about 50 images.
I checked the images not shown in search results, they belongs to that user too.
Look in your database. That field may not be set for all the images. When the admin looks at this it uses the object model, so if an image is in an "owned" album it will be marked as owned by the album owner.
(This is, of course, the problem with just looking at database fields. But I do not know how the serach could do otherwise.)
You're right, Stephan. All the images uploaded within the zip has NULL owner (and lot of other fields) in db, even if in the admin panel was assigned to their album's owner.
It needs to "save" every pages (even without changing anything) in the album/image control panel in order to set the right parameters for every image.
Ok. We can make the album owner propegate to the image by adding code to the image updateMetaData() method.
after the lines that read:
$alb = $this->album; if (!is_null($alb)) {
add:
if (!$this->get('owner')) { $this->setOwner($alb->getOwner()); }
Of course, this requires a metadata refresh if the album owner is changed after the image is discovered.
This will be added to the 1.4.4 release
great, it works. Thank you!
I think album/images structure should be similar to the unix structure of folder/files; the album should have its own owner, so as any image should. In this vision it's natural that album owner is indipendent from any singular image owner. At least zenphoto uses a unix filesystem to manage images, doesn't it?
However it could be nice having an option to change every image owner while changing album owner.
My 2 cents
A bit late to the party here, but I have modified my image.php to include the "owner" label:
`
`
but really I would like this to be a link and a tag allowing clicking on the owner to do a tag search. I see above that you are recommending using the object model to "assign a tag to each image based on the owner name". Can you provide some tips on how to do this?
Thanks
Great. URL based search is perfect for my needs. Unfortunately the syntax must be off slightly. On my site you can see the owner is "paul" but http://skishots.calgaryalpine.com/page/search/paul/?searchfields=owner yields 0 results.