workflow::case::action::permission_p (public)

 workflow::case::action::permission_p \
    [ -enabled_action_id enabled_action_id ] [ -case_id case_id ] \
    [ -action_id action_id ] [ -user_id user_id ]

Defined in packages/workflow/tcl/case-procs.tcl

Does the user have permission to perform this action. Doesn't check whether the action is enabled.

Switches:
-enabled_action_id
(optional)
The enabled action you want to test for permission on.
-case_id
(optional)
Deprecated. The ID of the case.
-action_id
(optional)
Deprecated. The ID of the action
-user_id
(optional)
The user.
Returns:
true or false.
Author:
Lars Pind <lars@collaboraid.biz>

Partial Call Graph (max 5 caller/called nodes):
%3 workflow::case::action::available_p workflow::case::action::available_p (public) workflow::case::action::permission_p workflow::case::action::permission_p workflow::case::action::available_p->workflow::case::action::permission_p workflow::case::action::execute workflow::case::action::execute (public) workflow::case::action::execute->workflow::case::action::permission_p workflow::case::get_available_actions workflow::case::get_available_actions (public, deprecated) workflow::case::get_available_actions->workflow::case::action::permission_p workflow::case::get_available_enabled_action_ids workflow::case::get_available_enabled_action_ids (public) workflow::case::get_available_enabled_action_ids->workflow::case::action::permission_p ad_conn ad_conn (public) workflow::case::action::permission_p->ad_conn db_string db_string (public) workflow::case::action::permission_p->db_string permission::permission_p permission::permission_p (public) workflow::case::action::permission_p->permission::permission_p workflow::action::get_allowed_roles workflow::action::get_allowed_roles (public) workflow::case::action::permission_p->workflow::action::get_allowed_roles workflow::action::get_privileges workflow::action::get_privileges (public) workflow::case::action::permission_p->workflow::action::get_privileges

Testcases:
No testcase defined.
Source code:
    if { (![info exists user_id] || $user_id eq "") } {
        set user_id [ad_conn user_id]
    }

    if { $enabled_action_id ne "" } {
        ns_log notice "#### workflow::case::enabled_action_get -enabled_action_id $enabled_action_id -array enabled_action"
        workflow::case::enabled_action_get -enabled_action_id $enabled_action_id -array enabled_action
        set case_id $enabled_action(case_id)
        set action_id $enabled_action(action_id)
    } else {
        set enabled_action_id [workflow::case::action::get_enabled_action_id  -any_parent  -case_id $case_id  -action_id $action_id]
    }

    set object_id [workflow::case::get_element -case_id $case_id -element object_id]
    set user_role_ids [workflow::case::get_user_roles -case_id $case_id -user_id $user_id]

    set permission_p 0

    set assigned_p [db_string assigned_p {
        select 1 
        from   wf_case_assigned_user_actions
        where  enabled_action_id = :enabled_action_id
        and    user_id = :user_id
    } -default 0]
    
    if { $assigned_p } {
        return 1
    }

    foreach role_id $user_role_ids {


        # Is this an allowed role for this action?
        set allowed_roles [workflow::action::get_allowed_roles -action_id $action_id]
        if {$role_id in $allowed_roles} {
            return 1
        }
    }

    if { !$permission_p } {
        set privileges [concat "admin" [workflow::action::get_privileges -action_id $action_id]]
        foreach privilege $privileges {
            if { [permission::permission_p -object_id $object_id -privilege $privilege -party_id $user_id] } {
                return 1
            }
        }
    }

    return 0
Generic XQL file:
packages/workflow/tcl/case-procs.xql

PostgreSQL XQL file:
packages/workflow/tcl/case-procs-postgresql.xql

Oracle XQL file:
packages/workflow/tcl/case-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: