function skinr_context_group_import in Skinr 7.2
Same name and namespace in other branches
- 8.2 skinr_context/skinr_context.module \skinr_context_group_import()
Import a skin settigns group object as defined in skinr_context_group_defaults().
Parameters
$default_group: A skin settings group object.
$force: If FALSE (default) the default skin settings group will only be imported if it doesn't exist, or if storage is default in code. If TRUE, the skin settings group in code will always be overwritten.
Return value
If import failed, returns FALSE. If it succeeded, returns TRUE.
4 calls to skinr_context_group_import()
- SkinrContextApiTestCase::testSkinrContextGroupDefaults in skinr_context/
tests/ skinr_context.test - Test default skin settings groups (in code).
- skinr_context_group_defaults_import in skinr_context/
skinr_context.module - Imports default skin settings group objects from code into database.
- skinr_context_group_revert in skinr_context/
skinr_context.module - Revert a skin settings group object that's stored in code to its default state.
- skinr_context_ui_import_form_submit in skinr_context/
skinr_context_ui.module - Form submission handler for skinr_ui_import_form().
File
- skinr_context/
skinr_context.module, line 386 - Provides Skinr integration with Context.
Code
function skinr_context_group_import($default_group, $force = FALSE) {
// Make sure we don't modify the cached default group array.
$group = clone $default_group;
// Functionality is abstracted for use in skinr_context_group_storage().
_skinr_context_group_import($group);
if (!$force) {
// Load existing skin configuration from DB.
if ($db_group = skinr_context_group_load_unchanged($group->gid)) {
// Sync status.
$group->status = $db_group->status;
if ($group != $db_group) {
// Group exists and is overridden, so cancel import.
watchdog('skinr', 'Canceled import of group with ID %gid. It is overridden.', array(
'%gid' => $group->gid,
), WATCHDOG_WARNING);
return FALSE;
}
}
}
if ($status = skinr_context_group_save($group)) {
watchdog('skinr', 'Imported group with ID %gid.', array(
'%gid' => $group->gid,
), WATCHDOG_NOTICE);
}
else {
watchdog('skinr', 'Failed to import group with ID %gid.', array(
'%gid' => $group->gid,
), WATCHDOG_WARNING);
}
return $status;
}