Hi

thanks for your great module. I use it on our site.

I like the link to user album on user profile.
Now I created new user profile using node profile.
And I would like to add this link too.
I looked into your gallery module code, but I didn't find simply solution for test if some user has his/her own user album,
and if he/she has, then write link to it.

I thought that writing this link will be simple, just e.g. your-albums/$user->name but our users can use nonenglish letters in their nicks
so gallery mod rewrite will do from name "chichúň obrovský" this
/your-albums/chich____+obrovsk__/ what is differen of drupal $user-name (by pathauto) "chichun-obrovsky"

So please, add some simply function into gallery module code, which if I could call with variable $user, and it will return link to this user album or false if user hasn't user album yet (what means that he/she wasn't in his own album yet so this album is not created yet)

Thanks a lot
Igor
somvprahe.sk

Comments

profix898’s picture

Status: Active » Fixed

I just committed a patch for this feature to cvs. The function is named 'gallery_user_useralbum()' and you can use it like this:

require_once(drupal_get_path('module', 'gallery') .'/gallery_user.inc');
if ($link = gallery_user_useralbum($user)) {
  $output = l(t('Link to User Album'), $link);
}

The function is defined in gallery_user.inc. Make sure to include this file on your profile pages.

igorik’s picture

Category: feature » bug

Hi, thanks
I tried it, but when I got this your code into my user profile tpl.php
I got this fatal error:

Fatal error: Class 'GalleryCoreApi' not found in /home/somvprahe.sk/somvprahe.sk/www/sites/all/modules/gallery/gallery_user.inc on line 271

I have latest dev version of gallery module -
Download: gallery-5.x-2.x-dev.tar.gz
Size: 63.23 KB
md5_file hash: 8223440d28d7dfbf51d4da80cb2c3a7d
Last updated: August 15, 2007 - 00:04

Thanks
Igor

igorik’s picture

Hi, thanks
I tried it, but when I give this your code into my user profile tpl.php
I got this fatal error:

Fatal error: Class 'GalleryCoreApi' not found in /home/somvprahe.sk/somvprahe.sk/www/sites/all/modules/gallery/gallery_user.inc on line 271

I have latest dev version of gallery module -
Download: gallery-5.x-2.x-dev.tar.gz
Size: 63.23 KB
md5_file hash: 8223440d28d7dfbf51d4da80cb2c3a7d
Last updated: August 15, 2007 - 00:04

Thanks
Igor

igorik’s picture

Hi, thanks
I tried it, but when I give this your code into my user profile tpl.php
I got this fatal error:

Fatal error: Class 'GalleryCoreApi' not found in /home/somvprahe.sk/somvprahe.sk/www/sites/all/modules/gallery/gallery_user.inc on line 271

I have latest dev version of gallery module -
Download: gallery-5.x-2.x-dev.tar.gz
Size: 63.23 KB
md5_file hash: 8223440d28d7dfbf51d4da80cb2c3a7d
Last updated: August 15, 2007 - 00:04

Thanks
Igor

igorik’s picture

Status: Fixed » Active
igorik’s picture

sorry for inserting it 3times.

profix898’s picture

Category: bug » support

Thats no really a bug. It only means that you forgot to initialize the gallery first! Try to add _gallery_init(TRUE); before the call to gallery_user_useralbum(). The full code may look like

if (_gallery_init(TRUE)) {
  require_once(drupal_get_path('module', 'gallery') .'/gallery_user.inc');
  if ($link = gallery_user_useralbum($user)) {
    $output = l(t('Link to User Album'), $link);
  }
  else {
    $output = t('Album not available');
  }
}
profix898’s picture

Status: Active » Fixed
profix898’s picture

Title: to create simple function to test if user have his/her useralbum, and write to links into it » create simple function to test if user have his/her useralbum
Category: support » feature

I have slightly changed the parameters of the function. It now takes the uid instead of the $user object:
$link = gallery_user_useralbum($user->uid)
Also: If you omit the parameter (or pass NULL) it returns the useralbum of the current user.

Anonymous’s picture

Status: Fixed » Closed (fixed)