forked from GetDKAN/dkan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dkan.profile
187 lines (173 loc) · 5.96 KB
/
dkan.profile
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
<?php
/**
* @file
* Additional setup tasks for DKAN.
*/
/**
* Implements hook_install_tasks().
*/
function dkan_install_tasks() {
return array(
'dkan_additional_setup' => array(
'display_name' => t('DKAN final setup tasks'),
'display' => TRUE,
'type' => 'batch',
'run' => INSTALL_TASK_RUN_IF_NOT_COMPLETED,
),
);
}
/**
* DKAN setup task. Runs a series of helper functions defined below.
*/
function dkan_additional_setup() {
return array(
'operations' => array(
array('dkan_theme_config', array()),
array('dkan_change_block_titles', array()),
array('dkan_install_markdown', array()),
array('dkan_enable_roles_perms', array()),
array('dkan_revert_feature', array('dkan_sitewide_menu', array('content_menu_links', 'menu_links'))),
array('dkan_revert_feature', array('dkan_dataset_content_types', array('field_base', 'field_instance'))),
array('dkan_revert_feature', array('dkan_dataset_groups', array('field_base'))),
array('dkan_revert_feature', array('dkan_sitewide_roles_perms', array('user_permission', 'og_features_permission'))),
array('dkan_revert_feature', array('dkan_sitewide', array('variable'))),
array('dkan_revert_feature', array('dkan_data_story_storyteller_role', array('user_role', 'roles_permissions'))),
array('dkan_revert_feature', array('dkan_sitewide_profile_page', array('menu_custom', 'menu_links'))),
array('dkan_build_menu_links', array()),
array('dkan_flush_image_styles', array()),
array('dkan_colorizer_reset', array()),
array('dkan_misc_variables_set', array()),
array('dkan_set_adminrole', array()),
),
);
}
function dkan_theme_config(&$context) {
$context['message'] = t('Setting theme options.');
theme_enable(array('nuboot_radix'));
theme_enable(array('seven'));
variable_set('theme_default', 'nuboot_radix');
variable_set('admin_theme', 'nuboot_radix');
// Disable the default Bartik theme
theme_disable(array('bartik'));
theme_disable(array('seven'));
}
/**
* Change block titles for selected blocks.
*/
function dkan_change_block_titles(&$context) {
$context['message'] = t('Changing block titles for selected blocks');
db_query("UPDATE {block} SET title ='<none>' WHERE delta = 'main-menu' OR delta = 'login'");
variable_set('node_access_needs_rebuild', FALSE);
variable_set('gravatar_size', 190);
}
/**
* Make sure markdown editor installs correctly.
* @param $context
*/
function dkan_install_markdown(&$context) {
$context['message'] = t('Installing Markdown');
module_load_include('install', 'markdowneditor', 'markdowneditor');
_markdowneditor_insert_latest();
$data = array(
'pages' => "node/*\ncomment/*\nsystem/ajax",
'eid' => 5,
);
drupal_write_record('bueditor_editors', $data, array('eid'));
}
/**
* Keeps us from getting notices "No module defines permission".
* @param $context
*/
function dkan_enable_roles_perms(&$context) {
$context['message'] = t('Enabling Sitewide Roles and Permissions');
module_enable(array('dkan_sitewide_roles_perms'));
}
/**
* Revert particular feature components that have been overridden in the setup process
*
* @param $feature The feature module name
* @param $components Array of components to revert
* @param $context
*/
function dkan_revert_feature($feature, $components, &$context) {
$context['message'] = t('Reverting feature %feature_name', array('%feature_name' => $feature));
features_revert(array($feature => $components));
cache_clear_all();
}
/**
* Build menu links
*
* @param $context
*/
function dkan_build_menu_links(&$context) {
$context['message'] = t('Building menu links');
$menu_links = features_get_default('menu_links', 'dkan_sitewide_profile_page');
menu_links_features_rebuild_ordered($menu_links, TRUE);
unset($_SESSION['messages']['warning']);
cache_clear_all();
}
/**
* Flush the image styles
*
* @param $context
*/
function dkan_flush_image_styles(&$context) {
$context['message'] = t('Flushing image styles');
$menu_links = features_get_default('menu_links', 'dkan_sitewide_profile_page');
menu_links_features_rebuild_ordered($menu_links, TRUE);
unset($_SESSION['messages']['warning']);
cache_clear_all();
$image_styles = image_styles();
foreach ( $image_styles as $image_style ) {
image_style_flush($image_style);
}
}
/**
* Reset colorizer cache so that background colors and other colorizer settings are not blank at first page view
*
* @param $context
*/
function dkan_colorizer_reset(&$context) {
$context['message'] = t('Resetting colorizer cache');
global $theme_key;
$instance = $theme_key;
drupal_alter('colorizer_instance', $instance);
$palette = colorizer_get_palette($theme_key, $instance);
$file = colorizer_update_stylesheet($theme_key, $theme_key, $palette);
clearstatcache();
dkan_default_content_base_install();
}
/**
* Set a number of miscellaneous variables
*
* @param $context
*/
function dkan_misc_variables_set(&$context) {
$context['message'] = t('Setting misc DKAN variables');
variable_set('honeypot_form_user_register_form', 1);
variable_set('site_frontpage', 'welcome');
variable_set('page_manager_node_view_disabled', FALSE);
variable_set('page_manager_node_edit_disabled', FALSE);
variable_set('page_manager_user_view_disabled', FALSE);
// variable_set('page_manager_override_anyway', 'TRUE');
variable_set('jquery_update_jquery_version', '1.7');
// Disable selected views enabled by contributed modules.
$views_disable = array(
'og_extras_nodes' => TRUE,
'feeds_log' => TRUE,
'groups_page' => TRUE,
'og_extras_groups' => TRUE,
'og_extras_members' => TRUE,
'dataset' => TRUE,
);
variable_set('views_defaults', $views_disable);
}
/**
* Set the user admin role
*
* @param $context
*/
function dkan_set_adminrole(&$context) {
$context['message'] = t('Setting user admin role');
dkan_sitewide_roles_perms_set_admin_role();
}