forked from tag1consulting/ckeditor_comment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathckeditor_comment.install
190 lines (183 loc) · 5.49 KB
/
ckeditor_comment.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<?php
/**
* Implements hook_install().
*/
function ckeditor_comment_install() {
// Create a default type for CKEditor Comments.
$type = new stdClass();
$type->type = 'default';
$type->label = 'Default';
$type->description = 'Default CKEditor comment type.';
$type->status = 1;
ckeditor_comment_type_save($type);
// Add a body field to our comment entity.
$field = field_info_field('ckeditor_comment_body');
if (empty($field)) {
$field = array(
'field_name' => 'ckeditor_comment_body',
'type' => 'text_long',
'entity_types' => array('ckeditor_comment'),
);
$field = field_create_field($field);
}
$instance = field_info_instance('ckeditor_comment', 'ckeditor_comment_body', 'default');
if (empty($instance)) {
$instance = array(
'field_name' => 'ckeditor_comment_body',
'entity_type' => 'ckeditor_comment',
'bundle' => 'default',
'label' => t('Body'),
'widget' => array('type' => 'text_textarea'),
);
$instance = field_create_instance($instance);
}
}
/**
* Implements hook_uninstall().
*/
function ckeditor_comment_uninstall() {
field_delete_instance(field_info_instance('ckeditor_comment', 'ckeditor_comment_body', 'default'));
}
/**
* Implements hook_schema().
*/
function ckeditor_comment_schema() {
$schema = array();
$schema['ckeditor_comment'] = array(
'description' => 'The base table for ckeditor_comments.',
'fields' => array(
'cid' => array(
'description' => 'The primary identifier of this comment.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'pid' => array(
'description' => 'The identifier of the parent comment of this comment.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'type' => array(
'description' => 'The type (bundle) of this comment.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'uid' => array(
'description' => 'ID of Drupal user creator.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'created' => array(
'description' => 'The Unix timestamp when the comment was created.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'changed' => array(
'description' => 'The Unix timestamp when the comment was most recently saved.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'bookmarks' => array(
'description' => 'The position of bookmarks for the comment inside CKEditor.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'serialize' => TRUE,
),
'resolved' => array(
'description' => 'Boolean indicating whether the comment is resolved.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'entity_type' => array(
'description' => 'Entity type of the target entity (e.g. "node")',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'entity_bundle' => array(
'description' => 'Entity bundle of the target entity (e.g. "article")',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'entity_id' => array(
'description' => 'ID of the target entity (e.g. $node->nid).',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'entity_vid' => array(
'description' => 'Revision ID of the target entity (e.g. $node->vid).',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'field_name' => array(
'description' => 'The field which the comment resides (e.g. "body").',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'field_summary' => array(
'description' => 'Boolean indicating whether this comment resides in the field summary, if applicable.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array('cid'),
);
$schema['ckeditor_comment_type'] = array(
'description' => 'Stores information about all defined ckeditor_comment types.',
'fields' => array(
'id' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique ckeditor_comment type ID.',
),
'type' => array(
'description' => 'The machine-readable name of this type.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
),
'label' => array(
'description' => 'The human-readable name of this type.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'description' => array(
'description' => 'A brief description of this type.',
'type' => 'text',
'not null' => TRUE,
'size' => 'medium',
'translatable' => TRUE,
),
) + entity_exportable_schema_fields(),
'primary key' => array('id'),
'unique keys' => array(
'type' => array('type'),
),
);
return $schema;
}