1

I am developing moderation workflow using Workflow modeule. I have created different states for that. And using rules module I am putting node into one of the state based on certain event. It is working fine.

Now to emulate the Moderation process, I wanted to hide workflow tab (that appears on node page) when node is in certain state, and to display tab only when node is in one of the given states.

Is there any way I can achieve this?

-- Many thanks for your time.

0

Solved it using hook_menu_alter and adding custom module. I have modified the access callback function to suit my needs.

Here is my code, may help user having same task:

    function mymodule_tab_menu_alter(&$items) {
        $items['node/%node/workflow']['access callback'] =
        'custom_workflow_tab_node_access';
    }

    function custom_workflow_tab_node_access($node = NULL) {

    global $user;

    if ($workflow = workflow_get_workflow_type_map_by_type($node->type)) {
        if ($workflow = workflow_get_workflows_by_wid($workflow->wid)) {
            $roles = array_keys($user->roles);
            if ($node->uid == $user->uid) {
                $roles = array_merge(array('author'), $roles);
            }
            $allowed_roles = $workflow->tab_roles ? 
            explode(',', $workflow->tab_roles) : array();

          if (user_access('administer nodes') || array_intersect($roles, $allowed_roles)) {

      /* This is additional Condition*/

      if ($node->type == "article") {
     $current_state = workflow_get_workflow_states_by_sid(workflow_node_current_state($node));
                    if ($current_state->state == "State_name") {
                        return FALSE;
                    } else {
                        return TRUE;
                    }
                } else /*End Additional Condition */{
                    return TRUE;
                }
            } else {
                return FALSE;
            }
        }
    }
    return FALSE;
}

As above in custom access callback, I have used the same code, just added the additional condition and it solved my issue. :)

-- Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.