You are here

function skinr_set in Skinr 6.2

Same name and namespace in other branches
  1. 6 skinr.module \skinr_set()

Save a skinr object.

Parameters

$skinr: A skinr object.

Return value

TRUE on success, FALSE on failure.

8 calls to skinr_set()
comment_skinr_form_index_handler in modules/comment.skinr.inc
Skinr form index handler.
node_skinr_form_index_handler in modules/node.skinr.inc
Skinr form index handler.
skinr_submit_handler in ./skinr.handlers.inc
Skinr submit handler.
skinr_ui_delete_confirm_submit in ./skinr_ui.admin.inc
skinr_ui_import_form_submit in ./skinr_ui.admin.inc
Submit handler for skinr settings import form.

... See full list

File

./skinr.module, line 456

Code

function skinr_set($skinr) {

  // Make sure we're getting valid data.
  if (!skinr_validate($skinr)) {
    return FALSE;
  }
  if (empty($skinr->skins) && empty($skinr->settings)) {

    // Delete the db entry if it exists.
    db_query("DELETE FROM {skinr} WHERE theme = '%s' AND module = '%s' AND sid = '%s'", $skinr->theme, $skinr->module, $skinr->sid);
  }
  else {

    // Let's save the data.
    if (skinr_get($skinr->theme, $skinr->module, $skinr->sid) !== FALSE) {

      // Record exists, so let's update.
      drupal_write_record('skinr', $skinr, array(
        'theme',
        'module',
        'sid',
      ));
    }
    else {

      // Insert a new record.
      drupal_write_record('skinr', $skinr);
    }
  }
  return TRUE;
}