'gallery', 'title' => t('Gallery'), 'description' => t('Visit your embedded Gallery2.'), 'callback' => 'gallery_page', 'access' => user_access('access gallery'), ); } // settings / general administration $items[] = array( 'path' => 'admin/settings/gallery', 'title' => t('Gallery settings'), 'callback' => 'gallery_settings', 'callback arguments' => '_gallery_settings_general', 'description' => t('Configure settings for embedding Gallery2 into Drupal.'), 'access' => user_access('administer gallery settings'), ); $items[] = array( 'path' => 'admin/settings/gallery/install', 'title' => t('Install'), 'callback' => 'gallery_settings', 'callback arguments' => '_gallery_settings_install', 'access' => user_access('administer gallery settings'), 'type' => variable_get('gallery_valid', 0) ? MENU_LOCAL_TASK : MENU_DEFAULT_LOCAL_TASK, 'weight' => 0 ); 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/filter', 'title' => t('Filter'), 'callback' => 'gallery_settings', 'callback arguments' => '_gallery_settings_filter', 'access' => user_access('administer gallery settings'), 'type' => MENU_LOCAL_TASK, 'weight' => 2 ); $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' => 3 ); if (module_exists('search')) { $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' => 4 ); } $items[] = array( 'path' => 'admin/settings/gallery/report', 'callback' => 'gallery_report', 'access' => user_access('administer site configuration'), 'type' => MENU_CALLBACK ); // 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'); drupal_add_css(drupal_get_path('module', 'gallery') .'/gallery_filter.css'); // Switch theme for gallery pages if (arg(0) == 'gallery' && ($custom_theme = variable_get('gallery_page_theme', NULL)) != 'default') { init_theme(); } } return $items; } /** * Implementation of hook_help(). */ function gallery_help($section) { require_once(drupal_get_path('module', 'gallery') .'/gallery_help.inc'); return _gallery_help($section); } /** * Function gallery_settings(). */ function gallery_settings($form = '_gallery_settings_general') { require_once(drupal_get_path('module', 'gallery') .'/gallery_settings.inc'); return drupal_get_form(variable_get('gallery_valid', 0) ? $form : '_gallery_settings_install'); } /** * Function gallery_report(). */ function gallery_report($download = NULL) { require_once(drupal_get_path('module', 'gallery') .'/gallery_report.inc'); return _gallery_report(isset($download)); } /** * Implementation of hook_info(). */ function gallery_info($field = NULL) { $info['name'] = 'Gallery2'; $info['protocol'] = 'internal'; return isset($field) ? $info[$field] : $info; } /** * Implementation of hook_auth(). */ function gallery_auth($username, $password, $server) { if (_gallery_init()) { // Is the user allowed to login? list($ret, $disabled) = GalleryCoreApi::isDisabledUsername($username); if (!$ret && !$disabled) { // Load G2 user to get the hashed password list($ret, $g2_user) = GalleryCoreApi::fetchUserByUsername($username); if (!$ret) { // Authenticate the G2 user if (GalleryUtilities::isCorrectPassword($password, $g2_user->hashedPassword)) { // Does this user exist in Drupal, then override password // (so that next time the user can be authenticated directly) if ($user = user_load(array('name' => $username, 'status' => 1))) { user_save($user, array('pass' => $password)); return TRUE; } } } } } return FALSE; } /** * Implementation of hook_user(). */ function gallery_user($op, &$edit, &$user, $category = NULL) { require_once(drupal_get_path('module', 'gallery') .'/gallery_user.inc'); switch ($op) { case 'login': gallery_login(); break; case 'logout': gallery_logout(); break; case 'view': return gallery_user_view($user); case 'insert': return gallery_user_insert($edit, drupal_clone($user)); case 'update': return gallery_user_update($edit, drupal_clone($user)); case 'delete': return gallery_user_delete($user); } } /** * Function gallery_users(). * (gallery user administration) */ function gallery_users($args = NULL) { require_once(drupal_get_path('module', 'gallery') .'/gallery_user_admin.inc'); return _gallery_user_users($args); } /** * Function gallery_user_admin(). */ function gallery_user_admin($form) { require_once(drupal_get_path('module', 'gallery') .'/gallery_user_admin.inc'); return drupal_get_form($form); } /** * Function gallery_user_admin_advanced_progress(). */ function gallery_user_admin_advanced_progress() { require_once(drupal_get_path('module', 'gallery') .'/gallery_user_admin.inc'); return _gallery_user_advanced_progress(); } /** * Implementation of hook_search(). */ function gallery_search($op = 'search', $keys = NULL) { require_once(drupal_get_path('module', 'gallery') .'/gallery_search.inc'); return _gallery_search($op, $keys); } /** * Implementation of hook_search_item(). * (override how to display the item) */ function gallery_search_page($results) { require_once(drupal_get_path('module', 'gallery') .'/gallery_search.inc'); return _gallery_search_page($results); } /** * Implementation of hook_form_alter(). */ function gallery_form_alter($form_id, &$form) { if (($form_id == 'user_admin_role') || ($form_id == 'user_admin_new_role')) { require_once(drupal_get_path('module', 'gallery') .'/gallery_groups.inc'); $form['#submit']['_gallery_groups_submit'] = array(); } elseif ($form_id == 'search_form' && arg(1) == 'gallery' && variable_get('gallery_search_advanced', 1) && user_access('access gallery')) { require_once(drupal_get_path('module', 'gallery') .'/gallery_search.inc'); _gallery_search_form($form); } elseif ($form_id == 'user_register' && count(module_implements('info')) < 2) { unset($form['affiliates']); } } /** * Implementation of hook_filter(). */ function gallery_filter($op, $delta = 0, $format = -1, $text = '') { require_once(drupal_get_path('module', 'gallery') .'/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', TRUE); default: return $text; } } /** * Implementation of hook_filter_tips(). */ function gallery_filter_tips($delta = 0, $format = -1, $long = FALSE) { require_once(drupal_get_path('module', 'gallery') .'/gallery_help.inc'); if ($long) { return gallery_filter_long_tip_translated(); } else { return gallery_filter_short_tip_translated(); } } /** * Implementation of hook_elements(). */ function gallery_elements() { $type['textarea'] = array('#process' => array('gallery_g2image_textarea' => array())); return $type; } /** * Function gallery_g2image_textarea(). * (add image link underneath textareas) */ function gallery_g2image_textarea($element) { require_once(drupal_get_path('module', 'gallery') .'/gallery_g2image.inc'); if (_gallery_g2image_page_match() && !strstr($_GET['q'], 'gallery') && (variable_get('gallery_g2image_mode', 'disabled') == 'standalone') && (user_access('access standalone g2image'))) { gallery_g2image_add_js(); $output = theme('gallery_g2image_textarea_link', $element, $link); $element['#suffix'] .= $output; } return $element; } /** * Implementation of hook_block(). */ function gallery_block($op = 'list', $delta = 0, $edit = array()) { require_once(drupal_get_path('module', 'gallery') .'/gallery_block.inc'); if (variable_get('gallery_valid', 0)) { return _gallery_block($op, $delta, $edit); } } /** * Function gallery_page(). * (main gallery display page) */ function gallery_page() { if (!_gallery_init()) { return ''; } // Turn off sidebar if (variable_get('gallery_move_sidebar_to_block', 1)) { GalleryCapabilities::set('showSidebarBlocks', FALSE); } $result = gallery_handle_request(); // Pass $result to gallery_menu_page() if available if (module_exists('gallery_menu')) { gallery_menu_page($result); } // Now format the page, breadcrumb and sidebars if ($result && !$result['isDone']) { gallery_set_head($result['headHtml'], TRUE); // Add pathbar (see http://gallery.menalto.com/node/33447) if (isset($result['themeData'])) { $breadcrumb = array(l(t('Home'), '')); // Some themes (eg hybrid) do not set $result['themeData']['parents'] if ($result['themeData']['parents']) { foreach ($result['themeData']['parents'] as $parent) { $parent_title = _gallery_htmlcharsdecode($parent['title']); // Simple strip of bbcode (italic, bold) $parent_title = str_replace( array('[i]', '[/i]', '[b]', '[/b]'), array('', '', '', ''), $parent_title ); $parent_title = str_replace('[/i]', '', $parent_title); // Still does not generate a clean url for /gallery (uses index.php?q=gallery) $link = gallery_generate_url(array('itemId' => $parent['id']), FALSE); $breadcrumb[] = l($parent_title, $link); } } drupal_set_breadcrumb($breadcrumb); } // Hack to get the admin sidebar if (variable_get('gallery_move_admin_sidebar_to_block', 0)) { if (preg_match("/^(.*)(.*?)(<\/td>.*?)$/s", $result['bodyHtml'], $match)) { // New body $result['bodyHtml'] = $match[1] . $match[3]; // Insert admin sidebar in $result['sidebarBlocksHtml'] if (empty($result['sidebarBlocksHtml'][1])) { $result['sidebarBlocksHtml'][1] = $match[2]; } else { $result['sidebarBlocksHtml'][] = $match[2]; } } } // Store the sidebar info in a global variable for use in the gallery navigation block $GLOBALS['gallery_sidebar'] = $result['sidebarBlocksHtml']; return $result['bodyHtml']; } return ''; } /** * Implementation of hook_xmlsitemap_links(). * (define additional links to add to the site map) */ function gallery_xmlsitemap_links($type = NULL, $excludes = array()) { if (($type != 'xml') || !variable_get('gallery_enable_sitemap', 1) || !_gallery_init(TRUE)) { return; } list($ret, $view) = GalleryView::loadView('sitemap.Sitemap'); if ($ret) { gallery_error(t('Error loading the Gallery2 Sitemap. Make sure the \'Sitemap\' plugin is enabled in Gallery2.'), $ret); return; } list($ret, $root) = GalleryCoreApi::getDefaultAlbumId(); if ($ret) { gallery_error(t('Error calling getDefaultAlbumId()'), $ret); return; } // Get the sitemap from Gallery2 ob_start(); $ret = $view->renderSitemap($root); $g2_sitemap = ob_get_contents(); ob_end_clean(); if ($ret) { gallery_error(t('Error getting sitemap from Gallery2.'), $ret); return; } return $g2_sitemap; }