Project

General

Profile

Download (10 KB) Statistics
| Branch: | Tag: | Revision:
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
  /****************************************
79
   *  Blocks
80
   ****************************************/
81

    
82
  // >>> admin/structure/block
83
  //    Disable the blocks that were enabled for the dashboard in the standard install.
84
  //    In the CDM dataportals we use the admin_menu module instead of taskbar and dashboard.
85
  $query = db_update('block')->fields(array('status' => '0'))
86
    ->condition('region', 'dashboard_main', '=')
87
    ->execute();
88
  $query = db_update('block')->fields(array('status' => '0'))
89
    ->condition('region', 'dashboard_sidebar', '=')
90
    ->execute();
91

    
92
  // disable "Search form"  block for all themes
93
  $query = db_update('block')->fields(array('status' => '0'))
94
    ->condition(
95
        db_and()
96
          ->condition('module', 'search', '=')
97
          ->condition('delta', 'form', '=')
98
        )
99
    ->execute();
100

    
101
  // disable the "Powered by Drupal" block for all themes
102
  $query = db_update('block')->fields(array('status' => '0'))
103
    ->condition(
104
        db_and()
105
          ->condition('module', 'system', '=')
106
          ->condition('delta', 'powered-by', '=')
107
        )
108
    ->execute();
109

    
110
  // enable "CDM Search Taxa" block for all themes
111
  $new_blocks = array(
112
      array(
113
          'module' => 'cdm_dataportal',
114
          'delta' => '2',
115
          'theme' => $default_theme,
116
          'status' => 1,
117
          'weight' => -11,
118
          'region' => 'sidebar_first',
119
          'pages' => '',
120
          'cache' => -1,
121
      ),
122
   );
123
  $query = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
124
  foreach ($new_blocks as $block) {
125
    $query->values($block);
126
  }
127
  $query->execute();
128

    
129

    
130
 /****************************************
131
  *  Reconfigure Drupal core modules
132
  ****************************************/
133

    
134
  // >>> admin/config/media/file-system
135
  //    Temporary directory
136
  if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
137
    variable_set('file_temporary_path', 'c:\\windows\\temp');
138
  }
139
  else {
140
    variable_set('file_temporary_path', '/tmp');
141
  }
142

    
143
  // >>> admin/config/content/formats
144
  //    Do not use the line-break filter for the full_html input format.
145
  $full_html_format = array(
146
    'format' => 'full_html',
147
    'name' => 'Full HTML',
148
    'weight' => 1,
149
    'filters' => array(
150
      // URL filter.
151
      'filter_url' => array(
152
        'weight' => 0,
153
        'status' => 1,
154
      ),
155
      // HTML corrector filter.
156
      'filter_htmlcorrector' => array(
157
        'weight' => 10,
158
        'status' => 1,
159
      ),
160
    ),
161
  );
162
  $full_html_format = (object) $full_html_format;
163
  filter_format_save($full_html_format);
164

    
165
  // variable_set('filter_html_1', 1);
166
  // variable_set('menu_primary_menu', 2);
167
  // variable_set('menu_secondary_menu', 2);
168

    
169

    
170
  variable_set('node_options_forum', array (0 => 'status'));
171
  variable_set('node_options_page', array (0 => 'status'));
172
  // variable_set('site_footer', '');
173

    
174
  // >>> admin/config/system/site-information
175
  //
176
  variable_set('site_frontpage', 'node/1');
177
  variable_set('site_mail', '');
178
  // variable_set('site_mission', '');
179
  variable_set('site_name', 'CDM Dataportal');
180
  variable_set('site_slogan', '');
181
  variable_set('cdm_dataportal_geoservice_display_width', '600');
182

    
183

    
184
  // >>> admin/structure/types/manage/*
185
  //    Display author and date information: [off]
186
  variable_set('node_submitted_page', 0);
187
  variable_set('node_submitted_article', 0);
188
  variable_set('node_submitted_cdm_media', 0);
189
  variable_set('node_submitted_cdm_name', 0);
190
  variable_set('node_submitted_cdm_taxon', 0);
191
  variable_set('node_submitted_cdm_reference', 0);
192
  // turn comments off for all content types (disabling the comment module would lead to an error)
193
  variable_set('comment_page', 0);
194
  variable_set('comment_article', 0);
195
  variable_set('comment_cdm_media', 0);
196
  variable_set('comment_cdm_name', 0);
197
  variable_set('comment_cdm_taxon', 0);
