From 12ba9b318abd51b3479851c72a9d13d1b5e0c35a Mon Sep 17 00:00:00 2001 From: Carlo Landmeter Date: Fri, 6 May 2011 21:31:48 +0200 Subject: remove delete all apk nodes (we can use bulkdelete module for this) --- apk_browser.module | 74 ------------------------------------------------------ 1 file changed, 74 deletions(-) (limited to 'apk_browser.module') diff --git a/apk_browser.module b/apk_browser.module index f30e451..89422b0 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; } @@ -588,73 +581,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 -- cgit v1.2.3