Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method CanProcessUser ( 
 | 
  output String feedback_o, 
 | 
  const SWF_User user, 
 | 
  String action 
 | 
) const declarative remote as Boolean 
 | 
{ 
 | 
  Description: 'Indicate if this user can process the [action] for the given [user].' 
 | 
  TextBody: 
 | 
  [* 
 | 
    result := true; 
 | 
     
 | 
    // Current user can only edit their own profile while admin can edit all user 
 | 
    // Only admin can set user as active/inactive 
 | 
    if( not this.IsAdministrator()  
 | 
        and ( action = SWF_User::ACTION_Edit() and user <> this ) 
 | 
            or ( action = SWF_User::ACTION_SetActive() 
 | 
                  or action = SWF_User::ACTION_SetInActive() ) ) 
 | 
         
 | 
    { 
 | 
      result := false; 
 | 
      feedback_o := SWF_Translation::TRANSLATE_Auth_UnauthorizeAction(); 
 | 
    } 
 | 
    // Only active user can be set to inactive 
 | 
    else if( action = SWF_User::ACTION_SetInActive() 
 | 
             and not user.IsActive() ) 
 | 
    { 
 | 
      result := false; 
 | 
      feedback_o := SWF_Translation::TRANSLATE_Auth_ProcessUser_IsInactive(); 
 | 
    } 
 | 
    // Only inactive user can be set to active 
 | 
    else if( action = SWF_User::ACTION_SetActive() 
 | 
             and user.IsActive() ) 
 | 
    { 
 | 
      result := false; 
 | 
      feedback_o := SWF_Translation::TRANSLATE_Auth_ProcessUser_IsActive(); 
 | 
    } 
 | 
     
 | 
    return result; 
 | 
  *] 
 | 
} 
 |