As I have a requirement that, admin wants direct button for the approve or needs review.

Please suggest me...

CommentFileSizeAuthor
#3 states_submit_buttons-1970576-3.patch4.03 KBGaëlG
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ashrafabed’s picture

Assigned: Unassigned » ashrafabed

I happened to be working on this today.. here's code that can be put in your own module which will add workbench buttons to edit pages instead of submit/preview buttons.


function yourmodule_form_alter(&$form, &$form_state, $form_id) {
  if(($form['#node_edit_form']==TRUE) && !empty($form['#node']->workbench_moderation)) {
    $my_revision = $form['#node']->workbench_moderation['my_revision'];
    if ($my_revision->vid == $form['#node']->workbench_moderation['current']->vid
      && $next_states = workbench_moderation_states_next($my_revision->state, $user, $form['#node'])) {

      $i=1;
      foreach($next_states as $next_state_id => $next_state_label) {
        $form['actions'][$next_state_id] = array(
            '#type' => 'submit',
            '#value' => t($next_state_label),
            '#weight' => $i++,
            '#submit' => array('your_module_edit_submit'),
        );
      }
      unset($form['actions']['submit']);
      unset($form['actions']['preview']);
    }
  }
}

function your_module_edit_submit($form, &$form_state) {
  $new_state=preg_replace('/^edit-(.*)/', '$1', $form_state['triggering_element']['#id']);
  $new_state=str_replace('-','_',$new_state);

  $form_state['values']['workbench_moderation_state_new']=$new_state;

  // call default node save/submit function
  node_form_submit($form, $form_state);
}

I plan to come back to this and finish it + turn it into a patch with an on/off switch or its own module

boyan.borisov’s picture

I just found this one. Seems to be what you are looking for https://drupal.org/sandbox/rmn/2088327

If you try it give your feedback here https://drupal.org/node/2106515

GaëlG’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
4.03 KB

According to #2106515-2: [D7] Workbench Moderation Buttons, I made a patch based on rmn's code (highly refactored though). It seems to work for me.

Status: Needs review » Needs work

The last submitted patch, 3: states_submit_buttons-1970576-3.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 3: states_submit_buttons-1970576-3.patch, failed testing.

DamienMcKenna’s picture

Version: 7.x-1.3 » 7.x-1.x-dev

This also needs to be rerolled against v7.x-1.x-dev.

joevagyok’s picture

Any update on this, which solution is the good or other is being implemented?

The #1 is looking good but, but you are not able to Save as the current state, you can only change the states with the buttons, but if you want to Save as Draft from Draft you can't.

Thanks