Forum Index > FlashYourWeb Development > FlashYourWeb - Design & Support New Topic Post Reply
 How to make a new album for a new user?
 |  Printable Version
Anonymous: Patrick
 August 06 2009 08:37 AM (Read 2207 times)  


Hey suprsidr,

I think you have done this already. I have my G2 user albums set to create when first accessed, but I do not see a way for a new account to access the album to create it. It does not get a "your album" link on the G2 page. I am using G2 bridge with Joomla and Community builder.

Is there code I can use to present a link that either goes to my album if it exists, or creates it and goes to it if it doesn't exist yet?

Thanks,
Patrick


 
Quote
suprsidr
 August 06 2009 09:56 AM  
Forum Admin
Admin

Status: offline

Registered: 12/20/06
Posts: 1221

I could only supply a code example.
My G2Bridge is for Geeklog, not Joomla. They may already have their own solution.

-s


There will always be...
 
Profile Email Website
Quote
Anonymous: Patrick
 August 07 2009 07:20 AM  


A code example would be fantastic ... can you point me to the right file?

Thanks much,
Patrick


 
Quote
suprsidr
 August 07 2009 09:12 AM  
Forum Admin
Admin

Status: offline

Registered: 12/20/06
Posts: 1221

Gallery creates its own "Your Album" link, my example would be fore creating a link from the host app of an embedded gallery. So I would not know which file for someone else' bridge.

-s


There will always be...
 
Profile Email Website
Quote
Anonymous: Patrick
 August 07 2009 10:39 AM  


Yes, I have a Joomla module, but it does not seem to work if the album does not exist. And I'm not sure why they are not being created. I wrote a little Joomla module to display the link.

The guts are like this:

PHP Formatted Code
require_once(JPATH_ADMINISTRATOR.DS.'components'.DS."com_g2bridge".DS."helpers".DS."g2bridgecore.class.php" );
        $error = '';
        $text = '#';
    if(!G2BridgeCore::loadSettings( )) { 
        $error = "Bad Gallery2 settings detected.";
    } else {
                $logged_user = &JFactory::getUser();
                $logged_userid=$logged_user->get('id');
                /* check user */
                $ret = GalleryEmbed::isExternalIdMapped($logged_userid, 'GalleryUser');
                if($ret && $ret->getErrorCode() & ERROR_MISSING_OBJECT){
                /* user doesn't exist or isn't synced */
                       $error = "user doesn't exist or isn't synced.";
                }
                /* get the Gallery 2 user */
                list($ret, $user ) =
                        GalleryCoreApi::loadEntityByExternalId($logged_userid, 'GalleryUser');
                if($ret){
                        $error = "You must log in or register.\n";
                } else {
                        $g2ViewerId = $user->id;
                        list ($ret, $albumId) =
                                GalleryCoreApi::getPluginParameter('module', 'useralbum', 'albumId', $g2ViewerId );
//                  $error = "G2 viewer id = $g2ViewerId -- $logged_userid";
                        if($ret){
                              $error = "You must log in or register.";
                        } else {
                              $text = "index.php?option=com_g2bridge&view=gallery&Itemid=53&g2_view=core.ItemAdmin&g2_subView=core.ItemAdd&g2_itemId=$albumId&g2_return=%2Findex.php%3Foption%3Dcom_g2bridge%26view%3Dgallery%26Itemid%3D53%26g2_ion%3Dcom_g2bridge%26g2_w%3Dgallery%26g2_mid%3D53%26g2_itemId%3D$albumId";
                        }
                }
    }
}
require(JModuleHelper::getLayoutPath('mod_myalbumlink'));
 


What do I need to add to make it create the album?

Thanks,
Patrick


 
Quote
suprsidr
 August 07 2009 13:32 PM  
Forum Admin
Admin

Status: offline

Registered: 12/20/06
Posts: 1221

This is how I do it:

PHP Formatted Code

function userAlbumCreateUrl() {
    global $gallery;
    $urlGenerator = &$gallery->getUrlGenerator();
    return $urlGenerator->generateUrl(array('controller'=>'useralbum.UserAlbum'),
         array('forceFullUrl'=>true, 'forceSessionId'=>false, 'htmlEntities'=>false));
}
}


