'admin/settings/demo', 'title' => t('Demonstration site'), 'description' => t('Administer reset interval, create new dumps and manually reset this site.'), 'callback' => 'drupal_get_form', 'callback arguments' => array('demo_admin_settings'), 'access' => user_access('administer demo settings'), ); $items[] = array( 'path' => 'admin/settings/demo/maintenance', 'title' => 'Status', 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => 0, ); $items[] = array( 'path' => 'admin/settings/demo/dump', 'title' => t('Create snapshot'), 'callback' => 'drupal_get_form', 'callback arguments' => array('demo_dump'), 'access' => user_access('administer demo settings'), 'type' => MENU_LOCAL_TASK, 'weight' => 1, ); $items[] = array( 'path' => 'admin/settings/demo/reset', 'title' => t('Reset site'), 'callback' => 'drupal_get_form', 'callback arguments' => array('demo_reset_confirm'), 'access' => user_access('administer demo settings'), 'type' => MENU_LOCAL_TASK, 'weight' => 2, ); } return $items; } function demo_admin_settings() { global $base_url; $form['status'] = array( '#type' => 'fieldset', '#title' => t('Status'), '#collapsible' => false, ); $form['status'][] = array( '#value' => t('
Last Reset: !date
', array('!date' => format_date(variable_get('demo_reset_last', t('Never'))))), ); if ($mtime = filemtime(variable_get('demo_dump_path', file_directory_path()) .'/demo_site.sql')) { $last_dump_date = format_date($mtime); } else { $last_dump_date = t('Never'); } $form['status'][] = array( '#value' => t('Last Dump: !date
', array('!date' => $last_dump_date)), ); $form['dump'] = array( '#type' => 'fieldset', '#title' => t('Dump settings'), '#collapsible' => true, '#collapsed' => (variable_get('demo_reset_interval', 0) ? false : true), ); $period = drupal_map_assoc(array(0, 1800, 3600, 7200, 10800, 14400, 18000, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval'); $period[0] = t('disabled'); $form['dump']['interval'] = array( '#type' => 'select', '#title' => t('Automatically reset site every'), '#default_value' => variable_get('demo_reset_interval', 0), '#options' => $period, '#description' => t('Select how often this Demo site shall be automatically resetted. Note: This requires cron to run at least within this interval.'), ); $form['dump']['path'] = array( '#type' => 'textfield', '#title' => t('Dump path'), '#default_value' => variable_get('demo_dump_path', file_directory_path()), '#size' => 30, '#description' => t('Enter a writable subdirectory below %files where dump files of this Demo site shall be stored.', array('%files' => file_directory_path() .'/')), ); $form[] = array( '#type' => 'submit', '#value' => t('Save'), ); return $form; } function demo_admin_settings_submit($form_id, $values) { if (!file_check_directory($values['path'], FILE_CREATE_DIRECTORY)) { drupal_set_message(t('Dump could not be created. The directory %directory has not been properly configured.', array('%directory' => $values['path'])), 'error'); } else { variable_set('demo_dump_path', $values['path']); } variable_set('demo_reset_interval', $values['interval']); } function demo_dump() { $form = array(); return confirm_form($form, t('Are you sure you want to overwrite the site dump?'), 'admin/settings/demo', t('Creating a new dump will overwrite the previous dump of this Drupal installation. This action cannot be undone.'), t('Create'), t('Cancel')); } function demo_dump_submit() { module_invoke('dba', 'auto_backup', variable_get('demo_dump_path', file_directory_path()), 'demo_site.sql', array(), false, false ); drupal_goto('admin/settings/demo'); } function demo_reset_confirm() { $form = array(); return confirm_form($form, t('Are you sure you want to reset the site?'), 'admin/settings/demo', t('