This repository has been archived by the owner on Jul 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cu_forms_bundle.install
122 lines (103 loc) · 3.5 KB
/
cu_forms_bundle.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
<?php
/**
* @file
* Install hooks for the cu_forms_bundle module.
*/
/**
* Implements hook_enable()
*/
function cu_forms_bundle_enable() {
// Add form manager role to user invite.
secure_permissions_build_roles();
$campaign_manager_role = user_role_load_by_name('form_manager');
$invite_roles = variable_get('user_external_invite_addon_roles', array());
$invite_roles[] = $campaign_manager_role->rid;
variable_set('user_external_invite_addon_roles', $invite_roles);
}
/**
* Express 2.8.5 update
* Add schema version to diff bundles.
*/
function cu_forms_bundle_update_7001() {
// This space intentionally left blank.
}
/**
* Update permissions for new form owner role.
*/
function cu_forms_bundle_update_7002() {
secure_permissions_rebuild();
cu_core_revert_features();
}
/**
* Update permissions for new form owner role.
*/
function cu_forms_bundle_update_7003() {
db_update('system')
->fields(array('weight' => 10))
->condition('name', 'cu_forms_bundle', '=')
->execute();
}
/**
* Update permissions for site_editor, edit_only roles.
*/
function cu_forms_bundle_update_7004() {
secure_permissions_rebuild();
}
/**
* Add form manager role to user invite.
*/
function cu_forms_bundle_update_7005() {
// Add form manager role to user invite.
secure_permissions_build_roles();
$campaign_manager_role = user_role_load_by_name('form_manager');
$invite_roles = variable_get('user_external_invite_addon_roles', array());
$invite_roles[] = $campaign_manager_role->rid;
variable_set('user_external_invite_addon_roles', $invite_roles);
}
/**
* Update permissions for form manager role.
*/
function cu_forms_bundle_update_7006() {
secure_permissions_rebuild();
$fm_role = user_role_load_by_name("form_manager");
$uids = db_query("SELECT DISTINCT uid FROM {node} n WHERE n.type = 'webform'")->fetchCol();
foreach ($uids as $uid) {
$user = user_load($uid);
if (isset($user->uid) && $user->uid) {
if (!in_array('developer', array_values($user->roles)) && !in_array('administrator', array_values($user->roles)) && !in_array('site_owner', array_values($user->roles))) {
user_multiple_role_edit(array($uid), 'add_role', $fm_role->rid);
watchdog('cu_forms_bundle', ':user has been given the form manager role.', [':user' => $user->name]);
}
}
}
}
/**
* Enable cu_unused_forms.
*/
function cu_forms_bundle_update_7007() {
module_enable(array('cu_unused_forms'));
}
/**
* Updating site and web emails to prepare for new infrastructure smtp configuration
*/
function cu_forms_bundle_update_7008() {
variable_set('webform_default_from_address', 'webexpress_noreply@colorado.edu');
variable_set('site_mail', 'webexpress_noreply@colorado.edu');
}
/**
* Remove single-page webform progress bar for Webform 4.18 update.
*/
function cu_forms_bundle_update_7009() {
// See https://www.drupal.org/project/webform/releases/7.x-4.18
$multipage_webform_nids = db_select('webform_component');
$multipage_webform_nids->distinct();
$multipage_webform_nids->addField('webform_component', 'nid');
$multipage_webform_nids->condition('type', 'pagebreak');
// Remove confirmation page from the progress bar for single-page Webforms.
$updated_count = db_update('webform')
->fields(array('progressbar_include_confirmation' => 0))
->condition('preview', 0)
->condition('nid', $multipage_webform_nids, 'NOT IN')
->execute();
watchdog('cu_forms_bundle', t("Disabled progress bar for @count single-page webforms.", array('@count' => $updated_count)));
}