Project

General

Profile

Download (2.57 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 funktions:
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.13:
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
 * @todo Please document this function.
50
 * @see http://drupal.org/node/1354
51
 */
52
function _rename_variable($old_name, $new_name) {
53
  $success = FALSE;
54
  $value = variable_get($old_name, FALSE);
55
  variable_del($old_name);
56
  if ($value !== FALSE) {
57
    variable_set($new_name, $value);
58
    $success = variable_get($new_name, FALSE) === $value;
59
  }
60
  else {
61
    $success = TRUE;
62
  }
63

    
64
  return array('success' => $success, 'query' => "Renaming variable $old_name to $new_name");
65
}
66

    
67
/**
68
 * @todo Please document this function.
69
 * @see http://drupal.org/node/1354
70
 */
71
function _remove_variable($name) {
72
  variable_del($name);
73
  return array('success' => TRUE, 'query' => "Removing variable $name");
74
}
75

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

    
85
/**
86
 * @todo Please document this function.
87
 * @see http://drupal.org/node/1354
88
 */
89
function _modify_variable($name, $value_override) {
90
  /*
91
   * FIXME take care for correct handling of tree variables
92
   * for example description_gallery contains the array:
93
   * Array
94
   (
95
   [cdm_dataportal_show_thumbnail_captions] => 1
96
   [cdm_dataportal_media_maxextend] => 120
97
   [cdm_dataportal_media_cols] => 4
98
   )
99
   * -----> solutions merge arrays !!!
100
   */
101
  return _create_variable($name, $value_override);
102
}
103

    
104

    
(5-5/13)