| 1 |
<?php |
<?php |
| 2 |
// $Id: profiles.inc,v 1.1.2.1.2.11 2009/04/04 05:30:17 ronan Exp $ |
// $Id: profiles.inc,v 1.1.2.1.2.12 2009/04/05 03:04:08 ronan Exp $ |
| 3 |
|
|
| 4 |
|
|
| 5 |
/** |
/** |
| 44 |
function backup_migrate_backup_migrate_profiles() { |
function backup_migrate_backup_migrate_profiles() { |
| 45 |
$out = array(); |
$out = array(); |
| 46 |
|
|
| 47 |
|
// Get the module defaults. |
| 48 |
|
$out['default'] = _backup_migrate_profile_default_profile() + array('name' => t("Default Settings"), 'profile_id' => 'default'); |
| 49 |
|
|
| 50 |
// Get the default profiles from settings.php |
// Get the default profiles from settings.php |
| 51 |
$out += (array)variable_get('backup_migrate_profiles_defaults', array()); |
$out += (array)variable_get('backup_migrate_profiles_defaults', array()); |
| 52 |
|
|
| 53 |
// Get the saved profiless |
// Get the saved profiles |
| 54 |
$result = db_query('SELECT * FROM {backup_migrate_profiles}'); |
$result = db_query('SELECT * FROM {backup_migrate_profiles}'); |
| 55 |
while ($profile = db_fetch_array($result)) { |
while ($profile = db_fetch_array($result)) { |
| 56 |
$profile['db'] = TRUE; |
$profile['db'] = TRUE; |
| 59 |
$profile['filters'] = unserialize($profile['filters']); |
$profile['filters'] = unserialize($profile['filters']); |
| 60 |
$out[$profile['profile_id']] = $profile; |
$out[$profile['profile_id']] = $profile; |
| 61 |
} |
} |
| 62 |
|
|
| 63 |
return $out; |
return $out; |
| 64 |
} |
} |
| 65 |
|
|
| 258 |
$source = backup_migrate_get_destination($profile['source_id']); |
$source = backup_migrate_get_destination($profile['source_id']); |
| 259 |
$tables = _backup_migrate_get_table_names($source); |
$tables = _backup_migrate_get_table_names($source); |
| 260 |
|
|
| 261 |
$sources = _backup_migrate_get_destination_form_item_options('source'); |
$form['source'] = _backup_migrate_get_source_form($profile); |
|
if (count($sources) > 1) { |
|
|
$form['source'] = array( |
|
|
"#type" => "fieldset", |
|
|
"#title" => t("Backup Source"), |
|
|
"#collapsible" => TRUE, |
|
|
"#collapsed" => FALSE, |
|
|
"#tree" => FALSE, |
|
|
"#description" => t("Choose the database to backup. Any database destinations you have created and any databases specified in your settings.php can be backed up."), |
|
|
); |
|
|
$form['source']['source_id'] = array( |
|
|
"#type" => "select", |
|
|
"#title" => t("Source"), |
|
|
"#options" => _backup_migrate_get_destination_form_item_options('source'), |
|
|
"#default_value" => $profile['source_id'], |
|
|
); |
|
|
} |
|
|
else { |
|
|
$form['source_id'] = array( |
|
|
"#type" => "value", |
|
|
"#value" => $profile['source_id'], |
|
|
); |
|
|
} |
|
| 262 |
|
|
| 263 |
$form['file'] = array( |
$form['file'] = array( |
| 264 |
"#type" => "fieldset", |
"#type" => "fieldset", |
| 278 |
'#type' => 'fieldset', |
'#type' => 'fieldset', |
| 279 |
'#collapsible' => TRUE, |
'#collapsible' => TRUE, |
| 280 |
'#collapsed' => TRUE, |
'#collapsed' => TRUE, |
|
'#description' => t('Prefer raw-text replacements for text to avoid problems with HTML entities!'), |
|
| 281 |
); |
); |
| 282 |
$form['file']['token_help']['help'] = array( |
$form['file']['token_help']['help'] = array( |
| 283 |
'#value' => theme('token_help', ''), |
'#value' => theme('token_help', ''), |
| 284 |
); |
); |
| 285 |
$form['file']['filename']['#description'] = t('You can use tokens to in the file name.', array('!tokenurl' => 'http://drupal.org/project/token')); |
$form['file']['filename']['#description'] = t('You can use tokens in the file name.'); |
| 286 |
} |
} |
| 287 |
else { |
else { |
| 288 |
$form['file']['filename']['#description'] = t('If you install the <a href="!tokenurl">Token Module</a> you can use tokens to in the file name.', array('!tokenurl' => 'http://drupal.org/project/token')); |
$form['file']['filename']['#description'] = t('If you install the <a href="!tokenurl">Token Module</a> you can use tokens in the file name.', array('!tokenurl' => 'http://drupal.org/project/token')); |
| 289 |
} |
} |
| 290 |
$form['file']['append_timestamp'] = array( |
$form['file']['append_timestamp'] = array( |
| 291 |
"#type" => "checkbox", |
"#type" => "checkbox", |
| 337 |
} |
} |
| 338 |
|
|
| 339 |
/** |
/** |
| 340 |
|
* Get the source options as a form element. |
| 341 |
|
*/ |
| 342 |
|
function _backup_migrate_get_source_form($profile) { |
| 343 |
|
require_once './'. drupal_get_path('module', 'backup_migrate') .'/includes/destinations.inc'; |
| 344 |
|
|
| 345 |
|
$form = array(); |
| 346 |
|
$sources = _backup_migrate_get_source_pulldown($source_id = NULL); |
| 347 |
|
if (count($sources['#options']) > 1) { |
| 348 |
|
$form = array( |
| 349 |
|
"#type" => "fieldset", |
| 350 |
|
"#title" => t("Backup Source"), |
| 351 |
|
"#collapsible" => TRUE, |
| 352 |
|
"#collapsed" => FALSE, |
| 353 |
|
"#tree" => FALSE, |
| 354 |
|
); |
| 355 |
|
$sources['#description'] = t("Choose the database to backup. Any database destinations you have created and any databases specified in your settings.php can be backed up."); |
| 356 |
|
|
| 357 |
|
$form['source_id'] = $sources; |
| 358 |
|
} |
| 359 |
|
else { |
| 360 |
|
$form = array(); |
| 361 |
|
$form['source_id'] = array( |
| 362 |
|
"#type" => "value", |
| 363 |
|
"#value" => $profile['source_id'], |
| 364 |
|
); |
| 365 |
|
$form['source_name'] = array( |
| 366 |
|
"#type" => "value", |
| 367 |
|
"#value" => @$sources[$profile['source_id']], |
| 368 |
|
); |
| 369 |
|
} |
| 370 |
|
return $form; |
| 371 |
|
} |
| 372 |
|
|
| 373 |
|
/** |
| 374 |
|
* Get pulldown to select existing source options. |
| 375 |
|
*/ |
| 376 |
|
function _backup_migrate_get_source_pulldown($source_id = NULL) { |
| 377 |
|
require_once './'. drupal_get_path('module', 'backup_migrate') .'/includes/destinations.inc'; |
| 378 |
|
$sources = _backup_migrate_get_destination_form_item_options('source'); |
| 379 |
|
$form = array( |
| 380 |
|
"#type" => "select", |
| 381 |
|
"#title" => t("Backup Source"), |
| 382 |
|
"#options" => _backup_migrate_get_destination_form_item_options('source'), |
| 383 |
|
"#default_value" => $source_id, |
| 384 |
|
); |
| 385 |
|
return $form; |
| 386 |
|
} |
| 387 |
|
|
| 388 |
|
/** |
| 389 |
* Get the action links for a profile. |
* Get the action links for a profile. |
| 390 |
*/ |
*/ |
| 391 |
function _backup_migrate_profile_get_links($profile_id) { |
function _backup_migrate_profile_get_links($profile_id) { |