'admin/build/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' => $admin_access, ); $items[] = array( 'path' => 'admin/build/demo/maintenance', 'title' => t('Status'), 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => 0, ); $items[] = array( 'path' => 'admin/build/demo/manage', 'title' => t('Manage snapshots'), 'callback' => 'drupal_get_form', 'callback arguments' => array('demo_manage'), 'access' => $admin_access, 'type' => MENU_LOCAL_TASK, 'weight' => 1, ); $items[] = array( 'path' => 'admin/build/demo/dump', 'title' => t('Create snapshot'), 'callback' => 'drupal_get_form', 'callback arguments' => array('demo_dump'), 'access' => $admin_access, 'type' => MENU_LOCAL_TASK, 'weight' => 2, ); $items[] = array( 'path' => 'admin/build/demo/reset', 'title' => t('Reset site'), 'callback' => 'drupal_get_form', 'callback arguments' => array('demo_reset_confirm'), 'access' => $admin_access, 'type' => MENU_LOCAL_TASK, 'weight' => 3, ); $items[] = array( 'path' => 'admin/build/demo/delete', 'title' => t('Delete snapshot'), 'callback' => 'drupal_get_form', 'callback arguments' => array('demo_delete_confirm'), 'access' => $admin_access, 'type' => MENU_CALLBACK, ); $items[] = array( 'path' => 'demo/autocomplete', 'callback' => 'demo_autocomplete', 'access' => $admin_access, 'type' => MENU_CALLBACK, ); $items[] = array( 'path' => 'demo/download', 'callback' => 'demo_download', 'access' => $admin_access, 'type' => MENU_CALLBACK, ); } else if (strpos($_GET['q'], 'admin/build/demo') === 0 || strpos($_GET['q'], 'demo') === 0) { require_once drupal_get_path('module', 'demo') . '/demo.admin.inc'; } return $items; } /** * Implementation of hook_block(). */ function demo_block($op = 'list', $delta = 0, $edit = array()) { switch ($op) { case 'list': $blocks[0] = array('info' => t('Demo site reset'), 'enabled' => 1, 'region' => 'right'); return $blocks; case 'view': $block = array( 'subject' => t('Reset demo'), 'content' => drupal_get_form('demo_reset_now'), ); return $block; } } function demo_reset_now() { $form['redirect'] = array( '#type' => 'value', '#value' => $_GET['q'], ); $form['filename'] = array( '#type' => 'value', '#value' => variable_get('demo_dump_cron', 'demo_site'), ); $form['snapshot'] = array( '#value' => t('Active snapshot: !snapshot', array('!snapshot' => variable_get('demo_dump_cron', 'demo_site'))), ); $form['reset-demo'] = array( '#type' => 'submit', '#value' => t('Reset now'), ); return $form; } function demo_reset_now_submit($form_id, $values) { require_once drupal_get_path('module', 'demo') . '/demo.admin.inc'; return demo_reset_confirm_submit($form_id, $values); } /** * Implementation of hook_cron(). */ function demo_cron() { if ($interval = variable_get('demo_reset_interval', 0)) { // See if it's time for a reset. $time = $_SERVER['REQUEST_TIME']; if (($time - $interval) >= variable_get('demo_reset_last', 0)) { require_once drupal_get_path('module', 'demo') . '/demo.admin.inc'; demo_reset(variable_get('demo_dump_cron', 'demo_site'), FALSE); variable_set('demo_reset_last', $time); } } }