-s


There will always be...
 
Profile Email Website
Quote
Anonymous: Patrick
 August 07 2009 15:40 PM  


I tried the generateUrl call, and it gave me a link with index.php?option=com_g2bridge&view=gallery&Itemid=53&g2_controller=useralbum.UserAlbum&g2_authToken=c7e1b4c905cb

However, if I access that link I get an Authentication Failure. Error 500.

If I access the "Your album" link from the gallery page it creates the album correctly. The URL is similar although the auth token is different.

Here is the code I am using:

PHP Formatted Code

                              if( empty( $albumId ) ) {
                                    global $gallery;
                                    $urlGenerator = &$gallery->getUrlGenerator();
                                    $text = $urlGenerator->generateUrl(array('controller'=>'useralbum.UserAlbum'),
                                            array(      'forceFullUrl'=>true,
                                                    'forceSessionId'=>false,
                                                    'htmlEntities'=>false) );
                              } else {
                                    $text = "index.php?option=com_g2bridge&view=gallery&Itemid=53&g2_view=core.ItemAdmin"
                                                        . "&g2_subView=core.ItemAdd&g2_itemId=$albumId&g2_return=%2Findex.php%3Foption"
                                                        . "%3Dcom_g2bridge%26view%3Dgallery%26Itemid%3D53%26g2_ion%3Dcom_g2bridge%26"
                                                        . "g2_w%3Dgallery%26g2_mid%3D53%26g2_itemId%3D$albumId";
                              }
 



 
Quote
suprsidr
 August 07 2009 16:57 PM  
Forum Admin
Admin

Status: offline

Registered: 12/20/06
Posts: 1221

try adding the session's authToken:

PHP Formatted Code

$session =& $gallery->getSession();
$urlGenerator->generateUrl(array('controller'=>'useralbum.UserAlbum'),
         array('forceFullUrl'=>true, 'forceSessionId'=>false, 'htmlEntities'=>false, 'authToken'=>$session->getAuthToken()));


-s


There will always be...
 
Profile Email Website
Quote
Anonymous: Patrick
 August 08 2009 04:33 AM  


Thanks. I am still getting an authentication failure.

Every time I refresh the page, I get a different Authtoken. Is that expected?


 
Quote
suprsidr
 August 08 2009 05:10 AM  
Forum Admin
Admin

Status: offline

Registered: 12/20/06
Posts: 1221

Every time I refresh the page, I get a different Authtoken. Is that expected?

Yes.

Has your user been mapped to gallery yet?
Has your gallery session been created yet?

I don't know the inner workings of your bridge.

-s


There will always be...
 
Profile Email Website
Quote
Anonymous: Patrick
 August 08 2009 07:32 AM  



Has your user been mapped to gallery yet?


Yes, I believe this checks for that:

PHP Formatted Code
                $logged_user = &JFactory::getUser();
                $logged_userid=$logged_user->get('id');
                /* check user */
                $ret = GalleryEmbed::isExternalIdMapped($logged_userid, 'GalleryUser');
                if($ret && $ret->getErrorCode() & ERROR_MISSING_OBJECT){
                /* user doesn't exist or isn't synced */
                       $error = "user doesn't exist or isn't synced.";
                }
 


Has your gallery session been created yet?


Hmmm ... not sure. Is there an API call to check or initialize the current session?

Thanks again,
Patrick


 
Quote
suprsidr
 August 08 2009 08:51 AM  
Forum Admin
Admin

Status: offline

Registered: 12/20/06
Posts: 1221

You initialize gallery 'fullInit'=>false
login your user
reinitialize gallery 'activeUserId' => $logged_user->get('id'Wink, 'fullInit' => true
I believe on second pass fullInit defaults to true.

-s


There will always be...
 
Profile Email Website
Quote
Content generated in: 0.41 seconds
New Topic Post Reply



 All times are PST. The time is now 09:33 AM.
Normal Topic Normal Topic
Locked Topic Locked Topic
Sticky Topic Sticky Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Anonymous users can post 
HTML Allowed 
Censored Content