cdm-dataportal / 7.x / modules / cdm_dataportal / profile / CDM_Portal / CDM_Portal.install @ a4f964ee
History | View | Annotate | Download (10.9 KB)
1 |
<?php |
---|---|
2 |
/** |
3 |
* @file |
4 |
* Install, update and uninstall functions for CDM_DataPortal install profile. |
5 |
* |
6 |
* This profile performs the same actions as the standard profile, but with |
7 |
* some customizations for CDM portals. |
8 |
*/ |
9 |
|
10 |
/** |
11 |
* Implements hook_install(). |
12 |
* |
13 |
* Perform actions to set up the site for this profile. |
14 |
* |
15 |
* @see system_install() |
16 |
*/ |
17 |
function CDM_Portal_install() { |
18 |
|
19 |
|
20 |
/**************************************** |
21 |
* First of all configure the default theme |
22 |
****************************************/ |
23 |
|
24 |
// >>> admin/appearance |
25 |
// set the default theme |
26 |
// This must be done first, otherwise blocks are not |
27 |
// configured correctly for the default theme |
28 |
$default_theme = 'bartik'; |
29 |
if( drupal_get_path('theme', 'zen_dataportal') ){ |
30 |
$default_theme = 'zen_dataportal'; |
31 |
} |
32 |
variable_set('theme_default', $default_theme); |
33 |
|
34 |
// enable default theme |
35 |
db_update('system') |
36 |
->fields(array('status' => 1)) |
37 |
->condition( |
38 |
db_and() |
39 |
->condition('type', 'theme') |
40 |
->condition('name', $default_theme)) |
41 |
->execute(); |
42 |
|
43 |
// Run drupal standard install after the theme has been chosen |
44 |
// standard_install() will configure blocks, filters, etc. |
45 |
// After the standard_install() the dataportal |
46 |
// customization can be applied |
47 |
|
48 |
include_once DRUPAL_ROOT . '/profiles/standard/standard.install'; |
49 |
standard_install(); |
50 |
|
51 |
// >>> admin/appearance/settings |
52 |
// Toggle display of various page details |
53 |
// some of the below keys are specific to the |
54 |
// zen theme |
55 |
variable_set('theme_settings', array( |
56 |
'toggle_logo' => 1, |
57 |
'toggle_name' => 1, |
58 |
'toggle_slogan' => 0, |
59 |
'toggle_node_user_picture' => 0, |
60 |
'toggle_comment_user_picture' => 0, |
61 |
'toggle_comment_user_verification' => 0, |
62 |
'toggle_favicon' => 1, |
63 |
'toggle_main_menu' => 1, |
64 |
'toggle_secondary_menu' => 0, |
65 |
'default_logo' => 1, |
66 |
'logo_path' => NULL, |
67 |
'logo_upload' => NULL, |
68 |
'default_favicon' => 1, |
69 |
'favicon_path' => NULL, |
70 |
'favicon_upload' => NULL, |
71 |
// >>> admin/appearance/settings/zen_dataportal |
72 |
// Display breadcrumbs only in the admin section |
73 |
'zen_breadcrumb' => 'admin', |
74 |
'zen_rebuild_registry' => 0, |
75 |
)); |
76 |
|
77 |
/**************************************** |
78 |
* Reconfigure Drupal core modules |
79 |
****************************************/ |
80 |
|
81 |
// >>> admin/config/media/file-system |
82 |
// Temporary directory |
83 |
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
84 |
variable_set('file_temporary_path', 'c:\\windows\\temp'); |
85 |
} |
86 |
else { |
87 |
variable_set('file_temporary_path', '/tmp'); |
88 |
} |
89 |
|
90 |
// >>> admin/config/content/formats |
91 |
// Do not use the line-break filter for the full_html input format. |
92 |
$full_html_format = array( |
93 |
'format' => 'full_html', |
94 |
'name' => 'Full HTML', |
95 |
'weight' => 1, |
96 |
'filters' => array( |
97 |
// URL filter. |
98 |
'filter_url' => array( |
99 |
'weight' => 0, |
100 |
'status' => 1, |
101 |
), |
102 |
// HTML corrector filter. |
103 |
'filter_htmlcorrector' => array( |
104 |
'weight' => 10, |
105 |
'status' => 1, |
106 |
), |
107 |
), |
108 |
); |
109 |
$full_html_format = (object) $full_html_format; |
110 |
filter_format_save($full_html_format); |
111 |
|
112 |
// variable_set('filter_html_1', 1); |
113 |
// variable_set('menu_primary_menu', 2); |
114 |
// variable_set('menu_secondary_menu', 2); |
115 |
|
116 |
|
117 |
variable_set('node_options_forum', array (0 => 'status')); |
118 |
variable_set('node_options_page', array (0 => 'status')); |
119 |
// variable_set('site_footer', ''); |
120 |
|
121 |
// >>> admin/config/system/site-information |
122 |
// |
123 |
variable_set('site_frontpage', 'node/1'); |
124 |
variable_set('site_mail', ''); |
125 |
// variable_set('site_mission', ''); |
126 |
variable_set('site_name', 'CDM Dataportal'); |
127 |
variable_set('site_slogan', ''); |
128 |
variable_set('cdm_dataportal_geoservice_display_width', '600'); |
129 |
|
130 |
// >>> admin/config/development/logging |
131 |
// Error messages to display: Errors and warnings |
132 |
variable_set('error_level', '1'); |
133 |
|
134 |
// >>> admin/structure/types/manage/* |
135 |
// Display author and date information: [off] |
136 |
variable_set('node_submitted_page', 0); |
137 |
variable_set('node_submitted_article', 0); |
138 |
variable_set('node_submitted_cdm_media', 0); |
139 |
variable_set('node_submitted_cdm_name', 0); |
140 |
variable_set('node_submitted_cdm_taxon', 0); |
141 |
variable_set('node_submitted_cdm_reference', 0); |
142 |
// turn comments off for all content types (disabling the comment module would lead to an error) |
143 |
variable_set('comment_page', 0); |
144 |
variable_set('comment_article', 0); |
145 |
variable_set('comment_cdm_media', 0); |
146 |
variable_set('comment_cdm_name', 0); |
147 |
variable_set('comment_cdm_taxon', 0); |
148 |
variable_set('comment_cdm_reference', 0); |
149 |
|
150 |
|
151 |
/**************************************** |
152 |
* CDM DataPortal - specific |
153 |
* |
154 |
* TODO consider moving these into |
155 |
* the module |
156 |
****************************************/ |
157 |
|
158 |
variable_set('cdm_webservice_cache', 0); |
159 |
variable_set('distribution_sort', 'HIDE_TDWG2'); |
160 |
|
161 |
variable_set('baselayers', array( |
162 |
'metacarta_vmap0' => 'metacarta_vmap0', |
163 |
'PREFERRED' => 'metacarta_vmap0' |
164 |
)); |
165 |
|
166 |
/**************************************** |
167 |
* User management |
168 |
****************************************/ |
169 |
// USER_REGISTER_ADMINISTRATORS_ONLY = 0 |
170 |
// USER_REGISTER_VISITORS = 1 |
171 |
// USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL = 2 |
172 |
variable_set('user_register', USER_REGISTER_ADMINISTRATORS_ONLY); |
173 |
|
174 |
// Create a role for CDM administrator. |
175 |
$admin_role = new stdClass(); |
176 |
$admin_role->name = 'CDM admin'; |
177 |
$admin_role->weight = 3; |
178 |
user_role_save($admin_role); |
179 |
|
180 |
// Make sure these permissions are present, e.g. that the modules defining these permissions are installed. |
181 |
// This because user_role_grant_permissions() will create the permission in the role_permision table if it does not |
182 |
// exist, and for that it needs to find a module that defines the permission (there is a module column in this table). |
183 |
$permissions = array( |
184 |
'access administration menu', |
185 |
'access administration pages', |
186 |
'access content', |
187 |
'access content overview', |
188 |
'access extlinks content', |
189 |
'access site in maintenance mode', |
190 |
'administer blocks', |
191 |
'administer cdm_dataportal', |
192 |
'administer content types', |
193 |
'administer extlinks', |
194 |
'administer menu', |
195 |
'administer nodes', |
196 |
'administer site configuration', |
197 |
'administer themes', |
198 |
'administer users', |
199 |
'bypass node access', |
200 |
'cdm_dataportal view notes', |
201 |
'create article content', |
202 |
'create page content', |
203 |
'create url aliases', |
204 |
'delete any article content', |
205 |
'delete any page content', |
206 |
'delete own article content', |
207 |
'delete own page content', |
208 |
'delete revisions', |
209 |
'edit any article content', |
210 |
'edit any page content', |
211 |
'edit own article content', |
212 |
'edit own page content', |
213 |
'flush caches', |
214 |
'revert revisions', |
215 |
'use text format full_html', |
216 |
'view own unpublished content', |
217 |
'view revisions', |
218 |
'view the administration theme' |
219 |
// Devel and IMCE modules are not yet required modules in this profile. |
220 |
// 'access devel information', |
221 |
// 'access imce', |
222 |
// 'administer imce', |
223 |
); |
224 |
user_role_grant_permissions($admin_role->rid, $permissions); |
225 |
|
226 |
// Assign user 1 the "CDM admin" role. |
227 |
db_insert('users_roles') |
228 |
->fields(array('uid' => 1, 'rid' => $admin_role->rid)) |
229 |
->execute(); |
230 |
|
231 |
/**************************************** |
232 |
* Blocks |
233 |
****************************************/ |
234 |
|
235 |
// >>> admin/structure/block |
236 |
// Disable the blocks that were enabled for the dashboard in the standard install. |
237 |
// In the CDM dataportals we use the admin_menu module instead of taskbar and dashboard. |
238 |
$query = db_update('block')->fields(array('status' => '0')) |
239 |
->condition('region', 'dashboard_main', '=') |
240 |
->execute(); |
241 |
$query = db_update('block')->fields(array('status' => '0')) |
242 |
->condition('region', 'dashboard_sidebar', '=') |
243 |
->execute(); |
244 |
|
245 |
// disable "Search form" block for all themes |
246 |
$query = db_update('block')->fields(array('status' => '0')) |
247 |
->condition( |
248 |
db_and() |
249 |
->condition('module', 'search', '=') |
250 |
->condition('delta', 'form', '=') |
251 |
) |
252 |
->execute(); |
253 |
|
254 |
// disable the "Powered by Drupal" block for all themes |
255 |
$query = db_update('block')->fields(array('status' => '0')) |
256 |
->condition( |
257 |
db_and() |
258 |
->condition('module', 'system', '=') |
259 |
->condition('delta', 'powered-by', '=') |
260 |
) |
261 |
->execute(); |
262 |
|
263 |
$new_blocks = array( |
264 |
// enable "CDM Search Taxa" block for all themes |
265 |
array( |
266 |
'block' => array( |
267 |
'module' => 'cdm_dataportal', |
268 |
'delta' => '2', |
269 |
'theme' => $default_theme, |
270 |
'status' => 1, |
271 |
'weight' => -11, |
272 |
'region' => 'sidebar_first', |
273 |
'pages' => '', |
274 |
'cache' => -1, |
275 |
) |
276 |
), |
277 |
// CDM web service debug block |
278 |
array( |
279 |
'block' => array( |
280 |
'module' => 'cdm_api', |
281 |
'delta' => 'cdm_ws_debug', |
282 |
'theme' => $default_theme, |
283 |
'status' => 1, |
284 |
'weight' => -50, |
285 |
'region' => 'sidebar_first', |
286 |
'pages' => '', |
287 |
'cache' => -1, |
288 |
), |
289 |
'block_role' => array( |
290 |
'module' => 'cdm_api', |
291 |
'delta' => 'cdm_ws_debug', |
292 |
'rid' => $admin_role->rid |
293 |
) |
294 |
) |
295 |
); |
296 |
$block_insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache')); |
297 |
$block_role_insert = db_insert('block_role')->fields(array('module', 'delta', 'rid')); |
298 |
foreach ($new_blocks as $block) { |
299 |
$block_insert->values($block['block']); |
300 |
if(isset($block['block_role'])){ |
301 |
$block_role_insert->values($block['block_role']); |
302 |
} |
303 |
} |
304 |
$block_insert->execute(); |
305 |
$block_role_insert->execute(); |
306 |
|
307 |
/**************************************** |
308 |
* Create the front page |
309 |
****************************************/ |
310 |
$node = new stdClass(); |
311 |
$node->uid = 1; |
312 |
$node->type = 'page'; |
313 |
|
314 |
// Sets some defaults. |
315 |
node_object_prepare($node); |
316 |
|
317 |
$node->status = 1; |
318 |
$node->language = LANGUAGE_NONE; |
319 |
|
320 |
// Promoted to front page. |
321 |
$node->promote = 0; |
322 |
|
323 |
// Comments on. |
324 |
// $node->comment = 1; |
325 |
$node->title = 'CDM DataPortal'; |
326 |
// Format to use = full html. |
327 |
$node->body[$node->language][0]['format'] = 'full_html'; |
328 |
$node->body[$node->language][0]['value'] = sprintf( |
329 |
'<h3>Welcome to your CDM DataPortal. </h3> |
330 |
This data portal makes full use of the Common Data Model (CDM), |
331 |
a central component of the Internet Platform for Cybertaxonomy being |
332 |
developed by EDIT workpackage 5. All taxon pages are created as dynamic |
333 |
web pages from the underlying database. |
334 |
In order to finish the setup of your DataPortal please visit the %s. |
335 |
The CDM Dataportal provides several Drupal Blocks (<i>taxon search</i>, |
336 |
<i>classification browser</i>, <i>external links</i>, |
337 |
<i>print this page</i>) which you may want to activate in the |
338 |
%s.', |
339 |
l('CDM Dataportal settings','admin/config/cdm_dataportal/settings'), |
340 |
l('Blocks Settings', 'admin/structure/block') |
341 |
); |
342 |
node_save($node); |
343 |
|
344 |
} |