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 |
a6e869e4
|
Assos Assos
|
}
|
76 |
66b5cbf6
|
Assos Assos
|
|
77 |
a6e869e4
|
Assos Assos
|
/**
|
78 |
|
|
* Implements hook_disable().
|
79 |
|
|
*
|
80 |
|
|
* Remove cache directory if module is disabled (or uninstalled).
|
81 |
|
|
*/
|
82 |
|
|
function twitter_block_disable() {
|
83 |
66b5cbf6
|
Assos Assos
|
twitter_block_clear_js_cache();
|
84 |
85ad3d82
|
Assos Assos
|
}
|
85 |
|
|
|
86 |
|
|
/**
|
87 |
|
|
* Remove any old Twitter Block blocks and install the new Twitter Block schema.
|
88 |
|
|
*/
|
89 |
|
|
function twitter_block_update_7200() {
|
90 |
66b5cbf6
|
Assos Assos
|
// Remove old Twitter Block schema.
|
91 |
85ad3d82
|
Assos Assos
|
drupal_uninstall_schema('twitter_block');
|
92 |
|
|
|
93 |
66b5cbf6
|
Assos Assos
|
// Remove any old Twitter Block blocks.
|
94 |
85ad3d82
|
Assos Assos
|
db_delete('block')
|
95 |
|
|
->condition('module', 'twitter_block')
|
96 |
|
|
->execute();
|
97 |
|
|
db_delete('block_role')
|
98 |
|
|
->condition('module', 'twitter_block')
|
99 |
|
|
->execute();
|
100 |
|
|
|
101 |
66b5cbf6
|
Assos Assos
|
// Clear the site cache.
|
102 |
85ad3d82
|
Assos Assos
|
cache_clear_all();
|
103 |
|
|
|
104 |
66b5cbf6
|
Assos Assos
|
// Install the new Twitter Block schema.
|
105 |
85ad3d82
|
Assos Assos
|
drupal_install_schema('twitter_block');
|
106 |
|
|
|
107 |
|
|
return t('Removed any old Twitter Block blocks and installed the new Twitter Block schema.');
|
108 |
|
|
}
|
109 |
66b5cbf6
|
Assos Assos
|
|
110 |
|
|
/**
|
111 |
|
|
* Add a column to the {twitter_block} table to store the Twitter account username.
|
112 |
|
|
*/
|
113 |
|
|
function twitter_block_update_7201() {
|
114 |
|
|
db_add_field('twitter_block', 'username', array(
|
115 |
|
|
'type' => 'varchar',
|
116 |
|
|
'length' => 128,
|
117 |
|
|
'not null' => TRUE,
|
118 |
|
|
'default' => '',
|
119 |
|
|
'description' => 'Account username.',
|
120 |
|
|
));
|
121 |
|
|
} |