/**
  * Capture bulk actions - gf_entries table
  *
  * @uses  GravityView_frontend::get_search_criteria() Convert the $_POST search request into a properly formatted request.
  * @access public
  * @return void|boolean
  */
 public function process_bulk_action()
 {
     if (!class_exists('RGForms')) {
         return;
     }
     if ('bulk' === RGForms::post('action')) {
         check_admin_referer('gforms_entry_list', 'gforms_entry_list');
         // The action is formatted like: approve-16 or disapprove-16, where the first word is the name of the action and the second is the ID of the form. Bulk action 2 is the bottom bulk action select form.
         $bulk_action = !empty($_POST['bulk_action']) ? $_POST['bulk_action'] : $_POST['bulk_action2'];
         /**
          * The extra '-' is to make sure that there are at *least* two items in array.
          * @see https://github.com/katzwebservices/GravityView/issues/370
          */
         $bulk_action .= '-';
         list($approved_status, $form_id) = explode('-', $bulk_action);
         if (empty($form_id)) {
             do_action('gravityview_log_error', '[process_bulk_action] Form ID is empty from parsing bulk action.', $bulk_action);
             return false;
         }
         // All entries are set to be updated, not just the visible ones
         if (!empty($_POST['all_entries'])) {
             // Convert the current entry search into GF-formatted search criteria
             $search = array('search_field' => isset($_POST['f']) ? $_POST['f'][0] : 0, 'search_value' => isset($_POST['v'][0]) ? $_POST['v'][0] : '', 'search_operator' => isset($_POST['o'][0]) ? $_POST['o'][0] : 'contains');
             $search_criteria = GravityView_frontend::get_search_criteria($search, $form_id);
             // Get all the entry IDs for the form
             $entries = gravityview_get_entry_ids($form_id, $search_criteria);
         } else {
             $entries = $_POST['lead'];
         }
         if (empty($entries)) {
             do_action('gravityview_log_error', '[process_bulk_action] Entries are empty');
             return false;
         }
         $entry_count = count($entries) > 1 ? sprintf(__('%d entries', 'gravityview'), count($entries)) : __('1 entry', 'gravityview');
         switch ($approved_status) {
             case 'approve':
                 self::update_bulk($entries, 1, $form_id);
                 $this->bulk_update_message = sprintf(__('%s approved.', 'gravityview'), $entry_count);
                 break;
             case 'unapprove':
                 self::update_bulk($entries, 0, $form_id);
                 $this->bulk_update_message = sprintf(__('%s disapproved.', 'gravityview'), $entry_count);
                 break;
         }
     }
 }
 /**
  * Capture bulk actions - gf_entries table
  *
  * @uses  GravityView_frontend::get_search_criteria() Convert the $_POST search request into a properly formatted request.
  * @access public
  * @return void|boolean
  */
 public function process_bulk_action()
 {
     if (!is_admin() || !class_exists('GFForms') || empty($_POST)) {
         return false;
     }
     // The action is formatted like: gvapprove-16 or gvunapprove-16, where the first word is the name of the action and the second is the ID of the form.
     $bulk_action = $this->get_gv_bulk_action();
     // gforms_entry_list is the nonce that confirms we're on the right page
     // gforms_update_note is sent when bulk editing entry notes. We don't want to process then.
     if ($bulk_action && rgpost('gforms_entry_list') && empty($_POST['gforms_update_note'])) {
         check_admin_referer('gforms_entry_list', 'gforms_entry_list');
         /**
          * The extra '-' is to make sure that there are at *least* two items in array.
          * @see https://github.com/katzwebservices/GravityView/issues/370
          */
         $bulk_action .= '-';
         list($approved_status, $form_id) = explode('-', $bulk_action);
         if (empty($form_id)) {
             do_action('gravityview_log_error', '[process_bulk_action] Form ID is empty from parsing bulk action.', $bulk_action);
             return false;
         }
         // All entries are set to be updated, not just the visible ones
         if (!empty($_POST['all_entries'])) {
             // Convert the current entry search into GF-formatted search criteria
             $search = array('search_field' => isset($_POST['f']) ? $_POST['f'][0] : 0, 'search_value' => isset($_POST['v'][0]) ? $_POST['v'][0] : '', 'search_operator' => isset($_POST['o'][0]) ? $_POST['o'][0] : 'contains');
             $search_criteria = GravityView_frontend::get_search_criteria($search, $form_id);
             // Get all the entry IDs for the form
             $entries = gravityview_get_entry_ids($form_id, $search_criteria);
         } else {
             // Changed from 'lead' to 'entry' in 2.0
             $entries = isset($_POST['lead']) ? $_POST['lead'] : $_POST['entry'];
         }
         if (empty($entries)) {
             do_action('gravityview_log_error', '[process_bulk_action] Entries are empty');
             return false;
         }
         $entry_count = count($entries) > 1 ? sprintf(__('%d entries', 'gravityview'), count($entries)) : __('1 entry', 'gravityview');
         switch ($approved_status) {
             case $this->bulk_action_prefixes['approve']:
                 self::update_bulk($entries, 1, $form_id);
                 $this->bulk_update_message = sprintf(__('%s approved.', 'gravityview'), $entry_count);
                 break;
             case $this->bulk_action_prefixes['unapprove']:
                 self::update_bulk($entries, 0, $form_id);
                 $this->bulk_update_message = sprintf(__('%s disapproved.', 'gravityview'), $entry_count);
                 break;
         }
     }
 }