1 |
c7e36592
|
Andreas Kohlbecker
|
<?php
|
2 |
|
|
// $Id$
|
3 |
|
|
|
4 |
|
|
/**
|
5 |
|
|
* Implementation of hook_install().
|
6 |
|
|
*/
|
7 |
|
|
function cdm_dataportal_install(){
|
8 |
e48b96fe
|
Andreas Kohlbecker
|
db_query(_get_sql_fix_module_weight());
|
9 |
c7e36592
|
Andreas Kohlbecker
|
}
|
10 |
|
|
|
11 |
90f6855c
|
Andreas Kohlbecker
|
/**
|
12 |
|
|
* Implementation of hook_uninstall().
|
13 |
|
|
*/
|
14 |
|
|
function cdm_dataportal_uninstall(){
|
15 |
|
|
|
16 |
|
|
cdm_delete_all_cdm_nodes();
|
17 |
|
|
}
|
18 |
|
|
|
19 |
|
|
|
20 |
c7e36592
|
Andreas Kohlbecker
|
/**
|
21 |
|
|
* Implementation of hook_api_update_N().
|
22 |
31afa334
|
Andreas Kohlbecker
|
*
|
23 |
|
|
* Database updates consist of 3 parts:
|
24 |
|
|
* 1 digit for Drupal core compatibility
|
25 |
|
|
* 1 digit for your module's major release version (e.g. is this the 5.x-1.* (1) or 5.x-2.* (2) series of your module?)
|
26 |
|
|
* 2 digits for sequential counting starting with 00
|
27 |
|
|
* The 2nd digit should be 0 for initial porting of your module to a new Drupal core API.
|
28 |
|
|
*
|
29 |
c7e36592
|
Andreas Kohlbecker
|
* Update 1 for version 5.x-1.0
|
30 |
|
|
*/
|
31 |
|
|
function cdm_dataportal_update_5101() {
|
32 |
31afa334
|
Andreas Kohlbecker
|
$items = array();
|
33 |
|
|
$items[] = update_sql(_get_sql_fix_module_weight());
|
34 |
|
|
return $items;
|
35 |
|
|
}
|
36 |
|
|
|
37 |
|
|
/**
|
38 |
|
|
* Implementation of hook_api_update_N().
|
39 |
|
|
*
|
40 |
|
|
* Database updates consist of 3 parts:
|
41 |
|
|
* 1 digit for Drupal core compatibility
|
42 |
|
|
* 1 digit for your module's major release version (e.g. is this the 5.x-1.* (1) or 5.x-2.* (2) series of your module?)
|
43 |
|
|
* 2 digits for sequential counting starting with 00
|
44 |
|
|
* The 2nd digit should be 0 for initial porting of your module to a new Drupal core API.
|
45 |
|
|
*
|
46 |
|
|
* Update 1 for version 5.x-1.0
|
47 |
|
|
*/
|
48 |
|
|
function cdm_dataportal_update_5102() {
|
49 |
c7e36592
|
Andreas Kohlbecker
|
$items = array();
|
50 |
31afa334
|
Andreas Kohlbecker
|
$items[] = _remove_variable('cdm_currentSecRef');
|
51 |
|
|
|
52 |
|
|
if(variable_get('distribution_sort', false) == 1){
|
53 |
|
|
$items[] = _modify_variable('distribution_sort', 'HIDE_TDWG2');
|
54 |
|
|
} else {
|
55 |
|
|
$items[] = _modify_variable('distribution_sort', 'NO_SORT');
|
56 |
|
|
}
|
57 |
|
|
|
58 |
31ad58f0
|
Andreas Kohlbecker
|
$items[] = _create_variable('cdm_dataportal_geoservice_distributionOpacity', '1.0');
|
59 |
|
|
$items[] = _create_variable('cdm_dataportal_geoservice_legendOpacity', '0.75');
|
60 |
|
|
|
61 |
c7e36592
|
Andreas Kohlbecker
|
return $items;
|
62 |
|
|
}
|
63 |
|
|
|
64 |
31afa334
|
Andreas Kohlbecker
|
// ------------------------- SQL Scripts ------------------------ //
|
65 |
c7e36592
|
Andreas Kohlbecker
|
|
66 |
|
|
|
67 |
|
|
function _get_sql_fix_module_weight() {
|
68 |
31afa334
|
Andreas Kohlbecker
|
return "UPDATE {system} SET weight = 20 WHERE name = 'cdm_dataportal'";
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
function _rename_variable($old_name, $new_name) {
|
72 |
|
|
$success = FALSE;
|
73 |
|
|
$value = variable_get($old_name, FALSE);
|
74 |
|
|
variable_del($old_name);
|
75 |
|
|
if($value !== FALSE){
|
76 |
|
|
variable_set($new_name, $value);
|
77 |
|
|
$success = variable_get($new_name, FALSE) === $value;
|
78 |
|
|
} else {
|
79 |
|
|
$success = TRUE;
|
80 |
|
|
}
|
81 |
|
|
|
82 |
|
|
return array('success' => $success, 'query' => "Renaming variable $old_name to $new_name");
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
function _remove_variable($name) {
|
86 |
|
|
variable_del($name);
|
87 |
|
|
return array('success' => TRUE, 'query' => "Removing variable $name");
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
|
91 |
31ad58f0
|
Andreas Kohlbecker
|
function _create_variable($name, $value) {
|
92 |
|
|
variable_set($name, $value);
|
93 |
|
|
return array('success' => TRUE, 'query' => "Creating variable $name new value: $value");
|
94 |
|
|
}
|
95 |
|
|
|
96 |
|
|
function _modify_variable($name, $value_override) {
|
97 |
31afa334
|
Andreas Kohlbecker
|
|
98 |
|
|
/*
|
99 |
|
|
* FIXME take care for correct handling of tree variables
|
100 |
|
|
* for example description_gallery contains the array:
|
101 |
|
|
* Array
|
102 |
|
|
(
|
103 |
|
|
[cdm_dataportal_show_thumbnail_captions] => 1
|
104 |
|
|
[cdm_dataportal_media_maxextend] => 120
|
105 |
|
|
[cdm_dataportal_media_cols] => 4
|
106 |
|
|
)
|
107 |
|
|
* -----> solutions merge arrays !!!
|
108 |
|
|
*/
|
109 |
|
|
|
110 |
31ad58f0
|
Andreas Kohlbecker
|
return _create_variable($name, $value_override);
|
111 |
c7e36592
|
Andreas Kohlbecker
|
}
|