You are here

function custom_pub_node_filter_form_submit in Custom Publishing Options 7

Form submit function for the content administration form.

1 string reference to 'custom_pub_node_filter_form_submit'
custom_pub_node_admin_content in ./custom_pub.admin.inc
Menu callback: content administration form.

File

./custom_pub.admin.inc, line 388
Admin functions.

Code

function custom_pub_node_filter_form_submit($form, $form_state) {
  $types = variable_get('custom_pub_types', array());
  $filters = node_filters();
  switch ($form_state['values']['op']) {
    case t('Filter'):
    case t('Refine'):

      // Apply every filter that has a choice selected other than 'any'.
      foreach ($filters as $filter => $options) {
        $custom = FALSE;
        if (isset($form_state['values'][$filter]) && $form_state['values'][$filter] != '[any]') {

          // Flatten the options array to accommodate hierarchical/nested options.
          $flat_options = form_options_flatten($filters[$filter]['options']);

          // Only accept valid selections offered on the dropdown, block bad input.
          if ($filter == 'status') {
            list($type, $val) = explode('-', $form_state['values'][$filter]);
            $custom = isset($types[$type]);
          }
          if (isset($flat_options[$form_state['values'][$filter]]) || $custom) {
            $_SESSION['node_overview_filter'][] = array(
              $filter,
              $form_state['values'][$filter],
            );
          }
        }
      }
      break;
    case t('Undo'):
      array_pop($_SESSION['node_overview_filter']);
      break;
    case t('Reset'):
      $_SESSION['node_overview_filter'] = array();
      break;
  }
}