/[drupal]/contributions/modules/phpbb2drupal/phpbb2drupal.pages.inc
ViewVC logotype

Contents of /contributions/modules/phpbb2drupal/phpbb2drupal.pages.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.12 - (show annotations) (download) (as text)
Tue Jun 30 01:31:33 2009 UTC (4 months, 3 weeks ago) by nbz
Branch: MAIN
CVS Tags: DRUPAL-6--2-1, HEAD
Changes since 1.11: +2 -3 lines
File MIME type: text/x-php
#299145 - make the final fieldset be not collapsed
1 <?php
2 // $Id: phpbb2drupal.pages.inc,v 1.11 2008/11/30 15:26:18 nbz Exp $
3
4 /**
5 * Callback admin/settings/phpbb2drupal
6 */
7 function phpbb2drupal_admin_settings() {
8 global $conf ;
9 global $db_url;
10 $stage = variable_get('phpbb2drupal_config_stage', 0);
11
12 //We'll be checking that the setup is complete.
13 //If it is not complete, the migration will not go ahead.
14 $ready_for_migration = 1;
15
16 // Checking that the migration has been tested on a copy first.
17 $form['test'] = array(
18 '#type' => 'fieldset',
19 '#title' => t('Test on copy first'),
20 '#collapsible' => TRUE,
21 '#collapsed' => TRUE,
22 );
23
24 $output = '';
25 if (!variable_get('phpbb2drupal_tested', 0)) {
26 $form['test']['#collapsed']= FALSE;
27 $output = '<span class="marker">';
28 $ready_for_migration = 0;
29 }
30 $output .= t('<p>The migration will modify and even destroy some data. You must test this module on a copy of your data first, several times if necessary. Only use this module on your live data when you are familiar with the procedure and you\'re confident everything will run smoothly.</p>
31 <p>Also, you should make a full backup of your database just prior to permorming the migration on the live data. It is better to turn off both the phpBB board and the Drupal site during the migration.</p>');
32 if (!variable_get('phpbb2drupal_tested', 0)) {
33 $output .= '</span>';
34 }
35 $form['test']['intro'] = array('#value' => $output);
36 $output = '';
37
38 $form['test']['phpbb2drupal_tested'] = array(
39 '#type' => 'checkbox',
40 '#title' => t('I am running a trial migration on a disposable copy of the database OR I have already done so and I am running this on my live site, confident that the migration will proceed smoothly'),
41 '#return_value' => 1,
42 '#default_value' => variable_get('phpbb2drupal_tested', 0),
43 '#description' => '',
44 );
45
46 // Where is phpbb data?
47 $form['phpbb_data'] = array(
48 '#type' => 'fieldset',
49 '#title' => t('Location of phpBB data'),
50 '#collapsible' => TRUE,
51 '#collapsed' => TRUE,
52 );
53 $form['phpbb_data']['phpbb2drupal_same_db'] = array(
54 '#type' => 'checkbox',
55 '#title' => t('phpbb is on the same database as drupal'),
56 '#return_value' => 1,
57 '#default_value' => variable_get('phpbb2drupal_same_db', 1),
58 '#description' => '',
59 );
60 if (variable_get('phpbb2drupal_same_db', 1) != 1) {
61 $url = variable_get('phpbb2drupal_db_url', $db_url);
62 if ($url == $db_url) {
63 $output = '<p class="marker">'. t('Set the address of the phpBB database according to the following format: <br /><pre>mysql://phpbb_username:phpbb_password@localhost/phpbb_database</pre>') .'</p>';
64 $ready_for_migration = 0;
65 $form['phpbb']['#collapsed']= FALSE;
66 }
67
68 $form['phpbb_data']['phpbb2drupal_db_url'] = array(
69 '#type' => 'textfield',
70 '#title' => t('phpBB database location'),
71 '#default_value' => variable_get('phpbb2drupal_db_url', $db_url),
72 '#size' => 80,
73 '#maxlength' => 255,
74 '#description' => '',
75 );
76 }
77
78 $output = t('<p>Note that due to a limitation within Drupal core, we cannot import messages from one database type to another database type. E.g, we cannot import phpBB from a myqsl DB, to a postgresql DB. You need to import the data into the same type of database first (import all the phpBB data, as is, from mysql to postgresql.</p>
79 <p>If both phpBB and Drupal are on postgresql, see <a href="http://drupal.org/node/64877">this issue</a>.</p>');
80 $form['phpbb_data']['note'] = array('#value' => $output);
81
82 // phpBB2 table prefix
83 $output = '';
84 $form['phpbb_data']['phpbb2drupal_table_prefix'] = array(
85 '#type' => 'textfield',
86 '#title' => t('phpBB table prefix'),
87 '#default_value' => variable_get('phpbb2drupal_table_prefix', 'phpbb_'),
88 '#size' => 20,
89 '#maxlength' => 255,
90 '#description' => t('What prefix is used for your phpBB2 tables?'),
91 );
92 $pre = variable_get('phpbb2drupal_table_prefix', 'phpbb_');
93
94 $tables = array($pre .'forums', $pre .'posts', $pre .'topics', $pre .'users');
95
96 $result = _phpbb2drupal_check_tables($tables, 'phpbb', 0);
97 $output .= $result['html'];
98
99 if ($result['result'] != 1) {
100 $ready_for_migration = 0;
101 $form['phpbb_data']['#collapsed']= FALSE;
102 $output .= '<span class="marker">';
103 $output .= t("Some tables couldn't be found. This can be caused by an incorrect prefix or if your phpbb version is incorrectly set. Please correct the errors so that the phpBB tables can be accessed.");
104 $output .= '</span>';
105 }
106
107 $form['phpbb_data']['result'] = array('#value' => $output);
108
109 // Misc.
110 $form['time'] = array(
111 '#type' => 'fieldset',
112 '#title' => t('php Data Import Time limit'),
113 '#collapsible' => TRUE,
114 '#collapsed' => TRUE,
115 );
116
117 // Time limit
118 $output = '';
119 $form['time']['phpbb2drupal_time_limit'] = array(
120 '#type' => 'textfield',
121 '#title' => t('Time limit'),
122 '#default_value' => variable_get('phpbb2drupal_time_limit', 1200),
123 '#size' => 7,
124 '#maxlength' => 10,
125 '#description' => t('How long, in seconds, will the migration take?'),
126 );
127 $form['time']['info'] = array(
128 '#value' => '<p>'. t('1200 = 20 minutes should be enough for most boards. It worked well for a board with 300,000 rows. Beware: if your site is cohosted and safe-mode is on, then this value will have no effect.') .'</p>',
129 );
130
131 // USERS settings
132 $form['users'] = array(
133 '#type' => 'fieldset',
134 '#title' => t('User import'),
135 '#collapsible' => TRUE,
136 '#collapsed' => TRUE,
137 );
138 // User to map admin user too
139 $drupal_admin = user_load(array('uid' => 1));
140 $form['users']['phpbb2drupal_admin_user'] = array(
141 '#title' => t('User to map phpBB admin'),
142 '#type' => 'textfield',
143 '#autocomplete_path' => 'user/autocomplete',
144 '#default_value' => variable_get('phpbb2drupal_admin_user', $drupal_admin->name ),
145 );
146
147 //Registration date format
148 $form['users']['phpbb2drupal_regdate_us_english'] = array(
149 '#type' => 'checkbox',
150 '#title' => t('Convert Registration Date'),
151 '#default_value' => variable_get('phpbb2drupal_regdate_us_english', 0),
152 '#return_value' => 1,
153 '#description' => t('If you find out that the registration date for ALL your users is over 36 years ago, maybe your DB stores the registration date in the English US format (like: "Sep 11, 2001") instead as a linux timestamp (like: "1152568884"). If so, check this box.'),
154 );
155
156 // Import users who have never posted?
157 $form['users']['phpbb2drupal_import_spammers'] = array(
158 '#type' => 'checkbox',
159 '#title' => t('Import users who have never posted?'),
160 '#return_value' => 1,
161 '#default_value' => variable_get('phpbb2drupal_import_spammers', 1),
162 '#description' => 'Do you want to import with zero posts? If the phpbb forums had a problem with spam accounts, it may be beneficial to not import any users with zero posts.',
163 );
164
165 // Input format settings
166 $form['input'] = array(
167 '#type' => 'fieldset',
168 '#title' => t('Input Format settings'),
169 '#collapsible' => TRUE,
170 '#collapsed' => TRUE,
171 );
172 $output = '<p>'. t('Select which <a href="@link">input format</a> should the imported messages be set:', array('@link' => url('admin/settings/filters'))) .'</p>';
173 $form['input']['intro'] = array('#value' => $output);
174 $output = '';
175
176 $input_formats = array(0 => t('not set yet'));
177 $sql = 'SELECT format, name FROM {filter_formats}';
178 $result = db_query($sql);
179 while ($format = db_fetch_array($result)) {
180 $input_formats[$format['format']]= $format['name'];
181 }
182 $input_format = variable_get('phpbb2drupal_input_format', 0);
183 $form['input']['phpbb2drupal_input_format'] = array(
184 '#type' => 'radios',
185 '#title' => t('Input format'),
186 '#default_value' => $input_format,
187 '#options' => $input_formats,
188 );
189 if (!$input_format) {
190 $ready_for_migration = 0;
191 $form['input']['#collapsed']= FALSE;
192 }
193 $output .= '<p><em>'. t('This setting will be applied to all posts and private messages.') .'</em></p>';
194 $form['input']['result'] = array('#value' => $output);
195
196
197 // BBcode settings
198 $form['bbcode'] = array(
199 '#type' => 'fieldset',
200 '#title' => t('BBcode settings'),
201 '#collapsible' => TRUE,
202 '#collapsed' => TRUE,
203 );
204
205 $output = t('<p>pbpBB2 posts are often formatted in BBcode. During the import process, BBcode can be handled in two diffent ways:</p>
206 <ul><li>You can leave the BBcode as is, and use the <a href="http://drupal.org/project/bbcode" target="_blank">bbcode module</a> after the migration to filter the imported posts. In this case, the module is not required during the migration but you will need to install it and configure it later.</li>
207 <li>You can decide to have the BBcode filtered now and replaced by plain HTML. The BBcode module will be required during the migration process, but you can disable it later.</li> </ul>
208 <p>Which one do you choose?</p>
209 <p>Also, make sure to choose the proper input filter, for it will affect how the post is displayed. For example, if you choose to strip the bbcode altogether and use HTML instead, some HTML tags will be stripped by the "filtered HTML" input format, unless you add those tags in the list of allowed tags. Using "Full HTML" is recommanded for the imported posts when doing away with bbcode.</p>');
210 $form['bbcode']['intro'] = array('#value' => $output);
211 $form['bbcode']['phpbb2drupal_bbcode'] = array(
212 '#type' => 'radios',
213 '#title' => t('BBcode handling'),
214 '#default_value' => variable_get('phpbb2drupal_bbcode', 0),
215 '#options' => array(t('Leave BBcode as is.'), t('Transform BBcode into HTML.')),
216 '#description' => '',
217 );
218 $output = '';
219 $result7 = _phpbb2drupal_check_module('bbcode');
220 $output .= $result7['html'];
221 $link_input_format_enable = url('admin/settings/filters/'. $input_format);
222 $link_input_format_configure = url('admin/settings/filters/'. $input_format .'/configure');
223 if (variable_get('phpbb2drupal_bbcode', 0)) {
224 if ($result7['result'] == 0) {
225 $ready_for_migration = 0;
226 $form['bbcode']['#collapsed']= FALSE;
227 $output .= '<p><span class="marker">';
228 $output .= t('<a href="http://drupal.org/project/bbcode" target="_blank">The bbcode module</a> is required to transform BBcode into HTML.
229 You first need to <a href="@adminmodules">enable the bbcode module</a>', array('@adminmodules' => url('admin/modules')));
230 $output .= '</span></p>';
231 }
232 $sql = 'SELECT COUNT(*) FROM {filters} WHERE module = \'bbcode\' AND format = %d';
233 $result = db_query($sql, $input_format);
234 if (!db_result($result)) {
235 $form['bbcode']['#collapsed']= FALSE;
236 $output .= '<p class="marker">'. t('You need to <a href="@formatenable">enable bbcode in the selected input format</a> <a href="@formatconfigure">THEN click on configure to see bbcode options</a>', array('@formatenable' => $link_input_format_enable, '@formatconfigure' => $link_input_format_configure)) .'</p>';
237 }
238 $output .= '<p>'. t('For best results, <a href="@bbcodeconfig">all four BBcode configure options should be disabled</a>.', array('@bbcodeconfig' => url('admin/settings/filters/'. $input_format .'/configure'))) .'</p>';
239
240 }
241 else {
242 if ($result7['result'] == 0) {
243 $form['bbcode']['#collapsed']= FALSE;
244 $output .= '<p>'. t('<a href="http://drupal.org/project/bbcode" target="_blank">The bbcode module</a> is only recommanded. You may <a href="@adminmodules">enable the bbcode module</a> after having installed it.', array('@adminmodules' => url('admin/modules'))) .'</p>';
245 }
246 $output .= t('<p>Don\'t forget to <a href="@formatenable">enable bbcode in the selected input format</a> (admin > input formats > configure) and enable bbcode for the format selected for the imported posts. <a href="@formatconfigure">Then click on configure to see bbcode options</a></p>
247 <p>You may want to enable it for other input formats, too.</p>', array('@formatenable' => $link_input_format_enable, '@formatconfigure' => $link_input_format_configure));
248 }
249 $output .= '<p><em>'. t('This setting will be applied to all posts, private messages and the users\' signature.') .'</em></p>';
250 $form['bbcode']['result'] = array('#value' => $output);
251
252 //Attachments
253 $output ='';
254 $form['attachments'] = array(
255 '#type' => 'fieldset',
256 '#title' => t('Attachments import'),
257 '#collapsible' => TRUE,
258 '#collapsed' => TRUE,
259 );
260 $form['attachments']['phpbb2drupal_import_attachments'] = array(
261 '#type' => 'checkbox',
262 '#title' => t('Import attachments?'),
263 '#return_value' => 1,
264 '#default_value' => variable_get('phpbb2drupal_import_attachments', 0),
265 '#description' => '',
266 );
267 if (variable_get('phpbb2drupal_import_attachments', 0) == 1) {
268 // Comment attachments module
269 $result = _phpbb2drupal_check_module('comment_upload');
270 $output .= $result['html'];
271 if ($result['result'] != 1) {
272 $ready_for_migration = 0;
273 $form['attachments']['#collapsed']= FALSE;
274 $output .= '<span class="marker">';
275 $output .= t('The comment_upload.module is not enabled. You can go to the <a href="http://drupal.org/node/37197" target="_blank">module Home Page</a> and download it. Then go to <a href="@adminmodules">admin/build/modules</a> to enable the module.', array('@adminmodules' => url('admin/build/modules')));
276 $output .= '</span>';
277 $form['attachments']['result'] = array('#value' => $output);
278 }
279 }
280
281 // Are we ready for migration?
282 $form['migration'] = array(
283 '#type' => 'fieldset',
284 '#title' => 'Migration',
285 '#collapsible' => TRUE,
286 '#collapsed' => FALSE,
287 );
288 variable_set('phpbb2drupal_ready', $ready_for_migration);
289 if ($ready_for_migration) {
290 $output .= '<p>'. t('Check again all the settings above, and if everything is ok, <a href="@migratelink">you can now proceed with the migration</a>', array('@migratelink' => url('admin/phpbb2drupal/migrate'))) .'</p>';
291 }
292 else {
293 $output = '<p class="marker">'. t('You are not ready for the migration yet. Check the settings above.') .'</p>';
294 }
295
296 $form['migration']['info'] = array('#value' => $output);
297 return system_settings_form($form);
298
299 }
300
301 /**
302 * Callback admin/phpbb2drupal/postconfiguration
303 */
304 function phpbb2drupal_postconfiguration() {
305 $output = '<p>'. t('This page will help guide you set up the forums. Before continuing it may be best to have already:') .'</p>';
306 $output .= '<ul>';
307 $output .= '<li>'. t('Imported users, forums, topics and optionally polls using the phpbb2drupal Module') .'</li>';
308 $output .= '<li>'. t('Imported any additional data using add on modules if available.') .'</li>';
309 $output .= '</ul>';
310 //User Set up
311 $output .= '<h2>'. t('User Settings') .'</h2>';
312 $output .= '<p>'. t('Make sure your <a href="@usersettings">user settings</a> are correct. here you can enable or disable signature. In order to activate avatar/picture support, you need to enable pictures on this page and also:', array('@usersettings' => url('admin/user/settings'))) .'</p>';
313 $output .= '<ul>';
314 $output .= '<li>'. t('Tick the checkboxes to allow "User pictures in posts" and/or "User pictures in comments" on the <a href="@themeconfig">themes configuration</a> page.', array('@themeconfig' => url('admin/build/themes/settings'))) .'</li>';
315 $output .= '<li>'. t('Manually copy the avatars from the phpbb2/images/avatars/ directory to the @files directory.', array('@files' => file_directory_path(). '/pictures')) .'</li>';
316 $output .= '</ul>';
317 // Forum Set up
318 $output .= '<h2>'. t('Forum Settings') .'</h2>';
319 $output .= '<p>'. t('If you imported polls, you need to allow polls to show in the forums. On <a href="@forumvocab">this page</a> tick the checkbox next to the "polls" content type to allow polls to display in forums. Addidtionally check any additional content types you want to allow in the forums.',
320 array('@forumvocab' => url('admin/content/taxonomy/edit/vocabulary/' .variable_get('forum_nav_vocabulary', 0)))) .'</p>';
321 $output .= '<p>'. t('If need be, set up the private forums as explained in the <a href="http://drupal.org/node/58969" target="_blank">documentation</a>.') .'</p>';
322
323 // Redirection from old URL:
324 $output .= '<h2>'. t('Redirection from phpBB2 forum URL to new Drupal forum URL') .'</h2>';
325 $output .= '<p>'. t('Enable the phpbb_redirect.module. This way, users accessing URLs from your old phpBB2 installation will be redirected to your new Drupal forum. (note that currently the module assumes that the phpbb forum was located in the forum/ subdirectory of your Drupal installation).') .'</p>';
326
327 // BBcode
328 $bbcode = variable_get('phpbb2drupal_bbcode', 0);
329 if ($bbcode) {
330 $output .= '<h2>'. t('Remove BBcode module') .'</h2>';
331 $output .= '<p>'. t("The bbcode has been cleaned from the posts. You shouldn't need the bbcode module anymore. You can disable it.") .'</p>';
332 }
333 else {
334 $output .= '<h2>'. t('Configure BBcode module') .'</h2>';
335 $output .= '<p>'. t('Most probably, there are many phpBB forum postings formatted in BBcode. During the import procedure, the BBcode has been cleaned so that it can work with the Drupal bbcode.module. Please install and configure the <a href="http://drupal.org/project/bbcode" target="_blank">BBcode module</a> so that the forum topics display properly. See the BBcode module documentation for details.') .'</p>';
336 }
337
338 return $output;
339 }
340
341 /**
342 * Callback admin/phpbb2drupal
343 */
344 function phpbb2drupal_main() {
345 $output = '<ol><li>';
346 $output .= t('You may want to <a href="http://drupal.org/node/58199" target="_blank">check the documentation</a> before starting.');
347 $output .= '</li>';
348 $output .= '<li>';
349 $output .= t('phpass.module by default changes hashing for all users from md5 to phpass. If you do not want this, please select md5 as the password hash method on the <a href="@phpass">User Settings page</a>. This will not affect user import from phpbb as this module ignores that page.', array('@phpass' => url('admin/user/settings')));
350 $output .= '</li>';
351 $output .= '<li>';
352 $output .= l(t('Configure the migration'), 'admin/settings/phpbb2drupal');
353 $output .= '</li>';
354 $output .= '<li>';
355 $output .= l(t('Execute the migration'), 'admin/phpbb2drupal/migrate');
356 $output .= '</li>';
357 $output .= '<li>';
358 $output .= l(t('Post migration configuration'), 'admin/phpbb2drupal/postconfiguration');
359 $output .= '</li>';
360 $output .= '<li>';
361 $output .= t('Import additional data using other modules. Private Messages can be imported using the bundled phpbb2privatemsg module.');
362 $output .= '</li>';
363 $output .= '<li>';
364 $output .= t('<a href="@cleanuplink">Cleanup</a> (Accessing this link will delete all the saved phpbb2drupal settings: click only when you\'re done with all the above.)', array('@cleanuplink' => url('admin/phpbb2drupal/cleanup')));
365 $output .= '</li>';
366 $output .= '<li>';
367 $output .= t('Enable the phpBB_Redirect module for seamless redirection from the old forums to the new. This module requires <a href="@cleanurls">clean urls</a> to be active.', array('@cleanurls' => url('admin/settings/clean-urls')));
368 $output .= '</li>';
369 $output .= '<li>';
370 $output .= t('If you decide to use the phpBB_Redirect module, do NOT uninstall phpbb2drupal - This will delete tables necessary for redirection. You CAN deactivate the module safely.');
371 $output .= '</li>';
372 $output .= '</ol>';
373
374 // process will die() if the link to the phpBB2 database is wrong:
375 $output .= '<p>'. t('If the phpBB2 data is in another data base, but you made a mistake while setting up the data base url, you may be unable to access the setting page due to some limitations of the core of Drupal. <a href="@reseturl">Click here to reset the database url</a>.',
376 array('@reseturl' => url('admin/phpbb2drupal/reset'))) .'</p>';
377
378 return $output;
379 }

  ViewVC Help
Powered by ViewVC 1.1.2