-
Notifications
You must be signed in to change notification settings - Fork 0
/
voipnode.cck_fields.inc
349 lines (338 loc) · 8.51 KB
/
voipnode.cck_fields.inc
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
<?php
/**
* @file
*
* CCK voip audio fields and group.
* This file contains the helper functions having cck field deinitions.
* The voipnode module calls the function of this file to add/edit/delete
* the cck fields and group.
*/
/**
* Internal Functions
*/
/**
* Change the status of the cck audio fields to the status of the voipextensio module.
* @param $node_type
* A valid content type, in which the audio fields needs to be changed.
* @param $status
* Boolean value for the status, enabled/disabled
*/
function _voipnode_change_audio_fields_status($node_type, $status = 1) {
$fields = _voipnode_audio_fields_definitions();
foreach ($fields as $key => $field) {
db_query("UPDATE {". content_field_tablename() ."} SET active = %d WHERE field_name = '%s' AND module = '%s'", $status, $field['field_name'], 'filefield');
db_query("UPDATE {". content_instance_tablename() ."} SET widget_active = %d WHERE field_name = '%s' AND type_name = '%s' AND widget_module = '%s'", $status, $field['field_name'], $node_type, 'audiofield');
}
content_clear_type_cache(TRUE);
}
/**
* Setup and created the provided audio cck fields from the cck_fields file.
* Uses the core crud operations of the content module.
* @param $node_type
* The content type in which these fields needs to be created.
*/
function _voipnode_create_audio_fields($node_type) {
// Need to load the CCK include file where content_field_instance_create() is defined.
module_load_include('inc', 'content', 'includes/content.crud');
$fields_to_create = _voipnode_audio_fields_definitions();
foreach ($fields_to_create as $key => $field) {
if (!content_fields($field['field_name'], $node_type)) {
$field['type_name'] = $node_type;
content_field_instance_create($field);
}
}
}
/**
* VOIP CCK field and group settings
*/
/**
* Contains the fieldgroup cck field structure.
* This is the exported form of cck field.
*
* @return
* An array having fielgroup cck structure.
*/
function _voipnode_extension_group_defintion() {
return array (
'label' => 'VoIP Extension Settings',
'group_type' => 'standard',
'settings' =>
array (
'form' =>
array (
'style' => 'fieldset_collapsible',
'description' => '',
),
'display' =>
array (
'description' => '',
'teaser' =>
array (
'format' => 'fieldset',
'exclude' => 0,
),
'full' =>
array (
'format' => 'fieldset',
'exclude' => 0,
),
4 =>
array (
'format' => 'fieldset',
'exclude' => 0,
),
'token' =>
array (
'format' => 'fieldset',
'exclude' => 0,
),
'label' => 'above',
),
),
'weight' => '7',
'group_name' => 'group_voipnode_settings',
);
}
/**
* Returns an array of the fields names that we control.
*/
function _voipnode_audio_fields_names() {
$definitions = _voipnode_audio_fields_definitions();
return array_keys($definitions);
}
/**
* Store and returns field definitions, from audiofield cck fields
* It stores three cck fields, Audio name, Audio description and Audio greeting
* @param $field_type
* If the field type is specified then it returns only specific audio field.
* @return
* An array having the structured format of all or the required audio cck fields.
*/
function _voipnode_audio_fields_definitions($field_type = '') {
$fields = array();
$fields['field_voipnode_aname'] = array (
'label' => 'Audio Name',
'field_name' => 'field_voipnode_aname',
'type' => 'filefield',
'widget_type' => 'audiofield_widget',
'change' => 'Change basic information',
'weight' => '8',
'file_extensions' => 'mp3',
'progress_indicator' => 'bar',
'file_path' => '',
'max_filesize_per_file' => '',
'max_filesize_per_node' => '',
'description' => '',
'group' => 'group_voipnode_settings',
'required' => 0,
'multiple' => '0',
'list_field' => '0',
'list_default' => 1,
'description_field' => '0',
'op' => 'Save field settings',
'module' => 'filefield',
'widget_module' => 'audiofield',
'columns' =>
array (
'fid' =>
array (
'type' => 'int',
'not null' => false,
'views' => true,
),
'list' =>
array (
'type' => 'int',
'size' => 'tiny',
'not null' => false,
'views' => true,
),
'data' =>
array (
'type' => 'text',
'serialize' => true,
'views' => true,
),
),
'display_settings' =>
array (
'label' =>
array (
'format' => 'above',
'exclude' => 0,
),
'teaser' =>
array (
'format' => 'audiofield_embedded',
'exclude' => 0,
),
'full' =>
array (
'format' => 'audiofield_embedded',
'exclude' => 0,
),
4 =>
array (
'format' => 'audiofield_embedded',
'exclude' => 0,
),
'token' =>
array (
'format' => 'audiofield_embedded',
'exclude' => 0,
),
),
);
$fields['field_voipnode_adesc'] = array (
'label' => 'Audio Description',
'field_name' => 'field_voipnode_adesc',
'type' => 'filefield',
'widget_type' => 'audiofield_widget',
'change' => 'Change basic information',
'weight' => '9',
'file_extensions' => 'mp3',
'progress_indicator' => 'bar',
'file_path' => '',
'max_filesize_per_file' => '',
'max_filesize_per_node' => '',
'description' => '',
'group' => 'group_voipnode_settings',
'required' => 0,
'multiple' => '0',
'list_field' => '0',
'list_default' => 1,
'description_field' => '0',
'op' => 'Save field settings',
'module' => 'filefield',
'widget_module' => 'audiofield',
'columns' =>
array (
'fid' =>
array (
'type' => 'int',
'not null' => false,
'views' => true,
),
'list' =>
array (
'type' => 'int',
'size' => 'tiny',
'not null' => false,
'views' => true,
),
'data' =>
array (
'type' => 'text',
'serialize' => true,
'views' => true,
),
),
'display_settings' =>
array (
'label' =>
array (
'format' => 'above',
'exclude' => 0,
),
'teaser' =>
array (
'format' => 'audiofield_embedded',
'exclude' => 0,
),
'full' =>
array (
'format' => 'audiofield_embedded',
'exclude' => 0,
),
4 =>
array (
'format' => 'audiofield_embedded',
'exclude' => 0,
),
'token' =>
array (
'format' => 'audiofield_embedded',
'exclude' => 0,
),
),
);
$fields['field_voipnode_agreet'] = array (
'label' => 'Audio Greeting',
'field_name' => 'field_voipnode_agreet',
'type' => 'filefield',
'widget_type' => 'audiofield_widget',
'change' => 'Change basic information',
'weight' => '10',
'file_extensions' => 'mp3',
'progress_indicator' => 'bar',
'file_path' => '',
'max_filesize_per_file' => '',
'max_filesize_per_node' => '',
'description' => '',
'group' => 'group_voipnode_settings',
'required' => 0,
'multiple' => '0',
'list_field' => '0',
'list_default' => 1,
'description_field' => '0',
'op' => 'Save field settings',
'module' => 'filefield',
'widget_module' => 'audiofield',
'columns' =>
array (
'fid' =>
array (
'type' => 'int',
'not null' => false,
'views' => true,
),
'list' =>
array (
'type' => 'int',
'size' => 'tiny',
'not null' => false,
'views' => true,
),
'data' =>
array (
'type' => 'text',
'serialize' => true,
'views' => true,
),
),
'display_settings' =>
array (
'label' =>
array (
'format' => 'above',
'exclude' => 0,
),
'teaser' =>
array (
'format' => 'audiofield_embedded',
'exclude' => 0,
),
'full' =>
array (
'format' => 'audiofield_embedded',
'exclude' => 0,
),
4 =>
array (
'format' => 'audiofield_embedded',
'exclude' => 0,
),
'token' =>
array (
'format' => 'audiofield_embedded',
'exclude' => 0,
),
),
);
if (isset($fields[$field_type])) {
return $fields[$field_type];
}
else {
return $fields;
}
}