Project

General

Profile

Download (9.8 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
    // Roles same as in D5 portals.
235
    'access administration menu',
236
    'administer blocks',
237
    'administer cdm_dataportal',
238
    'cdm_dataportal view notes',
239
    // @comment WA: Devel and IMCE modules are not required modules in this profile.
240
    // 'access devel information',
241
    // 'access imce',
242
    // 'administer imce',
243
    'administer menu',
244
    'access content',
245
    'administer content types',
246
    'administer nodes',
247
    'create page content',
248
    'edit own page content',
249
    'view revisions',
250
    'access administration pages',
251
    'administer site configuration',
252
    'administer users',
253

    
254
    // Roles as in D5 but with different name.
255
    'edit any page content',
256
    'edit any article content',
257
    'create article content',
258
    'edit own article content',
259
    'administer themes',
260

    
261
    // New roles for D7.
262
    'access content overview',
263
    'access site in maintenance mode',
264
    'bypass node access',
265
    'view the administration theme',
266
    // 'use text format 3',
267
  );
268
  user_role_grant_permissions($admin_role->rid, $permissions);
269

    
270
  // Assign user 1 the "CDM admin" role.
271
  db_insert('users_roles')
272
    ->fields(array('uid' => 1, 'rid' => $admin_role->rid))
273
    ->execute();
274

    
275
  /****************************************
276
   *  Create the front page
277
   ****************************************/
278
  $node = new stdClass();
279
  $node->uid = 1;
280
  $node->type = 'page';
281

    
282
  // Sets some defaults.
283
  node_object_prepare($node);
284

    
285
  $node->status = 1;
286
  $node->language = LANGUAGE_NONE;
287

    
288
  // Promoted to front page.
289
  $node->promote = 0;
290

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

    
312
 }
(2-2/3)