Project

General

Profile

Download (6.71 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
  variable_set('theme_default', 'garland');
19

    
20
  include_once DRUPAL_ROOT . '/profiles/standard/standard.install';
21
  standard_install();
22
  
23
  // Disable the blocks that were enabled for the dashboard in the standard install.
24
  // In the CDM dataportals we use the admin_menu module instead of taskbar and dashboard.
25
  $query = db_update('block')->fields(array('status' => '0'))
26
  ->condition('region', 'dashboard_main', '=')
27
  ->execute();
28
  $query = db_update('block')->fields(array('status' => '0'))
29
  ->condition('region', 'dashboard_sidebar', '=')
30
  ->execute();  
31

    
32
  // CDM Portal specific settings.
33
    variable_set('anonymous', 'Anonymous');
34
  if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
35
    variable_set('file_temporary_path', 'c:\\windows\\temp');
36
  }
37
  else {
38
    variable_set('file_temporary_path', '/tmp');
39
  }
40

    
41
  // Do not use the line-break filter for the full_html input format.
42
  $full_html_format = array(
43
    'format' => 'full_html',
44
    'name' => 'Full HTML',
45
    'weight' => 1,
46
    'filters' => array(
47
      // URL filter.
48
      'filter_url' => array(
49
        'weight' => 0,
50
        'status' => 1,
51
      ),
52
      // HTML corrector filter.
53
      'filter_htmlcorrector' => array(
54
        'weight' => 10,
55
        'status' => 1,
56
      ),
57
    ),
58
  );
59
  $full_html_format = (object) $full_html_format;
60
  filter_format_save($full_html_format);
61
  
62
  // variable_set('filter_html_1', 1);
63
  // variable_set('menu_primary_menu', 2);
64
  // variable_set('menu_secondary_menu', 2);
65
  variable_set('node_options_forum', array (0 => 'status'));
66
  variable_set('node_options_page', array (0 => 'status'));
67
  // variable_set('site_footer', '');
68
  variable_set('site_frontpage', 'node/1');
69
  variable_set('site_mail', '');
70
  // variable_set('site_mission', '');
71
  variable_set('site_name', 'CDM Dataportal');
72
  variable_set('site_slogan', '');
73
  variable_set('cdm_dataportal_geoservice_display_width', '600');
74
  
75
  // Enable the Garland theme.
76
  db_update('system')
77
  ->fields(array('status' => 1))
78
  ->condition('type', 'theme')
79
  ->condition('name', 'garland')
80
  ->execute();
81

    
82
// a:16:{s:11:"toggle_logo";i:1;s:11:"toggle_name";i:1;s:13:"toggle_slogan";i:0;s:14:"toggle_mission";i:0;s:24:"toggle_node_user_picture";i:0;s:27:"toggle_comment_user_picture";i:0;s:13:"toggle_search";i:1;s:14:"toggle_favicon";i:1;s:12:"default_logo";i:1;s:9:"logo_path";s:0:"";s:11:"logo_upload";s:0:"";s:15:"default_favicon";i:1;s:12:"favicon_path";s:0:"";s:14:"favicon_upload";s:0:"";s:2:"op";s:18:"Save configuration";s:10:"form_token";s:32:"3e11e7c40e73cf4b3e70ae5703d87d72";}
83
  variable_set('theme_settings', array (
84
    'toggle_node_info_page' => FALSE,
85
    'toggle_node_info_cdm_media' => FALSE,
86
    'toggle_node_info_cdm_name' => FALSE,
87
    'toggle_node_info_cdm_taxon' => FALSE,
88
    'toggle_node_info_cdm_reference' => FALSE,
89
  ));
90

    
91
  variable_set('cdm_webservice_debug', 0);
92
  variable_set('cdm_webservice_cache', 0);
93
  variable_set('distribution_sort', 'HIDE_TDWG2');
94

    
95
  variable_set('baselayers', array(
96
    'metacarta_vmap0' => 'metacarta_vmap0',
97
    'PREFERRED' => 'metacarta_vmap0'
98
  ));
