diff options
author | Carlo Landmeter <clandmeter@gmail.com> | 2011-05-06 21:32:18 +0200 |
---|---|---|
committer | Carlo Landmeter <clandmeter@gmail.com> | 2011-05-06 21:32:18 +0200 |
commit | 844a5b0c261a2683c2a6cdb1a7d2d25177d94c82 (patch) | |
tree | 2f38a37ade0cee31e1fb0ed4497207318c7bc73d | |
parent | 63ac830da3abed083d5936d2f7be384a22dc8702 (diff) | |
parent | 12ba9b318abd51b3479851c72a9d13d1b5e0c35a (diff) | |
download | apk_browser-844a5b0c261a2683c2a6cdb1a7d2d25177d94c82.tar.bz2 apk_browser-844a5b0c261a2683c2a6cdb1a7d2d25177d94c82.tar.xz |
Merge branch 'master' into stable
-rw-r--r-- | apk_browser.module | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/apk_browser.module b/apk_browser.module index d864ef8..33c0064 100644 --- a/apk_browser.module +++ b/apk_browser.module @@ -52,13 +52,6 @@ function apk_browser_menu() { 'page callback' => 'apk_browser_importer', 'access arguments' => array('access apk browser'), ); - $items['admin/config/apk_browser/delete/all'] = array( - 'title' => 'Delete all packages', - 'description' => 'Delete all APK packages', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('apk_browser_delete_all_apk_form'), - 'access arguments' => array('access apk browser'), - ); return $items; } @@ -590,73 +583,6 @@ function apk_browser_preprocess_node(&$vars) { } } -function apk_browser_delete_all_apk_form($form, $form_state) { - $form = array(); - $question = t('Are you sure you want to remove all packages?'); - $path = 'admin/config/apk_browser'; - $description = t('This action cannot be undone.'); - $yes = t('Remove all'); - $no = t('Cancel'); - return confirm_form($form, $question, $path, $description, $yes, $no); -} - -function apk_browser_delete_all_apk_form_submit($form, &$form_state) { - apk_browser_batch_delete_all_apk(); -} - -function apk_browser_batch_delete_all_apk() { - //define batch options - $batch = array( - 'operations' => array( - array('apk_browser_delete_all_apk', array()), - ), - 'finished' => 'apk_browser_batch_delete_all_apk_finished', - 'title' => t('Deleting all apks'), - 'init_message' => t('Starting deletion of all apks.'), - 'progress_message' => t('Processed @current out of @total.'), - 'error_message' => t('Batch apk delete has encountered an error.'), - ); - //set the batch - batch_set($batch); - //Only used when not run from forms api. forwards to admin page after complete. - batch_process('admin'); -} - -function apk_browser_delete_all_apk(&$context) { - //node delete limit depending on php timeout - $limit = variable_get('apk_import_delete_all_apk_limit', '20'); - if (!isset($context['sandbox']['progress'])) { - $context['sandbox']['progress'] = 0; - $qty = db_query("SELECT nid FROM {node} WHERE type = 'apk'")->rowCount(); - $context['sandbox']['max'] = ceil($qty / $limit); - $context['results']['qty'] = $qty; - } - //delete X nodes set by limit. - $nids = db_query("SELECT nid FROM {node} WHERE type = 'apk' LIMIT :limit", array(':limit' => $limit))->fetchCol(); - node_delete_multiple($nids); - //setting progress to calculate progress and display progress bar. - $context['sandbox']['progress']++; - $context['message'] = t('Deleting @qty packages', array('@qty' => $context['results']['qty'])); - //on last run we do not set finished and will end batch - if ($context['sandbox']['progress'] != $context['sandbox']['max']) { - $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; - } -} - -function apk_browser_batch_delete_all_apk_finished($success, $results, $operations) { - if ($success) { - // Here we do something meaningful with the results. - $message = $results['qty'] . ' packages deleted.'; - $message .= theme('item_list', $results); - } else { - // An error occurred. - // $operations contains the operations that remained unprocessed. - $error_operation = reset($operations); - $message = t('An error occurred while processing %error_operation with arguments: @arguments', array('%error_operation' => $error_operation[0], '@arguments' => print_r($error_operation[1], TRUE))); - } - drupal_set_message($message); -} - function apk_browser_origin_table($vars) { $rows = db_query(" SELECT node.title |