You are here

drd_server.admin.inc in Drupal Remote Dashboard Server 7

Same filename and directory in other branches
  1. 6.2 drd_server.admin.inc
  2. 7.2 drd_server.admin.inc

File

drd_server.admin.inc
View source
<?php

/**
 * DRD Server Admin block.
 */
function drd_server_admin_block() {
  $block = array(
    'subject' => t('Extra Admin'),
    'content' => '',
  );
  $menu = array();
  if (user_access('administer site configuration')) {
    $menu[] = array(
      'data' => l(t('Run Cron'), 'admin/reports/status/run-cron'),
      'class' => array(
        'leaf',
      ),
    );
    $menu[] = array(
      'data' => l(t('Run Update'), 'update.php'),
      'class' => array(
        'leaf',
      ),
    );
  }
  if (user_access('flush cache')) {
    $menu[] = array(
      'data' => l(t('Flush Cache'), 'admin/drd_server/flush/cache'),
      'class' => array(
        'leaf',
      ),
    );
  }
  if (user_access('translate interface')) {
    $menu[] = array(
      'data' => l(t('Update Translation'), 'admin/drd_server/update/translation'),
      'class' => array(
        'leaf',
      ),
    );
  }
  drupal_alter('drd_server_admin_block', $menu);
  $block['content'] = theme('item_list', array(
    'items' => $menu,
    'attributes' => array(
      'class' => array(
        'menu',
      ),
    ),
  ));
  return $block;
}
function drd_server_admin_flush_cache() {
  drupal_flush_all_caches();
  drupal_set_message(t('Caches cleared.'));
  drupal_goto($_SERVER['HTTP_REFERER']);
}
function drd_server_admin_update_translation($redirect = TRUE) {
  if (module_exists('l10n_update')) {
    set_time_limit(0);
    module_load_include('admin.inc', 'l10n_update');
    $steps = array(
      t('Refresh information'),
      t('Update translations'),
    );
    foreach ($steps as $step) {
      $projects = l10n_update_get_projects();
      $languages = l10n_update_language_list('name');
      if ($languages) {
        $history = l10n_update_get_history();
        $available = l10n_update_available_releases();
        $updates = l10n_update_build_updates($history, $available);
        $form_state = array(
          'values' => array(
            'op' => $step,
            'mode' => variable_get('l10n_update_import_mode', LOCALE_IMPORT_KEEP),
            'languages' => array(),
            //send the empty array so that all languages get updated
            'updates' => $updates,
          ),
        );
        $form = array();
        l10n_update_admin_import_form_submit($form, $form_state);
      }
    }
    if (($batch =& batch_get()) && !isset($batch['current_set'])) {
      $batch['progressive'] = TRUE;
      $batch['form_state'] = array(
        'rebuild' => FALSE,
        'programmed' => FALSE,
      );
      batch_process();
    }
  }
  if ($redirect) {
    drupal_goto($_SERVER['HTTP_REFERER']);
  }
}