diff --git a/backup_migrate.install b/backup_migrate.install index 49899ab..a1ff221 100644 --- a/backup_migrate.install +++ b/backup_migrate.install @@ -132,14 +132,14 @@ function backup_migrate_schema() { 'key name' => 'Profile ID', 'admin_title' => 'name', 'primary key' => 'profile_id', + // Exports will be defined as $preset. 'identifier' => 'item', - // Exports will be defined as $preset. + // Function hook name. 'default hook' => 'exportables_backup_migrate_profiles', - // Function hook name. 'api' => array( 'owner' => 'backup_migrate', + // Base name for api include files. 'api' => 'backup_migrate_exportables', - // Base name for api include files. 'minimum_version' => 1, 'current_version' => 1, ), @@ -150,8 +150,8 @@ function backup_migrate_schema() { 'unsigned' => TRUE, 'not null' => TRUE, 'description' => 'Primary ID field for the table. Not used for anything except internal lookups.', + // Do not export database-only keys. 'no export' => TRUE, - // Do not export database-only keys. ), 'machine_name' => array( 'type' => 'varchar', @@ -202,14 +202,14 @@ function backup_migrate_schema() { 'key name' => 'Destination ID', 'admin_title' => 'name', 'primary key' => 'destination_id', + // Exports will be defined as $preset. 'identifier' => 'item', - // Exports will be defined as $preset. + // Function hook name. 'default hook' => 'exportables_backup_migrate_destinations', - // Function hook name. 'api' => array( 'owner' => 'backup_migrate', + // Base name for api include files. 'api' => 'backup_migrate_exportables', - // Base name for api include files. 'minimum_version' => 1, 'current_version' => 1, ), @@ -220,8 +220,8 @@ function backup_migrate_schema() { 'unsigned' => TRUE, 'not null' => TRUE, 'description' => 'Primary ID field for the table. Not used for anything except internal lookups.', + // Do not export database-only keys. 'no export' => TRUE, - // Do not export database-only keys. ), 'machine_name' => array( 'type' => 'varchar', @@ -263,14 +263,14 @@ function backup_migrate_schema() { 'key name' => 'Source ID', 'admin_title' => 'name', 'primary key' => 'source_id', + // Exports will be defined as $preset. 'identifier' => 'item', - // Exports will be defined as $preset. + // Function hook name. 'default hook' => 'exportables_backup_migrate_sources', - // Function hook name. 'api' => array( 'owner' => 'backup_migrate', + // Base name for api include files. 'api' => 'backup_migrate_exportables', - // Base name for api include files. 'minimum_version' => 1, 'current_version' => 1, ), @@ -281,8 +281,8 @@ function backup_migrate_schema() { 'unsigned' => TRUE, 'not null' => TRUE, 'description' => 'Primary ID field for the table. Not used for anything except internal lookups.', + // Do not export database-only keys. 'no export' => TRUE, - // Do not export database-only keys. ), 'machine_name' => array( 'type' => 'varchar', @@ -325,14 +325,14 @@ function backup_migrate_schema() { 'key name' => 'Source ID', 'admin_title' => 'name', 'primary key' => 'schedule_id', + // Exports will be defined as $preset. 'identifier' => 'item', - // Exports will be defined as $preset. + // Function hook name. 'default hook' => 'exportables_backup_migrate_schedules', - // Function hook name. 'api' => array( 'owner' => 'backup_migrate', + // Base name for api include files. 'api' => 'backup_migrate_exportables', - // Base name for api include files. 'minimum_version' => 1, 'current_version' => 1, ), @@ -343,8 +343,8 @@ function backup_migrate_schema() { 'unsigned' => TRUE, 'not null' => TRUE, 'description' => 'Primary ID field for the table. Not used for anything except internal lookups.', + // Do not export database-only keys. 'no export' => TRUE, - // Do not export database-only keys. ), 'machine_name' => array( 'type' => 'varchar', @@ -478,7 +478,7 @@ function backup_migrate_update_2001() { } /** - * Clear the cache because there was a menu structure change in the dev of 2009-05-31. + * Clear the cache because there was a menu structure change. */ function backup_migrate_update_2002() { // Cache should clear automatically. Nothing to do here. @@ -623,7 +623,7 @@ function backup_migrate_update_7202() { } /** - * Update schedule last run times to use variables instead of saving with the schedule. + * Schedule last run times to use variables instead of saving with the schedule. */ function backup_migrate_update_7203() { $result = db_query('SELECT * FROM {backup_migrate_schedules}', array(), array('fetch' => PDO::FETCH_ASSOC)); @@ -781,8 +781,8 @@ function backup_migrate_update_7303() { 'unsigned' => TRUE, 'not null' => TRUE, 'description' => 'Primary ID field for the table. Not used for anything except internal lookups.', + // Do not export database-only keys. 'no export' => TRUE, - // Do not export database-only keys. ), array('primary key' => array($id)) ); diff --git a/backup_migrate.js b/backup_migrate.js index 15c215b..84591d2 100644 --- a/backup_migrate.js +++ b/backup_migrate.js @@ -1,9 +1,13 @@ /** * @file + * Custom JS for the Backup and Migrate module. */ + (function($) { + 'use strict'; + Drupal.behaviors.backupMigrate = { - attach: function(context) { + attach: function(context, settings) { if (Drupal.settings.backup_migrate !== undefined) { if (Drupal.settings.backup_migrate.dependents !== undefined) { for (key in Drupal.settings.backup_migrate.dependents) { @@ -15,15 +19,15 @@ var dependency = $(this); (function(dependent, dependency) { var checkval = function(inval) { - if (dependency.attr('type') == 'radio') { + if (dependency.attr('type') === 'radio') { var val = $('[name="' + dependency.attr('name') + '"]:checked').val(); - return val == inval; + return val === inval; } - else if (dependency.attr('type') == 'checkbox') { - return dependency.is(':checked') && inval == dependency.val(); + else if (dependency.attr('type') === 'checkbox') { + return dependency.is(':checked') && inval === dependency.val(); } else { - return dependency.val() == inval; + return dependency.val() === inval; } return false; }; @@ -61,7 +65,8 @@ $(this).remove(); }) - // Assign an action to the main selector to modify the secondary selector. + // Assign an action to the main selector to modify the secondary + // selector. selector.each(function() { $(this).bind('load change click keypress focus', function() { var group = $(this).find('option[value=' + $(this).val() + ']').parents('optgroup').attr('label'); @@ -78,6 +83,7 @@ }); })(info); } + // Add the convert to checkboxes functionality to all multiselects. $('#backup-migrate-ui-manual-backup-form select[multiple], #backup-migrate-crud-edit-form select[multiple]').each(function() { var self = this; @@ -92,23 +98,23 @@ $('').prepend( $('') .bind('click change load', function() { - if (this.checked) { - $(this).parent().addClass('checked'); - } - else { - $(this).parent().removeClass('checked'); - } - }).load() - ) - ) - ); + if (this.checked) { + $(this).parent().addClass('checked'); + } + else { + $(this).parent().removeClass('checked'); + } + }).load(); + ) + ) + ); }); $select.parent().find('.backup-migrate-checkbox-link').remove(); $select.before($checkboxes); $select.hide(); }) - ) - ); + ) + ); }); } } diff --git a/backup_migrate.module b/backup_migrate.module index 41cf8e8..266520f 100644 --- a/backup_migrate.module +++ b/backup_migrate.module @@ -2,10 +2,10 @@ /** * @file - * Backup and restore MySQL databases for Drupal. + * Backup and restore databases for Drupal. * - * Create (manually or scheduled) and restore backups of your Drupal MySQL - * database with an option to exclude table data (e.g. cache_*). + * Create (manually or scheduled) and restore backups of the Drupal database + * with an option to exclude table data (e.g. cache_*). */ define('BACKUP_MIGRATE_VERSION', '7.x-3.x'); @@ -268,10 +268,9 @@ function backup_migrate_form_update_script_selection_form_alter(&$form, $form_st /** * Implements hook_cron(). - * - * Takes care of scheduled backups and deletes abandoned temp files. */ function backup_migrate_cron() { + // Takes care of scheduled backups and deletes abandoned temp files. // Set the message mode to logging. _backup_migrate_message_callback('_backup_migrate_message_log'); @@ -381,8 +380,6 @@ function backup_migrate_theme() { return $themes; } -/* Blocks */ - /** * Implements hook_block_info(). */ @@ -468,17 +465,14 @@ function backup_migrate_backup_migrate_schedules() { /** * Implements hook_ctools_plugin_api(). - * - * Tell CTools that we support the default_mymodule_presets API. */ function backup_migrate_ctools_plugin_api($owner, $api) { + // Tell CTools that we support the default_mymodule_presets API. if ($owner == 'backup_migrate') { return array('version' => 1); } } -/* Menu Callbacks */ - /** * A menu callback helper. Handles file includes and interactivity setting. */ @@ -624,13 +618,13 @@ function backup_migrate_ui_schedule_form($form, &$form_state, $sources, $schedul '#title' => t('Automatically backup my @source', array('@source' => $source->get('name'))), '#default_value' => $schedule->get('enabled'), ); - /* - $form['quickschedule'][$id]['source_id'] = array( - '#type' => 'item', - '#title' => t('Backup Source'), - '#value' => $source->get('name'), - ); - */ + + // $form['quickschedule'][$id]['source_id'] = array( + // '#type' => 'item', + // '#title' => t('Backup Source'), + // '#value' => $source->get('name'), + // ); + $form['quickschedule'][$key]['settings'] = array( '#type' => 'backup_migrate_dependent', '#dependencies' => array( @@ -897,9 +891,8 @@ function theme_backup_migrate_ui_manual_quick_backup_form_inline($form) { $form['quickbackup']['destination']['copy']["#prefix"] = '
'; $form['quickbackup']['destination']['copy']["#suffix"] = $replacements['!to'] . '
'; // This is not good translation practice as it relies on the structure of - // English. - // If I add the pulldown to the label, howerver, the box toggles when the - // pulldown is clicked. + // English. If I add the pulldown to the label, howerver, the box toggles + // when the pulldown is clicked. // $form['quickbackup']['destination']['copy']['#title'] = t('Save a copy to'); unset($form['quickbackup']['source_id']); unset($form['quickbackup']['destination']['destination_id']); @@ -1050,8 +1043,8 @@ function backup_migrate_ui_manual_backup_form($form, &$form_state, $profile) { $form += _backup_migrate_ui_backup_settings_form($profile); - // Make the source settings dependent on the source selected. - // Except don't because it looks super weird. + // Make the source settings dependent on the source selected. Except don't + // because it looks super weird. // @code // foreach (element_children($form['sources']) as $source) { // $form['sources'][$source] = array( @@ -1340,7 +1333,7 @@ function backup_migrate_ui_manual_restore_form() { $form = array_merge_recursive($form, backup_migrate_filters_settings_form(backup_migrate_filters_settings_default('restore'), 'restore')); // Add the advanced fieldset if there are any fields in it. - if (@$form['advanced']) { + if (isset($form['advanced'])) { $form['advanced']['#type'] = 'fieldset'; $form['advanced']['#title'] = t('Advanced Options'); $form['advanced']['#collapsed'] = TRUE; @@ -1431,11 +1424,11 @@ function backup_migrate_ui_saved_backups() { // Add a remote backups warning if there are no remote backups. if (!$remote && user_access('administer backup and migrate')) { drupal_set_message( - t('You do not have any offsite backups. For the highest level of protection, create an offsite destination or set up NodeSquirrel to save your backups to.', - array( - '!addurl' => url(BACKUP_MIGRATE_MENU_PATH . '/settings/destination/add'), - '!nsurl' => url(BACKUP_MIGRATE_MENU_PATH . '/nodesquirrel'), - )), 'warning', FALSE); + t('You do not have any offsite backups. For the highest level of protection, create an offsite destination or set up NodeSquirrel to save your backups to.', + array( + '!addurl' => url(BACKUP_MIGRATE_MENU_PATH . '/settings/destination/add'), + '!nsurl' => url(BACKUP_MIGRATE_MENU_PATH . '/nodesquirrel'), + )), 'warning', FALSE); } return $out; @@ -1704,8 +1697,6 @@ function backup_migrate_shutdown($settings) { } } -/* Actions/Workflow integration */ - /** * Action to backup the drupal site. * @@ -1737,17 +1728,17 @@ function backup_migrate_shutdown($settings) { * }. */ -/* +/** * Implements hook_action_info(). -function backup_migrate_action_info() { -return array( -'backup_migrate_action_backup' => array( -'label' => t('Backup the database'), -'description' => t('Backup the database with the default settings.'), -), -); -} */ +// function backup_migrate_action_info() { +// return array( +// 'backup_migrate_action_backup' => array( +// 'label' => t('Backup the database'), +// 'description' => t('Backup the database with the default settings.'), +// ), +// ); +// } /** * Action callback. @@ -1756,8 +1747,6 @@ function backup_migrate_action_backup() { _backup_migrate_backup_with_defaults(); } -/* Utilities */ - /** * Backup the database with the default settings. */ diff --git a/includes/backup_migrate.drush.inc b/includes/backup_migrate.drush.inc index 00344ff..49527cb 100644 --- a/includes/backup_migrate.drush.inc +++ b/includes/backup_migrate.drush.inc @@ -40,7 +40,6 @@ function backup_migrate_drush_command() { 'callback' => 'backup_migrate_drush_destinations', 'description' => dt('Get a list of available destinations.'), ); - $items['bam-sources'] = array( 'callback' => 'backup_migrate_drush_sources', 'description' => dt('Get a list of available sources.'), @@ -114,7 +113,6 @@ function backup_migrate_drush_backup($source_id = 'db', $destination_id = 'manua * Restore to the default database. */ function backup_migrate_drush_restore($source_id = '', $destination_id = '', $file_id = '') { - backup_migrate_include('profiles', 'destinations', 'sources'); // Set the message mode to drush output. @@ -246,13 +244,15 @@ function backup_migrate_drush_destination_files($destination_id = NULL) { } } - $headers = array(array( - dt('Filename'), - dt('Destination'), - dt('Date'), - dt('Age'), - dt('Size'), - )); + $headers = array( + array( + dt('Filename'), + dt('Destination'), + dt('Date'), + dt('Age'), + dt('Size'), + ) + ); if (count($rows)) { array_multisort($sort, SORT_DESC, $rows); @@ -267,7 +267,8 @@ function backup_migrate_drush_destination_files($destination_id = NULL) { * Send a message to the drush log. */ function _backup_migrate_message_drush($message, $replace, $type) { - // If this is an error use drush_set_error to notify the end user and set the exit status. + // If this is an error use drush_set_error to notify the end user and set the + // exit status. if ($type == 'error') { drush_set_error(strip_tags(dt($message, $replace))); } diff --git a/includes/crud.inc b/includes/crud.inc index cef7487..0f01257 100644 --- a/includes/crud.inc +++ b/includes/crud.inc @@ -56,8 +56,9 @@ function backup_migrate_crud_subtypes($type) { backup_migrate_include($info['include']); } - // Allow modules (including this one) to declare backup and migrate subtypes. - // We don't use module_invoke_all so we can avoid the side-effects of array_merge_recursive. + // Allow modules (including this one) to declare backup and migrate + // subtypes. We don't use module_invoke_all so we can avoid the + // side-effects of array_merge_recursive. $out = array(); foreach (module_implements('backup_migrate_' . $type . '_subtypes') as $module) { $function = $module . '_backup_migrate_' . $type . '_subtypes'; @@ -87,7 +88,8 @@ function backup_migrate_crud_subtype_info($type, $subtype) { /** * Get a generic object of the given type to be used for static-like functions. * - * I'm not using actual static method calls since they don't work on variables prior to PHP 5.3.0 + * I'm not using actual static method calls since they don't work on variables + * prior to PHP 5.3.0. */ function backup_migrate_crud_type_load($type, $subtype = NULL) { $out = $info = NULL; @@ -232,7 +234,6 @@ function backup_migrate_crud_edit_form_submit($form, &$form_state) { } } - /** * Page callback to delete an item. */ @@ -374,7 +375,6 @@ function backup_migrate_crud_get_items($type) { } } - /** * Get an item of the specified type. */ @@ -394,7 +394,7 @@ function backup_migrate_crud_create_item($type, $params) { } /** - * A base class for items which can be stored in the database, listed, edited, deleted etc. + * A base class for items which can be stored in the database. */ class backup_migrate_item { var $show_in_list = TRUE; @@ -409,9 +409,11 @@ class backup_migrate_item { var $title_singular = 'Item'; /** - * This function is not supposed to be called. It is just here to help the po extractor out. + * This function is not supposed to be called. + * + * It is just here to help the po extractor out. */ - function strings() { + public function strings() { // Help the pot extractor find these strings. t('item'); t('items'); @@ -426,20 +428,20 @@ function strings() { t('Export !type'); } - /** - * Constructor, set the basic info pulled from the db or generated programatically. + * Set the basic info pulled from the db or generated programatically. */ - function __construct($params = array()) { + public function __construct($params = array()) { $this->from_array($this->_merge_defaults((array) $params, (array) $this->get_default_values())); } /** * Merge parameters with the given defaults. * - * Works like array_merge_recursive, but it doesn't turn scalar values into arrays. + * Works like array_merge_recursive, but it doesn't turn scalar values into + * arrays. */ - function _merge_defaults($params, $defaults) { + public function _merge_defaults($params, $defaults) { foreach ($defaults as $key => $val) { if (!isset($params[$key])) { $params[$key] = $val; @@ -454,14 +456,14 @@ function _merge_defaults($params, $defaults) { /** * Get the default values for standard parameters. */ - function get_default_values() { + public function get_default_values() { return $this->default_values; } /** * Save the item to the database. */ - function save() { + public function save() { if (!$this->get_id()) { $this->unique_id(); } @@ -472,16 +474,15 @@ function save() { /** * Delete the item from the database. */ - function delete() { + public function delete() { $keys = (array) $this->get_machine_name_field(); db_query('DELETE FROM {' . $this->db_table . '} WHERE ' . $keys[0] . ' = :id', array(':id' => $this->get_id())); } - /** * Load an existing item from an array. */ - function from_array($params) { + public function from_array($params) { foreach ($params as $key => $value) { if (method_exists($this, 'set_' . $key)) { $this->{'set_' . $key}($value); @@ -495,7 +496,7 @@ function from_array($params) { /** * Return as an array of values. */ - function to_array() { + public function to_array() { $out = array(); // Return fields as specified in the schema. $schema = $this->get_schema(); @@ -510,7 +511,7 @@ function to_array() { /** * Return as an exported array of values. */ - function export() { + public function export() { $out = $this->to_array(); $out['type_name'] = $this->type_name; @@ -524,7 +525,7 @@ function export() { /** * Load an existing item from an database (serialized) array. */ - function load_row($data) { + public function load_row($data) { $params = array(); $schema = $this->get_schema(); // Load fields as specified in the schema. @@ -534,11 +535,10 @@ function load_row($data) { $this->from_array($params); } - /** * Decode a loaded db row (unserialize necessary fields). */ - function decode_db_row($data) { + public function decode_db_row($data) { $params = array(); $schema = $this->get_schema(); // Load fields as specified in the schema. @@ -551,7 +551,7 @@ function decode_db_row($data) { /** * Return the fields which must be serialized before saving to the db. */ - function get_serialized_fields() { + public function get_serialized_fields() { $out = array(); $schema = $this->get_schema(); foreach ($schema['fields'] as $field => $info) { @@ -565,7 +565,7 @@ function get_serialized_fields() { /** * Get the primary key field title from the schema. */ - function get_primary_key() { + public function get_primary_key() { $schema = $this->get_schema(); return @$schema['primary key']; } @@ -573,7 +573,7 @@ function get_primary_key() { /** * Get the machine name field name from the schema. */ - function get_machine_name_field() { + public function get_machine_name_field() { $schema = $this->get_schema(); if (isset($schema['export']['key'])) { return $schema['export']['key']; @@ -584,7 +584,7 @@ function get_machine_name_field() { /** * Get the schema for the item type. */ - function get_schema() { + public function get_schema() { return drupal_get_schema($this->db_table); } @@ -593,7 +593,7 @@ function get_schema() { * * We only handle single field keys since that's all we need. */ - function get_id() { + public function get_id() { $keys = (array) $this->get_machine_name_field(); return !empty($keys[0]) && !empty($this->{$keys[0]}) ? (string) $this->{$keys[0]} : ''; } @@ -601,7 +601,7 @@ function get_id() { /** * Set the primary id for this item (if any is set). */ - function set_id($id) { + public function set_id($id) { $keys = (array) $this->get_machine_name_field(); if (!empty($keys[0])) { return $this->{$keys[0]} = $id; @@ -612,7 +612,7 @@ function set_id($id) { /** * Return a random (very very likely unique) string id for a new item. */ - function generate_id() { + public function generate_id() { $id = md5(uniqid(mt_rand(), TRUE)); // Find the shortest possible unique id from (min 4 chars). @@ -622,15 +622,18 @@ function generate_id() { return $new_id; } } - // If we get here, then all 28 increasingly complex ids were already taken so we'll try again. - // this could theoretially lead to an infinite loop, but the odds are incredibly low. + // If we get here, then all 28 increasingly complex ids were already taken + // so we'll try again; this could theoretially lead to an infinite loop, + // but the odds are incredibly low. return $this->generate_id(); } /** - * Make sure this item has a unique id. Should only be called for new items or the item will collide with itself. + * Make sure this item has a unique id. + * + * Should only be called for new items or the item will collide with itself. */ - function unique_id() { + public function unique_id() { $id = $this->get_id(); // Unset the autoincrement field so it can be regenerated. @@ -638,7 +641,8 @@ function unique_id() { $this->{$key} = NULL; } - // If the item doesn't have an ID or if it's id is already taken, generate random one. + // If the item doesn't have an ID or if it's id is already taken, generate + // random one. if (!$id || $this->item($id)) { $this->set_id($this->generate_id()); } @@ -647,26 +651,24 @@ function unique_id() { /** * Get the name of the item. */ - function get_name() { + public function get_name() { return @$this->name; } /** * Get the member with the given key. */ - function get($key) { + public function get($key) { if (method_exists($this, 'get_' . $key)) { return $this->{'get_' . $key}(); } return @$this->{$key}; } - /* UI Stuff */ - /** * Get the action links for a destination. */ - function get_action_links() { + public function get_action_links() { $out = array(); $item_id = $this->get_id(); @@ -693,7 +695,7 @@ function get_action_links() { /** * Get a table of all items of this type. */ - function get_list() { + public function get_list() { $items = $this->all_items(); $rows = array(); foreach ((array) $items as $item) { @@ -718,22 +720,21 @@ function get_list() { /** * Get the columns needed to list the type. */ - function show_in_list() { + public function show_in_list() { return $this->show_in_list; } /** * Get the columns needed to list the type. */ - function get_settings_path() { + public function get_settings_path() { return BACKUP_MIGRATE_MENU_PATH . $this->settings_path . $this->type_name; } - /** * Get the columns needed to list the type. */ - function get_list_column_info() { + public function get_list_column_info() { return array( 'actions' => array('title' => t('Operations'), 'html' => TRUE), ); @@ -742,7 +743,7 @@ function get_list_column_info() { /** * Get header for a lost of this type. */ - function get_list_header() { + public function get_list_header() { $out = array(); foreach ($this->get_list_column_info() as $key => $col) { $out[] = $col['title']; @@ -753,7 +754,7 @@ function get_list_header() { /** * Get a row of data to be used in a list of items of this type. */ - function get_list_row() { + public function get_list_row() { $out = array(); foreach ($this->get_list_column_info() as $key => $col) { $out[$key] = empty($col['html']) ? check_plain($this->get($key)) : $this->get($key); @@ -767,7 +768,7 @@ function get_list_row() { /** * Get the rendered action links for a destination. */ - function get_actions() { + public function get_actions() { $links = $this->get_action_links(); return implode("   ", $links); } @@ -775,7 +776,7 @@ function get_actions() { /** * Get the edit form for the item. */ - function edit_form() { + public function edit_form() { $form = array(); $form['item'] = array( '#type' => 'value', @@ -812,37 +813,36 @@ function edit_form() { /** * Validate the edit form for the item. */ - function edit_form_validate($form, &$form_state) { + public function edit_form_validate($form, &$form_state) { } /** * Submit the edit form for the item. */ - function edit_form_submit($form, &$form_state) { + public function edit_form_submit($form, &$form_state) { $this->from_array($form_state['values']); $this->save(); _backup_migrate_message('Your !type was saved', array('!type' => t($this->singular))); } /** - * Get the message to send to the user when confirming the deletion of the item. + * The message to send to the user when confirming the deletion of the item. */ - function delete_confirm_message() { + public function delete_confirm_message() { return t('Are you sure you want to delete the !type %name?', array('!type' => t($this->singular), '%name' => $this->get('name'))); } /** - * Get the message to send to the user when confirming the deletion of the item. + * The message to send to the user when confirming the deletion of the item. */ - function revert_confirm_message() { + public function revert_confirm_message() { return t('Are you sure you want to revert the !type %name back to the default settings?', array('!type' => t($this->singular), '%name' => $this->get('name'))); } - /* Static Functions */ /** * Get the menu items for manipulating this type. */ - function get_menu_items() { + public function get_menu_items() { $path = $this->get_settings_path(); $type = $this->type_name; @@ -898,9 +898,12 @@ function get_menu_items() { /** - * Create a new items with the given input. Doesn't load the parameters, but could use them to determine what type to create. + * Create a new items with the given input. + * + * Doesn't load the parameters, but could use them to determine what type to + * create. */ - function create($params = array()) { + public function create($params = array()) { $type = get_class($this); return new $type($params); } @@ -908,10 +911,11 @@ function create($params = array()) { /** * Get all of the given items. */ - function all_items() { + public function all_items() { $items = array(); - // Get any items stored as a variable. This allows destinations to be defined in settings.php + // Get any items stored as a variable. This allows destinations to be + // defined in settings.php $defaults = (array) variable_get($this->db_table . '_defaults', array()); foreach ($defaults as $info) { if (is_array($info) && $item = $this->create($info)) { @@ -952,7 +956,8 @@ function all_items() { } } - // Add the default items to the array or set the storage flag if they've already been overridden. + // Add the default items to the array or set the storage flag if they've + // already been overridden. foreach ($default_items as $item) { if (isset($items[$item->get_id()])) { $items[$item->get_id()]->storage = BACKUP_MIGRATE_STORAGE_OVERRIDEN; @@ -963,9 +968,10 @@ function all_items() { } } - // Allow other modules to alter the items. This should maybe be before the db override code above - // but then the filters are not able to set defaults for missing values. Other modules should just - // be careful not to overwrite the user's UI changes in an unexpected way. + // Allow other modules to alter the items. This should maybe be before the + // db override code above but then the filters are not able to set defaults + // for missing values. Other modules should just be careful not to + // overwrite the user's UI changes in an unexpected way. drupal_alter($this->db_table, $items); return $items; @@ -974,7 +980,7 @@ function all_items() { /** * A particular item. */ - function item($item_id) { + public function item($item_id) { $items = $this->all_items(); return !empty($items[$item_id]) ? $items[$item_id] : NULL; } @@ -982,7 +988,7 @@ function item($item_id) { /** * A particular item. */ - function item_exists($item_id) { + public function item_exists($item_id) { $items = $this->all_items(); return !empty($items[$item_id]); } diff --git a/includes/destinations.browser.inc b/includes/destinations.browser.inc index 0953498..1af06bb 100644 --- a/includes/destinations.browser.inc +++ b/includes/destinations.browser.inc @@ -28,8 +28,15 @@ public function get_list_row() { * @ingroup backup_migrate_destinations */ class backup_migrate_destination_browser_upload extends backup_migrate_destination_browser { + + /** + * {@inheritdoc} + */ var $supported_ops = array('restore'); + /** + * Constructor. + */ public function __construct() { $params = array(); $params['name'] = "Upload"; @@ -57,11 +64,21 @@ public function load_file($file_id) { * @ingroup backup_migrate_destinations */ class backup_migrate_destination_browser_download extends backup_migrate_destination_browser { + + /** + * {@inheritdoc} + */ var $supported_ops = array('manual backup'); - // Browser downloads must always be the last destination as they must end the - // current process when they are done. + + /** + * Browser downloads must always be the last destination as they must end the + * current process when they are done. + */ var $weight = 1000; + /** + * Constructor. + */ public function __construct() { $params = array(); $params['name'] = "Download"; diff --git a/includes/destinations.db.inc b/includes/destinations.db.inc index b8e4696..c68424d 100644 --- a/includes/destinations.db.inc +++ b/includes/destinations.db.inc @@ -16,14 +16,14 @@ class backup_migrate_destination_db extends backup_migrate_destination_remote { var $connection = NULL; - function type_name() { + public function type_name() { return t("Database"); } /** * Save the info by importing it into the database. */ - function save_file($file, $settings) { + public function save_file($file, $settings) { backup_migrate_include('files'); // Set the source_id to the destination_id in the settings since for a restore, the source_id is the @@ -39,7 +39,7 @@ function save_file($file, $settings) { /** * Destination configuration callback. */ - function edit_form() { + public function edit_form() { $form = parent::edit_form(); $form['scheme']['#title'] = t('Database type'); // $form['scheme']['#options'] = array($GLOBALS['db_type'] => $GLOBALS['db_type']); @@ -53,7 +53,7 @@ function edit_form() { /** * Validate the configuration form. Make sure the db info is valid. */ - function edit_form_validate($form, &$form_state) { + public function edit_form_validate($form, &$form_state) { if (!preg_match('/[a-zA-Z0-9_\$]+/', $form_state['values']['path'])) { form_set_error('path', t('The database name is not valid.')); } @@ -70,7 +70,7 @@ function edit_form_validate($form, &$form_state) { * necessarily extremely important to back up or migrate during development * (such as access log and watchdog). */ - function backup_settings_default() { + public function backup_settings_default() { $all_tables = $this->_get_table_names(); // Basic modules that should be excluded. @@ -117,7 +117,7 @@ function backup_settings_default() { /** * Get the form for the backup settings for this destination. */ - function backup_settings_form($settings) { + public function backup_settings_form($settings) { $objects = $this->get_object_names(); $form['#description'] = t("You may omit specific tables, or specific table data from the backup file. Only omit data that you know you will not need such as cache data, or tables from other applications. Excluding tables can break your Drupal install, so do not change these settings unless you know what you're doing."); $form['exclude_tables'] = array( @@ -149,7 +149,7 @@ function backup_settings_form($settings) { /** * Backup from this source. */ - function backup_to_file($file, $settings) { + public function backup_to_file($file, $settings) { $file->push_type($this->get_file_type_id()); backup_migrate_filters_invoke_all('pre_backup', $this, $file, $settings); @@ -166,7 +166,7 @@ function backup_to_file($file, $settings) { /** * Restore to this source. */ - function restore_from_file($file, &$settings) { + public function restore_from_file($file, &$settings) { $num = 0; $type = $this->get_file_type_id(); // Open the file using the file wrapper. Check that the dump is of the right type (allow .sql for legacy reasons). @@ -188,7 +188,7 @@ function restore_from_file($file, &$settings) { /** * Get the db connection for the specified db. */ - function _get_db_connection() { + public function _get_db_connection() { if (!$this->connection) { $target = $key = ''; $parts = explode(':', $this->get_id()); @@ -228,21 +228,21 @@ function _get_db_connection() { /** * Backup the databases to a file. */ - function _backup_db_to_file($file, $settings) { + public function _backup_db_to_file($file, $settings) { // Must be overridden. } /** * Backup the databases to a file. */ - function _restore_db_from_file($file, $settings) { + public function _restore_db_from_file($file, $settings) { // Must be overridden. } /** * Get a list of objects in the database. */ - function get_object_names() { + public function get_object_names() { // Must be overridden. $out = $this->_get_table_names(); if (method_exists($this, '_get_view_names')) { @@ -254,7 +254,7 @@ function get_object_names() { /** * Get a list of tables in the database. */ - function get_table_names() { + public function get_table_names() { // Must be overridden. $out = $this->_get_table_names(); return $out; @@ -263,7 +263,7 @@ function get_table_names() { /** * Get a list of tables in the database. */ - function _get_table_names() { + public function _get_table_names() { // Must be overridden. return array(); } @@ -271,7 +271,7 @@ function _get_table_names() { /** * Lock the database in anticipation of a backup. */ - function lock_tables($settings) { + public function lock_tables($settings) { if ($settings->filters['utils_lock_tables']) { $tables = array(); foreach ($this->get_table_names() as $table) { @@ -287,14 +287,14 @@ function lock_tables($settings) { /** * Lock the list of given tables in the database. */ - function _lock_tables($tables) { + public function _lock_tables($tables) { // Must be overridden. } /** * Unlock any tables that have been locked. */ - function unlock_tables($settings) { + public function unlock_tables($settings) { if ($settings->filters['utils_lock_tables']) { $this->_unlock_tables(); } @@ -303,14 +303,14 @@ function unlock_tables($settings) { /** * Unlock the list of given tables in the database. */ - function _unlock_tables($tables) { + public function _unlock_tables($tables) { // Must be overridden. } /** * Get the file type for to backup this destination to. */ - function get_file_type_id() { + public function get_file_type_id() { return 'sql'; } diff --git a/includes/destinations.db.mysql.inc b/includes/destinations.db.mysql.inc index cd667b9..3474216 100644 --- a/includes/destinations.db.mysql.inc +++ b/includes/destinations.db.mysql.inc @@ -17,14 +17,14 @@ * @ingroup backup_migrate_destinations */ class backup_migrate_destination_db_mysql extends backup_migrate_destination_db { - function type_name() { + public function type_name() { return t("MySQL Database"); } /** * Return a list of backup filetypes. */ - function file_types() { + public function file_types() { return array( "sql" => array( "extension" => "sql", @@ -44,7 +44,7 @@ function file_types() { /** * Declare any mysql databases defined in the settings.php file as a possible destination. */ - function destinations() { + public function destinations() { $out = array(); global $databases; foreach ((array) $databases as $db_key => $target) { @@ -77,14 +77,14 @@ function destinations() { /** * Get the file type for to backup this destination to. */ - function get_file_type_id() { + public function get_file_type_id() { return 'mysql'; } /** * Get the form for the backup settings for this destination. */ - function backup_settings_form($settings) { + public function backup_settings_form($settings) { $form = parent::backup_settings_form($settings); $form['use_mysqldump'] = array( @@ -105,7 +105,7 @@ function backup_settings_form($settings) { * That makes it easier to import without loading the whole file into memory. * The files are a little harder to read, but human-readability is not a priority. */ - function _backup_db_to_file($file, $settings) { + public function _backup_db_to_file($file, $settings) { if (!empty($settings->filters['use_mysqldump']) && $this->_backup_db_to_file_mysqldump($file, $settings)) { return TRUE; } @@ -152,7 +152,7 @@ function _backup_db_to_file($file, $settings) { /** * Backup the databases to a file using the mysqldump command. */ - function _backup_db_to_file_mysqldump($file, $settings) { + public function _backup_db_to_file_mysqldump($file, $settings) { $success = FALSE; $nodata_tables = array(); $alltables = $this->_get_tables(); @@ -198,7 +198,7 @@ function _backup_db_to_file_mysqldump($file, $settings) { /** * Backup the databases to a file. */ - function _restore_db_from_file($file, $settings) { + public function _restore_db_from_file($file, $settings) { $num = 0; if ($file->open() && $conn = $this->_get_db_connection()) { @@ -230,7 +230,7 @@ function _restore_db_from_file($file, $settings) { * * Supports the formatting created by mysqldump, but won't handle multiline comments. */ - function _read_sql_command_from_file($file) { + public function _read_sql_command_from_file($file) { $out = ''; while ($line = $file->read()) { $first2 = substr($line, 0, 2); @@ -251,7 +251,7 @@ function _read_sql_command_from_file($file) { /** * Get a list of tables in the database. */ - function _get_table_names() { + public function _get_table_names() { $out = array(); foreach ($this->_get_tables() as $table) { $out[$table['name']] = $table['name']; @@ -262,7 +262,7 @@ function _get_table_names() { /** * Get a list of views in the database. */ - function _get_view_names() { + public function _get_view_names() { $out = array(); foreach ($this->_get_views() as $view) { $out[$view['name']] = $view['name']; @@ -273,7 +273,7 @@ function _get_view_names() { /** * Lock the list of given tables in the database. */ - function _lock_tables($tables) { + public function _lock_tables($tables) { if ($tables) { $tables_escaped = array(); foreach ($tables as $table) { @@ -286,14 +286,14 @@ function _lock_tables($tables) { /** * Unlock all tables in the database. */ - function _unlock_tables($settings) { + public function _unlock_tables($settings) { $this->query('UNLOCK TABLES'); } /** * Get a list of tables in the db. */ - function _get_tables() { + public function _get_tables() { $out = array(); // get auto_increment values and names of all tables. $tables = $this->query("show table status", array(), array('fetch' => PDO::FETCH_ASSOC)); @@ -311,7 +311,7 @@ function _get_tables() { /** * Get a list of views in the db. */ - function _get_views() { + public function _get_views() { $out = array(); // get auto_increment values and names of all tables. $tables = $this->query("show table status", array(), array('fetch' => PDO::FETCH_ASSOC)); @@ -329,7 +329,7 @@ function _get_views() { /** * Get the sql for the structure of the given table. */ - function _get_table_structure_sql($table) { + public function _get_table_structure_sql($table) { $out = ""; $result = $this->query("SHOW CREATE TABLE `" . $table['name'] . "`", array(), array('fetch' => PDO::FETCH_ASSOC)); foreach ($result as $create) { @@ -350,7 +350,7 @@ function _get_table_structure_sql($table) { /** * Get the sql for the structure of the given table. */ - function _get_view_create_sql($view) { + public function _get_view_create_sql($view) { $out = ""; // Switch SQL mode to get rid of "CREATE ALGORITHM..." what requires more permissions + troubles with the DEFINER user. $sql_mode = $this->query("SELECT @@SESSION.sql_mode")->fetchField(); @@ -369,7 +369,7 @@ function _get_view_create_sql($view) { /** * Get the sql to insert the data for a given table. */ - function _dump_table_data_sql_to_file($file, $table) { + public function _dump_table_data_sql_to_file($file, $table) { $rows_per_line = variable_get('backup_migrate_data_rows_per_line', 30); $bytes_per_line = variable_get('backup_migrate_data_bytes_per_line', 2000); @@ -427,7 +427,7 @@ function _dump_table_data_sql_to_file($file, $table) { /** * Get the db connection for the specified db. */ - function _get_db_connection() { + public function _get_db_connection() { if (!$this->connection) { $this->connection = parent::_get_db_connection(); // Set the sql mode because the default is ANSI,TRADITIONAL which is not aware of collation or storage engine. @@ -439,7 +439,7 @@ function _get_db_connection() { /** * Run a db query on this destination's db. */ - function query($query, $args = array(), $options = array()) { + public function query($query, $args = array(), $options = array()) { if ($conn = $this->_get_db_connection()) { return $conn->query($query, $args, $options); } @@ -449,7 +449,7 @@ function query($query, $args = array(), $options = array()) { * The header for the top of the sql dump file. These commands set the connection * character encoding to help prevent encoding conversion issues. */ - function _get_sql_file_header() { + public function _get_sql_file_header() { return "/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; @@ -465,7 +465,7 @@ function _get_sql_file_header() { /** * The footer of the sql dump file. */ - function _get_sql_file_footer() { + public function _get_sql_file_footer() { return " /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; diff --git a/includes/destinations.email.inc b/includes/destinations.email.inc index c4c0c9d..af5254c 100644 --- a/includes/destinations.email.inc +++ b/includes/destinations.email.inc @@ -16,7 +16,7 @@ class backup_migrate_destination_email extends backup_migrate_destination { /** * Save to (ie. email the file) to the email destination. */ - function save_file($file, $settings) { + public function save_file($file, $settings) { $size = filesize($file->filepath()); $max = variable_get('backup_migrate_max_email_size', 20971520); if ($size > $max) { @@ -33,7 +33,7 @@ function save_file($file, $settings) { /** * Get the form for the settings for this filter. */ - function edit_form() { + public function edit_form() { $form = parent::edit_form(); $form['location'] = array( "#type" => "textfield", @@ -48,7 +48,7 @@ function edit_form() { /** * Validate the configuration form. Make sure the email address is valid. */ - function settings_form_validate($values) { + public function settings_form_validate($values) { if (!valid_email_address($values['location'])) { form_set_error('[location]', t('The e-mail address %mail is not valid.', array('%mail' => $form_state['values']['location']))); } @@ -95,7 +95,7 @@ class mime_mail { var $subject; var $body; - function __construct() { + public function __construct() { $this->parts = array(); $this->to = ""; $this->from = ""; @@ -104,7 +104,7 @@ function __construct() { $this->body = ""; } - function add_attachment($message, $name = "", $ctype = "application/octet-stream", $encode = NULL, $attach = FALSE) { + public function add_attachment($message, $name = "", $ctype = "application/octet-stream", $encode = NULL, $attach = FALSE) { $this->parts[] = array( "ctype" => $ctype, "message" => $message, @@ -114,7 +114,7 @@ function add_attachment($message, $name = "", $ctype = "application/octet-stream ); } - function build_message($part) { + public function build_message($part) { $message = $part["message"]; $message = chunk_split(base64_encode($message)); $encoding = "base64"; @@ -122,7 +122,7 @@ function build_message($part) { return "Content-Type: " . $part["ctype"] . ($part["name"] ? "; name = \"" . $part["name"] . "\"" : "") . "\nContent-Transfer-Encoding: $encoding\n$disposition\n$message\n"; } - function build_multipart() { + public function build_multipart() { $boundary = "b" . md5(uniqid(time())); $multipart = "Content-Type: multipart/mixed; boundary = $boundary\n\nThis is a MIME encoded message.\n\n--$boundary"; for ($i = sizeof($this->parts) - 1; $i >= 0; $i--) { @@ -131,7 +131,7 @@ function build_multipart() { return $multipart .= "--\n"; } - function send() { + public function send() { $mime = ""; if (!empty($this->from)) { $mime .= "From: " . $this->from . "\n"; diff --git a/includes/destinations.file.inc b/includes/destinations.file.inc index dec493c..d926a13 100644 --- a/includes/destinations.file.inc +++ b/includes/destinations.file.inc @@ -13,21 +13,21 @@ class backup_migrate_destination_files extends backup_migrate_destination { var $supported_ops = array('scheduled backup', 'manual backup', 'local backup', 'restore', 'list files', 'configure', 'delete'); - function type_name() { + public function type_name() { return t("Server Directory"); } /** * Get the file location. */ - function get_realpath() { + public function get_realpath() { return drupal_realpath($this->get_location()); } /** * File save destination callback. */ - function _save_file($file, $settings) { + public function _save_file($file, $settings) { if ($this->confirm_destination() && $dir = $this->get_location()) { $filepath = rtrim($dir, "/") . "/" . $file->filename(); @@ -61,14 +61,14 @@ function _save_file($file, $settings) { /** * Determine if we can read the given file. */ - function can_read_file($file_id) { + public function can_read_file($file_id) { return $this->op('restore') && is_readable($this->get_filepath($file_id)); } /** * File load destination callback. */ - function load_file($file_id) { + public function load_file($file_id) { $filepath = $this->get_filepath($file_id); if (file_exists($filepath)) { backup_migrate_include('files'); @@ -79,7 +79,7 @@ function load_file($file_id) { /** * Get the file object for the given file. */ - function get_file($file_id) { + public function get_file($file_id) { $files = $this->list_files(); if (isset($files[$file_id])) { isset($files[$file_id]); @@ -90,7 +90,7 @@ function get_file($file_id) { /** * File list destination callback. */ - function _list_files() { + public function _list_files() { $files = array(); if ($dir = $this->get_realpath()) { if ($handle = @opendir($dir)) { @@ -109,7 +109,7 @@ function _list_files() { /** * File delete destination callback. */ - function _delete_file($file_id) { + public function _delete_file($file_id) { $filepath = $this->get_filepath($file_id); file_unmanaged_delete($filepath); } @@ -117,7 +117,7 @@ function _delete_file($file_id) { /** * Get the filepath from the given file id. */ - function get_filepath($file_id) { + public function get_filepath($file_id) { if ($dir = $this->get_realpath()) { $filepath = rtrim($dir, '/') . '/' . $file_id; return $filepath; @@ -128,7 +128,7 @@ function get_filepath($file_id) { /** * Get the form for the settings for the files destination. */ - function edit_form() { + public function edit_form() { $form = parent::edit_form(); $form['location'] = array( "#type" => "textfield", @@ -168,7 +168,7 @@ function edit_form() { /** * Validate the form for the settings for the files destination. */ - function edit_form_validate($form, &$form_state) { + public function edit_form_validate($form, &$form_state) { $values = $form_state['values']; if (isset($values['settings']['chmod']) && !empty($values['settings']['chmod']) && !preg_match('/0?[0-7]{3}/', $values['settings']['chmod'])) { form_set_error('chmod', t('You must enter a valid chmod octal value (e.g. 644 or 0644) in the change mode field, or leave it blank.')); @@ -179,7 +179,7 @@ function edit_form_validate($form, &$form_state) { /** * Submit the form for the settings for the files destination. */ - function edit_form_submit($form, &$form_state) { + public function edit_form_submit($form, &$form_state) { // Add a 0 to the start of a 3 digit file mode to make it proper PHP encoded octal. if (strlen($form_state['values']['settings']['chmod']) == 3) { $form_state['values']['settings']['chmod'] = '0' . $form_state['values']['settings']['chmod']; @@ -190,7 +190,7 @@ function edit_form_submit($form, &$form_state) { /** * Check that a destination is valid. */ - function confirm_destination() { + public function confirm_destination() { if ($dir = $this->get_location()) { return $this->check_dir($dir); } @@ -200,7 +200,7 @@ function confirm_destination() { /** * Prepare the destination directory for the backups. */ - function check_dir($directory) { + public function check_dir($directory) { if (!file_prepare_directory($directory, FILE_CREATE_DIRECTORY)) { // Unable to create destination directory. _backup_migrate_message("Unable to create or write to the save directory '%directory'. Please check the file permissions of that directory and try again.", array('%directory' => $directory), "error"); @@ -218,7 +218,7 @@ function check_dir($directory) { /** * Check that a web accessible directory has been properly secured, othewise attempt to secure it. */ - function check_web_dir($directory) { + public function check_web_dir($directory) { // Check if the file has already been tested. if (is_file($directory . '/tested.txt')) { return $directory; @@ -267,7 +267,7 @@ function check_web_dir($directory) { /** * Check if the given directory is within the webroot and is therefore web accessible. */ - function dir_in_webroot($directory) { + public function dir_in_webroot($directory) { $real_dir = drupal_realpath($directory); $real_root = drupal_realpath(DRUPAL_ROOT); if ($real_dir == $real_root || strpos($real_dir, $real_root . '/') === 0) { @@ -279,7 +279,7 @@ function dir_in_webroot($directory) { /** * Check if a file can be read remotely via http. */ - function test_file_readable_remotely($directory, $contents) { + public function test_file_readable_remotely($directory, $contents) { $real_dir = drupal_realpath($directory); $real_root = drupal_realpath(DRUPAL_ROOT); if ($real_dir && $real_root) { @@ -302,7 +302,7 @@ function test_file_readable_remotely($directory, $contents) { */ class backup_migrate_destination_files_manual extends backup_migrate_destination_files { var $supported_ops = array('manual backup', 'restore', 'list files', 'configure', 'delete'); - function __construct($params = array()) { + public function __construct($params = array()) { $dir = 'private://backup_migrate/manual'; parent::__construct($params + array('location' => $dir, 'name' => t('Manual Backups Directory'))); } @@ -314,7 +314,7 @@ function __construct($params = array()) { */ class backup_migrate_destination_files_scheduled extends backup_migrate_destination_files { var $supported_ops = array('scheduled backup', 'restore', 'list files', 'configure', 'delete'); - function __construct($params = array()) { + public function __construct($params = array()) { $dir = 'private://backup_migrate/scheduled'; parent::__construct($params + array('location' => $dir, 'name' => t('Scheduled Backups Directory'))); } diff --git a/includes/destinations.ftp.inc b/includes/destinations.ftp.inc index 363a8b7..0e91561 100644 --- a/includes/destinations.ftp.inc +++ b/includes/destinations.ftp.inc @@ -17,7 +17,7 @@ class backup_migrate_destination_ftp extends backup_migrate_destination_remote { /** * Save to the ftp destination. */ - function _save_file($file, $settings) { + public function _save_file($file, $settings) { $ftp = $this->ftp_object(); if (drupal_ftp_file_to_ftp($file->filepath(), $file->filename(), '.', $ftp)) { return $file; @@ -28,7 +28,7 @@ function _save_file($file, $settings) { /** * Load from the ftp destination. */ - function load_file($file_id) { + public function load_file($file_id) { backup_migrate_include('files'); $file = new backup_file(array('filename' => $file_id)); $this->ftp_object(); @@ -41,12 +41,12 @@ function load_file($file_id) { /** * Delete from the ftp destination. */ - function _delete_file($file_id) { + public function _delete_file($file_id) { $this->ftp_object(); drupal_ftp_delete_file($file_id, $this->ftp); } - function _list_files() { + public function _list_files() { backup_migrate_include('files'); $files = array(); $this->ftp_object(); @@ -60,7 +60,7 @@ function _list_files() { /** * Get the form for the settings for this filter. */ - function edit_form() { + public function edit_form() { $form = parent::edit_form(); $form['scheme']['#type'] = 'value'; $form['scheme']['#value'] = 'ftp'; @@ -79,15 +79,15 @@ function edit_form() { return $form; } - function set_pasv($value) { + public function set_pasv($value) { $this->settings['pasv'] = (bool) $value; } - function get_pasv() { + public function get_pasv() { return isset($this->settings['pasv']) ? $this->settings['pasv'] : FALSE; } - function ftp_object() { + public function ftp_object() { if (!$this->ftp) { $this->dest_url['port'] = empty($this->dest_url['port']) ? '21' : $this->dest_url['port']; $this->dest_url['pasv'] = $this->get_pasv(); diff --git a/includes/destinations.inc b/includes/destinations.inc index dd6645d..2ba71a6 100644 --- a/includes/destinations.inc +++ b/includes/destinations.inc @@ -776,7 +776,7 @@ class backup_migrate_destination extends backup_migrate_location { /** * This function is not supposed to be called. It is just here to help the po extractor out. */ - function strings() { + public function strings() { // Help the pot extractor find these strings. t('Destination'); t('Destinations'); @@ -787,7 +787,7 @@ function strings() { /** * Save the given file to the destination. */ - function save_file($file, $settings) { + public function save_file($file, $settings) { $this->file_cache_clear(); // Save the file metadata if the destination supports it. @@ -798,7 +798,7 @@ function save_file($file, $settings) { /** * Save the given file to the destination. */ - function _save_file($file, $settings) { + public function _save_file($file, $settings) { // This must be overriden. return $file; } @@ -806,7 +806,7 @@ function _save_file($file, $settings) { /** * Save the file metadata. */ - function save_file_info($file, $settings) { + public function save_file_info($file, $settings) { $info = $this->create_info_file($file); // Save the info file and the actual file. return $this->_save_file($info, $settings); @@ -815,7 +815,7 @@ function save_file_info($file, $settings) { /** * Load the file with the given destination specific id and return as a backup_file object. */ - function load_file($file_id) { + public function load_file($file_id) { // This must be overriden. return NULL; } @@ -823,7 +823,7 @@ function load_file($file_id) { /** * Check if a file exists in the given destination. */ - function file_exists($file_id) { + public function file_exists($file_id) { // Check if the file exists in the list of available files. Actual destination types may have more efficient ways of doing this. $files = $this->list_files(); return isset($files[$file_id]); @@ -832,7 +832,7 @@ function file_exists($file_id) { /** * List all the available files in the given destination with their destination specific id. */ - function list_files() { + public function list_files() { $files = NULL; if ($this->cache_files) { $files = $this->file_cache_get(); @@ -860,7 +860,7 @@ function list_files() { /** * List all the available files in the given destination with their destination specific id. */ - function count_files() { + public function count_files() { return count($this->list_files()); } @@ -868,14 +868,14 @@ function count_files() { /** * List all the available files in the given destination with their destination specific id. */ - function _list_files() { + public function _list_files() { return array(); } /** * Load up the file's metadata from the accompanying .info file if applicable. */ - function load_files_info($files) { + public function load_files_info($files) { foreach ($files as $key => $file) { // See if there is an info file with the same name as the backup. if (isset($files[$key . '.info'])) { @@ -899,7 +899,7 @@ function load_files_info($files) { /** * Create an ini file and write the meta data. */ - function create_info_file($file) { + public function create_info_file($file) { $info = $this->_file_info_file($file); $data = _backup_migrate_array_to_ini($file->file_info); $info->put_contents($data); @@ -909,7 +909,7 @@ function create_info_file($file) { /** * Create the info file object. */ - function _file_info_file($file) { + public function _file_info_file($file) { $info = new backup_file(array('filename' => $this->_file_info_filename($file->file_id()))); return $info; } @@ -917,7 +917,7 @@ function _file_info_file($file) { /** * Determine the file name of the info file for a file. */ - function _file_info_filename($file_id) { + public function _file_info_filename($file_id) { return $file_id . '.info'; } @@ -925,14 +925,14 @@ function _file_info_filename($file_id) { /** * Cache the file list. */ - function file_cache_set($files) { + public function file_cache_set($files) { cache_set('backup_migrate_file_list:' . $this->get_id(), $files, 'cache', time() + $this->cache_expire); } /** * Retrieve the file list. */ - function file_cache_get() { + public function file_cache_get() { backup_migrate_include('files'); $cache = cache_get('backup_migrate_file_list:' . $this->get_id()); if (!empty($cache->data) && $cache->created > (time() - $this->cache_expire)) { @@ -946,7 +946,7 @@ function file_cache_get() { /** * Retrieve the file list. */ - function file_cache_clear() { + public function file_cache_clear() { if ($this->cache_files) { $this->file_cache_set(NULL); } @@ -955,7 +955,7 @@ function file_cache_clear() { /** * Delete the file with the given destination specific id. */ - function delete_file($file_id) { + public function delete_file($file_id) { $this->file_cache_clear(); $this->_delete_file($file_id); $this->_delete_file($this->_file_info_filename($file_id)); @@ -964,14 +964,14 @@ function delete_file($file_id) { /** * Delete the file with the given destination specific id. */ - function _delete_file($file_id) { + public function _delete_file($file_id) { // This must be overriden. } /** * Get the edit form for the item. */ - function edit_form() { + public function edit_form() { if (get_class($this) !== 'backup_migrate_destination') { $form = parent::edit_form(); $form['subtype'] = array( @@ -1042,21 +1042,21 @@ function edit_form() { /** * Get the message to send to the user when confirming the deletion of the item. */ - function delete_confirm_message() { + public function delete_confirm_message() { return t('Are you sure you want to delete the destination %name? Backup files already saved to this destination will not be deleted.', array('%name' => $this->get_name())); } /** * Get a boolean representing if the destination is remote or local. */ - function get_remote() { + public function get_remote() { return $this->op('remote backup'); } /** * Get the action links for a destination. */ - function get_action_links() { + public function get_action_links() { $out = parent::get_action_links(); $item_id = $this->get_id(); @@ -1073,7 +1073,7 @@ function get_action_links() { /** * Get the action links for a file on a given destination. */ - function get_file_links($file_id) { + public function get_file_links($file_id) { $out = array(); // Don't display the download/delete/restore ops if they are not available for this destination. @@ -1098,55 +1098,55 @@ function get_file_links($file_id) { /** * Determine if we can read the given file. */ - function can_read_file($file_id) { + public function can_read_file($file_id) { return $this->op('restore'); } /** * Determine if we can read the given file. */ - function can_delete_file($file_id) { + public function can_delete_file($file_id) { return $this->op('delete'); } /** * Get the form for the settings for this destination type. */ - function settings_default() { + public function settings_default() { return array(); } /** * Get the form for the settings for this destination. */ - function settings_form($form) { + public function settings_form($form) { return $form; } /** * Validate the form for the settings for this destination. */ - function settings_form_validate($form_values) { + public function settings_form_validate($form_values) { } /** * Submit the settings form. Any values returned will be saved. */ - function settings_form_submit($form_values) { + public function settings_form_submit($form_values) { return $form_values; } /** * Check that a destination is valid. */ - function confirm_destination() { + public function confirm_destination() { return TRUE; } /** * Add the menu items specific to the destination type. */ - function get_menu_items() { + public function get_menu_items() { $items = parent::get_menu_items(); $path = $this->get_settings_path(); @@ -1194,21 +1194,21 @@ class backup_migrate_destination_remote extends backup_migrate_destination { /** * The location is a URI so parse it and store the parts. */ - function get_location() { + public function get_location() { return $this->url(FALSE); } /** * The location to display is the url without the password. */ - function get_display_location() { + public function get_display_location() { return $this->url(TRUE); } /** * Return the location with the password. */ - function set_location($location) { + public function set_location($location) { $this->location = $location; $this->set_url($location); } @@ -1216,7 +1216,7 @@ function set_location($location) { /** * Destination configuration callback. */ - function edit_form() { + public function edit_form() { $form = parent::edit_form(); $form['scheme'] = array( "#type" => "textfield", @@ -1266,7 +1266,7 @@ function edit_form() { /** * Submit the configuration form. Glue the url together and add the old password back if a new one was not specified. */ - function edit_form_submit($form, &$form_state) { + public function edit_form_submit($form, &$form_state) { $form_state['values']['pass'] = $form_state['values']['pass'] ? $form_state['values']['pass'] : $form_state['values']['old_password']; $form_state['values']['location'] = $this->glue_url($form_state['values'], FALSE); parent::edit_form_submit($form, $form_state); diff --git a/includes/destinations.s3.inc b/includes/destinations.s3.inc index d1a62dd..99bfc81 100644 --- a/includes/destinations.s3.inc +++ b/includes/destinations.s3.inc @@ -19,7 +19,7 @@ class backup_migrate_destination_s3 extends backup_migrate_destination_remote { /** * Save to to the s3 destination. */ - function _save_file($file, $settings) { + public function _save_file($file, $settings) { if ($s3 = $this->s3_object()) { $path = $file->filename(); if ($s3->putObject($s3->inputFile($file->filepath(), FALSE), $this->get_bucket(), $this->remote_path($file->filename()), S3::ACL_PRIVATE)) { @@ -32,7 +32,7 @@ function _save_file($file, $settings) { /** * Load from the s3 destination. */ - function load_file($file_id) { + public function load_file($file_id) { backup_migrate_include('files'); $file = new backup_file(array('filename' => $file_id)); if ($s3 = $this->s3_object()) { @@ -47,7 +47,7 @@ function load_file($file_id) { /** * Delete from the s3 destination. */ - function _delete_file($file_id) { + public function _delete_file($file_id) { if ($s3 = $this->s3_object()) { $s3->deleteObject($this->get_bucket(), $this->remote_path($file_id)); } @@ -56,7 +56,7 @@ function _delete_file($file_id) { /** * List all files from the s3 destination. */ - function _list_files() { + public function _list_files() { backup_migrate_include('files'); $files = array(); if ($s3 = $this->s3_object()) { @@ -76,7 +76,7 @@ function _list_files() { /** * Get the form for the settings for this filter. */ - function edit_form() { + public function edit_form() { // Check for the library. $this->s3_object(); @@ -107,7 +107,7 @@ function edit_form() { /** * Submit the form for the settings for the s3 destination. */ - function edit_form_submit($form, &$form_state) { + public function edit_form_submit($form, &$form_state) { // Append the subdir onto the path. if (!empty($form_state['values']['subdir'])) { $form_state['values']['path'] .= '/' . trim($form_state['values']['subdir'], '/'); @@ -118,7 +118,7 @@ function edit_form_submit($form, &$form_state) { /** * Generate a filepath with the correct prefix. */ - function remote_path($path) { + public function remote_path($path) { if ($subdir = $this->get_subdir()) { $path = $subdir . '/' . $path; } @@ -128,7 +128,7 @@ function remote_path($path) { /** * Generate a filepath with the correct prefix. */ - function local_path($path) { + public function local_path($path) { if ($subdir = $this->get_subdir()) { $path = str_replace($subdir . '/', '', $path); } @@ -138,7 +138,7 @@ function local_path($path) { /** * Get the bucket which is the first part of the path. */ - function get_bucket() { + public function get_bucket() { $parts = explode('/', @$this->dest_url['path']); return $parts[0]; } @@ -146,7 +146,7 @@ function get_bucket() { /** * Get the bucket which is the first part of the path. */ - function get_subdir() { + public function get_subdir() { // Support the older style of subdir saving. if ($subdir = $this->settings('subdir')) { return $subdir; @@ -156,7 +156,7 @@ function get_subdir() { return implode('/', array_filter($parts)); } - function s3_object() { + public function s3_object() { // Try to use libraries module if available to find the path. if (function_exists('libraries_get_path')) { $library_paths[] = libraries_get_path('s3-php5-curl'); diff --git a/includes/files.inc b/includes/files.inc index e3b4d98..441a1a8 100644 --- a/includes/files.inc +++ b/includes/files.inc @@ -215,7 +215,7 @@ class backup_file { /** * Construct a file object given a file path, or create a temp file for writing. */ - function __construct($params = array()) { + public function __construct($params = array()) { if (isset($params['filepath']) && file_exists($params['filepath'])) { $this->set_filepath($params['filepath']); } @@ -228,7 +228,7 @@ function __construct($params = array()) { /** * Get the file_id if the file has been saved to a destination. */ - function file_id() { + public function file_id() { // The default file_id is the filename. Destinations can override the file_id if needed. return isset($this->file_info['file_id']) ? $this->file_info['file_id'] : $this->filename(); } @@ -236,14 +236,14 @@ function file_id() { /** * Get the current filepath. */ - function filepath() { + public function filepath() { return drupal_realpath($this->path); } /** * Get the final filename. */ - function filename($name = NULL) { + public function filename($name = NULL) { if ($name) { $this->name = $name; } @@ -255,7 +255,7 @@ function filename($name = NULL) { /** * Set the current filepath. */ - function set_filepath($path) { + public function set_filepath($path) { $this->path = $path; $params = array( 'filename' => basename($path), @@ -271,7 +271,7 @@ function set_filepath($path) { /** * Get one or all pieces of info for the file. */ - function info($key = NULL) { + public function info($key = NULL) { if ($key) { return @$this->file_info[$key]; } @@ -282,45 +282,45 @@ function info($key = NULL) { /** * Get one or all pieces of info for the file. */ - function info_set($key, $value) { + public function info_set($key, $value) { $this->file_info[$key] = $value; } /** * Get the file extension. */ - function extension() { + public function extension() { return implode(".", $this->ext); } /** * Get the file type. */ - function type() { + public function type() { return $this->type; } /** * Get the file mimetype. */ - function mimetype() { + public function mimetype() { return @$this->type['filemime'] ? $this->type['filemime'] : 'application/octet-stream'; } /** * Get the file mimetype. */ - function type_id() { + public function type_id() { return @$this->type['id']; } - function filesize() { + public function filesize() { if (empty($this->file_info['filesize'])) { $this->calculate_filesize(); } return $this->file_info['filesize']; } - function calculate_filesize() { + public function calculate_filesize() { $this->file_info['filesize'] = ''; if (!empty($this->path) && file_exists($this->path)) { $this->file_info['filesize'] = filesize($this->path); @@ -330,28 +330,28 @@ function calculate_filesize() { /** * Can this file be used to backup to. */ - function can_backup() { + public function can_backup() { return @$this->type['backup']; } /** * Can this file be used to restore to. */ - function can_restore() { + public function can_restore() { return @$this->type['restore']; } /** * Can this file be used to restore to. */ - function is_recognized_type() { + public function is_recognized_type() { return @$this->type['restore'] || @$this->type['backup']; } /** * Open a file for reading or writing. */ - function open($write = FALSE, $binary = FALSE) { + public function open($write = FALSE, $binary = FALSE) { if (!$this->handle) { $path = $this->filepath(); @@ -376,7 +376,7 @@ function open($write = FALSE, $binary = FALSE) { /** * Close a file when we're done reading/writing. */ - function close() { + public function close() { fclose($this->handle); $this->handle = NULL; } @@ -384,7 +384,7 @@ function close() { /** * Write a line to the file. */ - function write($data) { + public function write($data) { if (!$this->handle) { $this->handle = $this->open(TRUE); } @@ -396,7 +396,7 @@ function write($data) { /** * Read a line from the file. */ - function read($size = NULL) { + public function read($size = NULL) { if (!$this->handle) { $this->handle = $this->open(); } @@ -409,14 +409,14 @@ function read($size = NULL) { /** * Write data to the file. */ - function put_contents($data) { + public function put_contents($data) { file_put_contents($this->filepath(), $data); } /** * Read data from the file. */ - function get_contents() { + public function get_contents() { return file_get_contents($this->filepath()); } @@ -424,7 +424,7 @@ function get_contents() { * Transfer file using http to client. Similar to the built in file_transfer, * but it calls module_invoke_all('exit') so that temp files can be deleted. */ - function transfer() { + public function transfer() { $headers = array( array('key' => 'Content-Type', 'value' => $this->mimetype()), array('key' => 'Content-Disposition', 'value' => 'attachment; filename="' . $this->filename() . '"'), @@ -472,7 +472,7 @@ function transfer() { /** * Push a file extension onto the file and return the previous file path. */ - function push_type($extension) { + public function push_type($extension) { $types = _backup_migrate_filetypes(); if ($type = @$types[$extension]) { $this->push_filetype($type); @@ -486,7 +486,7 @@ function push_type($extension) { /** * Push a file extension onto the file and return the previous file path. */ - function pop_type() { + public function pop_type() { $out = new backup_file(array('filepath' => $this->filepath())); $this->pop_filetype(); $this->temporary_file(); @@ -496,7 +496,7 @@ function pop_type() { /** * Set the current file type. */ - function set_filetype($type) { + public function set_filetype($type) { $this->type = $type; $this->ext = array($type['extension']); } @@ -504,7 +504,7 @@ function set_filetype($type) { /** * Set the current file type. */ - function push_filetype($type) { + public function push_filetype($type) { $this->ext[] = $type['extension']; $this->type = $type; } @@ -512,7 +512,7 @@ function push_filetype($type) { /** * Pop the current file type. */ - function pop_filetype() { + public function pop_filetype() { array_pop($this->ext); $this->detect_filetype_from_extension(); } @@ -520,7 +520,7 @@ function pop_filetype() { /** * Set the file info. */ - function set_file_info($file_info) { + public function set_file_info($file_info) { $this->file_info = $file_info; $this->ext = explode('.', @$this->file_info['filename']); @@ -535,7 +535,7 @@ function set_file_info($file_info) { /** * Get the filetype info of the given file, or false if the file is not a valid type. */ - function detect_filetype_from_extension() { + public function detect_filetype_from_extension() { $ext = end($this->ext); $this->type = array(); $types = _backup_migrate_filetypes(); @@ -550,7 +550,7 @@ function detect_filetype_from_extension() { /** * Get a temporary file name with path. */ - function temporary_file() { + public function temporary_file() { $file = drupal_tempnam('temporary://', 'backup_migrate_'); // Add the version without the extension. The tempnam function creates this for us. backup_migrate_temp_files_add($file); diff --git a/includes/filters.backup_restore.inc b/includes/filters.backup_restore.inc index 2d2e3f0..a3f7dc9 100644 --- a/includes/filters.backup_restore.inc +++ b/includes/filters.backup_restore.inc @@ -16,7 +16,7 @@ class backup_migrate_filter_backup_restore extends backup_migrate_filter { /** * Get the default destinations for this filter. */ - function destinations() { + public function destinations() { $out = array(); foreach ($this->_get_destination_types() as $destination) { if (method_exists($destination, 'destinations')) { @@ -29,7 +29,7 @@ function destinations() { /** * Get the default sources for this filter. */ - function sources() { + public function sources() { $out = array(); foreach ($this->_get_source_types() as $type) { if (method_exists($type, 'sources')) { @@ -42,7 +42,7 @@ function sources() { /** * Get the default backup settings for this filter. */ - function backup_settings_default() { + public function backup_settings_default() { backup_migrate_include('sources'); $out = array(); foreach (backup_migrate_get_sources() as $source) { @@ -54,7 +54,7 @@ function backup_settings_default() { /** * Get the form for the settings for this filter. */ - function backup_settings_form_validate($form, &$form_state) { + public function backup_settings_form_validate($form, &$form_state) { foreach ($this->_get_destination_types() as $destination) { $destination->backup_settings_form_validate($form, $form_state); } @@ -63,7 +63,7 @@ function backup_settings_form_validate($form, &$form_state) { /** * Submit the settings form. Any values returned will be saved. */ - function backup_settings_form_submit($form, &$form_state) { + public function backup_settings_form_submit($form, &$form_state) { foreach ($this->_get_destination_types() as $destination) { $destination->backup_settings_form_submit($form, $form_state); } @@ -72,7 +72,7 @@ function backup_settings_form_submit($form, &$form_state) { /** * Get the default restore settings for this filter. */ - function restore_settings_default() { + public function restore_settings_default() { $out = array(); foreach ($this->_get_destination_types() as $destination) { $out += $destination->restore_settings_default(); @@ -83,7 +83,7 @@ function restore_settings_default() { /** * Get the form for the backup settings for this filter. */ - function backup_settings_form($settings) { + public function backup_settings_form($settings) { backup_migrate_include('sources'); $out = array( 'sources' => array( @@ -107,7 +107,7 @@ function backup_settings_form($settings) { /** * Get the form for the restore settings for this filter. */ - function restore_settings_form($settings) { + public function restore_settings_form($settings) { $form = array(); foreach ($this->_get_destination_types() as $destination) { $destination->restore_settings_form($form, $settings); @@ -118,7 +118,7 @@ function restore_settings_form($settings) { /** * Get the before-backup form for the active sources and destinations. */ - function before_action_form($op, $settings) { + public function before_action_form($op, $settings) { $form = array(); $method = 'before_' . $op . '_form'; if ($source = $settings->get_source()) { @@ -137,7 +137,7 @@ function before_action_form($op, $settings) { /** * Get the before-backup form for the active sources and destinations. */ - function before_action_form_validate($op, $settings, $form, $form_state) { + public function before_action_form_validate($op, $settings, $form, $form_state) { $method = 'before_' . $op . '_form_validate'; foreach ($settings->get_all_locations() as $location) { if (method_exists($location, $method)) { @@ -149,7 +149,7 @@ function before_action_form_validate($op, $settings, $form, $form_state) { /** * Get the before-backup form for the active sources and destinations. */ - function before_action_form_submit($op, $settings, $form, $form_state) { + public function before_action_form_submit($op, $settings, $form, $form_state) { $method = 'before_' . $op . '_form_submit'; foreach ($settings->get_all_locations() as $location) { if (method_exists($location, $method)) { @@ -161,7 +161,7 @@ function before_action_form_submit($op, $settings, $form, $form_state) { /** * Get the file types supported by this destination. */ - function file_types() { + public function file_types() { $types = array(); foreach ($this->_get_destination_types() as $destination) { $types += $destination->file_types(); @@ -175,7 +175,7 @@ function file_types() { /** * Backup the data from the source specified in the settings. */ - function backup($file, $settings) { + public function backup($file, $settings) { if ($source = $settings->get_source()) { if (!empty($settings->filters['sources'][$source->get_id()])) { $settings->filters = (array) ($settings->filters['sources'][$source->get_id()]) + $settings->filters; @@ -191,7 +191,7 @@ function backup($file, $settings) { /** * Restore the data from to source specified in the settings. */ - function restore($file, $settings) { + public function restore($file, $settings) { if ($source = $settings->get_source()) { if (!empty($settings->filters['sources'][$source->get_id()])) { $settings->filters = (array) ($settings->filters['sources'][$source->get_id()]) + $settings->filters; @@ -206,7 +206,7 @@ function restore($file, $settings) { /** * Get a list of dummy destinations representing each of the available destination types. */ - function _get_destination_types() { + public function _get_destination_types() { backup_migrate_include('destinations'); $destinations = &drupal_static('backup_migrate_filter_backup_restore::_get_destination_types', NULL); if (!is_array($destinations)) { @@ -227,7 +227,7 @@ function _get_destination_types() { /** * Get a list of dummy destinations representing each of the available source types. */ - function _get_source_types() { + public function _get_source_types() { backup_migrate_include('sources'); $sources = &drupal_static('backup_migrate_filter_backup_restore::_get_source_types', NULL); if (!is_array($sources)) { diff --git a/includes/filters.compression.inc b/includes/filters.compression.inc index 8f045d2..cfd80e8 100644 --- a/includes/filters.compression.inc +++ b/includes/filters.compression.inc @@ -16,21 +16,21 @@ class backup_migrate_filter_compression extends backup_migrate_filter { /** * This function is called on a backup file after the backup has been completed. */ - function backup($file, $settings) { + public function backup($file, $settings) { return $this->_backup_migrate_file_compress($file, $settings); } /** * This function is called on a backup file before importing it. */ - function restore($file, $settings) { + public function restore($file, $settings) { return $this->_backup_migrate_file_decompress($file, $settings); } /** * Get the form for the settings for this filter. */ - function backup_settings_default() { + public function backup_settings_default() { $options = $this->_backup_migrate_get_compression_form_item_options(); return array('compression' => isset($options['gzip']) ? 'gzip' : 'none'); } @@ -38,7 +38,7 @@ function backup_settings_default() { /** * Get the form for the settings for this filter. */ - function backup_settings_form($settings) { + public function backup_settings_form($settings) { $form = array(); $compression_options = $this->_backup_migrate_get_compression_form_item_options(); $form['file']['compression'] = array( @@ -53,7 +53,7 @@ function backup_settings_form($settings) { /** * Return a list of backup filetypes. */ - function file_types() { + public function file_types() { return array( "gzip" => array( "extension" => "gz", @@ -85,7 +85,7 @@ function file_types() { /** * Get the compression options as an options array for a form item. */ - function _backup_migrate_get_compression_form_item_options() { + public function _backup_migrate_get_compression_form_item_options() { $compression_options = array("none" => t("No Compression")); if (@function_exists("gzencode")) { $compression_options['gzip'] = t("GZip"); @@ -102,7 +102,7 @@ function _backup_migrate_get_compression_form_item_options() { /** * Gzip encode a file. */ - function _backup_migrate_gzip_encode($source, $dest, $level = 9, $settings) { + public function _backup_migrate_gzip_encode($source, $dest, $level = 9, $settings) { $success = FALSE; // Try command line gzip first. if (!empty($settings->filters['use_cli'])) { @@ -124,7 +124,7 @@ function _backup_migrate_gzip_encode($source, $dest, $level = 9, $settings) { /** * Gzip decode a file. */ - function _backup_migrate_gzip_decode($source, $dest, $settings) { + public function _backup_migrate_gzip_decode($source, $dest, $settings) { $success = FALSE; if (!empty($settings->filters['use_cli'])) { @@ -147,7 +147,7 @@ function _backup_migrate_gzip_decode($source, $dest, $settings) { /** * Bzip encode a file. */ - function _backup_migrate_bzip_encode($source, $dest) { + public function _backup_migrate_bzip_encode($source, $dest) { $success = FALSE; if (@function_exists("bzopen")) { if (($fp_out = bzopen($dest, 'w')) && ($fp_in = fopen($source, 'rb'))) { @@ -168,7 +168,7 @@ function _backup_migrate_bzip_encode($source, $dest) { /** * Bzip decode a file. */ - function _backup_migrate_bzip_decode($source, $dest) { + public function _backup_migrate_bzip_decode($source, $dest) { $success = FALSE; if (@function_exists("bzopen")) { if (($fp_out = fopen($dest, 'w')) && ($fp_in = bzopen($source, 'r'))) { @@ -189,7 +189,7 @@ function _backup_migrate_bzip_decode($source, $dest) { /** * Zip encode a file. */ - function _backup_migrate_zip_encode($source, $dest, $filename) { + public function _backup_migrate_zip_encode($source, $dest, $filename) { $success = FALSE; if (class_exists('ZipArchive')) { $zip = new ZipArchive(); @@ -205,7 +205,7 @@ function _backup_migrate_zip_encode($source, $dest, $filename) { /** * Zip decode a file. */ - function _backup_migrate_zip_decode($source, $dest) { + public function _backup_migrate_zip_decode($source, $dest) { $success = FALSE; if (class_exists('ZipArchive')) { $zip = new ZipArchive(); @@ -228,7 +228,7 @@ function _backup_migrate_zip_decode($source, $dest) { * Compress a file with the given settings. * Also updates settings to reflect new file mime and file extension. */ - function _backup_migrate_file_compress($file, $settings) { + public function _backup_migrate_file_compress($file, $settings) { switch ($settings->filters['compression']) { case "gzip": $from = $file->push_type('gzip'); @@ -262,7 +262,7 @@ function _backup_migrate_file_compress($file, $settings) { * Decompress a file with the given settings. * Also updates settings to reflect new file mime and file extension. */ - function _backup_migrate_file_decompress($file, $settings) { + public function _backup_migrate_file_decompress($file, $settings) { $success = FALSE; switch ($file->type_id()) { diff --git a/includes/filters.statusnotify.inc b/includes/filters.statusnotify.inc index e34c087..6101349 100644 --- a/includes/filters.statusnotify.inc +++ b/includes/filters.statusnotify.inc @@ -15,7 +15,7 @@ class backup_migrate_filter_statusnotify extends backup_migrate_filter { /** * Get the default backup settings for this filter. */ - function backup_settings_default() { + public function backup_settings_default() { return array( 'notify_success_enable' => FALSE, 'notify_failure_enable' => FALSE, @@ -27,7 +27,7 @@ function backup_settings_default() { /** * Get the form for the settings for this filter. */ - function backup_settings_form($settings) { + public function backup_settings_form($settings) { $form = array(); $form['advanced']['notify_success_enable'] = array( "#type" => 'checkbox', @@ -67,7 +67,7 @@ function backup_settings_form($settings) { /** * Send the success email. */ - function backup_succeed($settings) { + public function backup_succeed($settings) { if (@$settings->filters['notify_success_enable'] && $to = @$settings->filters['notify_success_email']) { $messages = $this->get_messages(); if ($messages = $this->get_messages()) { @@ -83,7 +83,7 @@ function backup_succeed($settings) { /** * Send the failure email. */ - function backup_fail($settings) { + public function backup_fail($settings) { if (@$settings->filters['notify_failure_enable'] && $to = @$settings->filters['notify_failure_email']) { $messages = $this->get_messages(); if ($messages = $this->get_messages()) { @@ -99,7 +99,7 @@ function backup_fail($settings) { /** * Render the messages and errors for the email. */ - function get_messages() { + public function get_messages() { $out = ""; $messages = _backup_migrate_messages(); foreach ($messages as $message) { diff --git a/includes/filters.utils.inc b/includes/filters.utils.inc index 4e71006..c488ec0 100644 --- a/includes/filters.utils.inc +++ b/includes/filters.utils.inc @@ -17,7 +17,7 @@ class backup_migrate_filter_utils extends backup_migrate_filter { /** * Get the default backup settings for this filter. */ - function backup_settings_default() { + public function backup_settings_default() { return array( 'utils_disable_query_log' => TRUE, 'utils_site_offline' => FALSE, @@ -28,7 +28,7 @@ function backup_settings_default() { /** * Get the default restore settings for this filter. */ - function restore_settings_default() { + public function restore_settings_default() { return array( 'utils_disable_query_log' => TRUE, 'utils_site_offline' => FALSE, @@ -38,7 +38,7 @@ function restore_settings_default() { /** * Get the form for the backup settings for this filter. */ - function backup_settings_form($settings) { + public function backup_settings_form($settings) { $form = array(); if (module_exists('devel') && variable_get('dev_query', 0)) { $form['database']['utils_disable_query_log'] = array( @@ -91,7 +91,7 @@ function backup_settings_form($settings) { /** * Get the form for the restore settings for this filter. */ - function restore_settings_form($settings) { + public function restore_settings_form($settings) { $form = array(); if (module_exists('devel') && variable_get('dev_query', 0)) { $form['advanced']['utils_disable_query_log'] = array( @@ -134,12 +134,12 @@ function restore_settings_form($settings) { return $form; } - function pre_backup($file, $settings) { + public function pre_backup($file, $settings) { $this->take_site_offline($settings); $this->disable_devel_query($settings); } - function post_backup($file, $settings) { + public function post_backup($file, $settings) { $this->enable_devel_query($settings); $this->take_site_online($settings); if ($file) { @@ -147,12 +147,12 @@ function post_backup($file, $settings) { } } - function pre_restore($file, $settings) { + public function pre_restore($file, $settings) { $this->disable_devel_query($settings); $this->take_site_offline($settings); } - function post_restore($file, $settings) { + public function post_restore($file, $settings) { $this->enable_devel_query($settings); $this->take_site_online($settings); } @@ -160,7 +160,7 @@ function post_restore($file, $settings) { /** * Disable devel query logging if it's active and the user has chosen to do so. */ - function disable_devel_query($settings) { + public function disable_devel_query($settings) { $this->saved_devel_query = variable_get('dev_query', 0); if (module_exists('devel') && variable_get('dev_query', 0) && !empty($settings->filters['utils_disable_query_log'])) { variable_set('dev_query', 0); @@ -170,7 +170,7 @@ function disable_devel_query($settings) { /** * Restore devel query to previous state. */ - function enable_devel_query($settings) { + public function enable_devel_query($settings) { if (module_exists('devel')) { variable_set('dev_query', $this->saved_devel_query); } @@ -179,7 +179,7 @@ function enable_devel_query($settings) { /** * Add the backup metadata to the file. */ - function add_file_info($file, $settings) { + public function add_file_info($file, $settings) { $file->file_info['description'] = $settings->filters['utils_description']; $file->file_info['datestamp'] = time(); $file->file_info['generator'] = 'Backup and Migrate (http://drupal.org/project/backup_migrate)'; @@ -203,7 +203,7 @@ function add_file_info($file, $settings) { /** * Take the site offline if configured to do so. */ - function take_site_offline($settings) { + public function take_site_offline($settings) { // If the site is already offline then don't do anything. if (!variable_get('maintenance_mode', 0)) { // Save the current state of the site in case a restore overwrites it. @@ -223,7 +223,7 @@ function take_site_offline($settings) { /** * Take the site online again after backup or restore. */ - function take_site_online($settings) { + public function take_site_online($settings) { // Take the site back off/online because the restored db may have changed that setting. if (variable_get('maintenance_mode', 0) && !empty($this->saved_site_offline)) { variable_set('maintenance_mode', 0); diff --git a/includes/locations.inc b/includes/locations.inc index 2eb1243..c110238 100644 --- a/includes/locations.inc +++ b/includes/locations.inc @@ -95,7 +95,7 @@ class backup_migrate_location extends backup_migrate_item { /** * This function is not supposed to be called. It is just here to help the po extractor out. */ - function strings() { + public function strings() { // Help the pot extractor find these strings. t('location'); t('locations'); @@ -103,14 +103,14 @@ function strings() { t('Locations'); } - function ops() { + public function ops() { return $this->supported_ops; } /** * Does this location support the given operation. */ - function op($op) { + public function op($op) { $ops = (array) $this->ops(); return in_array($op, $ops); } @@ -118,34 +118,34 @@ function op($op) { /** * Remove the given op from the support list. */ - function remove_op($op) { + public function remove_op($op) { $key = array_search($op, $this->supported_ops); if ($key !== FALSE) { unset($this->supported_ops[$key]); } } - function get_name() { + public function get_name() { return @$this->name; } - function set_name($name) { + public function set_name($name) { return $this->name = $name; } - function set_location($location) { + public function set_location($location) { $this->location = $location; } - function get_location() { + public function get_location() { return @$this->location; } - function get_display_location() { + public function get_display_location() { return $this->get_location(); } - function settings($key = NULL) { + public function settings($key = NULL) { $out = $this->settings; if ($key) { $out = isset($out[$key]) ? $out[$key] : NULL; @@ -156,7 +156,7 @@ function settings($key = NULL) { /** * Get the type name of this location for display to the user. */ - function get_subtype_name() { + public function get_subtype_name() { if ($type = $this->get('subtype')) { $types = $this->location_types(); return isset($types[$type]['type_name']) ? $types[$type]['type_name'] : $type; @@ -166,7 +166,7 @@ function get_subtype_name() { /** * Get the edit form for the item. */ - function edit_form() { + public function edit_form() { if (!empty($this->supported_ops)) { $form = parent::edit_form(); $form['subtype'] = array( @@ -203,21 +203,21 @@ function edit_form() { /** * Get the available location types. */ - function location_types() { + public function location_types() { return backup_migrate_get_location_subtypes(); } /** * Get the message to send to the user when confirming the deletion of the item. */ - function delete_confirm_message() { + public function delete_confirm_message() { return t('Are you sure you want to delete the %name?', array('%name' => $this->get_name())); } /** * Get the columns needed to list the type. */ - function get_list_column_info() { + public function get_list_column_info() { $out = parent::get_list_column_info(); $out = array( 'name' => array('title' => t('Name')), @@ -230,7 +230,7 @@ function get_list_column_info() { /** * Get a row of data to be used in a list of items of this type. */ - function get_list_row() { + public function get_list_row() { $out = parent::get_list_row(); // Suppress locations with no actions as there's no value in showing them (and they may confuse new users). @@ -243,7 +243,7 @@ function get_list_row() { /** * Get the action links for a location. */ - function get_action_links() { + public function get_action_links() { $out = parent::get_action_links(); $item_id = $this->get_id(); @@ -260,94 +260,94 @@ function get_action_links() { /** * Determine if we can read the given file. */ - function can_read_file($file_id) { + public function can_read_file($file_id) { return $this->op('restore'); } /** * Get the form for the settings for this location type. */ - function settings_default() { + public function settings_default() { return array(); } /** * Get the form for the settings for this location. */ - function settings_form($form) { + public function settings_form($form) { return $form; } /** * Validate the form for the settings for this location. */ - function settings_form_validate($form_values) { + public function settings_form_validate($form_values) { } /** * Submit the settings form. Any values returned will be saved. */ - function settings_form_submit($form_values) { + public function settings_form_submit($form_values) { return $form_values; } /** * Get the form for the settings for this filter. */ - function backup_settings_default() { + public function backup_settings_default() { return array(); } /** * Get the form for the settings for this filter. */ - function backup_settings_form($settings) { + public function backup_settings_form($settings) { return array(); } /** * Get the form for the settings for this filter. */ - function backup_settings_form_validate($form, &$form_state) { + public function backup_settings_form_validate($form, &$form_state) { } /** * Submit the settings form. Any values returned will be saved. */ - function backup_settings_form_submit($form, &$form_state) { + public function backup_settings_form_submit($form, &$form_state) { } /** * Get the form for the settings for this filter. */ - function restore_settings_default() { + public function restore_settings_default() { return array(); } /** * Get the form for the settings for this filter. */ - function restore_settings_form($settings) { + public function restore_settings_form($settings) { return array(); } /** * Get the form for the settings for this filter. */ - function restore_settings_form_validate($form_values) { + public function restore_settings_form_validate($form_values) { } /** * Submit the settings form. Any values returned will be saved. */ - function restore_settings_form_submit($form_values) { + public function restore_settings_form_submit($form_values) { return $form_values; } /** * Create a new location of the correct type. */ - function create($params = array()) { + public function create($params = array()) { $out = NULL; $types = backup_migrate_get_location_subtypes(); // Get the type passed in in the params, or if none, check the url for a valid type name. @@ -371,14 +371,14 @@ function create($params = array()) { /** * Get a url from the parts. */ - function url($hide_password = TRUE) { + public function url($hide_password = TRUE) { return $this->glue_url($this->dest_url, $hide_password); } /** * Glue a URLs component parts back into a URL. */ - function glue_url($parts, $hide_password = TRUE) { + public function glue_url($parts, $hide_password = TRUE) { // Obscure the password if we need to. $parts['pass'] = $hide_password ? "" : $parts['pass']; @@ -397,7 +397,7 @@ function glue_url($parts, $hide_password = TRUE) { /** * Break a URL into it's component parts. */ - function set_url($url) { + public function set_url($url) { $parts = (array) parse_url($url); $parts['user'] = urldecode(@$parts['user']); $parts['pass'] = urldecode(@$parts['pass']); @@ -409,7 +409,7 @@ function set_url($url) { /** * Retrieve a list of filetypes supported by this source/destination. */ - function file_types() { + public function file_types() { return array(); } @@ -422,21 +422,21 @@ class backup_migrate_location_remote extends backup_migrate_location { /** * The location is a URI so parse it and store the parts. */ - function get_location() { + public function get_location() { return $this->url(FALSE); } /** * The location to display is the url without the password. */ - function get_display_location() { + public function get_display_location() { return $this->url(TRUE); } /** * Return the location with the password. */ - function set_location($location) { + public function set_location($location) { $this->location = $location; $this->set_url($location); } @@ -444,7 +444,7 @@ function set_location($location) { /** * Location configuration callback. */ - function edit_form() { + public function edit_form() { $form = parent::edit_form(); $form['scheme'] = array( "#type" => "select", @@ -495,7 +495,7 @@ function edit_form() { /** * Submit the configuration form. Glue the url together and add the old password back if a new one was not specified. */ - function edit_form_submit($form, &$form_state) { + public function edit_form_submit($form, &$form_state) { $form_state['values']['pass'] = $form_state['values']['pass'] ? $form_state['values']['pass'] : $form_state['values']['old_password']; $form_state['values']['location'] = $this->glue_url($form_state['values'], FALSE); parent::edit_form_submit($form, $form_state); diff --git a/includes/profiles.inc b/includes/profiles.inc index 191a8cb..b5e2928 100644 --- a/includes/profiles.inc +++ b/includes/profiles.inc @@ -235,7 +235,7 @@ public function __construct(array $params = array()) { /** * This function is not supposed to be called. It is just here to help the po extractor out. */ - function strings() { + public function strings() { // Help the pot extractor find these strings. t('Settings Profile'); t('Settings Profiles'); @@ -246,14 +246,14 @@ function strings() { /** * Get the default values for standard parameters. */ - function get_default_values() { + public function get_default_values() { return _backup_migrate_profile_default_profile() + array('name' => t("Untitled Profile")); } /** * Get a table of all items of this type. */ - function get_list() { + public function get_list() { drupal_add_css(drupal_get_path('module', 'backup_migrate') . '/backup_migrate.css'); return parent::get_list(); } @@ -261,7 +261,7 @@ function get_list() { /** * Get the columns needed to list the type. */ - function get_list_column_info() { + public function get_list_column_info() { $out = parent::get_list_column_info(); $out = array( 'name' => array('title' => t('Name')), @@ -274,7 +274,7 @@ function get_list_column_info() { /** * Set the source of this setings profile. Takes either a source object or source id. */ - function set_source($source) { + public function set_source($source) { if (is_object($source)) { $this->source = $source; $this->source_id = $source->get_id(); @@ -288,7 +288,7 @@ function set_source($source) { /** * Get the source of the profile. */ - function get_source() { + public function get_source() { backup_migrate_include('locations'); if (!empty($this->source_id) && (empty($this->source) || $this->source->get_id() !== $this->source_id)) { $this->source = backup_migrate_get_source($this->source_id); @@ -299,7 +299,7 @@ function get_source() { /** * Get the name of the source. */ - function get_source_name() { + public function get_source_name() { if ($source = $this->get_source()) { return $source->get_name(); } @@ -309,7 +309,7 @@ function get_source_name() { /** * Get the destination of the profile. */ - function get_destination() { + public function get_destination() { $destinations = (array) $this->get_destinations(); return reset($destinations); } @@ -317,7 +317,7 @@ function get_destination() { /** * Get the destination of the profile. */ - function get_destinations() { + public function get_destinations() { backup_migrate_include('destinations'); if (empty($this->destinations)) { $this->destinations = array(); @@ -341,7 +341,7 @@ function get_destinations() { /** * Get the name of the destination. */ - function get_destination_name() { + public function get_destination_name() { $out = array(); foreach ($this->get_destinations() as $destination) { $out[] = $destination->get_name(); @@ -355,7 +355,7 @@ function get_destination_name() { /** * Get the source and destinations specified in the given settings profile. */ - function get_all_locations() { + public function get_all_locations() { $out = array(); $out += $this->get('destinations'); $out[] = $this->get('source'); @@ -365,7 +365,7 @@ function get_all_locations() { /** * Get the edit form. */ - function edit_form() { + public function edit_form() { $form = parent::edit_form(); $form['name'] = array( "#type" => "textfield", @@ -380,7 +380,7 @@ function edit_form() { /** * Get the message to send to the user when confirming the deletion of the item. */ - function delete_confirm_message() { + public function delete_confirm_message() { return t('Are you sure you want to delete the profile %name? Any schedules using this profile will be disabled.', array('%name' => $this->get('name'))); } diff --git a/includes/schedules.inc b/includes/schedules.inc index adebf9d..a5f652c 100644 --- a/includes/schedules.inc +++ b/includes/schedules.inc @@ -108,7 +108,7 @@ class backup_migrate_schedule extends backup_migrate_item { /** * This function is not supposed to be called. It is just here to help the po extractor out. */ - function strings() { + public function strings() { // Help the pot extractor find these strings. t('Schedule'); t('Schedules'); @@ -119,7 +119,7 @@ function strings() { /** * Get the default values for this item. */ - function get_default_values() { + public function get_default_values() { return array( 'name' => t("Untitled Schedule"), 'source_id' => 'db', @@ -135,7 +135,7 @@ function get_default_values() { /** * Return as an array of values. */ - function to_array() { + public function to_array() { $out = parent::to_array(); unset($out['last_run']); return $out; @@ -144,7 +144,7 @@ function to_array() { /** * Get the columns needed to list the type. */ - function get_list_column_info() { + public function get_list_column_info() { $out = parent::get_list_column_info(); $out = array( 'name' => array('title' => t('Name')), @@ -161,7 +161,7 @@ function get_list_column_info() { /** * Get the columns needed to list the type. */ - function get_settings_path() { + public function get_settings_path() { // Pull the schedules tab up a level to the top. return BACKUP_MIGRATE_MENU_PATH . '/' . $this->type_name; } @@ -169,7 +169,7 @@ function get_settings_path() { /** * Get the menu items for manipulating this type. */ - function get_menu_items() { + public function get_menu_items() { $items = parent::get_menu_items(); $path = $this->get_settings_path(); return $items; @@ -178,7 +178,7 @@ function get_menu_items() { /** * Get a row of data to be used in a list of items of this type. */ - function get_list_row() { + public function get_list_row() { drupal_add_css(drupal_get_path('module', 'backup_migrate') . '/backup_migrate.css'); $row = parent::get_list_row(); if (!$this->is_enabled()) { @@ -200,7 +200,7 @@ function get_list_row() { /** * Is the schedule enabled and valid. */ - function is_enabled() { + public function is_enabled() { $destination = $this->get_destination(); $profile = $this->get_profile(); return (!empty($this->enabled) && !empty($destination) && !empty($profile)); @@ -209,7 +209,7 @@ function is_enabled() { /** * Get the destination object of the schedule. */ - function get_destination() { + public function get_destination() { $destinations = (array) $this->get_destinations(); return reset($destinations); } @@ -217,7 +217,7 @@ function get_destination() { /** * Get the destination object of the schedule. */ - function get_destination_ids() { + public function get_destination_ids() { $out = array(); foreach (array('destination_id', 'copy_destination_id') as $key) { if ($id = $this->get($key)) { @@ -230,7 +230,7 @@ function get_destination_ids() { /** * Get the destination object of the schedule. */ - function get_destinations() { + public function get_destinations() { backup_migrate_include('destinations'); $out = array(); foreach ($this->get_destination_ids() as $id) { @@ -244,14 +244,14 @@ function get_destinations() { /** * Get the destination object of the schedule. */ - function get_destination_remote() { + public function get_destination_remote() { backup_migrate_include('destinations'); return backup_migrate_get_destination($this->get('destination_remote_id')); } /** * Get the destination object of the schedule. */ - function get_destination_local() { + public function get_destination_local() { backup_migrate_include('destinations'); return backup_migrate_get_destination($this->get('destination_local_id')); } @@ -259,7 +259,7 @@ function get_destination_local() { /** * Get the name of the destination. */ - function get_destination_name() { + public function get_destination_name() { if ($destinations = $this->get_destinations()) { $out = array(); foreach ((array) $destinations as $destination) { @@ -273,7 +273,7 @@ function get_destination_name() { /** * Get the destination of the schedule. */ - function get_profile() { + public function get_profile() { backup_migrate_include('profiles'); if ($settings = backup_migrate_get_profile($this->get('profile_id'))) { $settings->file_info = empty($settings->file_info) ? array() : $settings->file_info; @@ -289,7 +289,7 @@ function get_profile() { /** * Get the name of the source. */ - function get_profile_name() { + public function get_profile_name() { if ($profile = $this->get_profile()) { return check_plain($profile->get_name()); } @@ -299,7 +299,7 @@ function get_profile_name() { /** * Format a frequency in human-readable form. */ - function get_frequency_description() { + public function get_frequency_description() { $period = $this->get_frequency_period(); $cron = $this->get('cron'); if ($cron == BACKUP_MIGRATE_CRON_BUILTIN) { @@ -317,14 +317,14 @@ function get_frequency_description() { /** * Format the number to keep in human-readable form. */ - function get_keep_description() { + public function get_keep_description() { return $this->generate_keep_description($this->keep); } /** * Format a number to keep in human readable from. */ - function generate_keep_description($keep, $terse = TRUE) { + public function generate_keep_description($keep, $terse = TRUE) { if ($keep == BACKUP_MIGRATE_KEEP_ALL) { return t('all backups'); } @@ -357,14 +357,14 @@ function generate_keep_description($keep, $terse = TRUE) { /** * Format the enabled status in human-readable form. */ - function get_enabled_description() { + public function get_enabled_description() { return !empty($this->enabled) ? t('Enabled') : t('Disabled'); } /** * Format the enabled status in human-readable form. */ - function get_last_run_description() { + public function get_last_run_description() { $last_run = $this->get('last_run'); return !empty($last_run) ? format_date($last_run, 'small') : t('Never'); } @@ -372,21 +372,21 @@ function get_last_run_description() { /** * Get the number of excluded tables. */ - function get_exclude_tables_count() { + public function get_exclude_tables_count() { return count($this->exclude_tables) ? count($this->exclude_tables) : t("No tables excluded"); } /** * Get the number of excluded tables. */ - function get_nodata_tables_count() { + public function get_nodata_tables_count() { return count($this->nodata_tables) ? count($this->nodata_tables) : t("No data omitted"); } /** * Get the edit form. */ - function edit_form() { + public function edit_form() { $form = parent::edit_form(); backup_migrate_include('destinations', 'sources', 'profiles'); @@ -555,7 +555,7 @@ function edit_form() { /** * Submit the edit form. */ - function edit_form_validate($form, &$form_state) { + public function edit_form_validate($form, &$form_state) { if (!is_numeric($form_state['values']['period']['number']) || $form_state['values']['period']['number'] <= 0) { form_set_error('period][number', t('Backup period must be a number greater than 0.')); } @@ -575,7 +575,7 @@ function edit_form_validate($form, &$form_state) { /** * Submit the edit form. */ - function edit_form_submit($form, &$form_state) { + public function edit_form_submit($form, &$form_state) { $periods = $this->frequency_periods(); $period = $periods[$form_state['values']['period']['type']]; $form_state['values']['period'] = $form_state['values']['period']['number'] * $period['seconds']; @@ -585,7 +585,7 @@ function edit_form_submit($form, &$form_state) { /** * Get the period of the frequency (ie: seconds, minutes etc.). */ - function get_frequency_period() { + public function get_frequency_period() { foreach (array_reverse($this->frequency_periods()) as $period) { if ($period['seconds'] && ($this->period % $period['seconds']) === 0) { return $period; @@ -597,7 +597,7 @@ function get_frequency_period() { * Get a list of available backup periods. Only returns time periods which have a * (reasonably) consistent number of seconds (ie: no months). */ - function frequency_periods() { + public function frequency_periods() { return array( 'seconds' => array('type' => 'seconds', 'seconds' => 1, 'title' => t('Seconds'), 'singular' => t('Once a second'), 'plural' => t('Every @count seconds')), 'minutes' => array('type' => 'minutes', 'seconds' => 60, 'title' => t('Minutes'), 'singular' => t('Once a minute'), 'plural' => t('Every @count minutes')), @@ -610,14 +610,14 @@ function frequency_periods() { /** * Get the message to send to the user when confirming the deletion of the item. */ - function delete_confirm_message() { + public function delete_confirm_message() { return t('Are you sure you want to delete the schedule %name? Backups made with this schedule will not be deleted.', array('%name' => $this->get('name'))); } /** * Perform the cron action. Run the backup if enough time has elapsed. */ - function cron() { + public function cron() { $now = time(); // Add a small negative buffer (1% of the entire period) to the time to account for slight difference in cron run length. @@ -632,7 +632,7 @@ function cron() { /** * Run the actual schedule. */ - function run() { + public function run() { // Clear cached profile data which could have been altered by previous // schedule run; see #2672478 drupal_static_reset('backup_migrate_get_profiles'); @@ -653,7 +653,7 @@ function run() { /** * Set the last run time of a schedule to the given timestamp, or now if none specified. */ - function update_last_run($timestamp = NULL) { + public function update_last_run($timestamp = NULL) { if ($timestamp === NULL) { $timestamp = time(); } @@ -663,14 +663,14 @@ function update_last_run($timestamp = NULL) { /** * Set the last run time of a schedule to the given timestamp, or now if none specified. */ - function get_last_run() { + public function get_last_run() { return variable_get('backup_migrate_schedule_last_run_' . $this->get('id'), 0); } /** * Remove older backups keeping only the number specified by the aministrator. */ - function remove_expired_backups() { + public function remove_expired_backups() { backup_migrate_include('destinations'); $num_to_keep = $this->keep; @@ -697,7 +697,7 @@ function remove_expired_backups() { /** * Remove older backups keeping only the number specified by the aministrator. */ - function delete_backups($destination, $files, $num_to_keep) { + public function delete_backups($destination, $files, $num_to_keep) { backup_migrate_include('destinations'); $num_to_keep = $this->keep; @@ -730,7 +730,7 @@ function delete_backups($destination, $files, $num_to_keep) { /** * Delete files keeping the specified number of hourly, daily, weekly and monthly backups. */ - function smart_delete_backups($destination, $files, $keep_subhourly = 3600, $keep_hourly = 24, $keep_daily = 14, $keep_weekly = PHP_INT_MAX, $keep_monthly = PHP_INT_MAX) { + public function smart_delete_backups($destination, $files, $keep_subhourly = 3600, $keep_hourly = 24, $keep_daily = 14, $keep_weekly = PHP_INT_MAX, $keep_monthly = PHP_INT_MAX) { $now = time(); $periods = array( 'subhourly' => array( diff --git a/includes/sources.db.inc b/includes/sources.db.inc index 4584c16..9dc969b 100644 --- a/includes/sources.db.inc +++ b/includes/sources.db.inc @@ -16,14 +16,14 @@ class backup_migrate_source_db extends backup_migrate_source_remote { var $connection = NULL; - function type_name() { + public function type_name() { return t("Database"); } /** * Save the info by importing it into the database. */ - function save_file($file, $settings) { + public function save_file($file, $settings) { backup_migrate_include('files'); // Set the source_id to the destination_id in the settings since for a restore, the source_id is the @@ -39,7 +39,7 @@ function save_file($file, $settings) { /** * Destination configuration callback. */ - function edit_form() { + public function edit_form() { $form = parent::edit_form(); $form['scheme']['#default_value'] = $this->default_scheme(); $form['scheme']['#access'] = FALSE; @@ -52,7 +52,7 @@ function edit_form() { /** * Validate the configuration form. Make sure the db info is valid. */ - function edit_form_validate($form, &$form_state) { + public function edit_form_validate($form, &$form_state) { if (!preg_match('/[a-zA-Z0-9_\$]+/', $form_state['values']['path'])) { form_set_error('path', t('The database name is not valid.')); } @@ -69,7 +69,7 @@ function edit_form_validate($form, &$form_state) { * necessarily extremely important to back up or migrate during development * (such as access log and watchdog). */ - function backup_settings_default() { + public function backup_settings_default() { $all_tables = $this->_get_table_names(); // Basic modules that should be excluded. @@ -116,7 +116,7 @@ function backup_settings_default() { /** * Get the form for the backup settings for this destination. */ - function backup_settings_form($settings) { + public function backup_settings_form($settings) { $objects = $this->get_object_names(); $form['#description'] = t("You may omit specific tables, or specific table data from the backup file. Only omit data that you know you will not need such as cache data, or tables from other applications. Excluding tables can break your Drupal install, so do not change these settings unless you know what you're doing."); $form['exclude_tables'] = array( @@ -147,7 +147,7 @@ function backup_settings_form($settings) { /** * Backup from this source. */ - function backup_to_file($file, $settings) { + public function backup_to_file($file, $settings) { $file->push_type($this->get_file_type_id()); // $this->lock_tables($settings); @@ -161,7 +161,7 @@ function backup_to_file($file, $settings) { /** * Restore to this source. */ - function restore_from_file($file, &$settings) { + public function restore_from_file($file, &$settings) { $num = 0; $type = $this->get_file_type_id(); // Open the file using the file wrapper. Check that the dump is of the right type (allow .sql for legacy reasons). @@ -183,7 +183,7 @@ function restore_from_file($file, &$settings) { /** * Get the db connection for the specified db. */ - function _get_db_connection() { + public function _get_db_connection() { if (!$this->connection) { $target = $key = ''; $parts = explode(':', $this->get_id()); @@ -223,21 +223,21 @@ function _get_db_connection() { /** * Backup the databases to a file. */ - function _backup_db_to_file($file, $settings) { + public function _backup_db_to_file($file, $settings) { // Must be overridden. } /** * Backup the databases to a file. */ - function _restore_db_from_file($file, $settings) { + public function _restore_db_from_file($file, $settings) { // Must be overridden. } /** * Get a list of objects in the database. */ - function get_object_names() { + public function get_object_names() { // Must be overridden. $out = $this->_get_table_names(); if (method_exists($this, '_get_view_names')) { @@ -249,7 +249,7 @@ function get_object_names() { /** * Get a list of tables in the database. */ - function get_table_names() { + public function get_table_names() { // Must be overridden. $out = $this->_get_table_names(); return $out; @@ -258,7 +258,7 @@ function get_table_names() { /** * Get a list of tables in the database. */ - function _get_table_names() { + public function _get_table_names() { // Must be overridden. return array(); } @@ -266,7 +266,7 @@ function _get_table_names() { /** * Lock the database in anticipation of a backup. */ - function lock_tables($settings) { + public function lock_tables($settings) { if ($settings->filters['utils_lock_tables']) { $tables = array(); foreach ($this->get_table_names() as $table) { @@ -282,14 +282,14 @@ function lock_tables($settings) { /** * Lock the list of given tables in the database. */ - function _lock_tables($tables) { + public function _lock_tables($tables) { // Must be overridden. } /** * Unlock any tables that have been locked. */ - function unlock_tables($settings) { + public function unlock_tables($settings) { if ($settings->filters['utils_lock_tables']) { $this->_unlock_tables(); } @@ -298,21 +298,21 @@ function unlock_tables($settings) { /** * Unlock the list of given tables in the database. */ - function _unlock_tables($tables) { + public function _unlock_tables($tables) { // Must be overridden. } /** * Get the file type for to backup this destination to. */ - function get_file_type_id() { + public function get_file_type_id() { return 'sql'; } /** * Get the version info for the given DB. */ - function _db_info() { + public function _db_info() { return array( 'type' => FALSE, 'version' => t('Unknown'), diff --git a/includes/sources.db.mysql.inc b/includes/sources.db.mysql.inc index f3bc671..aa6b714 100644 --- a/includes/sources.db.mysql.inc +++ b/includes/sources.db.mysql.inc @@ -17,14 +17,14 @@ * @ingroup backup_migrate_destinations */ class backup_migrate_source_db_mysql extends backup_migrate_source_db { - function type_name() { + public function type_name() { return t("MySQL Database"); } /** * Return a list of backup filetypes. */ - function file_types() { + public function file_types() { return array( "sql" => array( "extension" => "sql", @@ -44,7 +44,7 @@ function file_types() { /** * Return the scheme for this db type. */ - function default_scheme() { + public function default_scheme() { return 'mysql'; } @@ -52,7 +52,7 @@ function default_scheme() { /** * Declare any mysql databases defined in the settings.php file as a possible source. */ - function sources() { + public function sources() { $out = array(); global $databases; foreach ((array) $databases as $db_key => $target) { @@ -85,7 +85,7 @@ function sources() { /** * Get the file type for to backup this source to. */ - function get_file_type_id() { + public function get_file_type_id() { return 'mysql'; } @@ -96,7 +96,7 @@ function get_file_type_id() { * That makes it easier to import without loading the whole file into memory. * The files are a little harder to read, but human-readability is not a priority. */ - function _backup_db_to_file($file, $settings) { + public function _backup_db_to_file($file, $settings) { if (!empty($settings->filters['use_cli']) && $this->_backup_db_to_file_mysqldump($file, $settings)) { return TRUE; } @@ -142,7 +142,7 @@ function _backup_db_to_file($file, $settings) { /** * Backup the databases to a file using the mysqldump command. */ - function _backup_db_to_file_mysqldump($file, $settings) { + public function _backup_db_to_file_mysqldump($file, $settings) { $success = FALSE; $nodata_tables = array(); $alltables = $this->_get_tables(); @@ -186,7 +186,7 @@ function _backup_db_to_file_mysqldump($file, $settings) { /** * Backup the databases to a file. */ - function _restore_db_from_file($file, $settings) { + public function _restore_db_from_file($file, $settings) { $num = 0; if ($file->open() && $conn = $this->_get_db_connection()) { @@ -218,7 +218,7 @@ function _restore_db_from_file($file, $settings) { * * Supports the formatting created by mysqldump, but won't handle multiline comments. */ - function _read_sql_command_from_file($file) { + public function _read_sql_command_from_file($file) { $out = ''; while ($line = $file->read()) { $first2 = substr($line, 0, 2); @@ -239,7 +239,7 @@ function _read_sql_command_from_file($file) { /** * Get a list of tables in the database. */ - function _get_table_names() { + public function _get_table_names() { $out = array(); foreach ($this->_get_tables() as $table) { $out[$table['name']] = $table['name']; @@ -250,7 +250,7 @@ function _get_table_names() { /** * Get a list of views in the database. */ - function _get_view_names() { + public function _get_view_names() { $out = array(); foreach ($this->_get_views() as $view) { $out[$view['name']] = $view['name']; @@ -261,7 +261,7 @@ function _get_view_names() { /** * Lock the list of given tables in the database. */ - function _lock_tables($tables) { + public function _lock_tables($tables) { if ($tables) { $tables_escaped = array(); foreach ($tables as $table) { @@ -274,14 +274,14 @@ function _lock_tables($tables) { /** * Unlock all tables in the database. */ - function _unlock_tables($settings) { + public function _unlock_tables($settings) { $this->query('UNLOCK TABLES'); } /** * Get a list of tables in the db. */ - function _get_tables() { + public function _get_tables() { $out = array(); // get auto_increment values and names of all tables. $tables = $this->query("show table status", array(), array('fetch' => PDO::FETCH_ASSOC)); @@ -299,7 +299,7 @@ function _get_tables() { /** * Get a list of views in the db. */ - function _get_views() { + public function _get_views() { $out = array(); // get auto_increment values and names of all tables. $tables = $this->query("show table status", array(), array('fetch' => PDO::FETCH_ASSOC)); @@ -317,7 +317,7 @@ function _get_views() { /** * Get the sql for the structure of the given view. */ - function _get_view_create_sql($view) { + public function _get_view_create_sql($view) { $out = ""; // Switch SQL mode to get rid of "CREATE ALGORITHM..." what requires more permissions + troubles with the DEFINER user. $sql_mode = $this->query("SELECT @@SESSION.sql_mode")->fetchField(); @@ -341,7 +341,7 @@ function _get_view_create_sql($view) { /** * Get the sql for the structure of the given table. */ - function _get_table_structure_sql($table) { + public function _get_table_structure_sql($table) { $out = ""; $result = $this->query("SHOW CREATE TABLE `" . $table['name'] . "`", array(), array('fetch' => PDO::FETCH_ASSOC)); foreach ($result as $create) { @@ -362,7 +362,7 @@ function _get_table_structure_sql($table) { /** * Get the sql to insert the data for a given table. */ - function _dump_table_data_sql_to_file($file, $table) { + public function _dump_table_data_sql_to_file($file, $table) { $rows_per_line = variable_get('backup_migrate_data_rows_per_line', 30); $bytes_per_line = variable_get('backup_migrate_data_bytes_per_line', 2000); @@ -420,7 +420,7 @@ function _dump_table_data_sql_to_file($file, $table) { /** * Get the db connection for the specified db. */ - function _get_db_connection() { + public function _get_db_connection() { if (!$this->connection) { $this->connection = parent::_get_db_connection(); // Set the sql mode because the default is ANSI,TRADITIONAL which is not aware of collation or storage engine. @@ -432,7 +432,7 @@ function _get_db_connection() { /** * Run a db query on this destination's db. */ - function query($query, $args = array(), $options = array()) { + public function query($query, $args = array(), $options = array()) { if ($conn = $this->_get_db_connection()) { return $conn->query($query, $args, $options); } @@ -442,7 +442,7 @@ function query($query, $args = array(), $options = array()) { * The header for the top of the sql dump file. These commands set the connection * character encoding to help prevent encoding conversion issues. */ - function _get_sql_file_header() { + public function _get_sql_file_header() { $info = $this->_db_info(); return "-- Backup and Migrate (Drupal) MySQL Dump @@ -472,7 +472,7 @@ function _get_sql_file_header() { /** * The footer of the sql dump file. */ - function _get_sql_file_footer() { + public function _get_sql_file_footer() { return " /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; @@ -487,7 +487,7 @@ function _get_sql_file_footer() { /** * Get the version info for the given DB. */ - function _db_info() { + public function _db_info() { $db = $this->_get_db_connection(); return array( 'type' => 'mysql',