summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gallery_user.inc56
1 files changed, 33 insertions, 23 deletions
diff --git a/gallery_user.inc b/gallery_user.inc
index 885ee36..6248793 100644
--- a/gallery_user.inc
+++ b/gallery_user.inc
@@ -237,14 +237,42 @@ function gallery_user_view($user) {
if (variable_get('gallery_user_hide_profile', 0) || !_gallery_init(TRUE)) {
return;
}
- // Get map status info
+ // User album status
+ if ($useralbum = gallery_user_useralbum($user)) {
+ $form['gallery_view_user_album'] = array(
+ 'value' => l(t('User Album'), $useralbum),
+ 'class' => 'send-message');
+ }
+ else {
+ $form['gallery_view_user_album'] = array(
+ 'value' => t('User has not created an album yet'),
+ 'class' => 'send-message');
+ }
+ // Sync/Map status info
$g2_userinfo = gallery_user_map_info($user);
+ if (($g2_userinfo['status']) && (user_access('administer users'))) {
+ $form['gallery_view_user'] = array(
+ 'title' => t('Gallery2-Drupal Sync Status'),
+ 'value' => implode(',<br />', gallery_user_map_info_status($g2_userinfo['status']))
+ );
+ }
+
+ GalleryEmbed::done();
+ if (!empty($form)) {
+ return array(t('Gallery2') => $form);
+ }
+}
+
+/**
+ * Create link to user album
+ */
+function gallery_user_useralbum($user) {
// Load G2 user
list($ret, $g2_user) = GalleryCoreApi::loadEntityByExternalId($user->uid, 'GalleryUser');
if ($ret) {
if (!($ret->getErrorCode() & ERROR_MISSING_OBJECT)) {
gallery_error(t('Error loading Gallery user'), $ret);
- return;
+ return FALSE;
}
}
// User album status
@@ -253,33 +281,15 @@ function gallery_user_view($user) {
list($ret, $album_id) = GalleryCoreApi::getPluginParameter('module', 'useralbum', 'albumId', $g2_user->id);
if ($ret) {
gallery_error(t('Error fetching user album id'), $ret);
- return;
+ return FALSE;
}
// Generate link to user album
if (is_numeric($album_id) && $album_id > 0) {
- $link = gallery_generate_url(array('view' => 'core.ShowItem', 'itemId' => $album_id), FALSE);
- $form['gallery_view_user_album'] = array(
- 'value' => l(t('User Album'), $link),
- 'class' => 'send-message');
+ return gallery_generate_url(array('view' => 'core.ShowItem', 'itemId' => $album_id), FALSE);
}
- else {
- $form['gallery_view_user_album'] = array(
- 'value' => t('User has not created an album yet'),
- 'class' => 'send-message');
- }
- }
- // Sync status
- if (($g2_userinfo['status']) && (user_access('administer users'))) {
- $form['gallery_view_user'] = array(
- 'title' => t('Gallery2-Drupal Sync Status'),
- 'value' => implode(',<br />', gallery_user_map_info_status($g2_userinfo['status']))
- );
}
- GalleryEmbed::done();
- if (!empty($form)) {
- return array(t('Gallery2') => $form);
- }
+ return FALSE;
}
/**