function skinr_skin_import in Skinr 7.2
Same name and namespace in other branches
- 8.2 skinr.module \skinr_skin_import()
Import a skin configuration object as defined in skinr_skin_defaults().
Parameters
$default_skin: A skin configuration object.
$force: If FALSE (default) the default skin will only be imported if the skin configuration doesn't exist, or if storage is default in code. If TRUE, the skin configuration in code will always be overwritten.
Return value
If import failed, returns FALSE. If it succeeded, returns TRUE.
4 calls to skinr_skin_import()
- SkinrApiTestCase::testSkinrSkinDefaults in tests/
skinr.test - Test default skin configurations (in code).
- skinr_skin_defaults_import in ./
skinr.module - Imports default skin confiuration objects from code into database.
- skinr_skin_revert in ./
skinr.module - Revert a skin configuration object that's stored in code to its default state.
- skinr_ui_import_form_submit in ./
skinr_ui.admin.inc - Form submission handler for skinr_ui_import_form().
File
- ./
skinr.module, line 994 - Handles core Skinr functionality.
Code
function skinr_skin_import($default_skin, $force = FALSE) {
// Make sure we don't modify the cached default skin array.
$skin = clone $default_skin;
// Functionality is abstracted for use in skinr_skin_storage().
_skinr_skin_import($skin);
if (!$force && !empty($skin->sid)) {
// Load existing skin configuration from DB.
$db_skin = skinr_skin_load_unchanged($skin->sid);
// Sync status.
$skin->status = $db_skin->status;
if ($skin != $db_skin) {
// Skin exists and is overridden, so cancel import.
watchdog('skinr', 'Canceled import of skin with UUID %uuid and SID %sid. It is overridden.', array(
'%uuid' => $skin->uuid,
'%sid' => $skin->sid,
), WATCHDOG_WARNING);
return FALSE;
}
}
if ($status = skinr_skin_save($skin)) {
drupal_static_reset('skinr_skin_uuid_to_sid');
drupal_static_reset('skinr_skin_sid_to_uuid');
watchdog('skinr', 'Imported skin with UUID %uuid and SID %sid.', array(
'%uuid' => $skin->uuid,
'%sid' => $skin->sid,
), WATCHDOG_NOTICE);
}
else {
watchdog('skinr', 'Failed to import skin with UUID %uuid and SID %sid.', array(
'%uuid' => $skin->uuid,
'%sid' => isset($skin->sid) ? $skin->sid : t('unknown'),
), WATCHDOG_WARNING);
}
return $status;
}