summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThilo Wawrzik2007-04-15 20:51:36 (GMT)
committer Thilo Wawrzik2007-04-15 20:51:36 (GMT)
commit4fb8e1015a92932730358150af7add65673a1d82 (patch)
treebca538cbe6aa00d28bb251c3873c654719d7fcda
parentbc815dec20d92b2683163e15539a0205f7d5c79d (diff)
- misc. bugfixes and improved install handling
-rwxr-xr-xG2EmbedDiscoveryUtilities.class5
-rwxr-xr-xgallery.css71
-rw-r--r--gallery.module180
-rw-r--r--gallery_base.inc35
-rw-r--r--gallery_install.inc118
-rw-r--r--gallery_settings.inc20
-rw-r--r--gallery_user.inc4
7 files changed, 283 insertions, 150 deletions
diff --git a/G2EmbedDiscoveryUtilities.class b/G2EmbedDiscoveryUtilities.class
index ab5fcdc..2ea50cb 100755
--- a/G2EmbedDiscoveryUtilities.class
+++ b/G2EmbedDiscoveryUtilities.class
@@ -1,7 +1,5 @@
<?php
/*
- * $RCSfile$
- *
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2006 Bharat Mediratta
*
@@ -464,4 +462,5 @@ class G2EmbedDiscoveryUtilities {
return true;
}
}
-?> \ No newline at end of file
+
+?>
diff --git a/gallery.css b/gallery.css
index 40702f9..e60c776 100755
--- a/gallery.css
+++ b/gallery.css
@@ -4,11 +4,10 @@
* Drupal embeded Gallery2 css overrides.
* These do not make a perfect theme, but are not bad as a first step.
*/
-
/* Increase font size */
-#gallery {
- font-size: 100%;
-}
+ #gallery {
+ font-size: 100%;
+ }
/* Remove the header */
#gsHeader {
@@ -20,6 +19,43 @@
display: none;
}
+/* Drupal 5.x system.css adds a border to tbody */
+#gallery tbody {
+ border-top: none;
+}
+
+/* Garland adds a width: 100% to all tables */
+td.giAlbumCell table, td.giItemCell table {
+ width: auto;
+}
+
+/* Garland adds td and th padding which needs to be removed for imageframes.
+ Have to manually add each imageframe type -- annoying. */
+table.ImageFrame_bamboo td,
+table.ImageFrame_book td,
+table.ImageFrame_brand td,
+table.ImageFrame_dotapple td,
+table.ImageFrame_filmedges td,
+table.ImageFrame_flicking td,
+table.ImageFrame_gold td,
+table.ImageFrame_gold2 td,
+table.ImageFrame_notebook td,
+table.ImageFrame_notebooksquare td,
+table.ImageFrame_photocorners td,
+table.ImageFrame_photocorners_small td,
+table.ImageFrame_polaroid td,
+table.ImageFrame_polaroids td,
+table.ImageFrame_postage td,
+table.ImageFrame_shell td,
+table.ImageFrame_shadow td,
+table.ImageFrame_slide td,
+table.ImageFrame_slidesquare td,
+table.ImageFrame_wood td
+{
+ padding: 0;
+}
+
+
/* Brings h2 back for siteAdmin pages */
#siteAdminForm .gbBlock h2 {
display: block;
@@ -53,13 +89,23 @@
padding: 0 5px 3px 5px;
}
+/* Drupal 5.x system.css adds a border to tbody */
+.block-gallery tbody {
+ border-top: none;
+}
+
+.block-gallery td, th {
+ padding: 0; /* Garland adds padding which needs to be removed */
+}
+
/* Navigation Tree */
.block-gallery .dtree {
font-size: 1em;
}
/* For g2ic_plugin */
-img.g2image_float_left, div.g2image_float_left {
+img.g2image_float_left, div.g2image_float_left
+{
float: left;
margin: 4px;
}
@@ -83,15 +129,17 @@ img.g2image_centered, div.g2image_centered {
.g2image_clear_images {
clear: both;
-}
+ }
-.post-content img {
+.post-content img
+{
float: left;
clear: both;
margin: 4px;
}
-.page-content img {
+.page-content img
+{
float: left;
clear: both;
margin: 4px;
@@ -138,11 +186,15 @@ margin: 4px;
display: block;
padding: 1px;
}*/
-
.gallery-grid-block .one-image {
margin: 1px;
}
+/* Drupal 5.x system.css adds a border to tbody */
+.gallery-grid-block tbody {
+ border-top: none;
+}
+
td.gallery-grid-block {
text-align:center;
}
@@ -155,6 +207,7 @@ td.gallery-grid-block {
.gallery-grid-block table,
.gallery-grid-block .one-image td,
.gallery-grid-block .one-image table {
+ padding: 0; /* Garland adds padding which needs to be removed */
margin: auto;
}
diff --git a/gallery.module b/gallery.module
index b0949fd..b41b89e 100644
--- a/gallery.module
+++ b/gallery.module
@@ -23,51 +23,6 @@ function gallery_menu($may_cache) {
'callback' => variable_get('gallery_page_callback', 'gallery_page'),
'access' => user_access('access gallery'),
);
- // user administration
- $items[] = array(
- 'path' => 'admin/user/gallery',
- 'title' => t('Gallery users'),
- 'description' => t('Gallery2 user integration and synchronization'),
- 'callback' => 'gallery_users',
- 'access' => user_access('administer users'),
- );
- $items[] = array(
- 'path' => 'admin/user/gallery/users',
- 'title' => t('User Status'),
- 'access' => user_access('administer users'),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => 0
- );
- $items[] = array(
- 'path' => 'admin/user/gallery/advanced',
- 'title' => t('Advanced sync'),
- 'callback' => 'gallery_user_admin',
- 'callback arguments' => '_gallery_user_advanced',
- 'access' => user_access('administer users'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 1
- );
- $items[] = array(
- 'path' => 'admin/user/gallery/settings',
- 'title' => t('User Settings'),
- 'callback' => 'gallery_user_admin',
- 'callback arguments' => '_gallery_user_settings',
- 'access' => user_access('administer users') && user_access('administer gallery settings'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 2
- );
- $items[] = array(
- 'path' => 'admin/user/gallery/advanced_progress',
- 'callback' => 'gallery_user_admin_advanced_progress',
- 'access' => user_access('administer users'),
- 'type' => MENU_CALLBACK
- );
- $items[] = array(
- 'path' => 'admin/user/gallery/users/sync',
- 'callback' => 'gallery_users',
- 'access' => user_access('administer users'),
- 'type' => MENU_CALLBACK
- );
// settings / general administration
$items[] = array(
'path' => 'admin/settings/gallery',
@@ -86,49 +41,96 @@ function gallery_menu($may_cache) {
'type' => MENU_LOCAL_TASK,
'weight' => 0
);
- $items[] = array(
- 'path' => 'admin/settings/gallery/general',
- 'title' => t('General'),
- 'access' => user_access('administer gallery settings'),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => 1
- );
- $items[] = array(
- 'path' => 'admin/settings/gallery/blocks',
- 'title' => t('Blocks'),
- 'callback' => 'gallery_settings',
- 'callback arguments' => '_gallery_settings_blocks',
- 'access' => user_access('administer gallery settings'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 2
- );
- $items[] = array(
- 'path' => 'admin/settings/gallery/filter',
- 'title' => t('Filter'),
- 'callback' => 'gallery_settings',
- 'callback arguments' => '_gallery_settings_filter',
- 'access' => user_access('administer gallery settings'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 3
- );
- $items[] = array(
- 'path' => 'admin/settings/gallery/g2image',
- 'title' => t('G2Image'),
- 'callback' => 'gallery_settings',
- 'callback arguments' => '_gallery_settings_g2image',
- 'access' => user_access('administer gallery settings'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 4
- );
- $items[] = array(
- 'path' => 'admin/settings/gallery/search',
- 'title' => t('Search'),
- 'callback' => 'gallery_settings',
- 'callback arguments' => '_gallery_settings_search',
- 'access' => user_access('administer gallery settings'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 5
- );
+ if (variable_get('gallery_valid', 0)) {
+ $items[] = array(
+ 'path' => 'admin/settings/gallery/general',
+ 'title' => t('General'),
+ 'access' => user_access('administer gallery settings'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => 1
+ );
+ $items[] = array(
+ 'path' => 'admin/settings/gallery/blocks',
+ 'title' => t('Blocks'),
+ 'callback' => 'gallery_settings',
+ 'callback arguments' => '_gallery_settings_blocks',
+ 'access' => user_access('administer gallery settings'),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 2
+ );
+ $items[] = array(
+ 'path' => 'admin/settings/gallery/filter',
+ 'title' => t('Filter'),
+ 'callback' => 'gallery_settings',
+ 'callback arguments' => '_gallery_settings_filter',
+ 'access' => user_access('administer gallery settings'),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 3
+ );
+ $items[] = array(
+ 'path' => 'admin/settings/gallery/g2image',
+ 'title' => t('G2Image'),
+ 'callback' => 'gallery_settings',
+ 'callback arguments' => '_gallery_settings_g2image',
+ 'access' => user_access('administer gallery settings'),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 4
+ );
+ $items[] = array(
+ 'path' => 'admin/settings/gallery/search',
+ 'title' => t('Search'),
+ 'callback' => 'gallery_settings',
+ 'callback arguments' => '_gallery_settings_search',
+ 'access' => user_access('administer gallery settings'),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 5
+ );
+ // user administration
+ $items[] = array(
+ 'path' => 'admin/user/gallery',
+ 'title' => t('Gallery users'),
+ 'description' => t('Gallery2 user integration and synchronization'),
+ 'callback' => 'gallery_users',
+ 'access' => user_access('administer users'),
+ );
+ $items[] = array(
+ 'path' => 'admin/user/gallery/users',
+ 'title' => t('User Status'),
+ 'access' => user_access('administer users'),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => 0
+ );
+ $items[] = array(
+ 'path' => 'admin/user/gallery/advanced',
+ 'title' => t('Advanced sync'),
+ 'callback' => 'gallery_user_admin',
+ 'callback arguments' => '_gallery_user_advanced',
+ 'access' => user_access('administer users'),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 1
+ );
+ $items[] = array(
+ 'path' => 'admin/user/gallery/settings',
+ 'title' => t('User Settings'),
+ 'callback' => 'gallery_user_admin',
+ 'callback arguments' => '_gallery_user_settings',
+ 'access' => user_access('administer users') && user_access('administer gallery settings'),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 2
+ );
+ $items[] = array(
+ 'path' => 'admin/user/gallery/advanced_progress',
+ 'callback' => 'gallery_user_admin_advanced_progress',
+ 'access' => user_access('administer users'),
+ 'type' => MENU_CALLBACK
+ );
+ $items[] = array(
+ 'path' => 'admin/user/gallery/users/sync',
+ 'callback' => 'gallery_users',
+ 'access' => user_access('administer users'),
+ 'type' => MENU_CALLBACK
+ );
+ }
}
else {
drupal_add_css(drupal_get_path('module', 'gallery') .'/gallery.css', 'module', 'all');
@@ -289,7 +291,7 @@ function gallery_block($op = 'list', $delta = 0, $edit = array()) {
* Main gallery display page
*/
function gallery_page() {
- if (!_gallery_init(TRUE)) {
+ if (!_gallery_init(FALSE)) {
return '';
}
// turn off sidebar
diff --git a/gallery_base.inc b/gallery_base.inc
index 082efac..ea5b42e 100644
--- a/gallery_base.inc
+++ b/gallery_base.inc
@@ -44,13 +44,15 @@ function _gallery_init($full = FALSE, $vars = NULL) {
if (!$vars) {
$embedPath = variable_get('gallery_dir', './gallery2/') . 'embed.php';
$g2Uri = variable_get('gallery_uri', '/gallery2/');
- $embedUri = variable_get('gallery_embed_uri', '?q=gallery');
+ $embedUri = variable_get('gallery_embed_uri', '?q=gallery');
$gallery_valid = variable_get('gallery_valid', 0);
+ $uid = ($user->uid > 0) ? $user->uid : '';
} else {
$embedPath = $vars['gallery_dir'] . 'embed.php';
$g2Uri = $vars['gallery_uri'];
- $embedUri = $vars['gallery_embed_uri'];
- $gallery_valid = $vars['gallery_valid'];
+ $embedUri = $vars['gallery_embed_uri'];
+ $gallery_valid = $vars['gallery_valid'];
+ $uid = '';
}
$init_err_msg = t('Unable to initialize embedded Gallery. You need to <a href="@link"> configure your embedded Gallery</a>.', array('@link' => url('admin/settings/gallery/install')));
@@ -61,8 +63,7 @@ function _gallery_init($full = FALSE, $vars = NULL) {
}
include_once($embedPath);
-
- $uid = ($user->uid > 0) ? $user->uid : '';
+
$params = array('embedUri' => $embedUri,
'g2Uri' => $g2Uri,
'loginRedirect' => url('user/login', NULL, NULL, TRUE),
@@ -99,9 +100,27 @@ function gallery_handle_request() {
if ($output) {
preg_match('%<div id="giStackTrace" [^>]*>(.*?)</div>%is', $output, $matches);
- gallery_error(t('Error handling request (invalid request).'), $matches[1]);
+ gallery_error(t('Error handling request (invalid request)<br />or the requested Gallery URL does not exist.'), $matches[1]);
+ return NULL;
+ }
+
+ /*
+ // switch theme
+ $themeid = variable_get('gallery_theme', GALLERY_NO_EMBED_THEME);
+ if ($themeid != GALLERY_NO_EMBED_THEME) {
+ list ($ret, $theme) = GalleryCoreApi::loadPlugin('theme', $themeid, false, true);
+ if ($ret) {
+ gallery_error(t('Error switching theme'), $ret);
+ return NULL;
+ }
+ }
+ //////
+ $ret = GalleryCoreApi::setPluginParameter('module', 'core', 'theme', $themeid);
+ if ($ret) {
+ gallery_error(t('Error switching theme'), $ret);
return NULL;
}
+ */
return $result;
}
@@ -262,7 +281,7 @@ function _gallery_split_imageblock($html) {
function gallery_error($msg, $ret = NULL, $force = FALSE) {
$error_mode = variable_get('gallery_error_mode', array(GALLERY_ERROR_WATCHDOG));
// verbose error messages
- if ((in_array(GALLERY_ERROR_VERBOSE, $error_mode) || variable_get('gallery_debug', 0))) {
+ if (in_array(GALLERY_ERROR_VERBOSE, $error_mode) || variable_get('gallery_debug', 0)) {
$msg = $ret ? (is_object($ret) ? ($msg . '<br />' . $ret->getAsHtml()) : $ret) : $msg;
if (function_exists('debug_backtrace')) {
$trace = debug_backtrace();
@@ -342,7 +361,7 @@ function gallery_format_status($status = array(), $title = 'Gallery message(s):'
}
function gallery_version($setstatus = TRUE) {
- if (!_gallery_init(TRUE)) {
+ if (!_gallery_init(FALSE)) {
return '';
}
diff --git a/gallery_install.inc b/gallery_install.inc
index 5209c36..7a7f92d 100644
--- a/gallery_install.inc
+++ b/gallery_install.inc
@@ -41,6 +41,7 @@ function _gallery_install() {
} else {
$extra = t(' (Manually entered value)');
}
+
$form['install']['gallery_dir'] = array(
'#type' => 'textfield',
'#title' => t('Location of Gallery2') . $extra,
@@ -60,29 +61,36 @@ function _gallery_install() {
'#description' => t('URI to access G2 via drupal. Don\'t worry if you are using clean urls in drupal and this still ends in \'index.php?q=gallery\'. This is needed to get the Gallery2 URL rewrite module to work correctly and will not be visible.'),
);
+ $form['install']['gallery_valid'] = array('#type' => 'value', '#value' => TRUE);
+ $form['buttons']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
+ $form['buttons']['reset'] = array('#type' => 'submit', '#value' => t('Reset to defaults'));
+
$form['#validate']['_gallery_install_validate'] = array();
- return system_settings_form($form);
+ $form['#submit']['_gallery_install_submit'] = array();
+
+ return $form;
}
/**
* Validate the gallery form settings
*/
-function _gallery_install_validate($form_id, &$form_values) {
+function _gallery_install_validate($form_id, $form_values, $form) {
+ if ($form_values['op'] != t('Save configuration')) {
+ return;
+ }
+
include_once(drupal_get_path('module', 'gallery') .'/G2EmbedDiscoveryUtilities.class');
include_once(drupal_get_path('module', 'gallery') .'/G2EmbedTestUtilities.class');
- $gallery_valid = TRUE;
-
- // Store the original values for the variables
- $orig['g2Uri'] = $form_values['gallery_uri'];
- $orig['g2EmbedPath'] = $form_values['gallery_dir'];
- $orig['embedUri'] = $form_values['gallery_embed_uri'];
-
- // Check these variables
+ // Save these variables ...
+ $orig_values['g2Uri'] = $form_values['gallery_uri'];
+ $orig_values['g2EmbedPath'] = $form_values['gallery_dir'];
+ $orig_values['embedUri'] = $form_values['gallery_embed_uri'];
+ // ... and try to verify/autodetect locations
list($num_errors, $num_warnings, $detect_values, $results) =
- G2EmbedTestUtilities::checkLocations($orig, $form_values['gallery_autodetect_dir']);
+ G2EmbedTestUtilities::checkLocations($orig_values, $form_values['gallery_autodetect_dir']);
if ($num_errors) {
- $gallery_valid = FALSE;
+ $form_values['gallery_valid'] = FALSE;
}
// Update the variables with the new validated ones
@@ -94,63 +102,62 @@ function _gallery_install_validate($form_id, &$form_values) {
list($num_errors, $num_warnings, $pre_init_results) = G2EmbedTestUtilities::preInitTests();
$results = array_merge($results, $pre_init_results);
if ($num_errors) {
- $gallery_valid = FALSE;
+ $form_values['gallery_valid'] = FALSE;
}
-
+
// If the filepaths seem correct then check Gallery2 works and has the correct module configs
// This code is modified from the WPG2 integration code -- Thanks.
- if ($gallery_valid) {
+ if ($form_values['gallery_valid']) {
// Gallery install is thought valid, so init it.
- $title = t('Gallery2 Init:');
- $vars['gallery_uri'] = $form_values['gallery_uri'];
- $vars['gallery_dir'] = $form_values['gallery_dir'];
- $vars['gallery_embed_uri'] = $form_values['gallery_embed_uri'];
- $vars['gallery_valid'] = TRUE;
- if (!_gallery_init(TRUE, $vars)) {
+ if (!_gallery_init(TRUE, $form_values)) {
// Gallery install was supposed to be valid, but it still failed. Something is wrong.
- $results['gallery_init']['title'] = $title;
+ $results['gallery_init']['title'] = t('Gallery2 Init:');
$results['gallery_init']['error'] = TRUE;
$results['gallery_init']['notice'] = t('Everything seemed OK, but the Gallery could still not be initialised. Perhaps a manually entered value is incorrect.');
- $gallery_valid = FALSE;
+ $form_values['gallery_valid'] = FALSE;
}
else {
- $results['gallery_init']['title'] = $title;
+ $results['gallery_init']['title'] = t('Gallery2 Init:');
$results['gallery_init']['success'] = TRUE;
gallery_version();
list($num_errors, $num_warnings, $post_init_results) = G2EmbedTestUtilities::postInitTests();
if ($num_errors) {
- $gallery_valid = FALSE;
+ $form_values['gallery_valid'] = FALSE;
}
+
+ GalleryEmbed::done();
// Update the URL Rewrite Configuration
if ($post_init_results['urlrewrite']['success']) {
list($url_conf_num_errors, $url_conf_num_warnings, $post_init_results['urlrewrite2']) =
_gallery_install_url_rewrite();
}
-
$results = array_merge($results, $post_init_results);
-
- GalleryEmbed::done();
}
}
// Test again for validity
- if ($gallery_valid) {
+ if ($form_values['gallery_valid']) {
$status['gallery_valid']['title'] = t('Overall Status (Installation):');
$status['gallery_valid']['success'] = TRUE;
- } else {
+ }
+ else {
$status['gallery_valid']['title'] = t('Overall Status (Installation):');
$status['gallery_valid']['error'] = TRUE;
- $status['gallery_valid']['notice'] = t('You need to fix the above errors before Gallery2 will be embedded in Drupal.');
+ $status['gallery_valid']['notice'] = t('You need to fix the errors before Gallery2 will be embedded in Drupal.');
}
$results += $status;
+ // change value in the form to make them available in #submit
+ form_set_value($form['install']['gallery_uri'], $form_values['gallery_uri']);
+ form_set_value($form['install']['gallery_dir'], $form_values['gallery_dir']);
+ form_set_value($form['install']['gallery_embed_uri'], $form_values['gallery_embed_uri']);
+ form_set_value($form['install']['gallery_valid'], $form_values['gallery_valid']);
+
gallery_set_status($status);
drupal_set_message(gallery_format_status($results, t('Embedded Gallery2 Status: ')));
-
- $form_values['gallery_valid'] = $gallery_valid;
}
/**
@@ -168,12 +175,11 @@ function _gallery_install_url_rewrite() {
// Find the path to drupal. Will this always work?
$htaccess_path = realpath(".") . '/';
- $title = t('Gallery2 URL Rewrite Module Auto-Configuration:');
- $results['urlrewrite']['title'] = $title;
+ $results['urlrewrite']['title'] = t('Gallery2 URL Rewrite Module Auto-Configuration:');
list ($ret, $rewriteApi) = GalleryCoreApi::newFactoryInstance('RewriteApi');
if ($ret) {
- /* G2 Error handling */
+ // G2 Error handling //
// All other tests were run already
$results['urlrewrite']['error'] = TRUE;
$results['urlrewrite']['notice'] = t(
@@ -189,7 +195,8 @@ function _gallery_install_url_rewrite() {
if (is_writable($htaccess_path . '.htaccess')) {
$f = fopen($htaccess_path . '.htaccess', 'w');
fclose($f);
- } else {
+ }
+ else {
$results['urlrewrite']['error'] = TRUE;
$results['urlrewrite']['notice'] = t('There is no .htaccess file in your defined Drupal directory (@dir) and the directory is not writable. Please create a writable .htaccess file in that directory.', array('@dir' => $htaccess_path));
$num_errors++;
@@ -212,10 +219,12 @@ function _gallery_install_url_rewrite() {
$results['urlrewrite']['error'] = TRUE;
$results['urlrewrite']['notice'] = t('The Gallery2 URL Rewrite module returned the following error:') . '<pre>' . $errstr . '</pre>';
$num_errors++;
- } else {
+ }
+ else {
$results['urlrewrite']['success'] = TRUE;
}
- } else {
+ }
+ 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));
$num_errors++;
@@ -225,4 +234,35 @@ function _gallery_install_url_rewrite() {
return array($num_errors, $num_warnings, $results['urlrewrite']);
}
+function _gallery_install_submit($form_id, $form_data) {
+ if ($form_data['op'] == t('Save configuration')) {
+ // save configuration
+ variable_set('gallery_uri', $form_data['gallery_uri']);
+ variable_set('gallery_autodetect_dir', $form_data['gallery_autodetect_dir']);
+ variable_set('gallery_dir', $form_data['gallery_dir']);
+ variable_set('gallery_embed_uri', $form_data['gallery_embed_uri']);
+ if (!variable_get('gallery_valid', 0) && $form_data['gallery_valid']) {
+ global $user;
+ // we are slipping into a valid configuration, we must sync the
+ // current user to avoid errors during GalleryEmbed::init()
+ require_once(drupal_get_path('module', 'gallery') .'/gallery_user.inc');
+ gallery_user_modify($user, 'update', TRUE, $form_data);
+ drupal_set_message(t('You should now synchronize your users on the <a href="@user-admin">Gallery users</a> page.',
+ array('@user-admin' => url('admin/user/gallery'))));
+ }
+ variable_set('gallery_valid', $form_data['gallery_valid']);
+ }
+ else {
+ // reset configuration
+ variable_del('gallery_uri');
+ variable_del('gallery_autodetect_dir');
+ variable_del('gallery_dir');
+ variable_del('gallery_embed_uri');
+ variable_del('gallery_valid');
+ }
+
+ menu_rebuild();
+ drupal_set_message(t('The configuration options have been saved.'));
+}
+
?>
diff --git a/gallery_settings.inc b/gallery_settings.inc
index c73d280..27bce47 100644
--- a/gallery_settings.inc
+++ b/gallery_settings.inc
@@ -23,6 +23,26 @@ function _gallery_settings_general() {
'#collapsed' => FALSE,
);
+ /*
+ // Gallery2 Theme Settings
+ $form['theme'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Gallery2 theme settings'),
+ '#description' => '',
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
+ $themes = array(GALLERY_NO_EMBED_THEME => t('default'));
+ $themes += gallery_get_themes();
+ $form['theme']['gallery_theme'] = array(
+ '#type' => 'select',
+ '#title' => t('Gallery2 embedded theme'),
+ '#default_value' => variable_get('gallery_theme', GALLERY_NO_EMBED_THEME),
+ '#options' => $themes,
+ '#description' => t('Gallery2 will switch to this theme when viewed in embedded mode.'),
+ );
+ */
+
// Fullname settings
if (module_exists('profile')) {
$form['fullname'] = array(
diff --git a/gallery_user.inc b/gallery_user.inc
index 657be1c..b21b386 100644
--- a/gallery_user.inc
+++ b/gallery_user.inc
@@ -67,8 +67,8 @@ function gallery_user_delete($user) {
/**
* Modify (create/update/delete) a user
*/
-function gallery_user_modify($user, $action = 'create', $groups = TRUE) {
- if (!_gallery_init(TRUE)) {
+function gallery_user_modify($user, $action = 'create', $groups = TRUE, $vars = NULL) {
+ if (!_gallery_init(TRUE, $vars)) {
return FALSE;
}