-
Notifications
You must be signed in to change notification settings - Fork 0
/
vopros_editorial.install
69 lines (59 loc) · 1.92 KB
/
vopros_editorial.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
<?php
/**
* @file
* Install, update and uninstall functions for the vopros_editorial module.
*/
/**
* Implements hook_enable().
*/
function vopros_editorial_enable() {
// Create the question vopros_editorial vocabolary.
if (!taxonomy_vocabulary_machine_name_load('vopros_editorial')) {
$vocabulary = (object) array(
'name' => t('Editorial'),
'machine_name' => 'vopros_editorial',
'module' => 'vopros_editorial',
);
taxonomy_vocabulary_save($vocabulary);
}
vopros_editorial_configure_question();
}
/**
* Delete obsolete email macros.
*/
function vopros_editorial_update_7101() {
$vocabolary = taxonomy_vocabulary_machine_name_load('vopros_editorial');
$terms = taxonomy_term_load_multiple(NULL, array('vid' => $vocabolary->vid));
$condition = db_or();
foreach ($terms as $term) {
// Emails.
$condition->condition('name', 'vopros_email_subject_macro_%_' . $term->tid, 'like');
$condition->condition('name', 'vopros_email_macro_%_' . $term->tid, 'like');
$condition->condition('name', 'vopros_email_answered_question_subject_macro_' . $term->tid, 'like');
$condition->condition('name', 'vopros_email_answered_question_macro_' . $term->tid, 'like');
// SMS.
$condition->condition('name', 'vopros_sms_macro_%_' . $term->tid, 'like');
$condition->condition('name', 'vopros_sms_answered_question_macro_' . $term->tid, 'like');
}
$vars = db_select('variable', 'v')
->fields('v', array('name'))
->condition($condition)
->execute()
->fetchCol();
foreach ($vars as $var) {
variable_del($var);
}
}
/**
* Delete obsoleted service variables.
*/
function vopros_editorial_update_7102() {
$vars = db_select('variable', 'v')
->fields('v', array('name'))
->condition('name', 'vopros_editorial_service_default_%', "LIKE")
->execute()
->fetchCol();
foreach ($vars as $var) {
variable_del($var);
}
}