You are here

function apps_app_update in Apps 7

Callback for app update.

1 string reference to 'apps_app_update'
apps_menu in ./apps.module
Implements hook_menu().

File

./apps.pages.inc, line 419
The page callbacks for the Apps module.

Code

function apps_app_update($app) {
  $token_name = 'update-' . $app['machine_name'];
  if ($confirm_form = apps_display_confirm_form(t('Are you sure you want to update @name?', array(
    '@name' => $app['name'],
  )), $token_name)) {
    return $confirm_form;
  }

  // Redownload apps then run any updates.
  apps_include('installer');
  require_once DRUPAL_ROOT . '/includes/authorize.inc';
  $action = arg(5);
  switch ($action) {
    case 'updatedb':
      drupal_set_message($_SESSION['authorize_results']['page_message']['message'], $_SESSION['authorize_results']['page_message']['type']);
      unset($_SESSION['apps_install_next']);
      drupal_goto(apps_app_page_path($app));
      break;
    case 'update':
      $_SESSION['apps_install_next'] = apps_app_page_path($app, 'update/updatedb');
      return apps_install_downloads();
    default:

      // Need to clear update cache or it'll reuse all downloads.
      apps_clear_update_disk_cache();

      // Adds an extra path element to avoid an endless loop. If we check for
      // install at arg(4) we are usually there. So here we add an install at
      // arg(5) and that will get caught in the case above ^-^
      $_SESSION['apps_install_next'] = apps_app_page_path($app, 'update/update');
      apps_download_apps($app);
      break;
  }
}