You are here

function workbench_moderation_state_save in Workbench Moderation 7.3

Same name and namespace in other branches
  1. 7 workbench_moderation.module \workbench_moderation_state_save()

Save a new or existing moderation state.

Moderation state names must be unique, so saving a state object with a non-unique name updates the existing state.

Invokes hook_workbench_moderation_state_save().

Parameters

$state: An object with name, description, and weight properties.

Return value

int Returns MergeQuery::STATUS_INSERT or MergeQuery::STATUS_UPDATE depending on if this INSERT'ing a new transation or UPDATE'ing an existing one.

See also

hook_workbench_moderation_state_save()

2 calls to workbench_moderation_state_save()
workbench_moderation_admin_states_form_submit in ./workbench_moderation.admin.inc
Form submit handler for moderation state administration.
workbench_moderation_states_features_rebuild in ./workbench_moderation.features.inc
Implements COMPONENT_features_rebuild().

File

./workbench_moderation.module, line 1502
Content moderation for Workbench.

Code

function workbench_moderation_state_save($state) {
  $status = db_merge('workbench_moderation_states')
    ->key(array(
    'name' => $state->name,
  ))
    ->fields((array) $state)
    ->execute();
  foreach (module_implements('workbench_moderation_state_save') as $module) {

    // Don't call this function! That would lead to infinite recursion.
    if ($module !== 'workbench_moderation') {
      module_invoke($module, 'workbench_moderation_state_save', $state, $status);
    }
  }
  return $status;
}