You are here

function feeds_tamper_save_instance in Feeds Tamper 6

Same name and namespace in other branches
  1. 7 feeds_tamper.inc \feeds_tamper_save_instance()

Save a plugin instance.

Parameters

stdClass $instance: A plugin instance object.

Return value

mixed If the plugin save failed, returns FALSE. If it succeeded, returns SAVED_NEW or SAVED_UPDATED, depending on the operation performed.

Related topics

5 calls to feeds_tamper_save_instance()
FeedsTamperWebTestHelper::addTamperPlugin in tests/feeds_tamper.test
FeedsTamperWebTestHelper::disableTamperPlugin in tests/feeds_tamper.test
feeds_tamper_ui_add_plugin_form_submit in feeds_tamper_ui/feeds_tamper_ui.admin.inc
feeds_tamper_ui_edit_plugin_form_submit in feeds_tamper_ui/feeds_tamper_ui.admin.inc
feeds_tamper_ui_list_form_submit in feeds_tamper_ui/feeds_tamper_ui.admin.inc

File

./feeds_tamper.inc, line 71
Version agnostic parts of feeds_tamper.module.

Code

function feeds_tamper_save_instance($instance) {
  ctools_include('export');

  // It's a new instance, give it the heaviest weight.
  if (!isset($instance->weight)) {
    $conditions = array(
      'importer' => $instance->importer,
      'source' => $instance->source,
    );
    $all = ctools_export_load_object('feeds_tamper', 'conditions', $conditions);
    $weight = 0;
    foreach ($all as $i) {
      if ($i->weight >= $weight) {
        $weight = $i->weight + 1;
      }
    }
    $instance->weight = $weight;
  }
  $disabled = variable_get('default_feeds_tamper', array());
  $disabled[$instance->id] = !empty($instance->disabled) ? TRUE : FALSE;
  variable_set('default_feeds_tamper', $disabled);
  return ctools_export_crud_save('feeds_tamper', $instance);
}