Project

General

Profile

Download (2.03 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
 * @todo Please document this function.
33
 * @see http://drupal.org/node/1354
34
 */
35
function _rename_variable($old_name, $new_name) {
36
  $success = FALSE;
37
  $value = variable_get($old_name, FALSE);
38
  variable_del($old_name);
39
  if ($value !== FALSE) {
40
    variable_set($new_name, $value);
41
    $success = variable_get($new_name, FALSE) === $value;
42
  }
43
  else {
44
    $success = TRUE;
45
  }
46

    
47
  return array('success' => $success, 'query' => "Renaming variable $old_name to $new_name");
48
}
49

    
50
/**
51
 * @todo Please document this function.
52
 * @see http://drupal.org/node/1354
53
 */
54
function _remove_variable($name) {
55
  variable_del($name);
56
  return array('success' => TRUE, 'query' => "Removing variable $name");
57
}
58

    
59
/**
60
 * @todo Please document this function.
61
 * @see http://drupal.org/node/1354
62
 */
63
function _create_variable($name, $value) {
64
  variable_set($name, $value);
65
  return array('success' => TRUE, 'query' => "Creating variable $name new value: $value");
66
}
67

    
68
/**
69
 * @todo Please document this function.
70
 * @see http://drupal.org/node/1354
71
 */
72
function _modify_variable($name, $value_override) {
73
  /*
74
   * FIXME take care for correct handling of tree variables
75
   * for example description_gallery contains the array:
76
   * Array
77
   (
78
   [cdm_dataportal_show_thumbnail_captions] => 1
79
   [cdm_dataportal_media_maxextend] => 120
80
   [cdm_dataportal_media_cols] => 4
81
   )
82
   * -----> solutions merge arrays !!!
83
   */
84
  return _create_variable($name, $value_override);
85
}
(5-5/13)