View source
<?php
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(),
'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']);
}
}