summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gallery.module65
-rw-r--r--gallery_block.inc3
-rw-r--r--gallery_settings.inc205
-rw-r--r--gallery_user.inc44
4 files changed, 184 insertions, 133 deletions
diff --git a/gallery.module b/gallery.module
index 384e2da..351bd25 100644
--- a/gallery.module
+++ b/gallery.module
@@ -17,7 +17,7 @@ function gallery_menu($may_cache) {
'path' => 'gallery',
'title' => t('gallery'),
'callback' => 'gallery_page',
- 'access' => user_access('access content'),
+ 'access' => user_access('access gallery'),
'type' => MENU_NORMAL_ITEM,
);
$items[] = array(
@@ -116,42 +116,42 @@ function gallery_search_page($results) {
/**
* Implementation of hook_filter
- */
+ */
function gallery_filter($op, $delta = 0, $format = -1, $text = '') {
$path = drupal_get_path('module', 'gallery');
- require_once($path . '/gallery_filter.inc');
- switch ($op) {
- case 'list' :
- return array (0 => t('Gallery2 filter'));
- case 'description' :
- return t('Allow users to easily reference Gallery2 items from nodes.');
- case 'process' :
+ require_once($path . '/gallery_filter.inc');
+ switch ($op) {
+ case 'list' :
+ return array (0 => t('Gallery2 filter'));
+ case 'description' :
+ return t('Allow users to easily reference Gallery2 items from nodes.');
+ case 'process' :
return gallery_filter_process($text);
case 'no cache':
- return !variable_get('gallery_filter_can_cache', 1);
- default :
- return $text;
- }
+ return !variable_get('gallery_filter_can_cache', 1);
+ default :
+ return $text;
+ }
}
-
+
/**
* Implementation of hook_filter_tips
- */
+ */
function gallery_filter_tips($delta = 0, $format = -1, $long = false) {
$path = drupal_get_path('module', 'gallery');
- require_once($path . '/gallery_help.inc');
- if ($long) {
- return gallery_filter_long_tip_translated();
- } else {
- return gallery_filter_short_tip_translated();
- }
+ require_once($path . '/gallery_help.inc');
+ if ($long) {
+ return gallery_filter_long_tip_translated();
+ } else {
+ return gallery_filter_short_tip_translated();
+ }
}
/**
* Implementation of hook_perm().
*/
function gallery_perm() {
- return array('access standalone g2image');
+ return array('access gallery', 'access standalone g2image');
}
/**
@@ -215,13 +215,20 @@ function gallery_page() {
if (isset($result['themeData'])) {
$urlGenerator =& $GLOBALS['gallery']->getUrlGenerator();
$breadcrumb = array(l(t('Home'), ''));
- foreach ($result['themeData']['parents'] as $parent) {
- $parent_title = $parent['title'];
- // Simple strip of bbcode (italics)
- $parent_title = str_replace("[i]", "<i>", $parent_title);
- $parent_title = str_replace("[/i]", "</i>", $parent_title);
- $breadcrumb[] = '<a href="'.$urlGenerator->generateUrl(
- array('itemId' => $parent['id'])) .'">'.$parent_title."</a>";
+ // Some themes (eg hybrid) do not set $result['themeData']['parents']
+ if ($result['themeData']['parents']) {
+ foreach ($result['themeData']['parents'] as $parent) {
+ $parent_title = $parent['title'];
+ // Simple strip of bbcode (italics)
+ $parent_title = str_replace("[i]", "<i>", $parent_title);
+ $parent_title = str_replace("[/i]", "</i>", $parent_title);
+ // Still does not generate a clean url for /gallery (uses index.php?q=gallery)
+ $link = $urlGenerator->generateUrl(
+ array('view' => 'core.ShowItem',
+ 'itemId' => $parent['id']),
+ array('forceFullUrl' => 1));
+ $breadcrumb[] = l($parent_title, $link);
+ }
}
drupal_set_breadcrumb($breadcrumb);
}
diff --git a/gallery_block.inc b/gallery_block.inc
index 7181539..266de83 100644
--- a/gallery_block.inc
+++ b/gallery_block.inc
@@ -36,6 +36,9 @@ function _gallery_block($op = 'list', $delta = 0, $edit = array()) {
return $blocks;
case 'view':
+ if (!user_access('access gallery')) {
+ return;
+ }
list ($success, $ret) = _gallery_init(true);
if (!$success) {
$err_msg = t('Unable to initialize embedded Gallery. You need to <a href="%link">
diff --git a/gallery_settings.inc b/gallery_settings.inc
index dd5825b..71d4589 100644
--- a/gallery_settings.inc
+++ b/gallery_settings.inc
@@ -123,17 +123,17 @@ function _gallery_settings() {
// Image Block settings
$typeMap = array(
- 'randomImage' => t('Random image'),
- 'recentImage' => t('Recent image'),
- 'viewedImage' => t('Viewed image'),
- 'randomAlbum' => t('Random album'),
- 'recentAlbum' => t('Recent album'),
- 'viewedAlbum' => t('Viewed album'),
- 'dailyImage' => t('Daily image'),
- 'weeklyImage' => t('Weekly image'),
- 'monthlyImage' => t('Monthly image'),
- 'dailyAlbum' => t('Daily album'),
- 'weeklyAlbum' => t('Weekly album'),
+ 'randomImage' => t('Random image'),
+ 'recentImage' => t('Recent image'),
+ 'viewedImage' => t('Viewed image'),
+ 'randomAlbum' => t('Random album'),
+ 'recentAlbum' => t('Recent album'),
+ 'viewedAlbum' => t('Viewed album'),
+ 'dailyImage' => t('Daily image'),
+ 'weeklyImage' => t('Weekly image'),
+ 'monthlyImage' => t('Monthly image'),
+ 'dailyAlbum' => t('Daily album'),
+ 'weeklyAlbum' => t('Weekly album'),
'monthlyAlbum' => t('Monthly album'),
);
@@ -144,7 +144,7 @@ function _gallery_settings() {
'owner' => t('Item owner'),
'heading' => t('Heading'),
'fullSize' => t('Full Size'),
- );
+ );
$form['block'] = _gallery_block_settings($typeMap , $paramMap);
$form['grid'] = _gallery_grid_block_settings($typeMap , $paramMap);
@@ -378,23 +378,23 @@ function _gallery_filter_settings($typeMap , $paramMap) {
'#description' => '',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
- );
-//we don't include specificItem, since it can be selected automatically if n=1
- $form['filter']['gallery_filter_prefix'] = array(
- '#type' => 'textfield',
- '#title' => t('Filter prefix'),
- '#default_value' => variable_get('gallery_filter_prefix', 'G2'),
- '#size' => 10,
- '#maxlength' => 10,
- '#description' => t('Prefix to use with filter. Example: \'G2\' means you use [G2: 999].'),
- );
-
- $form['filter']['gallery_filter_default_block_type'] = array(
- '#type' => 'select',
- '#title' => t('Image Block Type'),
- '#default_value' => variable_get('gallery_filter_default_block_type', 'viewedImage'),
- '#options' => $typeMap,
- '#description' => t('Pick default type of image block you\'d like to use, default is Recent image. Viewed image is by most clicks.'),
+ );
+//we don't include specificItem, since it can be selected automatically if n=1
+ $form['filter']['gallery_filter_prefix'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Filter prefix'),
+ '#default_value' => variable_get('gallery_filter_prefix', 'G2'),
+ '#size' => 10,
+ '#maxlength' => 10,
+ '#description' => t('Prefix to use with filter. Example: \'G2\' means you use [G2: 999].'),
+ );
+
+ $form['filter']['gallery_filter_default_block_type'] = array(
+ '#type' => 'select',
+ '#title' => t('Image Block Type'),
+ '#default_value' => variable_get('gallery_filter_default_block_type', 'viewedImage'),
+ '#options' => $typeMap,
+ '#description' => t('Pick default type of image block you\'d like to use, default is Recent image. Viewed image is by most clicks.'),
);
$form['filter']['gallery_filter_can_cache'] = array(
@@ -403,50 +403,50 @@ function _gallery_filter_settings($typeMap , $paramMap) {
'#default_value' => variable_get('gallery_filter_can_cache', 1),
'#description' => t('By default the gallery filter output is cached by Drupal to speed up page loading. However, it will not cache the css class info for the frames. The best approach is the make sure that the sidebar image block and the gallery filter images use the same frames. If you are unable to do this you will have to deselect this option to force Drupal not to cache the pages, or else your frames will not appear. If you change this option you will need to go to <a href="%link">admin/filters</a> and re-save the image formats that use gallery filter.', array('%link' => url('admin/filters'))),
);
-
- $form['filter']['gallery_filter_n_images'] = array(
- '#type' => 'textfield',
- '#title' => t('Default Number of Images'),
- '#default_value' => variable_get('gallery_filter_n_images', 1),
- '#size' => 3,
- '#maxlength' => 3,
- '#description' => t('How many images you want the default block to show. Best to keep at 1 and use the n parameter.'),
- );
-//////*********in fact, should we remove this option all together? because the way it is now, if you change this to n>1
-//then instances where n was not specified and item_id is a specific item, the block breaks and nothing is shown.
- $form['filter']['gallery_filter_default_show'] = array(
- '#type' => 'checkboxes',
- '#title' => t('Default Image Block Settings'),
- '#default_value' => variable_get('gallery_filter_default_show', array('none')),
- '#options' => $paramMap,
- '#description' => t('Choose the item metadata you\'d like to display by default. This will change all instances where show parameter was not specified.'),
+
+ $form['filter']['gallery_filter_n_images'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Default Number of Images'),
+ '#default_value' => variable_get('gallery_filter_n_images', 1),
+ '#size' => 3,
+ '#maxlength' => 3,
+ '#description' => t('How many images you want the default block to show. Best to keep at 1 and use the n parameter.'),
+ );
+//////*********in fact, should we remove this option all together? because the way it is now, if you change this to n>1
+//then instances where n was not specified and item_id is a specific item, the block breaks and nothing is shown.
+ $form['filter']['gallery_filter_default_show'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Default Image Block Settings'),
+ '#default_value' => variable_get('gallery_filter_default_show', array('none')),
+ '#options' => $paramMap,
+ '#description' => t('Choose the item metadata you\'d like to display by default. This will change all instances where show parameter was not specified.'),
);
-
- $form['filter']['gallery_filter_default_size'] = array(
- '#type' => 'textfield',
- '#title' => t('Default thumbnail size'),
- '#default_value' => variable_get("gallery_filter_default_size", "150"),
- '#size' => 10,
- '#maxlength' => 10,
+
+ $form['filter']['gallery_filter_default_size'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Default thumbnail size'),
+ '#default_value' => variable_get("gallery_filter_default_size", "150"),
+ '#size' => 10,
+ '#maxlength' => 10,
'#description' => t('If no size is specified when calling the filter, this size will be used. If you want your size to be bigger than the thumbnail size for that image as defined in your Gallery2, you must select "Full Size" above (but note that the full image will be returned and then resized by the browser, so it may take a while to download).'),
);
-
- $form['filter']['gallery_filter_default_album_frame'] = array(
- '#type' => 'textfield',
- '#title' => t('Default album frame'),
- '#default_value' => variable_get('gallery_filter_default_album_frame', 'none'),
- '#size' => 20,
- '#maxlength' => 20,
- '#description' => t('Enter a frame name like notebook, polaroid, shadow, slide, wood, etc. See your G2 install for a complete list. Use \'none\' or blank for no frame. '),
+
+ $form['filter']['gallery_filter_default_album_frame'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Default album frame'),
+ '#default_value' => variable_get('gallery_filter_default_album_frame', 'none'),
+ '#size' => 20,
+ '#maxlength' => 20,
+ '#description' => t('Enter a frame name like notebook, polaroid, shadow, slide, wood, etc. See your G2 install for a complete list. Use \'none\' or blank for no frame. '),
);
-
- $form['filter']['gallery_filter_default_item_frame'] = array(
- '#type' => 'textfield',
- '#title' => t('Default item frame'),
- '#default_value' => variable_get('gallery_filter_default_item_frame', 'none'),
- '#size' => 20,
- '#maxlength' => 20,
- '#description' => t('Enter a frame name like notebook, polaroid, shadow, slide, wood, etc. See your G2 install for a complete list. Use \'none\' or blank for no frame.'),
+
+ $form['filter']['gallery_filter_default_item_frame'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Default item frame'),
+ '#default_value' => variable_get('gallery_filter_default_item_frame', 'none'),
+ '#size' => 20,
+ '#maxlength' => 20,
+ '#description' => t('Enter a frame name like notebook, polaroid, shadow, slide, wood, etc. See your G2 install for a complete list. Use \'none\' or blank for no frame.'),
);
$form['filter']['gallery_filter_default_link_target'] = array(
@@ -457,14 +457,14 @@ function _gallery_filter_settings($typeMap , $paramMap) {
'#maxlength' => 20,
'#description' => t('Enter a link target (eg "_blank", "_new").'),
);
-
- $form['filter']['gallery_filter_default_div_class'] = array(
- '#type' => 'textfield',
- '#title' => t('Default class'),
- '#default_value' => variable_get('gallery_filter_default_div_class', 'nowrap'),
- '#size' => 20,
- '#maxlength' => 20,
- '#description' => t('left, right, or nowrap. (See gallery_filter.css to add more or modify these.)'),
+
+ $form['filter']['gallery_filter_default_div_class'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Default class'),
+ '#default_value' => variable_get('gallery_filter_default_div_class', 'nowrap'),
+ '#size' => 20,
+ '#maxlength' => 20,
+ '#description' => t('left, right, or nowrap. (See gallery_filter.css to add more or modify these.)'),
);
return $form['filter'];
}
@@ -606,13 +606,13 @@ function _gallery_g2image_settings() {
'#description' => $description
);
- $form['g2image']['gallery_g2image_regex'] = array(
- '#type' => 'textfield',
- '#title' => t('Image Types Regular Expression'),
- '#default_value' => variable_get('gallery_g2image_regex', '@(jpg|jpeg|png|gif|bmp|svg|mov|mpg|mpeg)$@i'),
- '#size' => 50,
- '#maxlength' => 50,
- '#description' => t('Images with these file extensions will be displayed in g2image'),
+ $form['g2image']['gallery_g2image_regex'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Image Types Regular Expression'),
+ '#default_value' => variable_get('gallery_g2image_regex', '@(jpg|jpeg|png|gif|bmp|svg|mov|mpg|mpeg)$@i'),
+ '#size' => 50,
+ '#maxlength' => 50,
+ '#description' => t('Images with these file extensions will be displayed in g2image'),
);
$form['g2image']['gallery_g2image_sortby'] = array(
@@ -683,13 +683,13 @@ function _gallery_g2image_settings() {
'#description' => t('Choose the default method of inserting the image info.'),
);
- $form['g2image']['gallery_g2image_custom_url'] = array(
- '#type' => 'textfield',
- '#title' => t('Default custom url'),
- '#default_value' => variable_get('gallery_g2image_custom_url', 'http://'),
- '#size' => 50,
- '#maxlength' => 50,
- '#description' => t('The default custom url. Used with \'Thumbnail with link to custom URL\' action setting'),
+ $form['g2image']['gallery_g2image_custom_url'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Default custom url'),
+ '#default_value' => variable_get('gallery_g2image_custom_url', 'http://'),
+ '#size' => 50,
+ '#maxlength' => 50,
+ '#description' => t('The default custom url. Used with \'Thumbnail with link to custom URL\' action setting'),
);
// Fix - G2 prefix
@@ -913,14 +913,10 @@ function _gallery_configure_url_rewrite() {
// Find the public path to drupal from the base_url
global $base_url;
$http = 'http' . (isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] == 'on' ? 's' : '' : '');
- $public_path = str_replace($http . '://' . $_SERVER['HTTP_HOST'],'', $base_url);
+ $public_path = str_replace($http . '://' . $_SERVER['HTTP_HOST'],'', $base_url) . '/';
// Find the path to drupal. Will this always work?
- // FIX NEEDED: This will fail if the module is installed in the sites/XXX/modules dir.
- // Probably not a big deal for 99% of people.
- $drupal_root = dirname(__FILE__);
- $gallery_path = drupal_get_path('module', 'gallery');
- $htaccess_path = str_replace($gallery_path, '', $drupal_root);
+ $htaccess_path = realpath(".") . '/';
$title = t('Gallery2 URL Rewrite Module Auto-Configuration:');
$results['urlrewrite']['title'] = $title;
@@ -960,18 +956,18 @@ function _gallery_configure_url_rewrite() {
// Save the G2 rewrite Values
list ($ret, $code, $err) = $rewriteApi->saveEmbedConfig($params);
-
- if ( $code > 0 ) {
+ if ($code != REWRITE_STATUS_OK) {
list ($ret, $errstr) = $err;
$errstr = $code." - ".$errstr;
$results['urlrewrite']['error'] = true;
- $results['urlrewrite']['notice'] = t('The Gallery2 URL Rewrite module returned the following error') . '<pre>' . $errstr . '</pre>';
+ $results['urlrewrite']['notice'] = t('The Gallery2 URL Rewrite module returned the following error:') . '<pre>' . $errstr . '</pre>';
$num_errors++;
- }
- $results['urlrewrite']['success'] = true;
+ } else {
+ $results['urlrewrite']['success'] = true;
+ }
} else {
$results['urlrewrite']['error'] = true;
- $results['urlrewrite']['notice'] = t('The .htaccess file in your defined Drupal directory (%dir) is not writable. Please CHMOD it to 644 (or 666 if 644 does not work).', array('%dir' => $htaccess_path));
+ $results['urlrewrite']['notice'] = t('The .htaccess file in your defined Drupal directory (%dir) is not writable. Please CHMOD it to 644 (or 666 if 644 does not work).', array('%dir' => $htaccess_path));
$num_errors++;
}
}
@@ -998,7 +994,8 @@ function _gallery_g2image_settings_form_validate(&$form_values) {
}
$title = 'Gallery2 Image Assist (g2image) Status:';
// Note that file_check_directory uses &$path and will strip the trailing '/'
- if (!file_check_directory($path)) {
+ $filename = $path . '/config.php';
+ if (is_writable($filename) == false && !file_check_directory($path)) {
$results['gallery_g2image']['title'] = $title;
$results['gallery_g2image']['warning'] = true;
$results['gallery_g2image']['notice'] = t('g2image does not seem to be installed for %mode mode in the required directory (%dir), or the directory is not writable. Please see the INSTALL.txt for instructions.', array('%mode' => $mode, '%dir' => '&lt;drupal_path&gt;'.$path));
diff --git a/gallery_user.inc b/gallery_user.inc
index 74f471a..7976c11 100644
--- a/gallery_user.inc
+++ b/gallery_user.inc
@@ -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);
}
}