// Determine the corresponding save action name for this action.
$save_action=strtok($aid,'_').'_save_action';
// If no corresponding save action exists, we need to bail out.
if(!isset($actions[$save_action])){
thrownewException(t('Missing/undefined save action (%save_aid) for %aid action.',array('%save_aid'=>$aid,'%aid'=>$aid)));
}
// Delete previous save action if it exists, and re-add it using a higher
// weight.
$save_action_assigned=db_query("SELECT aid FROM {trigger_assignments} WHERE hook = :hook AND aid = :aid",array(':hook'=>$form_state['values']['hook'],':aid'=>$save_action))->fetchField();
if($save_post_action_assigned){
if($save_action_assigned){
db_delete('trigger_assignments')
->condition('hook',$form_values['hook'])
->condition('aid','node_save_action')
->condition('hook',$form_state['values']['hook'])
->condition('aid',$save_action)
->execute();
}
db_insert('trigger_assignments')
->fields(array(
'hook'=>$form_values['hook'],
'aid'=>'node_save_action',
'hook'=>$form_state['values']['hook'],
'aid'=>$save_action,
'weight'=>$weight+2,
))
->execute();
if(!$save_post_action_assigned){
drupal_set_message(t("You have added an action that changes a the property of some content. Your 'Save content' action has been moved later in the list so that the property change will be saved."));
// If no save action existed before, inform the user about it.
if(!$save_action_assigned){
drupal_set_message(t('The %label action has been appended, which is required to save the property change.',array('%label'=>$actions[$save_action]['label'])));
}
// Otherwise, just inform about the new weight.
else{
drupal_set_message(t('The %label action was moved to save the property change.',array('%label'=>$actions[$save_action]['label'])));