-
Notifications
You must be signed in to change notification settings - Fork 1
/
node_feedback.install
111 lines (101 loc) · 3.08 KB
/
node_feedback.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
/**
* @file
* Node Feedback module schema hooks.
*/
/**
* Implements hook_schema().
*/
function node_feedback_schema() {
$schema = [];
$schema['node_feedback'] = [
'description' => 'Node Feedback entries.',
'fields' => [
'nfid' => [
'description' => 'The unique ID for this particular flag.',
'type' => 'serial',
'size' => 'small',
'unsigned' => TRUE,
'not null' => TRUE,
],
'nid' => [
'description' => 'The unique ID of the node.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
],
'name' => [
'type' => 'varchar',
'length' => 60,
'not null' => TRUE,
'default' => '',
'description' => 'Unique user name.',
],
'response_text_feedback' => [
'description' => 'The response text feedback of this flag if any.',
'type' => 'text',
'not null' => FALSE,
],
'timestamp' => [
'description' => 'The UNIX time stamp representing when the flag was set.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
],
],
'primary key' => ['nfid'],
];
return $schema;
}
/**
* Implements hook_uninstall().
*/
function node_feedback_uninstall() {
// Remove default, un-modified views.
$configs = [
'views.view.node_feedback_stats',
'views.view.node_feedback_report',
];
foreach ($configs as $file) {
$config = config($file);
if ($config->get('storage') != VIEWS_STORAGE_OVERRIDE) {
$config->delete();
}
}
}
/**
* @defgroup updates-7.x-to-1.x Updates from 7.x to 1.x
* @{
* Update functions from Drupal 7.x to Backdrop CMS 1.x.
*/
/**
* Move book settings from variables to config.
*/
function node_feedback_update_1000() {
// Migrate variables to config.
$config = config('node_feedback.settings');
$config->set('nf_header_text', update_variable_get('nf_header_text', ''));
$config->set('nf_yes_text', update_variable_get('nf_yes_text', 'yes'));
$config->set('nf_button_text', update_variable_get('nf_button_text', 'no'));
$config->set('nf_yes_message', update_variable_get('nf_yes_message', 'Thanks for your feedback!'));
$config->set('nf_thanks_message', update_variable_get('nf_thanks_message', 'Thanks for your feedback!'));
$config->set('nf_feedback_title', update_variable_get('nf_feedback_title', 'Tell us more..'));
$config->set('nf_allowed_content_type', update_variable_get('nf_allowed_content_type', []));
$config->set('nf_show_stats', update_variable_get('nf_show_stats', []));
$config->save();
// Delete variables.
update_variable_del('nf_header_text');
update_variable_del('nf_yes_text');
update_variable_del('nf_button_text');
update_variable_del('nf_yes_message');
update_variable_del('nf_thanks_message');
update_variable_del('nf_feedback_title');
update_variable_del('nf_allowed_content_type');
update_variable_del('nf_show_stats');
}
/**
* @} End of "defgroup updates-7.x-to-1.x"
* The next series of updates should start at 2000.
*/