This repository has been archived by the owner on Nov 2, 2022. It is now read-only.
forked from os2loop/profile
-
Notifications
You must be signed in to change notification settings - Fork 1
/
loopdk.install
181 lines (154 loc) · 3.92 KB
/
loopdk.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
<?php
/**
* @file
* Install, update and uninstall functions for the Loop installation profile.
*/
/**
* Implements hook_install().
*
* Setting up default and admin theme. Activate node editing from admin theme.
* Enable user tracking via Google Analytics.
* Setup "Page not found" and "Access denied" pages.
*
* @see system_install()
*/
function loopdk_install() {
// Set default variables.
$default_theme = 'loop';
$admin_theme = 'seven';
// Enable themes.
theme_enable(array($default_theme, $admin_theme));
// Enable $default_theme.
variable_set('theme_default', $default_theme);
// Enable $admin_theme.
variable_set('admin_theme', $admin_theme);
// Activate admin theme when editing a node.
variable_set('node_admin_theme', '1');
// Enable User tracking in Google Analytics.
variable_set('googleanalytics_trackuserid', 1);
// Setup page not found.
loopdk_page_not_found();
// Setup access denied page.
loopdk_access_denied_page();
// Ignore any other install messages.
drupal_get_messages();
// Clear caches.
drupal_flush_all_caches();
}
/**
* Add a basic page for page-not-found.
*/
function loopdk_page_not_found() {
$node = new stdClass();
$node->uid = 1;
$node->title = 'Page not found';
$node->type = 'page';
$node->language = 'und';
$node->field_ding_page_body = array(
'und' => array(
array(
'value' => 'Page not found',
'format' => 'editor',
'safe_value' => '<p>Page not found</p>',
),
),
);
$node->path = array(
'alias' => 'page-not-found',
'language' => 'und',
);
node_save($node);
// Set the 404 page.
variable_set('site_404', 'page-not-found');
}
/**
* Add a basic access denied page.
*/
function loopdk_access_denied_page() {
$node = new stdClass();
$node->uid = 1;
$node->title = 'Access denied';
$node->type = 'page';
$node->language = 'und';
$node->field_ding_page_body = array(
'und' => array(
array(
'value' => 'Access denied',
'format' => 'editor',
'safe_value' => '<p>Access denied</p>',
),
),
);
$node->path = array(
'alias' => 'access_denied',
'language' => 'und',
);
node_save($node);
// Set the 404 page.
variable_set('site_403', 'access_denied');
}
/**
* Update the database with the newest translations.
*/
function loopdk_translation_update() {
// Update build-in translation group.
$file = new stdClass();
$file->uri = DRUPAL_ROOT . '/profiles/loopdk/translations/default.da.po';
$file->filename = basename($file->uri);
_locale_import_po($file, 'da', LOCALE_IMPORT_KEEP, 'default');
}
/**
* Update our own translations.
*/
function loopdk_update_7001() {
loopdk_translation_update();
}
/**
* Updated translations.
*/
function loopdk_update_7002() {
loopdk_translation_update();
}
/**
* Delete nodes and content types for leaf, tree and index.
*/
function loopdk_update_7003() {
$types = array(
'leaf',
'index',
'tree',
);
foreach ($types as $type) {
// First, delete nodes.
$results = db_select('node', 'n')
->fields('n', array('nid'))
->condition('type', $type)
->execute();
foreach ($results as $result) {
$nids[] = $result->nid;
}
if (!empty($nids)) {
node_delete_multiple($nids);
drupal_set_message(t('%count nodes has been deleted.', array('%count' => count($nids))));
}
// Then, delete content type.
if (node_type_load($type)) {
node_type_delete($type);
variable_del('node_preview_' . $type);
drupal_set_message(t('%type content type has been deleted.', array('%type' => $type)));
}
}
node_types_rebuild();
menu_rebuild();
// Uninstall module.
if (module_exists('loop_external_data')) {
module_disable(array('loop_external_data'));
drupal_uninstall_modules(array('loop_external_data'));
}
}
/**
* Updated translations.
*/
function loopdk_update_7004() {
loopdk_translation_update();
}