function skinr_context_group_save in Skinr 7.2
Same name and namespace in other branches
- 8.2 skinr_context/skinr_context.module \skinr_context_group_save()
Save a skin group object.
Parameters
$group: A skin settings group object.
Return value
TRUE on success, FALSE on failure.
13 calls to skinr_context_group_save()
- SkinrContextApiTestCase::testSkinrContextGroupDefaults in skinr_context/
tests/ skinr_context.test - Test default skin settings groups (in code).
- SkinrContextApiTestCase::testSkinrContextGroupHooks in skinr_context/
tests/ skinr_context.test - Test hook invocations for CRUD operations on skin settings groups.
- SkinrContextApiTestCase::testSkinrContextGroupLoadSave in skinr_context/
tests/ skinr_context.test - Test skinr_skin_save() against invalid entries.
- SkinrContextDisplayTestCase::testSkinrContextDisplayed in skinr_context/
tests/ skinr_context.test - SkinrContextUIAdminTestCase::testSkinListingWithGroups in skinr_context/
tests/ skinr_context_ui.test - Tests skin configuration listing functionality.
File
- skinr_context/
skinr_context.module, line 64 - Provides Skinr integration with Context.
Code
function skinr_context_group_save(&$group) {
// Make sure we're getting valid data.
if (!skinr_context_group_validate($group)) {
return FALSE;
}
// Load the stored skin settings group object, if any.
if (!isset($group->original)) {
// Load an uncached version of the skin settings object.
if (!($group->original = skinr_context_group_load_unchanged($group->gid))) {
unset($group->original);
}
}
// Let modules modify the node before it is saved to the database.
module_invoke_all('skinr_context_group_presave', $group);
// Clear the static loading cache. We do it ahead of saving to ensure
// skinr_context_skinr_skin_presave(), invoked through skinr_skin_save(),
// loads an updated $group.
// @todo Once we have a more granular reset for skinr_skin_load_multiple(), we
// need to use it here.
drupal_static_reset('skinr_context_group_load_multiple');
// Clear context's cache.
context_invalidate_cache();
if (!empty($group->original)) {
// Record exists, so let's update.
$status = drupal_write_record('skinr_groups', $group, 'gid');
// When status changes, update status of linked skin settings.
if ($group->status != $group->original->status) {
$params = array(
'gid' => $group->gid,
'status' => $group->status ? 0 : 1,
);
// Update status of linked skin configurations.
$sids = skinr_context_group_get_sids($params);
foreach ($sids as $sid) {
$skin = skinr_skin_load_unchanged($sid);
$skin->original = clone $skin;
$skin->status = $group->status;
skinr_skin_save($skin);
}
}
module_invoke_all('skinr_context_group_update', $group);
}
else {
// Insert a new record.
$status = drupal_write_record('skinr_groups', $group);
module_invoke_all('skinr_context_group_insert', $group);
}
// Clear internal properties.
unset($group->original);
return $status;
}