Projet

Général

Profil

Paste
Télécharger (2,81 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / twitter_block / twitter_block.install @ 66b5cbf6

1 85ad3d82 Assos Assos
<?php
2
3
/**
4
 * @file
5
 * Install, update and uninstall functions for the twitter_block module.
6
 */
7
8
/**
9
 * Implements hook_schema().
10
 */
11
function twitter_block_schema() {
12
  $schema['twitter_block'] = array(
13
    'description' => 'The table for storing twitter blocks.',
14
    'fields' => array(
15
      'bid' => array(
16
        'type' => 'serial',
17
        'unsigned' => TRUE,
18
        'not null' => TRUE,
19
        'description' => "The block's {block}.bid.",
20
      ),
21
      'info' => array(
22
        'type' => 'varchar',
23
        'length' => 128,
24
        'not null' => TRUE,
25
        'default' => '',
26
        'description' => 'Block description.',
27
      ),
28
      'widget_id' => array(
29
        'type' => 'varchar',
30
        'length' => 128,
31
        'not null' => TRUE,
32
        'default' => '',
33
        'description' => 'Widget ID.',
34
      ),
35 66b5cbf6 Assos Assos
      'username' => array(
36
        'type' => 'varchar',
37
        'length' => 128,
38
        'not null' => TRUE,
39
        'default' => '',
40
        'description' => 'Account username.',
41
      ),
42 85ad3d82 Assos Assos
      'data' => array(
43
        'type' => 'blob',
44
        'size' => 'big',
45
        'not null' => TRUE,
46
        'serialize' => TRUE,
47
        'description' => 'Serialized data containing the timeline properties.',
48
      ),
49
    ),
50
    'unique keys' => array(
51
      'info' => array('info'),
52
      'widget_id' => array('widget_id'),
53
    ),
54
    'primary key' => array('bid'),
55
  );
56
57
  return $schema;
58
}
59
60
/**
61
 * Implements hook_uninstall().
62
 */
63
function twitter_block_uninstall() {
64 66b5cbf6 Assos Assos
  // Remove blocks.
65 85ad3d82 Assos Assos
  db_delete('block')
66
    ->condition('module', 'twitter_block')
67
    ->execute();
68
  db_delete('block_role')
69
    ->condition('module', 'twitter_block')
70
    ->execute();
71
72 66b5cbf6 Assos Assos
  // Remove variables.
73
  variable_del('twitter_block_cache');
74
  variable_del('twitter_block_last_cache');
75
76
  // Remove the cache directory.
77
  twitter_block_clear_js_cache();
78
79
  // Clear the site cache.
80 85ad3d82 Assos Assos
  cache_clear_all();
81
}
82
83
/**
84
 * Remove any old Twitter Block blocks and install the new Twitter Block schema.
85
 */
86
function twitter_block_update_7200() {
87 66b5cbf6 Assos Assos
  // Remove old Twitter Block schema.
88 85ad3d82 Assos Assos
  drupal_uninstall_schema('twitter_block');
89
90 66b5cbf6 Assos Assos
  // Remove any old Twitter Block blocks.
91 85ad3d82 Assos Assos
  db_delete('block')
92
    ->condition('module', 'twitter_block')
93
    ->execute();
94
  db_delete('block_role')
95
    ->condition('module', 'twitter_block')
96
    ->execute();
97
98 66b5cbf6 Assos Assos
  // Clear the site cache.
99 85ad3d82 Assos Assos
  cache_clear_all();
100
101 66b5cbf6 Assos Assos
  // Install the new Twitter Block schema.
102 85ad3d82 Assos Assos
  drupal_install_schema('twitter_block');
103
104
  return t('Removed any old Twitter Block blocks and installed the new Twitter Block schema.');
105
}
106 66b5cbf6 Assos Assos
107
/**
108
 * Add a column to the {twitter_block} table to store the Twitter account username.
109
 */
110
function twitter_block_update_7201() {
111
  db_add_field('twitter_block', 'username', array(
112
    'type' => 'varchar',
113
    'length' => 128,
114
    'not null' => TRUE,
115
    'default' => '',
116
    'description' => 'Account username.',
117
  ));
118
}