function _workbench_moderation_insert_values in Workbench Moderation 7.3
Same name and namespace in other branches
- 7 workbench_moderation.install \_workbench_moderation_insert_values()
Adds default data for workflow states
1 call to _workbench_moderation_insert_values()
- workbench_moderation_install in ./
workbench_moderation.install - Implements hook_install().
File
- ./
workbench_moderation.install, line 192 - Install file for the Workbench Moderation module.
Code
function _workbench_moderation_insert_values() {
// Default states.
$states = array(
array(
'name' => 'draft',
'label' => 'Draft',
'description' => 'Work in progress',
'weight' => -99,
),
array(
'name' => 'needs_review',
'label' => 'Needs Review',
'description' => 'Ready for moderation',
'weight' => 0,
),
array(
'name' => 'published',
'label' => 'Published',
'description' => 'Make this version live',
'weight' => 99,
),
);
// Save default states to the database.
$query = db_insert('workbench_moderation_states')
->fields(array(
'name',
'label',
'description',
'weight',
));
foreach ($states as $state) {
$query
->values($state);
}
$query
->execute();
// Default transitions.
$transitions = array(
array(
'name' => 'Submit for Review',
'from_name' => 'draft',
'to_name' => 'needs_review',
),
array(
'name' => 'Reject',
'from_name' => 'needs_review',
'to_name' => 'draft',
),
array(
'name' => 'Publish',
'from_name' => 'needs_review',
'to_name' => 'published',
),
);
// Save default transitions to the database.
$query = db_insert('workbench_moderation_transitions')
->fields(array(
'name',
'from_name',
'to_name',
));
foreach ($transitions as $transition) {
$query
->values($transition);
}
$query
->execute();
}