Hello.
My task is the import of Album- and Picture-data into an existing Gallary2-System.
This Gallery2-System is runnig as a Slave being controlled by Joomla and the existing bridge to Gallery2.
I have to migrate about 5500 Pictures residing in about 500 albums (including description, title, and keywords for both the pictures and the albums) from about 40 users from an external database to this embeded Gallery2-System.
For the external database there was no documentation, but the structure was simple so writing a programm that runs through the data of each user, checking the albums and getting the pictures was (more or less) a straight forward job. So what I have now is a program that runs through my 'Source'-Database and has two entry-Points: One entry point when the Album changes, and One entry for each Picture.
My first aproach was to reverse engineer the gallery2 data-structure of the MySql database and writing directly to the database. (bad idea, as I know now). I ended up having to fill 16 tables, spend about 30 hours, succeeded for the Albums but failed for the Pictures.
So now I am having a try with the API:
GalleryCoreApi::addItemToAlbum(
$fileName, $itemName, $title, $summary, $description, $mimeType, $albumId)
GalleryCoreApi::createAlbum(
$parentAlbumId, $name, $title, $summary, $description, $keywords)
These functions sound like they are exactly what I need.
I have all the nesessary variables for the function-calls.
My Problem ist, that I do not quite understand why I get an error message when I try to switch the user from the admin user to the user, with the user-id in the g2_User table.
The user is a working user in gallery2 and I can do everything if I use the webfrontend.
The error Message I get is:
Error (ERROR_MISSING_OBJECT) : 2147 GalleryUser
* in modules/core/classes/helpers/GalleryEntityHelper_simple.class at line 124 (gallerycoreapi::error)
* in modules/core/classes/GalleryCoreApi.class at line 2290 (galleryentityhelper_simple::loadentitybyexternalid)
* in modules/core/classes/GalleryEmbed.class at line 215 (gallerycoreapi::loadentitybyexternalid)
* in modules/core/classes/GalleryEmbed.class at line 120 (galleryembed::checkactiveuser)
* in /usr/www/users/photop2/tkl_import/wrapper_main.php at line 56 (galleryembed::init)
* in /usr/www/users/photop2/tkl_import/wrapper_main.php at line 18
What can I do?
What can I check?
Thomas
Posts: 32509
are you maybe confusing externalIds with entityIds?
Most GalleryEmbed:: methods expect an externalId. A G2 userId is a G2 entityId. Each user has 2 ids when you're embedding G2 in your own application. The id of the user in your own application (the externalId) and the id of the user in G2's database (the entityId). If you're using GalleryEmbed::init or GalleryEmbed::checkActiveUser etc, then you need to provide the externalId, not the entityId.
--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage
Posts: 5
Hi,
upps - you are right!
I didn't use the external Id. This was my mistake.
I knew about the two id's but I didn't know GalleryEmbed
needed the external id.
Thanks a lot.
Thomas
Posts: 5
Now I ran into another problem while tying to add an album
one level below the user album. The steps I take are:
- lookup the g2 id
- lookup the g2 useralbum itemId
- check that this user has permissions on this album
=> error! no permissions! why?
I use:
The error messeage I get is:
If I continue creating the album anyway with:
The folder for the album gets created at the right spot in the servers fileystem, but I do not see any new album in the webfrontend.
Eaven when I am logged in with the user-id I used in the creation process.
Do I have to use a admin user to creat the Album an change the permissions afterwards?
Do I have to do some kind of "transaction-complete"-command so that the Album gets displayed?
Posts: 5
Found it by myself (seaching the forum http://gallery.menalto.com/node/66951 )
The funiction-call to tell gallery to realy execute the commands and write to the database was missing.
With this function-call:
I can see the album from the webfrontend.
I still don't understand why the user has no rights to his own "root"-Album (see) last post.
Posts: 8339
Gallery will automatically create the useralbum using the controller.
-s
FlashYourWeb and Your Gallery
Posts: 5
Generating the 'Root' User-Albun is not my task.
I know gallary (or the joomla bridge to gallery) is doing this automatically.
But I want to import a bunch of albums with photos per user from a external database.
Here I have to do the import especially if I want the picture, title, description, summary and keywords to be importet as well.
But thanks for the code. I'll have a look at it so this will help me developping myown code.