Project

General

Profile

Download (10.7 KB) Statistics
| Branch: | Tag: | Revision:
1 8ad37213 w.addink
<?php
2
/**
3
 * @file
4
 * Install, update and uninstall functions for CDM_DataPortal install profile.
5
 *
6 665559ca Andreas Kohlbecker
 * This profile performs the same actions as the standard profile, but with
7 8ad37213 w.addink
 * 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 665559ca Andreas Kohlbecker
20 284fb36d Andreas Kohlbecker
 /****************************************
21
  * First of all configure the default theme
22
  ****************************************/
23 665559ca Andreas Kohlbecker
24 284fb36d Andreas Kohlbecker
  // >>> admin/appearance
25 665559ca Andreas Kohlbecker
  //    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 284fb36d Andreas Kohlbecker
    $default_theme = 'zen_dataportal';
31 665559ca Andreas Kohlbecker
  }
32
  variable_set('theme_default', $default_theme);
33 284fb36d Andreas Kohlbecker
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 665559ca Andreas Kohlbecker
      ->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 284fb36d Andreas Kohlbecker
  // 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 665559ca Andreas Kohlbecker
  ));
76
77 284fb36d Andreas Kohlbecker
 /****************************************
78
  *  Reconfigure Drupal core modules
79 665559ca Andreas Kohlbecker
  ****************************************/
80
81
  // >>> admin/config/media/file-system
82
  //    Temporary directory
83 8ad37213 w.addink
  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 665559ca Andreas Kohlbecker
  // >>> admin/config/content/formats
91
  //    Do not use the line-break filter for the full_html input format.
92 8ad37213 w.addink
  $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 665559ca Andreas Kohlbecker
112 8ad37213 w.addink
  // variable_set('filter_html_1', 1);
113
  // variable_set('menu_primary_menu', 2);
114
  // variable_set('menu_secondary_menu', 2);
115 665559ca Andreas Kohlbecker
116
117 8ad37213 w.addink
  variable_set('node_options_forum', array (0 => 'status'));
118
  variable_set('node_options_page', array (0 => 'status'));
119
  // variable_set('site_footer', '');
120 665559ca Andreas Kohlbecker
121
  // >>> admin/config/system/site-information
122
  //
123 8ad37213 w.addink
  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 51537e91 Andreas Kohlbecker
  // >>> admin/config/development/logging
131
  //    Error messages to display: Errors and warnings
132
  variable_set('error_level', '1');
133 665559ca Andreas Kohlbecker
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 284fb36d Andreas Kohlbecker
  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 665559ca Andreas Kohlbecker
  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 a4f964ee Andreas Kohlbecker
158 8ad37213 w.addink
  variable_set('cdm_webservice_cache', 0);
159
160 665559ca Andreas Kohlbecker
  /****************************************
161
   * User management
162
   ****************************************/
163 8ad37213 w.addink
  // USER_REGISTER_ADMINISTRATORS_ONLY = 0
164
  // USER_REGISTER_VISITORS = 1
165
  // USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL = 2
166
  variable_set('user_register', USER_REGISTER_ADMINISTRATORS_ONLY);
167
168
  // Create a role for CDM administrator.
169
  $admin_role = new stdClass();
170
  $admin_role->name = 'CDM admin';
171
  $admin_role->weight = 3;
172
  user_role_save($admin_role);
173
174
  // Make sure these permissions are present, e.g. that the modules defining these permissions are installed.
175
  // This because user_role_grant_permissions() will create the permission in the role_permision table if it does not
176
  // exist, and for that it needs to find a module that defines the permission (there is a module column in this table).
177
  $permissions = array(
178
    'access administration menu',
179 3e36c87c Andreas Kohlbecker
    'access administration pages',
180
    'access content',
181
    'access content overview',
182
    'access extlinks content',
183
    'access site in maintenance mode',
184 8ad37213 w.addink
    'administer blocks',
185
    'administer cdm_dataportal',
186
    'administer content types',
187 3e36c87c Andreas Kohlbecker
    'administer extlinks',
188
    'administer menu',
189 8ad37213 w.addink
    'administer nodes',
190
    'administer site configuration',
191 3e36c87c Andreas Kohlbecker
    'administer themes',
192 8ad37213 w.addink
    'administer users',
193 3e36c87c Andreas Kohlbecker
    'bypass node access',
194
    'cdm_dataportal view notes',
195 8ad37213 w.addink
    'create article content',
196 3e36c87c Andreas Kohlbecker
    'create page content',
197
    'create url aliases',
198
    'delete any article content',
199
    'delete any page content',
200
    'delete own article content',
201
    'delete own page content',
202
    'delete revisions',
203
    'edit any article content',
204
    'edit any page content',
205 8ad37213 w.addink
    'edit own article content',
206 3e36c87c Andreas Kohlbecker
    'edit own page content',
207
    'flush caches',
208
    'revert revisions',
209
    'use text format full_html',
210
    'view own unpublished content',
211
    'view revisions',
212
    'view the administration theme'
213
    // Devel and IMCE modules are not yet required modules in this profile.
214
    // 'access devel information',
215
    // 'access imce',
216
    // 'administer imce',
217 8ad37213 w.addink
  );
