--- lightbox2.module.old 2007-04-11 22:38:58.000000000 +0100 +++ lightbox2.module 2007-04-11 23:13:24.000000000 +0100 @@ -59,6 +59,44 @@ } /** +* Implementation of hook_perm() +* Define the permissions this module uses +*/ +function faq_perm() { + return array('administer lightbox2'); +} + + +/** +* Implementation of hook_access() +*/ +function lightbox2_access($op, $node) { + return user_access('administer lightbox2'); +} + +/** +* Implementation of hook_menu() +*/ +function lightbox2_menu($may_cache) { + $items = array(); + + if ($may_cache) { + $items[] = array('path' => 'admin/settings/lightbox2', + 'title' => t('Lightbox2'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('lightbox2_settings_form'), + 'access' => user_access('administer lightbox2'), + 'description' => t('Allows the user to configure the lightbox2 settings.'), + ); + } + else { + } + + return $items; +} + + +/** * Implementation of hook_nodeapi(). */ function lightbox2_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { @@ -74,16 +112,14 @@ } } -/** - * Implementation of hook_settings(). - */ -function lightbox2_settings() { +function lightbox2_settings_form() { + // Define Lightbox2 Plus form. $form["lightbox2_plus_options"] = array( "#type" => "fieldset", "#title" => t("Lightbox2 Plus"), "#collapsible" => TRUE, - "#collapsed" => FALSE, + "#collapsed" => FALSE, ); // Add Checkbox for Lightbox2 Plus. $form["lightbox2_plus_options"]["lightbox2_plus"] = array( @@ -98,7 +134,7 @@ "#type" => "fieldset", "#title" => t("Lightbox2 Plus Image Node options"), "#collapsible" => TRUE, - "#collapsed" => TRUE, + "#collapsed" => TRUE, ); // Add Checkbox for Image Node. $form["image_node_options"]["lightbox2_image_node"] = array( @@ -106,7 +142,6 @@ "#title" => t("Enable for Image Nodes"), "#description" => t("Checking this box will enable automatic URL formatting for Image Nodes."), "#default_value" => variable_get("lightbox2_image_node", true), - "#return_value" => true, ); // Add Checkbox for Image Node Grouping. $form["image_node_options"]["lightbox2_image_group"] = array( @@ -114,7 +149,6 @@ "#title" => t("Enable Grouping"), "#description" => t("Checking this box will enable automatic grouping of Image Nodes on a page. Useful for image galleries."), "#default_value" => variable_get("lightbox2_image_group", true), - "#return_value" => true, ); // Add Checkbox for Gallery2 Image Filter. $form["image_node_options"]["lightbox2G2_filter"] = array( @@ -122,17 +156,34 @@ "#title" => t("Enable Gallery 2 Filter"), "#description" => t("Checking this box will enable the Gallery 2 filter."), "#default_value" => variable_get("lightbox2G2_filter", true), - "#return_value" => true, ); - + + $form["update"] = array( + '#type' => 'submit', + '#value' => t('Update'), + '#weight' => 3, + ); + + return $form; } + +function lightbox2_settings_form_submit($form_id, $form_values) { + if ($form_values['op'] == t('Update')) { + variable_set("lightbox2_plus", $form_values["lightbox2_plus"]); + variable_set("lightbox2G2_filter", $form_values["lightbox2G2_filter"]); + variable_set("lightbox2_image_node", $form_values["lightbox2_image_node"]); + variable_set("lightbox2_image_group", $form_values["lightbox2_image_group"]); + } +} + /** *Implementation of hook_filter(). */ function lightbox2_filter_tips($delta, $format, $long = false) { return t('Image links from G2 are formatted for use with Lightbox.V2'); } + // Check to see if the G2 Filter is Enabled in Settings if (variable_get("lightbox2G2_filter", true)) { function lightbox2_filter($op, $delta = 0, $format = -1, $text = '') {