Tags count only for published obj

I use the `printAllTagsAs()` function to display a tagcloud, with a counter on every tag. I noticed that even the unpublished objects are counted, so it cuold be possible that a unprivileged user click on the tag "photo(3)" but the search display no results.
I found that the problem is in the function `getAllTagsCount()`, in the sql request: I think the line
`$sql = "SELECT DISTINCT tags.name, tags.id, (SELECT COUNT(*) FROM ".prefix('obj_to_tag')." as object WHERE object.tagid = tags.id) AS count FROM ".prefix('tags')." as tags ORDER BY`name`";`
should be improved to count only the ids that matches "show=1" in the image table.
How can this be written?
Thanks

Comments

  • acrylian Administrator, Developer
    It is not that simple to ask for "show = 1" since images inherit their status from their parent. An album for example and that also from its parent. So an published image and its published album may all be in an unpublished album and therefore not counted (although you can link to any unpublished item directly).

    So you need to check the full tree first.
  • uhm, you're right... infact I have published images in unpublished albums and they also should not be counted.
    wow now it seems to be a very hard query to write, since it has to check dinamically every albumid and parentid for subalbums, stopping when parentid=NULL... have you got some ideas?
  • acrylian Administrator, Developer
    In any case have to use the object model first and build the query on its results.

    If you want to do this right now look at the functions getImageAlbumList(), getImageStatistics, getAlbumStatistics functions of the image_album_statistics plugin. Those actually do what this function would need.

    You could open a ticket as I have to discuss that with sbillard. Of course this means overhead.
Sign In or Register to comment.