You are here

function flickrcachewarmer_admin_settings_submit in Flickr 7

Submit form data.

1 string reference to 'flickrcachewarmer_admin_settings_submit'
flickrcachewarmer_form_flickr_admin_settings_alter in cachewarmer/flickrcachewarmer.admin.inc
Implements hook_form_FORM_ID_alter().

File

cachewarmer/flickrcachewarmer.admin.inc, line 77
The admin settings for the Flickr Cache Warmer module.

Code

function flickrcachewarmer_admin_settings_submit($form, &$form_state) {
  if ($form_state['values']['flickrcachewarmer_run']) {
    $content_types = array_filter(variable_get('flickrcachewarmer_nodetypes', array()));

    // If no content types are selected in the settings, use all.
    if (empty($content_types)) {
      $names = node_type_get_names();
      $content_types = array_flip(array_map('check_plain', $names));
    }

    // Returns an array of nid's for selected content types.
    $nids = db_select('node', 'n')
      ->fields('n', array(
      'nid',
    ))
      ->fields('n', array(
      'type',
    ))
      ->condition('n.type', array_filter($content_types), 'IN')
      ->execute()
      ->fetchCol();
    flickrcachewarmer_run($nids);
    drupal_set_message(t('All caches are rebuilt.'), 'status', FALSE);
  }
}