You are here

function media_admin_submit in D7 Media 7

Process media_admin_list form submissions.

Execute the chosen 'Update option' on the selected files.

1 string reference to 'media_admin_submit'
media_admin in includes/media.admin.inc
Display the list or thumbnails media admin display.

File

includes/media.admin.inc, line 277
This file contains the admin functions for the Media module.

Code

function media_admin_submit($form, &$form_state) {
  $operations = module_invoke_all('media_operations');
  $operation = $operations[$form_state['values']['operation']];

  // Filter out unchecked nodes
  $files = array_filter($form_state['values']['files']);
  if ($function = $operation['callback']) {

    // Add in callback arguments if present.
    if (isset($operation['callback arguments'])) {
      $args = array_merge(array(
        $files,
      ), $operation['callback arguments']);
    }
    else {
      $args = array(
        $files,
      );
    }
    call_user_func_array($function, $args);
    cache_clear_all();
  }
  elseif (!empty($operation['redirect'])) {
    $fids = implode(' ', array_keys(array_filter($form_state['values']['files'])));
    $form_state['redirect'] = array(
      str_replace('%fids', $fids, $operation['redirect']),
      array(
        'query' => array(
          'destination' => 'admin/content/media',
        ),
      ),
    );
  }
  else {

    // We need to rebuild the form to go to a second step. For example, to
    // show the confirmation form for the deletion of nodes.
    $form_state['rebuild'] = TRUE;
  }
}