99

    
100
  // USER_REGISTER_ADMINISTRATORS_ONLY = 0
101
  // USER_REGISTER_VISITORS = 1
102
  // USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL = 2
103
  variable_set('user_register', USER_REGISTER_ADMINISTRATORS_ONLY);
104

    
105
  // Create a role for CDM administrator.
106
  $admin_role = new stdClass();
107
  $admin_role->name = 'CDM admin';
108
  $admin_role->weight = 3;
109
  user_role_save($admin_role);
110

    
111
  // Make sure these permissions are present, e.g. that the modules defining these permissions are installed.
112
  // This because user_role_grant_permissions() will create the permission in the role_permision table if it does not
113
  // exist, and for that it needs to find a module that defines the permission (there is a module column in this table).
114
  $permissions = array(
115
    // Roles same as in D5 portals.
116
    'access administration menu',
117
    'administer blocks',
118
    'administer cdm_dataportal',
119
    'cdm_dataportal view notes',
120
    // @comment WA: Devel and IMCE modules are not required modules in this profile.
121
    // 'access devel information',
122
    // 'access imce',
123
    // 'administer imce',
124
    'administer menu',
125
    'access content',
126
    'administer content types',
127
    'administer nodes',
128
    'create page content',
129
    'edit own page content',
130
    'view revisions',
131
    'access administration pages',
132
    'administer site configuration',
133
    'administer users',
134

    
135
    // Roles as in D5 but with different name.
136
    'edit any page content',
137
    'edit any article content',
138
    'create article content',
139
    'edit own article content',
140
    'administer themes',
141

    
142
    // New roles for D7.
143
    'access content overview',
144
    'access site in maintenance mode',
145
    'bypass node access',
146
    'view the administration theme',
147
    // 'use text format 3',
148
  );
149
  user_role_grant_permissions($admin_role->rid, $permissions);
150

    
151
  /*
152
  // Create a portal admin user (uid = 1).
153
  $user = user_save(new stdClass(), array(
154
    'name' => 'admin',
155
    'mail' => 'admin@dataportal.net',
156
    'status' => '1',
157
    'init' => 'wp5Admin@bgbm.org',
158
    'pass' => 'admin',
159
  ));
160
*/
161
  // Assign user 1 the "CDM admin" role.
162
  db_insert('users_roles')
163
  ->fields(array('uid' => 1, 'rid' => $admin_role->rid))
164
  ->execute();
165

    
166
  // Create a first node page.
167
  $node = new stdClass();
168
  $node->uid = 1;
169
  $node->type = 'page';
170

    
171
  // Sets some defaults.
172
  node_object_prepare($node);
173

    
174
  $node->status = 1;
175
  $node->language = LANGUAGE_NONE;
176
  
177
  // Promoted to front page.
178
  $node->promote = 0;
179
  
180
  // Comments on.
181
  $node->comment = 1;
182
  $node->title = 'CDM DataPortal';
183
  // Format to use = full html.
184
  $node->body[$node->language][0]['format'] = 'full_html';
185
  $node->body[$node->language][0]['value'] = sprintf(
186
    '<h3>Welcome to your CDM DataPortal. </h3>
187
    This data portal makes full use of the Common Data Model (CDM),
188
    a central component of the Internet Platform for Cybertaxonomy being
189
    developed by EDIT workpackage 5. All taxon pages are created as dynamic
190
    web pages from the underlying database.
191
    In order to finish the setup of your DataPortal please visit the %s.
192
    The CDM Dataportal provides several Drupal Blocks (<i>taxon search</i>,
193
    <i>classification browser</i>, <i>external links</i>,
194
    <i>print this page</i>) which you may want to activate in the
195
    %s.',
196
    l('CDM Dataportal settings','admin/config/cdm_dataportal'),
197
    l('Blocks Settings', 'admin/structure/block')
198
  );
199
  node_save($node);
200

    
201
 }
(2-2/3)