Commit a2e83850 authored by kiz_0987's avatar kiz_0987

#67002 - Added user album link (thanks bharat)

parent f88309ad
......@@ -237,10 +237,54 @@ function _gallery_check_user_status($user) {
*/
function gallery_view_user($user) {
$g2_userinfo = gallery_user_info($user, true);
list ($success, $ret) = _gallery_init();
if (!$success) {
gallery_error(t('Unable to log in to Gallery'), $ret);
return;
}
list ($ret, $g2user) = GalleryCoreApi::loadEntityByExternalId($user->uid, 'GalleryUser');
if ($ret) {
if (!($ret->getErrorCode() & ERROR_MISSING_OBJECT)) {
gallery_error(t('Unable to load the Gallery user'), $ret);
return;
}
}
if ($g2user) {
list ($ret, $albumId) =
GalleryCoreApi::getPluginParameter('module', 'useralbum', 'albumId', $g2user->getId());
if ($ret) {
gallery_error(t('Unable to fetch the user album id'), $ret);
return;
}
}
if (!empty($albumId)) {
global $gallery;
$urlGenerator =& $gallery->getUrlGenerator();
$link = $urlGenerator->generateUrl(
array('view' => 'core.ShowItem',
'itemId' => $albumId),
array('forceFullUrl' => 1));
$form['gallery_view_user_album'] = array(
'value' => l(t('User Album'), $link),
'class' => 'send-message');
} else {
$form['gallery_view_user_album'] = array(
'value' => t('User has not created an album yet'),
'class' => 'send-message');
}
if (($g2_userinfo['error_msg']) && (user_access('administer users'))) {
$form['gallery_view_user'] = array(
'title' => t('Gallery2-Drupal Sync Status'),
'value' => implode(',<br />', $g2_userinfo['error_msg']) . '<br />');
}
if (!empty($form)) {
return array(t('Gallery2') => $form);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment