I am currently using the user album module to gives users there own private album. I also would like to be able to give users another album that is viewable by everyone. Looking at the code in UserAlbumHelperClass.class:
Quote:
/* Create album.. */
$albumTitle = trim($user->getFullName());
if (empty($albumTitle)) {
$albumTitle = $user->getUserName();
}
$albumName = $user->getUserName();
while (true) {
list ($ret, $album) = GalleryCoreApi::createAlbum(
$module['targetLocation'], $albumName, $albumTitle, '', '', '');
if ($ret->isSuccess()) {
break;
}
if ($ret->getErrorCode() & ERROR_COLLISION) {
$albumName .= '_';
} else {
return $ret->wrap(__FILE__, __LINE__);
}
}
list ($ret, $lockId) = GalleryCoreApi::acquireWriteLock($album->getId());
if ($ret->isError()) {
return $ret->wrap(__FILE__, __LINE__);
}
At this point in the function I have the album id of the newly created album. So after the function finishes adding permissions / setting owner / ect. Do I just need to call createAlbum($parentAlbumId, $name, $title, $summary, $description, $keywords) with the $parentAlbumId=$album->getID() being the id of the newly created album? so the code would look something like:
Quote:
$name = 'Your Public Album';
list ($ret,$pub_album)=GalleryCoreApi::createAlbum($album->getID(), $name, '', 'This album is viewable by Everyone','', '')
if ($ret->getErrorCode() & ERROR_COLLISION) {
$albumName .= '_';
} else {
return $ret->wrap(__FILE__, __LINE__);
}
list ($ret, $lockId) = GalleryCoreApi::acquireWriteLock($pub_album->getId());
if ($ret->isError()) {
return $ret->wrap(__FILE__, __LINE__);
}
/* Set owner.. */
$pub_album->setOwnerId($user->getId());
$ret = $pub_album->save();
if ($ret->isError()) {
GalleryCoreApi::releaseLocks($lockId);
return $ret->wrap(__FILE__, __LINE__);
}
$albumId = $pub_album->getId();
/* Set permissions.. */
$ret = GalleryCoreApi::removeItemPermissions($albumId);
if ($ret->isError()) {
GalleryCoreApi::releaseLocks($lockId);
return $ret->wrap(__FILE__, __LINE__);
}
$ret = GalleryCoreApi::addGroupPermission($albumId, $core['id.adminGroup'], 'core.viewAll');
if ($ret->isError()) {
GalleryCoreApi::releaseLocks($lockId);
return $ret->wrap(__FILE__, __LINE__);
}
ect....
In the long run I also want to add some pictures to users albums when it is created. If there is a more efficient way then hacking the useralbum module I am all ears.
Thanks in advance
Posts: 14
Hey, Did you ever come up with a solution for this? This is something Im looking to do. Hope you can point me in the right direction.
Thanks in Advance
Posts: 19
Have a look at http://gallery.menalto.com/node/26165. To add items to existing albums you can use a function like:
Hope that answered your question. What do you want to do exactly?
Posts: 19
This thread is recently active and the code is better.
http://gallery.menalto.com/node/32529