-
Notifications
You must be signed in to change notification settings - Fork 0
/
flag_note.install
79 lines (72 loc) · 2.11 KB
/
flag_note.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/**
* @file
* Flag note module install/schema/update hooks.
*/
/**
* Implementation of hook_install().
*/
function flag_note_install() {
$success = drupal_install_schema('flag_note');
if (empty($success[0]['success'])) {
drupal_set_message(st('The installation of Flag Note module failed.'), 'error');
}
}
/**
* Implementation of hook_uninstall().
*/
function flag_note_uninstall() {
db_query("DELETE FROM {variable} WHERE name LIKE 'flag_note_%'");
drupal_uninstall_schema('flag_note');
}
/**
* Implementation of hook_schema().
*/
function flag_note_schema() {
$flag_content = drupal_get_schema_unprocessed('flag', 'flag_content');
$flag_content['fields']['fcid']['type'] = 'int';
$schema['flag_note']['fields'] = array_merge($flag_content['fields'],
array(
'note' => array('type' => 'text', 'not null' => TRUE),
'tid' => array('type' => 'int', 'not null' => FALSE),
));
$schema['flag_note']['fields']['fnid'] = array('type' => 'serial');
$schema['flag_note']['primary key'] = array('fnid');
$schema['flag_note']['indexes'] = array(
'fcid' => array('fcid'),
'fid' => array('fid'),
'tid' => array('tid'),
'content_type_content_id' => array('content_type', 'content_id'),
);
return $schema;
}
function flag_note_update_6200() {
$ret = array();
db_add_field($ret, 'flag_note', 'tid', array('type' => 'int', 'not null' => FALSE));
db_add_index($ret, 'flag_note', 'tid', array('tid'));
return $ret;
}
function flag_note_update_6201() {
$ret = array();
cache_clear_all();
return $ret;
}
/**
* Copy all values for each flag from system variables to flag options
*/
function flag_note_update_6202() {
$ret = array();
$link_type = flag_note_flag_link_types();
foreach (flag_get_flags() as $flag) {
if ($flag->link_type == 'flag_note_form') {
foreach ($link_type['flag_note_form']['options'] as $option => $value) {
if (!isset($flag->$option)) {
$flag->$option = variable_get($option .'_'. $flag->name, $value);
variable_del($option .'_'. $flag->name);
}
}
$flag->update();
}
}
return $ret;
}