Project

General

Profile

Download (2.79 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/**
3
 * @file
4
 * Install, update and uninstall functions for the cdm_dataportal module.
5
 */
6

    
7
/**
8
 * Implements hook_install().
9
 */
10
function cdm_dataportal_install() {
11
  db_update('system')
12
    ->fields(array(
13
      'weight' => 20,
14
    ))
15
    ->condition('name', 'cdm_dataportal')
16
    ->execute();
17
}
18

    
19
/**
20
 * Implements hook_uninstall().
21
 */
22
function cdm_dataportal_uninstall() {
23
  // Delete all nodes with a cdm content type from the node table.
24
  // Comment @WA: you also may want to delete these content types from the
25
  // node_type table.
26
  db_delete('node')
27
    ->condition('type', 'cdm_%')
28
    ->execute();
29
}
30

    
31
/*
32
 * update functions:
33
 *
34
 * - 1 digit for Drupal core compatibility.
35
 * - 1 digit for your module's major release version (e.g., is this the 7.x-1.* (1) or 7.x-2.* (2) series of your module?). This digit should be 0 for initial porting of your module to a new Drupal core API.
36
 * - 2 digits for sequential counting, starting with 00.
37
 */
38

    
39
/**
40
 * update for RELEASE 3.1.3:
41
 *  - reset edit_map_server variable to default
42
 */
43
function cdm_dataportal_update_7301() {
44
  // reset edit_map_server variable to default
45
  variable_del('edit_map_server');
46
}
47

    
48
/**
49
 * update for RELEASE 3.1.4:
50
 *  - reset edit_map_server variable to default
51
 */
52
function cdm_dataportal_update_7302() {
53
  // once again reset edit_map_server variable to default
54
  variable_del('edit_map_server');
55
}
56

    
57
/**
58
 * @todo Please document this function.
59
 * @see http://drupal.org/node/1354
60
 */
61
function _rename_variable($old_name, $new_name) {
62
  $success = FALSE;
63
  $value = variable_get($old_name, FALSE);
64
  variable_del($old_name);
65
  if ($value !== FALSE) {
66
    variable_set($new_name, $value);
67
    $success = variable_get($new_name, FALSE) === $value;
68
  }
69
  else {
70
    $success = TRUE;
71
  }
72

    
73
  return array('success' => $success, 'query' => "Renaming variable $old_name to $new_name");
74
}
75

    
76
/**
77
 * @todo Please document this function.
78
 * @see http://drupal.org/node/1354
79
 */
80
function _remove_variable($name) {
81
  variable_del($name);
82
  return array('success' => TRUE, 'query' => "Removing variable $name");
83
}
84

    
85
/**
86
 * @todo Please document this function.
87
 * @see http://drupal.org/node/1354
88
 */
89
function _create_variable($name, $value) {
90
  variable_set($name, $value);
91
  return array('success' => TRUE, 'query' => "Creating variable $name new value: $value");
92
}
93

    
94
/**
95
 * @todo Please document this function.
96
 * @see http://drupal.org/node/1354
97
 */
98
function _modify_variable($name, $value_override) {
99
  /*
100
   * FIXME take care for correct handling of tree variables
101
   * for example description_gallery contains the array:
102
   * Array
103
   (
104
   [cdm_dataportal_show_thumbnail_captions] => 1
105
   [cdm_dataportal_media_maxextend] => 120
106
   [cdm_dataportal_media_cols] => 4
107
   )
108
   * -----> solutions merge arrays !!!
109
   */
110
  return _create_variable($name, $value_override);
111
}
112

    
113

    
(5-5/13)