218
  user_role_grant_permissions($admin_role->rid, $permissions);
219
220
  // Assign user 1 the "CDM admin" role.
221
  db_insert('users_roles')
222 665559ca Andreas Kohlbecker
    ->fields(array('uid' => 1, 'rid' => $admin_role->rid))
223
    ->execute();
224 8ad37213 w.addink
225 665559ca Andreas Kohlbecker
  /****************************************
226 86b65fa0 Andreas Kohlbecker
   *  Blocks
227 665559ca Andreas Kohlbecker
   ****************************************/
228 86b65fa0 Andreas Kohlbecker
229
  // >>> admin/structure/block
230
  //    Disable the blocks that were enabled for the dashboard in the standard install.
231
  //    In the CDM dataportals we use the admin_menu module instead of taskbar and dashboard.
232
  $query = db_update('block')->fields(array('status' => '0'))
233
  ->condition('region', 'dashboard_main', '=')
234
  ->execute();
235
  $query = db_update('block')->fields(array('status' => '0'))
236
  ->condition('region', 'dashboard_sidebar', '=')
237
  ->execute();
238
239
  // disable "Search form"  block for all themes
240
  $query = db_update('block')->fields(array('status' => '0'))
241
  ->condition(
242
      db_and()
243
      ->condition('module', 'search', '=')
244
      ->condition('delta', 'form', '=')
245
  )
246
  ->execute();
247
248
  // disable the "Powered by Drupal" block for all themes
249
  $query = db_update('block')->fields(array('status' => '0'))
250
  ->condition(
251
      db_and()
252
      ->condition('module', 'system', '=')
253
      ->condition('delta', 'powered-by', '=')
254
  )
255
  ->execute();
256
257
  $new_blocks = array(
258
      // enable "CDM Search Taxa" block for all themes
259
      array(
260
          'block' => array(
261
              'module' => 'cdm_dataportal',
262
              'delta' => '2',
263
              'theme' => $default_theme,
264
              'status' => 1,
265
              'weight' => -11,
266
              'region' => 'sidebar_first',
267
              'pages' => '',
268
              'cache' => -1,
269
          )
270
      ),
271
      // CDM web service debug block
272
      array(
273
          'block' => array(
274
              'module' => 'cdm_api',
275
              'delta' => 'cdm_ws_debug',
276
              'theme' => $default_theme,
277
              'status' => 1,
278
              'weight' => -50,
279
              'region' => 'sidebar_first',
280
              'pages' => '',
281
              'cache' => -1,
282
          ),
283
          'block_role' => array(
284
              'module' => 'cdm_api',
285
              'delta' => 'cdm_ws_debug',
286
              'rid' => $admin_role->rid
287
          )
288
      )
289
  );
290
  $block_insert = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
291
  $block_role_insert = db_insert('block_role')->fields(array('module', 'delta', 'rid'));
292
  foreach ($new_blocks as $block) {
293
    $block_insert->values($block['block']);
294
    if(isset($block['block_role'])){
295
      $block_role_insert->values($block['block_role']);
296
    }
297
  }
298
  $block_insert->execute();
299
  $block_role_insert->execute();
300
301
 /****************************************
302
  *  Create the front page
303
  ****************************************/
304 8ad37213 w.addink
  $node = new stdClass();
305
  $node->uid = 1;
306
  $node->type = 'page';
307
308
  // Sets some defaults.
309
  node_object_prepare($node);
310
311
  $node->status = 1;
312
  $node->language = LANGUAGE_NONE;
313 665559ca Andreas Kohlbecker
314 8ad37213 w.addink
  // Promoted to front page.
315
  $node->promote = 0;
316 665559ca Andreas Kohlbecker
317 8ad37213 w.addink
  // Comments on.
318 665559ca Andreas Kohlbecker
  //   $node->comment = 1;
319 8ad37213 w.addink
  $node->title = 'CDM DataPortal';
320
  // Format to use = full html.
321
  $node->body[$node->language][0]['format'] = 'full_html';
322
  $node->body[$node->language][0]['value'] = sprintf(
323
    '<h3>Welcome to your CDM DataPortal. </h3>
324
    This data portal makes full use of the Common Data Model (CDM),
325
    a central component of the Internet Platform for Cybertaxonomy being
326
    developed by EDIT workpackage 5. All taxon pages are created as dynamic
327
    web pages from the underlying database.
328
    In order to finish the setup of your DataPortal please visit the %s.
329
    The CDM Dataportal provides several Drupal Blocks (<i>taxon search</i>,
330
    <i>classification browser</i>, <i>external links</i>,
331
    <i>print this page</i>) which you may want to activate in the
332
    %s.',
333 665559ca Andreas Kohlbecker
    l('CDM Dataportal settings','admin/config/cdm_dataportal/settings'),
334 8ad37213 w.addink
    l('Blocks Settings', 'admin/structure/block')
335
  );
336
  node_save($node);
337
338
 }