forked from carletex/drupal-course-uz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cursodrupal.install
89 lines (77 loc) · 2.42 KB
/
cursodrupal.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
<?php
/**
* Implements hook_install().
*/
function cursodrupal_install() {
set_time_limit(0);
$default_theme = 'bartik';
$admin_theme = 'seven';
theme_enable(array($default_theme));
// Enable theme
db_update('system')
->fields(array('status' => 1))
->condition('type', 'theme')
->condition('name', $default_theme)
->execute();
variable_set('theme_default', $default_theme);
// Enable the admin theme.
theme_enable(array($admin_theme));
db_update('system')
->fields(array('status' => 1))
->condition('type', 'theme')
->condition('name', $admin_theme)
->execute();
variable_set('admin_theme', $admin_theme);
// Create a default role for site editor
$editor_role = new stdClass();
$editor_role->name = 'editor';
$editor_role->weight = 2;
user_role_save($editor_role);
// Set this as the editor role.
variable_set('user_editor_role', $editor_role->rid);
// Create a default role for site administrators, with all available permissions assigned.
$admin_role = new stdClass();
$admin_role->name = 'administrator';
$admin_role->weight = 3;
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();
variable_set('site_name', 'Curso Unizar');
variable_set('site_slogan', '');
variable_set('features_default_export_path', 'profiles/cursodrupal/modules/features');
entity_info_cache_clear();
cursodrupal_install_all_updates();
}
function cursodrupal_install_all_updates() {
drupal_flush_all_caches();
drupal_get_messages('status');
// Salto 7001
cursodrupal_update_7002();
}
/**
* Activa el módulo admin_menu_toolbar y desactiva el módulo toolbar
*/
function cursodrupal_update_7001() {
module_enable(array('admin_menu_toolbar'));
module_disable(array('toolbar'));
}
/**
* Carga términos en la taxonomía
*/
function cursodrupal_update_7002() {
$vocabulary = taxonomy_vocabulary_machine_name_load('categorias');
if ($vocabulary) {
$terminos = array('pop', 'rock', 'opera');
$term = array();
foreach ($terminos as $termino) {
$term['name'] = $termino;
$term['vid'] = $vocabulary->vid;
taxonomy_term_save((object)$term);
}
}
}