198
  variable_set('comment_cdm_reference', 0);
199

    
200

    
201
  /****************************************
202
   * CDM DataPortal - specific
203
   *
204
   *  TODO consider moving these into
205
   *       the module
206
   ****************************************/
207
  variable_set('cdm_webservice_debug', 0);
208
  variable_set('cdm_webservice_cache', 0);
209
  variable_set('distribution_sort', 'HIDE_TDWG2');
210

    
211
  variable_set('baselayers', array(
212
    'metacarta_vmap0' => 'metacarta_vmap0',
213
    'PREFERRED' => 'metacarta_vmap0'
214
  ));
215

    
216
  /****************************************
217
   * User management
218
   ****************************************/
219
  // USER_REGISTER_ADMINISTRATORS_ONLY = 0
220
  // USER_REGISTER_VISITORS = 1
221
  // USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL = 2
222
  variable_set('user_register', USER_REGISTER_ADMINISTRATORS_ONLY);
223

    
224
  // Create a role for CDM administrator.
225
  $admin_role = new stdClass();
226
  $admin_role->name = 'CDM admin';
227
  $admin_role->weight = 3;
228
  user_role_save($admin_role);
229

    
230
  // Make sure these permissions are present, e.g. that the modules defining these permissions are installed.
231
  // This because user_role_grant_permissions() will create the permission in the role_permision table if it does not
232
  // exist, and for that it needs to find a module that defines the permission (there is a module column in this table).
233
  $permissions = array(
234
    'access administration menu',
235
    'access administration pages',
236
    'access content',
237
    'access content overview',
238
    'access extlinks content',
239
    'access site in maintenance mode',
240
    'administer blocks',
241
    'administer cdm_dataportal',
242
    'administer content types',
243
    'administer extlinks',
244
    'administer menu',
245
    'administer nodes',
246
    'administer site configuration',
247
    'administer themes',
248
    'administer users',
249
    'bypass node access',
250
    'cdm_dataportal view notes',
251
    'create article content',
252
    'create page content',
253
    'create url aliases',
254
    'delete any article content',
255
    'delete any page content',
256
    'delete own article content',
257
    'delete own page content',
258
    'delete revisions',
259
    'edit any article content',
260
    'edit any page content',
261
    'edit own article content',
262
    'edit own page content',
263
    'flush caches',
264
    'revert revisions',
265
    'use text format full_html',
266
    'view own unpublished content',
267
    'view revisions',
268
    'view the administration theme'
269
    // Devel and IMCE modules are not yet required modules in this profile.
270
    // 'access devel information',
271
    // 'access imce',
272
    // 'administer imce',
273
  );
274
  user_role_grant_permissions($admin_role->rid, $permissions);
275

    
276
  // Assign user 1 the "CDM admin" role.
277
  db_insert('users_roles')
278
    ->fields(array('uid' => 1, 'rid' => $admin_role->rid))
279
    ->execute();
280

    
281
  /****************************************
282
   *  Create the front page
283
   ****************************************/
284
  $node = new stdClass();
285
  $node->uid = 1;
286
  $node->type = 'page';
287

    
288
  // Sets some defaults.
289
  node_object_prepare($node);
290

    
291
  $node->status = 1;
292
  $node->language = LANGUAGE_NONE;
293

    
294
  // Promoted to front page.
295
  $node->promote = 0;
296

    
297
  // Comments on.
298
  //   $node->comment = 1;
299
  $node->title = 'CDM DataPortal';
300
  // Format to use = full html.
301
  $node->body[$node->language][0]['format'] = 'full_html';
302
  $node->body[$node->language][0]['value'] = sprintf(
303
    '<h3>Welcome to your CDM DataPortal. </h3>
304
    This data portal makes full use of the Common Data Model (CDM),
305
    a central component of the Internet Platform for Cybertaxonomy being
306
    developed by EDIT workpackage 5. All taxon pages are created as dynamic
307
    web pages from the underlying database.
308
    In order to finish the setup of your DataPortal please visit the %s.
309
    The CDM Dataportal provides several Drupal Blocks (<i>taxon search</i>,
310
    <i>classification browser</i>, <i>external links</i>,
311
    <i>print this page</i>) which you may want to activate in the
312
    %s.',
313
    l('CDM Dataportal settings','admin/config/cdm_dataportal/settings'),
314
    l('Blocks Settings', 'admin/structure/block')
315
  );
316
  node_save($node);
317

    
318
 }
(2-2/3)