-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxforty.install
275 lines (250 loc) · 7.02 KB
/
xforty.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
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
<?php
/**
* The base profile xforty.install code. It was adapted
* from the OpenEnterprise profile install.
*/
define('XFORTY_DEFAULT_THEME', 'bartik');
define('XFORTY_ADMIN_THEME', 'seven');
/**
* Perform actions to set up the site for this profile.
*
* Implements hook_install().
*/
function xforty_install() {
// Make sure this function is only run once
static $xforty_install_ran;
if ($xforty_install_ran !== null) {
return;
} else {
$xforty_install_ran = true;
}
xforty_enable_theme_settings();
xforty_setup_admin_role();
xforty_create_menus();
xforty_add_default_blocks();
xforty_add_content_types();
xforty_setup_users();
xforty_setup_tags();
xforty_set_variables();
xforty_cleanup();
}
/**
* Set default and admin themes.
*/
function xforty_enable_theme_settings () {
// Enable and set default theme.
db_update('system')
->fields(array('status' => 1))
->condition('type', 'theme')
->condition('name', XFORTY_DEFAULT_THEME)
->execute();
variable_set('theme_default', XFORTY_DEFAULT_THEME);
// Enable and set admin theme.
db_update('system')
->fields(array('status' => 1))
->condition('type', 'theme')
->condition('name', XFORTY_ADMIN_THEME)
->execute();
variable_set('admin_theme', XFORTY_ADMIN_THEME);
variable_set('node_admin_theme', '1');
variable_set('theme_seven_settings', array(
'toggle_logo' => 1,
'toggle_name' => 1,
'toggle_slogan' => 1,
'toggle_node_user_picture' => 1,
'toggle_comment_user_picture' => 1,
'toggle_comment_user_verification' => 1,
'toggle_favicon' => 1,
'toggle_main_menu' => 1,
'toggle_secondary_menu' => 1,
'default_logo' => 0,
'logo_path' => '',
'logo_upload' => '',
'default_favicon' => 1,
'favicon_path' => '',
'favicon_upload' => '',
));
}
/*
* Create the admin role
*/
function xforty_setup_admin_role() {
// Create a default role for site administrators, with all available permissions assigned.
$admin_role = new stdClass();
$admin_role->name = 'administrator';
$admin_role->weight = 2;
user_role_save($admin_role);
user_role_grant_permissions($admin_role->rid, array_keys(module_invoke_all('permission')));
// Set this as the administrator role.
variable_set('user_admin_role', $admin_role->rid);
// Assign user 1 the "administrator" role.
db_insert('users_roles')
->fields(array('uid' => 1, 'rid' => $admin_role->rid))
->execute();
}
/**
* Create menus and links
*/
function xforty_create_menus() {
// Create a Home link in the main menu.
$item = array(
'link_title' => st('Home'),
'link_path' => '<front>',
'menu_name' => 'main-menu',
);
menu_link_save($item);
// Update the menu router information.
menu_rebuild();
}
/**
* Enable some standard blocks.
*/
function xforty_add_default_blocks() {
$values = array(
array(
'module' => 'system',
'delta' => 'main',
'theme' => XFORTY_DEFAULT_THEME,
'status' => 1,
'weight' => 0,
'region' => 'content',
'pages' => '',
'cache' => -1,
),
array(
'module' => 'user',
'delta' => 'login',
'theme' => XFORTY_DEFAULT_THEME,
'status' => 1,
'weight' => 0,
'region' => 'sidebar_second',
'pages' => '',
'cache' => -1,
),
array(
'module' => 'system',
'delta' => 'navigation',
'theme' => XFORTY_DEFAULT_THEME,
'status' => 1,
'weight' => 0,
'region' => 'sidebar_second',
'pages' => '',
'cache' => -1,
),
array(
'module' => 'xforty',
'delta' => 'powered-by',
'theme' => XFORTY_DEFAULT_THEME,
'status' => 1,
'weight' => 10,
'region' => 'footer_bottom',
'pages' => '',
'cache' => -1,
),
array(
'module' => 'system',
'delta' => 'main',
'theme' => XFORTY_ADMIN_THEME,
'status' => 1,
'weight' => 0,
'region' => 'content',
'pages' => '',
'cache' => -1,
),
array(
'module' => 'user',
'delta' => 'login',
'theme' => XFORTY_ADMIN_THEME,
'status' => 1,
'weight' => 10,
'region' => 'content',
'pages' => '',
'cache' => -1,
),
);
$query = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
foreach ($values as $record) {
$query->values($record);
}
$query->execute();
}
/**
* Add default content types.
*/
function xforty_add_content_types() {
$types = array(
array(
'type' => 'page',
'name' => st('Basic page'),
'base' => 'node_content',
'description' => st("Use <em>basic pages</em> for your static content, such as an 'About us' page."),
'custom' => 1,
'modified' => 1,
'locked' => 0,
),
);
foreach ($types as $type) {
$type = node_type_set_defaults($type);
node_type_save($type);
node_add_body_field($type);
}
// Default "Basic page" to not be promoted and have comments disabled.
variable_set('node_options_page', array('status'));
variable_set('comment_page', COMMENT_NODE_HIDDEN);
// Don't display date and author information for "Basic page" nodes by default.
variable_set('node_submitted_page', FALSE);
}
/**
* Configure some user settings.
*/
function xforty_setup_users() {
// Enable user picture support and set the default to a square thumbnail option.
variable_set('user_pictures', '1');
variable_set('user_picture_dimensions', '1024x1024');
variable_set('user_picture_file_size', '800');
variable_set('user_picture_style', 'thumbnail');
// Only administrators can register new users.
variable_set('user_register', USER_REGISTER_ADMINISTRATORS_ONLY);
}
/**
* Create a default vocabulary named "Tags".
*/
function xforty_setup_tags() {
$description = st('Use tags to group content into categories.');
$help = st('Enter a comma-separated list of words to describe your content.');
$vocabulary = (object) array(
'name' => st('Tags'),
'description' => $description,
'machine_name' => 'tags',
'help' => $help,
);
taxonomy_vocabulary_save($vocabulary);
}
/**
* Set miscellaneous variables.
*/
function xforty_set_variables() {
// pathauto variables since they don't get set early enough for content.
variable_set('pathauto_node_pattern', '[node:content-type:machine-name]/[node:title]');
variable_set('pathauto_punctuation_underscore', '1');
// Set up date defaults so it doesn't yell at us anymore
variable_set('date_first_day', 0);
variable_set('date_format_long', 'l, F j, Y - H:i');
variable_set('date_format_medium', 'D, Y-m-d H:i');
variable_set('date_format_short', 'Y-m-d H:i');
// Keep admin_menu displayed at top of view window
variable_set('admin_menu_position_fixed', 1);
}
/**
* Perform various cleanup tasks after site-install.
*/
function xforty_cleanup() {
// Content access permissions
if (node_access_needs_rebuild()) {
node_access_rebuild(true);
}
// Update the menu router information
menu_rebuild();
// Ignore any drupal messages generated by module installs
drupal_get_messages();
}