SA-CONTRIB-2010-095 - http://drupal.org/node/919610 - fixes XSS vulnerability
[project/lightbox2.git] / lightbox2.install
CommitLineData
ac1392ca 1<?php
7bea4c5f 2// $Id$
e6a138f1
SP
3
4/**
e14574de
SP
5 * @file
6 * Installation functions for Lightbox2.
7 */
8
9/**
ee0a41e7 10 * Implementation of hook_install().
1caf161e 11 */
ac1392ca 12function lightbox2_install() {
7b915f93 13 module_invoke('content', 'clear_type_cache');
ac1392ca
SP
14}
15
e6a138f1 16/**
ee0a41e7 17 * Implementation of hook_uninstall().
1caf161e 18 */
ac1392ca 19function lightbox2_uninstall() {
ee0a41e7 20 // Delete the variables we created.
09d4f013 21 variable_del('lightbox2_plus');
59c04a7b 22 variable_del('lightbox2G2_filter');
3e3b4759 23
59c04a7b
SP
24 // Remove the general settings.
25 variable_del('lightbox2_lite');
27f345ed
SP
26 variable_del('lightbox2_use_alt_layout');
27 variable_del('lightbox2_force_show_nav');
18afc483 28 variable_del('lightbox2_loop_items');
3e3b4759 29 variable_del('lightbox2_image_count_str');
5297a1a6 30 variable_del('lightbox2_page_count_str');
4ed8502a 31 variable_del('lightbox2_video_count_str');
3dd068be 32 variable_del('lightbox2_disable_resize');
3e3b4759 33 variable_del('lightbox2_disable_zoom');
546c243f 34 variable_del('lightbox2_enable_login');
e07af458 35 variable_del('lightbox2_enable_contact');
cab19dbc 36 variable_del('lightbox2_enable_video');
110906f3 37 variable_del('lightbox2_flv_player_path');
54f91898 38 variable_del('lightbox2_flv_player_flashvars');
983418ec
SP
39 variable_del('lightbox2_page_init_action');
40 variable_del('lightbox2_page_list');
59c04a7b
SP
41 variable_del('lightbox2_disable_these_urls');
42 variable_del('lightbox2_imagefield_group_node_id');
cab19dbc 43 variable_del('lightbox2_imagefield_use_node_title');
0392ac27 44 variable_del('lightbox2_image_ncck_group_node_id');
3dd068be 45 // Advanced settings.
d284e1a1 46 variable_del('lightbox2_js_location');
c4db83a0
SP
47 variable_del('lightbox2_border_size');
48 variable_del('lightbox2_box_color');
49 variable_del('lightbox2_font_color');
06ac6b1e
SP
50 variable_del('lightbox2_keys_close');
51 variable_del('lightbox2_keys_previous');
52 variable_del('lightbox2_keys_next');
53 variable_del('lightbox2_keys_zoom');
54 variable_del('lightbox2_keys_play_pause');
2434da10 55 variable_del('lightbox2_top_position');
3dd068be
SP
56 variable_del('lightbox2_overlay_opacity');
57 variable_del('lightbox2_overlay_color');
8be2588c 58 variable_del('lightbox2_disable_close_click');
3dd068be
SP
59 variable_del('lightbox2_resize_sequence');
60 variable_del('lightbox2_resize_speed');
61 variable_del('lightbox2_fadein_speed');
62 variable_del('lightbox2_slidedown_speed');
63
3e3b4759 64
59c04a7b
SP
65 // Remove slideshow settings.
66 variable_del('lightbox2_slideshow_interval');
01c6dbfe 67 variable_del('lightbox2_slideshow_automatic_start');
59c04a7b
SP
68 variable_del('lightbox2_slideshow_automatic_exit');
69 variable_del('lightbox2_slideshow_show_play_pause');
70 variable_del('lightbox2_slideshow_pause_on_next_click');
71 variable_del('lightbox2_slideshow_pause_on_previous_click');
18afc483 72 variable_del('lightbox2_loop_slides');
59c04a7b 73
8733dffc
SP
74 // Remove iframe settings.
75 variable_del('lightbox2_default_frame_width');
76 variable_del('lightbox2_default_frame_height');
68b7654c 77 variable_del('lightbox2_frame_border');
8733dffc 78
59c04a7b 79 // Remove the automatic image handling settings.
09d4f013 80 variable_del('lightbox2_image_node');
c571d3bb
SP
81 variable_del('lightbox2_display_image_size');
82 variable_del('lightbox2_trigger_image_size');
59c04a7b 83 variable_del('lightbox2_disable_nested_galleries');
ae2fcbc1 84 variable_del('lightbox2_flickr');
59c04a7b 85 variable_del('lightbox2_gallery2_blocks');
c571d3bb 86 variable_del('lightbox2_inline');
59c04a7b 87 variable_del('lightbox2_image_assist_custom');
d0fd6e66 88 variable_del('lightbox2_custom_class_handler');
c571d3bb 89 variable_del('lightbox2_custom_trigger_classes');
b5b1538e 90 variable_del('lightbox2_node_link_text');
19f4a474 91 variable_del('lightbox2_node_link_target');
59c04a7b 92 variable_del('lightbox2_image_group');
54312d03 93 variable_del('lightbox2_disable_nested_acidfree_galleries');
28b2b802 94 variable_del('lightbox2_acidfree_video');
ac1392ca 95}
e6a138f1 96
23b9eafc 97/**
e14574de
SP
98 * One of the variables was renamed from 'lightbox2_plus' to 'lightbox2_lite'.
99 */
1cadb408
SP
100function lightbox2_update_1() {
101 $ret = array();
102 switch ($GLOBALS['db_type']) {
103 case 'mysql':
104 case 'mysqli':
105 $ret[] = update_sql('UPDATE {variable} SET name="lightbox2_lite"
106 WHERE name="lightbox2_plus";');
107 break;
108
109 case 'pgsql':
110 $ret[] = update_sql('UPDATE {variable} SET name="lightbox2_lite"
111 WHERE name="lightbox2_plus";');
112 break;
113 }
114
115 return $ret;
116}
117
23b9eafc
SP
118/**
119 * 'lightbox2_image_group' variable has been removed and others need to be
120 * updated accordingly.
121 */
122function lightbox2_update_2() {
123 $image_group = variable_get('lightbox2_image_group', TRUE);
124 $image_node = variable_get('lightbox2_image_node', TRUE);
125 $flickr = variable_get('lightbox2_flickr', TRUE);
126 $gallery2 = variable_get('lightbox2_gallery2_blocks', TRUE);
127 $inline = variable_get('lightbox2_inline', TRUE);
128 $image_assist = variable_get('lightbox2_image_assist_custom', TRUE);
1cadb408 129
23b9eafc
SP
130 if ($image_group) {
131 if ($image_node) {
132 variable_set('lightbox2_image_node', 2);
133 }
134 if ($flickr) {
135 variable_set('lightbox2_flickr', 2);
136 }
137 if ($gallery2) {
138 variable_set('lightbox2_gallery2_blocks', 2);
139 }
140 if ($inline) {
141 variable_set('lightbox2_inline', 2);
142 }
143 if ($image_assist) {
144 variable_set('lightbox2_image_assist_custom', 2);
145 }
146 }
147 variable_del('lightbox2_image_group');
148
149 return array();
150}
983418ec
SP
151
152/**
153 * 'lightbox2_disable_these_urls' was renamed to 'lightbox2_page_list'.
154 * 'lightbox2_page_init_action' was also added which determines whether the
155 * lightbox functionality should be enabled or disabled for the page list.
3dd068be
SP
156 * 'lightbox2_disable_zoom' has been replaced by 'lightbox2_disable_resize'.
157 * 'lightbox2_disable_zoom' still exists but has a different meaning.
983418ec
SP
158 */
159function lightbox2_update_3() {
160 $disabled_urls = variable_get('lightbox2_disable_these_urls', '');
161 variable_set('lightbox2_page_init_action', 'page_disable');
162 variable_set('lightbox2_page_list', $disabled_urls);
3dd068be
SP
163 variable_del('lightbox2_disable_these_urls');
164
165 $disable_zoom = variable_get('lightbox2_disable_zoom', FALSE);
166 variable_set('lightbox2_disable_resize', $disable_zoom);
167 variable_set('lightbox2_disable_zoom', FALSE);
983418ec
SP
168
169 return array();
170}
1b8efa95
SP
171
172function lightbox2_update_4() {
173 $size = variable_get('lightbox2_display_image_size', 'original');
174 if ($size == '') {
175 variable_set('lightbox2_display_image_size', 'original');
176 }
177 return array();
178}
179
d49487e3
SP
180/**
181 * Menu paths changed.
182 */
183function lightbox2_update_5() {
184 menu_rebuild();
185 return array();
186}
187