Once I have ported all my users and integrated the necessary hooks I want to further the integration.
what do I do in order to create albums for all of them?
I also have a table full of events.
How do I create an album for each of these?
I may also make it so that the albums are created on request to limit the number of empty albums.
thanks.
Posts: 32509
the g2 useralbum module does exactly that. activate it and configure it to create a useralbum when first accessed and show the your album link.
Posts: 153
where do i find this useralbum module ?
What about creating an album for each event in my events table if someone has images to upload for it?
Posts: 32509
so you didn't install the full package?
site admin -> modules. if it's not there:
http://gallery.menalto.com/downloads -> http://codex.gallery2.org/index.php/Gallery2:Download#Modules
Posts: 153
My mistake.
It was there but just not installed and activated.
I've done that now.
I haven't found where to configure it yet though.
I see some of the other modules have "configure" actions in the column on the modules page but "User Albums" does not.
Posts: 32509
once installed and activated, there's a user albums link in the site admin menu.
Posts: 153
Found it. Thanks.
So the album will be created when the user first accesses the gallery.
Any part of the gallery in particular?
I'm trying to figure out the API.
I have the user logging in now it seems but I actually haven't figure out yet how to let him see the pictures!
Posts: 153
Ok so I got it all enabled but when I log in as one of my users in my contact point script it doesn't create a user album for me.
I am accessing through an embedded gallery with the guidelines outlines in docs/EMBEDDING.
What do i have to do in order to get the User Albums module to create an album when I log in?
or at all?
Posts: 153
It did create a gallery for "Gallery Administrator" when I logged in through the main installation.
It doesn't seem to create one for the users logging in through the Embedded yet.
Posts: 32509
you said you wanted that it doesn't create a useralbum for any user, just for those that actually want to use it. thus use the option "when first accessed". and also activate the option " Link to user album".
then you'll see a link to your user album in the top right.
Posts: 153
Ah Ha. So I have to click on "my album" ?
well I did that and it seems to work now. Thank you!
Is there some way for me to poll gallery to find out if a particular user has created their album yet?
I would like to dynamically link to the user's album from their profile page.
Is there a way to ask gallery for the link?
Posts: 32509
hmm, let's see...
if you have the G2 user id (you can get it with $user->getId() if you already have a user object), you can get the information with
if you only have the id of the user in your CMS, you can load the G2 user object with
if you want more information about the user album, you can load it with
Posts: 153
In my CMS i will only have the CMS userID initially.
If I use GalleryEmbed::loadEntityByExternalId($cmsUserId) to get the user object I presume the G2 UserID is in there somewhere?
Posts: 32509
as i said, use ist ($ret, $user) = GalleryEmbed::loadEntityByExternalId($cmsUserId); and $user will be a G2 user entity. use $user->getId() to get the g2 user id.
Posts: 153
Can I get a link to a thumbnail of the user's main photo in their gallery?
Posts: 32509
you mean a link to the thumbnail of the user album?
yes.
take a look at modules/core/classes/GalleryCoreApi.class there you see a long list of G2 API functions.
you need to call the fetch thumbnail function to fetch a thumbnail for the album item.
once you have the thumbnail, you can then, once you're sure it has a thumbnail (check), to generate the url to the thumbnail, use:
$imgSrc = $urlGenerator->generateUrl(array('view' => 'core.DownloadItem',
'itemId' => $thumbnail->getId(),
'serialNumber' => $thumbnail->getSerialNumber()));
Posts: 153
Thanks for all your help. I am really learning alot quickly and I like that.
I adapted your code above a bit..
But I'm now getting a strange storage error?
any ideas?
Posts: 32509
cool
change:
list ($ret, $albumId) = GalleryCoreApi::getPluginParameter('module', 'useralbum', 'albumId', $galleryuser);
to
list ($ret, $albumId) = GalleryCoreApi::getPluginParameter('module', 'useralbum', 'albumId', $galleryuser->getId());
Posts: 153
I put something together that seems to do the trick.
But some reason the generated URL points back to my install G2 directory instead of to my Embeded G2 access point.
This is what I hacked together.
Any ideas why this would happen?
Posts: 32509
where's your CMS / application installed (url to access it, url to access the frontpage of embedded g2 ?, filesystem path?)
where's your G2 installed ? url and filesystem path
Posts: 153
> CMS / application installed (url to access it, url to access the frontpage of embedded g2 ?,
/gallery/main.php
>filesystem path
/pathtodocumentroot/gallery
> where's your G2 installed ?
> url
/phpgallery
> filesystem path
/pathtodocumentroot/phpgallery
Posts: 32509
correct values:
embedUri => 'main.php'
embedPath => '/gallery/'
relativeG2Path => '../phpgallery/'
Posts: 32509
which is what you already had.
but what i don't get is: your profile, or event page, they are not accessed with /gallery/main.php, right?
there you'll have to use other parameter values in ::init().
Posts: 153
I'm not sure I understand.
What is the embed script?
whatever script is calling the GalleryEmbed::init at that time?
or the actual access point to the gallery?
I have one main access point that I made at /gallery/main.php
but the scripts that call the api are varied and all over.
this particlular one is in /lib/gallery.inc which is in turn called by /directory/profile.php
Posts: 32509
note: core.DownloadUrl urls always point to the G2 installation, never to embedded G2.
reason: performance and it doesn't make sense to route all image download requests through an external application.
core.ShowItem and pretty much everything else points to the embedded G2.
Posts: 153
In my case, and I imagine in other cases, I would like to keep the base code installation somewhat secret.
I don't want my users accessing the gallery through /phpgallery.
With all the links being directed to there there seems no way for me to keep my users out of there.
is there?
Posts: 32509
you can set embed.mode.only = true in config.php and then they won't be able to access g2 standalone.
but this will also disable the gallery remote / upload applet features ( gotta fix that once).
Posts: 153
i think people are already liking the upload feature.
is this something that will be fixed soon?
Posts: 32509
fixed in cvs, mode.embed.only = true works now with GR, upload applet and slideshowapplet.
Posts: 153
i guess that's pretty soon.
Posts: 153
Many of my users have now created albums by accessing their gallery for the first time.
Many of my users still have not however.
I happen to have a long list of URLs that point to one image per user for many of the users who have not yet created an album.
How can I create an album for these users as if they created them for themselves?
Will I have to pay special attention to permissions to make sure the user owns their own album?
Once the album is created how do I tell it to add an image by an URL that I specify?
Posts: 32509
see modules/useralbum/UserAlbum.inc function handlerequest.
Posts: 153
ok.. that tells me how to create the user album right ?
Will that assure that it has the proper permissions?
also I am wondering once the album is created how do I insert the first Item from an URL and make sure the thumbnail is generated?
is that in modules/useralbum/UserAlbum.inc as well?
Posts: 32509
just take a look at this UserAlbumController::handleRequest.
yes, permissions are set there.
how to add an item: see modules/core/ItemAddFrom...inc + ItemAdd.inc how it uses GalleryCoreApi::addItemToAlbum etc
Posts: 153
I see this code which seems would do the trick?
how important is the list $mimeType ?
is there a way I could get the same results of this from within my script?
" $this->_getMimeType($url, $headers, true); "
Posts: 32509
if the file is already on the same server, there's no need to call ::fetchWebFile .
addItemToAlbum requires the mimetype, period.
Posts: 153
it isn't already on the same server. it's on a remote web server.
So how do i get the mime type would you say?
copy and paste the whole getMimeType() function into my own script?
or is there a way to obtain the needed information through the embed API ?
Posts: 32509
see ItemAddFromWeb.inc function handlerequest.
Posts: 153
Ok. I copy and pasted the getMimeType() function to my script and that aspect seems to work..
However now I am getting another strange error.. soemthing about an "ERROR_LOCK_REQUIRED" ??
Posts: 153
ok.. i figured the lock thing out.
Posts: 153
now how do i get it to create the thumbnail at the same time as I add it to the gallery?
Posts: 32509
see modules/core/CreateThumbnailOption.inc
Posts: 153
so basically just this?
GalleryCoreApi::rebuildDerivativeCacheIfNotCurrent($thumbnail->getId())
Posts: 32509
yep. and don't forget to check the returned $ret status as usual
Posts: 81
hi,
I am using Joomla and I would like the user to have a thumbnails of each a their album in their profil.
Does your code enable that?
can you give me some explaination on how to use it. G2 is already integrated in my CMS.
tks
florian
I put something together that seems to do the trick.
But some reason the generated URL points back to my install G2 directory instead of to my Embeded G2 access point.
This is what I hacked together.
Any ideas why this would happen?
Posts: 81
I have try to copy the code in a useralbum.php, when I run the page on my server I have a blank page. Could you send me your file please. Or give me some imput on how to do it.
tks a lot
Florian