You are here

public static function FeedImport::saveFeed in Feed Import 7.3

Same name and namespace in other branches
  1. 7 feed_import.inc.php \FeedImport::saveFeed()
  2. 7.2 feed_import.inc.php \FeedImport::saveFeed()

Saves a feed in database

Parameters

object $feed: Feed info

8 calls to FeedImport::saveFeed()
feed_import_class_settings_form_submit in ./feed_import.module
Options edit form submit
feed_import_dynamic_func_form_submit in ./feed_import.module
Dynamic functions form submit.
feed_import_edit_feed_form_submit in ./feed_import.module
Edit form submit
feed_import_edit_filter_form_submit in ./feed_import.module
Edit filter form submit
feed_import_fields_form_submit in ./feed_import.module
Edit fields form submit

... See full list

File

feed_import_base/inc/feed_import.inc, line 383
This file contains Feed Import helpers.

Class

FeedImport
This class provides helper functions for feed import.

Code

public static function saveFeed($feed) {
  if (empty($feed->name) || empty($feed->machine_name) || empty($feed->entity) || empty($feed->settings)) {
    return FALSE;
  }
  if (!isset($feed->cron_import)) {
    $feed->cron_import = 0;
  }
  $fields = array(
    'name' => $feed->name,
    'machine_name' => $feed->machine_name,
    'entity' => $feed->entity,
    'cron_import' => (int) $feed->cron_import,
    'settings' => serialize($feed->settings),
  );
  if (isset($feed->id)) {
    db_update('feed_import_settings')
      ->fields($fields)
      ->condition('id', $feed->id)
      ->execute();
  }
  else {
    $fields += array(
      'last_run' => 0,
      'last_run_duration' => 0,
      'last_run_items' => 0,
    );
    db_insert('feed_import_settings')
      ->fields($fields)
      ->execute();
  }
  return TRUE;
}