forked from amoore5/campuscms-profile
-
Notifications
You must be signed in to change notification settings - Fork 1
/
campuscms_profile.install
474 lines (411 loc) · 13.2 KB
/
campuscms_profile.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
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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
<?php
/**
* Implements hook_install().
*
* Perform actions to set up the site for this profile.
*/
function campuscms_profile_install() {
$themes = array(
'default' => 'bartik',
'admin' => 'seven',
);
variable_set('theme_default', $themes['default']);
_campuscms_profile_setup_time_date();
$filter_perms = _campuscms_profile_setup_filter_formats();
_campuscms_profile_setup_menus();
_campuscms_profile_setup_blocks($themes);
_campuscms_profile_setup_user_pictures();
_campuscms_profile_setup_roles($filter_perms);
_campuscms_profile_setup_quickbar();
_campuscms_profile_setup_admin_theme($themes['admin']);
}
function _campuscms_profile_setup_time_date() {
// Set default country to US
variable_set('site_default_country', 'US');
// First day of the week will be sunday
variable_set('date_first_day', '0');
// Timezone
variable_set('date_default_timezone', 'America/Los_Angeles');
// Users set their own timezone
variable_set('configurable_timezones', 1);
// Don't show a message to users if the timezone is empty
variable_set('empty_timezone_message', 0);
// Users default timezone
variable_set('user_default_timezone', '0');
// Insert custom format: November 25, 2011
db_insert('date_formats')
->fields(array('format' => 'F j, Y - g:ia', 'type' => 'custom', 'locked' => 0))
->execute();
// Insert custom format: Nov 25, 2011
db_insert('date_formats')
->fields(array('format' => 'M. j, Y - g:ia', 'type' => 'custom', 'locked' => 0))
->execute();
// Date Long Format
variable_set('date_format_long', 'F j, Y - g:ia');
// Date Medium Format
variable_set('date_format_medium', 'M. j, Y - g:ia');
// Date Short Format
variable_set('date_format_short', 'm/d/Y - g:ia');
}
function _campuscms_profile_setup_filter_formats() {
// Add text formats.
$filtered_html_format = array(
'format' => 'filtered_html',
'name' => 'Filtered HTML',
'weight' => 0,
'filters' => array(
// URL filter.
'filter_url' => array(
'weight' => 0,
'status' => 1,
),
// HTML filter.
'filter_html' => array(
'weight' => 1,
'status' => 1,
'settings' => array(
'allowed_html' => '<a> <em> <strong> <cite> <blockquote> <ul> <ol> <li> <dl> <dt> <dd> <img> <table> <tbody> <th> <tr> <td> <div>',
),
),
// Line break filter.
'filter_autop' => array(
'weight' => 2,
'status' => 1,
),
// HTML corrector filter.
'filter_htmlcorrector' => array(
'weight' => 10,
'status' => 1,
),
),
);
$filtered_html_format = (object) $filtered_html_format;
filter_format_save($filtered_html_format);
$full_html_format = array(
'format' => 'full_html',
'name' => 'Full HTML',
'weight' => 1,
'filters' => array(
// URL filter.
'filter_url' => array(
'weight' => 0,
'status' => 1,
),
// Line break filter.
'filter_autop' => array(
'weight' => 1,
'status' => 1,
),
// HTML corrector filter.
'filter_htmlcorrector' => array(
'weight' => 10,
'status' => 1,
),
),
);
$full_html_format = (object) $full_html_format;
filter_format_save($full_html_format);
// Enable default permissions for system roles.
$filter_perms = array(
'filtered_html' => filter_permission_name($filtered_html_format),
'full_html' => filter_permission_name($full_html_format),
);
return $filter_perms;
}
function _campuscms_profile_setup_menus() {
// Build left footer menu
$left_footer_definition = array(
'menu_name' => 'menu-left-footer',
'title' => 'Left Footer',
'description' => 'This is the left footer menu.',
);
menu_save($left_footer_definition);
// Build center footer menu
$center_footer_definition = array(
'menu_name' => 'menu-center-footer',
'title' => 'Center Footer',
'description' => 'This is the center footer menu.',
);
menu_save($center_footer_definition);
// Build right footer menu
$right_footer_definition = array(
'menu_name' => 'menu-right-footer',
'title' => 'Right Footer',
'description' => 'This is the right footer menu.',
);
menu_save($right_footer_definition);
}
function _campuscms_profile_setup_blocks($themes) {
// Enable some standard blocks.
$values = array(
array(
'module' => 'system',
'delta' => 'main',
'theme' => $themes['default'],
'status' => 1,
'weight' => 0,
'region' => 'content',
'pages' => '',
'cache' => -1,
),
array(
'module' => 'node',
'delta' => 'recent',
'theme' => $themes['admin'],
'status' => 1,
'weight' => 10,
'region' => 'dashboard_main',
'pages' => '',
'cache' => -1,
),
array(
'module' => 'user',
'delta' => 'login',
'theme' => $themes['default'],
'status' => 1,
'weight' => 0,
'region' => 'sidebar_first',
'pages' => '',
'cache' => -1,
),
array(
'module' => 'system',
'delta' => 'help',
'theme' => $themes['default'],
'status' => 1,
'weight' => 0,
'region' => 'help',
'pages' => '',
'cache' => -1,
),
array(
'module' => 'system',
'delta' => 'main',
'theme' => $themes['admin'],
'status' => 1,
'weight' => 0,
'region' => 'content',
'pages' => '',
'cache' => -1,
),
array(
'module' => 'system',
'delta' => 'help',
'theme' => $themes['admin'],
'status' => 1,
'weight' => 0,
'region' => 'help',
'pages' => '',
'cache' => -1,
),
array(
'module' => 'user',
'delta' => 'login',
'theme' => $themes['admin'],
'status' => 1,
'weight' => 10,
'region' => 'content',
'pages' => '',
'cache' => -1,
),
array(
'module' => 'user',
'delta' => 'new',
'theme' => $themes['admin'],
'status' => 1,
'weight' => 0,
'region' => 'dashboard_sidebar',
'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();
}
function _campuscms_profile_setup_user_pictures() {
// 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');
}
function _campuscms_profile_setup_roles($filter_perms) {
// Set permissions for anonymous and authenticated roles.
user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access content', $filter_perms['filtered_html']));
user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access content', $filter_perms['filtered_html']));
// Create a default role for site administrators, with all available permissions assigned.
$admin_role = new stdClass();
$admin_role->name = 'administrator';
$admin_role->weight = 4;
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 a content editor role
$content_editor = new stdClass();
$content_editor->name = 'content editor';
$content_editor->weight = 2;
user_role_save($content_editor);
$content_editor_permissions = array(
$filter_perms['filtered_html'],
'administer nodes',
'access content overview',
'view revisions',
'view own unpublished content',
'access overlay',
'create url aliases',
'view the administration theme',
'administer main-menu menu items',
'administer menu-center-footer menu items',
'administer menu-right-footer menu items',
);
user_role_grant_permissions($content_editor->rid, $content_editor_permissions);
// Create a site manager role
$site_manager = new stdClass();
$site_manager->name = 'site manager';
$site_manager->weight = 3;
user_role_save($site_manager);
$site_manager_permissions = array(
$filter_perms['filtered_html'],
'administer blocks',
'access contextual links',
'view own unpublished content',
'access overlay',
'administer nodes',
'access content overview',
'view revisions',
'revert revisions',
'delete revisions',
'create url aliases',
'assign content editor role',
'assign site manager role',
'administer site configuration',
'administer themes',
'view the administration theme',
'access site reports',
'administer users',
'administer main-menu menu items',
'administer menu-center-footer menu items',
'administer menu-right-footer menu items',
);
user_role_grant_permissions($site_manager->rid, $site_manager_permissions);
}
function _campuscms_profile_setup_quickbar() {
// Enable faux machine names for roles.
variable_set('quickbar_use_machine_names', 1);
$quickbar_settings = array(
'iconset' => 'quickbar',
'sticky' => 0,
'float' => 0,
'secondary_menu_visibility' => 0,
'nofollow' => 0,
);
$quickbar_extras_settings = array(
'show_username' => 1,
'show_username_prefix' => 'Hello, ',
'show_username_suffix' => '',
'show_username_link' => 1,
);
$home_link = array(
'link_path' => drupal_get_normal_path('<front>'),
'link_title' => 'Home',
);
$add_content_link = array(
'link_path' => drupal_get_normal_path('node/add'),
'link_title' => 'Add Content',
);
$manage_content_link = array(
'link_path' => drupal_get_normal_path('admin/content'),
'link_title' => 'Manage Content',
);
$menus_link = array(
'link_path' => drupal_get_normal_path('admin/structure/menu'),
'link_title' => 'Menus',
);
$users_link = array(
'link_path' => drupal_get_normal_path('admin/people'),
'link_title' => 'Users',
);
$site_configuration_link = array(
'link_path' => drupal_get_normal_path('admin/config'),
'link_title' => 'Site Configuration',
);
$logout_link = array(
'link_path' => drupal_get_normal_path('caslogout'),
'link_title' => 'Logout',
);
/**
* Build administrator toolbar menu
*/
$administrator_menu_definition = array(
'menu_name' => 'menu-toolbar-administrator',
'title' => 'Toolbar - Administrator',
'description' => 'This is the administration toolbar for adminstrators.',
);
menu_save($administrator_menu_definition);
// Add Home Menu Item
$administrator_home_link = $home_link;
$administrator_home_link['menu_name'] = 'menu-toolbar-administrator';
menu_link_save($administrator_home_link);
// Add Logout Menu Item
$administrator_logout_link = $logout_link;
$administrator_logout_link['menu_name'] = 'menu-toolbar-administrator';
$administrator_logout_mlid = menu_link_save($administrator_logout_link);
// Add administrator menu settings for quickbar.
$menus['administrator'] = 'menu-toolbar-administrator';
$weights['administrator'] = -10;
variable_set('quickbar_settings_administrator', $quickbar_settings);
$administrator_quickbar_extras_settings = $quickbar_extras_settings;
$administrator_quickbar_extras_settings['menu']['mlid_' . $administrator_logout_mlid] = 'right';
variable_set('quickbar_extras_settings_administrator', $administrator_quickbar_extras_settings);
/**
* Build site manager toolbar menu
*/
$site_manager_menu_definition = array(
'menu_name' => 'menu-toolbar-site-manager',
'title' => 'Toolbar - Site Manager',
'description' => 'This is the administration toolbar for site managers.',
);
menu_save($site_manager_menu_definition);
// Add site manager settings for quickbar
$menus['site-manager'] = 'menu-toolbar-site-manager';
$weights['site-manager'] = -9;
/**
* Build content editor toolbar menu
*/
$content_editor_menu_definition = array(
'menu_name' => 'menu-toolbar-content-editor',
'title' => 'Toolbar - Content Editor',
'description' => 'This is the administration toolbar for content editors.',
);
menu_save($content_editor_menu_definition);
// Add content editor settings for quickbar
$menus['content-editor'] = 'menu-toolbar-content-editor';
$weights['content-editor'] = -8;
menu_cache_clear_all();
// Add the authenticated user settings for quickbar
$menus['authenticated-user'] = 0;
$weights['authenticated-user'] = 0;
// Add the anonymous user settings for quickbar
$menus['anonymous-user'] = 0;
$weights['anonymous-user'] = 1;
variable_set('quickbar_role_menus', $menus);
variable_set('quickbar_role_weights', $weights);
}
function _campuscms_profile_setup_admin_theme($theme) {
// Enable the admin theme.
db_update('system')
->fields(array('status' => 1))
->condition('type', 'theme')
->condition('name', $theme)
->execute();
variable_set('admin_theme', $theme);
variable_set('node_admin_theme', '1');
}