You are here

function fusion_apply_skin_save in Fusion Accelerator 7

Same name and namespace in other branches
  1. 7.2 fusion_apply/fusion_apply.module \fusion_apply_skin_save()

Save a skin object.

Parameters

$skin: A skin object.

Return value

TRUE on success, FALSE on failure.

11 calls to fusion_apply_skin_save()
comment_fusion_apply_form_index_handler in fusion_apply/modules/comment.fusion.inc
Fusion Apply form index handler.
FusionApplyApiTestCase::testFusionApplySkinHooks in fusion_apply/tests/fusion_apply.test
Test hook invocations for CRUD operations on skin configurations.
FusionApplyApiTestCase::testFusionApplySkinLoadSave in fusion_apply/tests/fusion_apply.test
Test fusion_apply_skin_save() against invalid entries.
FusionApplyDisplayTestCase::testFusionApplyDisplayed in fusion_apply/tests/fusion_apply.test
FusionApplyUIAdminTestCase::testSkinDefaultStatus in fusion_apply/tests/fusion_apply_ui.test
Tests default status of skins.

... See full list

File

fusion_apply/fusion_apply.module, line 408
Handles core Fusion Apply functionality.

Code

function fusion_apply_skin_save(&$skin) {

  // Make sure we're getting valid data.
  if (!fusion_apply_skin_validate($skin)) {
    return FALSE;
  }

  // Load the stored skin configuration object, if any.
  if (!empty($skin->sid)) {
    if (!isset($skin->original)) {

      // Load an uncached version of the skin configuration object.
      $skin->original = fusion_apply_skin_load_unchanged($skin->sid);
    }
  }

  // Let modules modify the node before it is saved to the database.
  module_invoke_all('fusion_apply_skin_presave', $skin);
  if (!empty($skin->sid)) {

    // Record exists, so let's update.
    $status = drupal_write_record('fusion_apply_skins', $skin, 'sid');
    module_invoke_all('fusion_apply_skin_update', $skin);
  }
  else {

    // Insert a new record.
    $status = drupal_write_record('fusion_apply_skins', $skin);
    module_invoke_all('fusion_apply_skin_insert', $skin);
  }

  // Clear internal properties.
  unset($skin->original);

  // Clear the static loading cache.
  // @todo If we have a more granular reset for fusion_apply_skin_load_multiple(), we
  //   need to use it here.
  drupal_static_reset('fusion_apply_skin_load_multiple');
  return $status;
}