API Method to check if user has any albums/items

hennagaijin

Joined: 2006-01-24
Posts: 23
Posted: Mon, 2006-01-30 02:41

I've searched the API docs, but can't seem to find what I need. Basically, I'm looking for a method that can be called from an embedding application to find out if a user has created any albums or uploaded any items. Something like GalleryEmbed::isUserHasContent($user)...

Does this exist? If not, any suggestions on how best to get this information? Many thanks.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2006-01-30 02:53

fetchAllItemIdsByOwnerId() in GalleryCoreApi

1. call GalleryEmbed::init with fullInit
2. call GalleryCoreApi:fetchAllItemIdsByOwnerId

 
hennagaijin

Joined: 2006-01-24
Posts: 23
Posted: Mon, 2006-01-30 03:13

Thanks! In between those two steps, though, I need to fetch the gallery user id by the external user id. I know how to use GalleryEmbed::getExternalIdMap(), but that seems rather heavy-handed. Is there an easier way?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2006-01-30 09:58

no, it's IMO reasonably easy. 3 function calls.. if we had a GallerEmbed wrapper for the whole thing it would be reduced to 2 function calls for you, but in the background it would do the same 3 function calls.

 
hennagaijin

Joined: 2006-01-24
Posts: 23
Posted: Mon, 2006-01-30 13:42

You're right, it is easy. When I said heavy-handed, though, I mean that the getExternalIdMap seems to return the entire contents of the ExternalIdMap table, which in my case has over 3000 rows. It seems like it would be much more efficient to just select the single value that I need, especially since the query can use a pk index.

SELECT entityId FROM ExternalIdMap WHERE externalId = ? AND entityType = 'GalleryUser'

I can implement this code quite easily in the embedding app, but my concern is what happens if/when a Gallery update changes the database structure and this no longer works. That's why I'd be more comfortable using the Gallery API, if it were available.

Is this something that others might benefit from? I'd be happy to attempt a patch, if you think this is something that deserves a spot in the API.

Anyway, thanks for your help.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2006-01-30 17:58

there's already

GalleryCoreApi::loadEntityByExternalId to load the user by your external id.