Project

General

Profile

Download (3.94 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
// $Id$
3

    
4
/**
5
 * Implementation of hook_install().
6
 */
7
function cdm_dataportal_install(){
8
   db_query(_get_sql_fix_module_weight());
9
}
10

    
11
/**
12
 * Implementation of hook_uninstall().
13
 */
14
function cdm_dataportal_uninstall(){
15

    
16
   cdm_delete_all_cdm_nodes();
17
}
18

    
19

    
20
/**
21
 * Implementation of hook_api_update_N().
22
 *
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
 * Update 1 for version 5.x-1.0
30
 */
31
function cdm_dataportal_update_5101() {
32
	$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 2 for version 5.x-1.0
47
 */
48
function cdm_dataportal_update_5102() {
49
  $items = array();
50
  $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
  $items[] = _create_variable('cdm_dataportal_geoservice_distributionOpacity', '1.0');
59
  $items[] = _create_variable('cdm_dataportal_geoservice_legendOpacity', '0.75');
60

    
61
  return $items;
62
}
63

    
64
/**
65
 * Implementation of hook_api_update_N().
66
 *
67
 * Database updates consist of 3 parts:
68
 *    1 digit for Drupal core compatibility
69
 *    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?)
70
 *    2 digits for sequential counting starting with 00
71
 * The 2nd digit should be 0 for initial porting of your module to a new Drupal core API.
72
 *
73
 * Update 1 for version 5.x-3.0
74
 */
75
function cdm_dataportal_update_5301() {
76
  $items = array();
77
  // add new default to
78
  $annotation_types_filter = variable_get('annotations_types_as_footnotes', FALSE);
79
  if($annotation_types_filter) {
80
    $annotation_types_filter['NULL_VALUE'] = 'NULL_VALUE';
81
  }
82
  $items[] = _modify_variable('annotations_types_as_footnotes', $annotation_types_filter);
83
  return $items;
84
}
85

    
86
// ------------------------- SQL  Scripts ------------------------ //
87

    
88

    
89
function _get_sql_fix_module_weight() {
90
	return  "UPDATE {system} SET weight = 20 WHERE name = 'cdm_dataportal'";
91
}
92

    
93
function _rename_variable($old_name, $new_name) {
94
	$success = FALSE;
95
	$value = variable_get($old_name, FALSE);
96
	variable_del($old_name);
97
	if($value !== FALSE){
98
		variable_set($new_name, $value);
99
		$success = variable_get($new_name, FALSE) === $value;
100
	} else {
101
		$success = TRUE;
102
	}
103

    
104
	return array('success' => $success, 'query' => "Renaming variable $old_name to $new_name");
105
}
106

    
107
function _remove_variable($name) {
108
  variable_del($name);
109
  return array('success' => TRUE, 'query' => "Removing variable $name");
110
}
111

    
112

    
113
function _create_variable($name, $value) {
114
  variable_set($name, $value);
115
  return array('success' => TRUE, 'query' => "Creating variable $name new value: $value");
116
}
117

    
118
function _modify_variable($name, $value_override) {
119

    
120
  /*
121
   * FIXME take care for correct handling of tree variables
122
   * for example description_gallery contains the array:
123
   * Array
124
			(
125
			    [cdm_dataportal_show_thumbnail_captions] => 1
126
			    [cdm_dataportal_media_maxextend] => 120
127
			    [cdm_dataportal_media_cols] => 4
128
			)
129
	 * -----> solutions merge arrays !!!
130
   */
131

    
132
  return _create_variable($name, $value_override);
133
}
(5-5/12)