You are here

function fb_instant_articles_rss_node_form_submit in Facebook Instant Articles 7

Same name and namespace in other branches
  1. 7.2 modules/fb_instant_articles_rss/fb_instant_articles_rss.module \fb_instant_articles_rss_node_form_submit()

Submit callback for node form.

1 string reference to 'fb_instant_articles_rss_node_form_submit'
fb_instant_articles_rss_form_node_form_alter in modules/fb_instant_articles_rss/fb_instant_articles_rss.module
Implements hook_form_BASE_FORM_ID_alter().

File

modules/fb_instant_articles_rss/fb_instant_articles_rss.module, line 207
Facebook Instant Articles RSS module.

Code

function fb_instant_articles_rss_node_form_submit($form, &$form_state) {
  $fb_instant_enabled = fb_instant_articles_display_is_article_type('node', $form['type']['#value']);
  if ($fb_instant_enabled) {
    if (!isset($form_state['values']['fb_instant_enabled'])) {
      $form_state['values']['fb_instant_enabled'] = 0;
    }
    $value = $form_state['values']['fb_instant_enabled'];
    $default_enabled = variable_get('fb_instant_articles_rss_all_enabled_default', TRUE);
    if ($default_enabled xor $value) {

      // Save the new article entity setting if the value is different from the
      // default value.
      fb_instant_articles_rss_set_entity($form['nid']['#value'], $value);
    }
    else {

      // Otherwise if the value and default value are the same, delete the entry
      // to keep the table clean.
      fb_instant_articles_rss_delete_entity($form['nid']['#value']);
    }
  }
}