function context_save_context in Context 6
Same name and namespace in other branches
- 6.2 context.module \context_save_context()
Inserts or updates a context object into the database. @TODO: should probably return the new cid on success -- make sure this doesn't break any checks elsewhere.
Parameters
$context: The context object to be inserted.
Return value
Returns true on success, false on failure.
2 calls to context_save_context()
- context_ui_form_submit in context_ui/
context_ui.admin.inc - Submit handler for main context_ui form.
- context_update_6001 in ./
context.install - Update script for context that installs the context schema and migrates any existing context data from deprecated context_ui tables.
File
- ./
context.module, line 229
Code
function context_save_context($context) {
// Insert or update the core context definition
if (!isset($context->cid)) {
$existing = context_load_context($context, TRUE);
if ($existing && $existing->cid) {
return false;
}
else {
$context = context_pack_context($context);
drupal_write_record('context', $context);
}
}
else {
$context = context_pack_context($context);
drupal_write_record('context', $context, 'cid');
}
// Invalidate context cache
cache_clear_all('context', 'cache');
return TRUE;
}