Deletion Folder Check

 

 

User's Requirement

 

User don't have Administrator Grant cannot delete folders until the 2nd level in the TestPlan Tree Structure.

 

 

Proposed Solution

 

Prevent the deletion of folders if user isn't in TDAdmin group. When the user selects a folder and click the delete button it checks the tree level and allowed/not allowed the action.


 

 

__________________________________________________________________________

 

Implementation on the Product

 

In this case it is necessary, to have a clearest code, create:

 

  • a global object that rappresent the TestPlan Selected Folder
  • a boolean function that returns to the caller (ActionCanExecute) the results of the checks. True: deletion CAN be done; False: deletion is forbidden and will show a warning popup.

 

1. Decleration of objFold_TP object into the Common Module

 

Dim objFold_TP

 

2. Manage of the Object

    2.1 Instance the object into the MoveToSubject Event in TestPlan Module

    2.2 Destruction of the object into the ExitModule (Common) and Test_MoveTo (TestPlan)

 

Sub MoveToSubject(Subject)

On Error Resume Next

    set objFold_TP = Subject

On Error Goto 0

End Sub

 

 

Sub ExitModule

On Error Resume Next

 

     if ActiveModule = "Test Plan" then set objFold_TP = Nothing   

 

On Error Goto 0

End Sub

 

Sub Test_MoveTo

On Error Resume Next

     set objFold_TP = Nothing

On Error Goto 0

End Sub

 

 

3. Call boolean function when the delete button is pressed

 

Function ActionCanExecute(ActionName)

On Error Resume Next

 

Dim Res

Res = True

   

    if ActionName = "act_delete_folder" then

        Res = Test_bolCanDeleteFolder  'Name of the boolean function in TestPlan

    end if

 

ActionCanExecute = Res

On Error Goto 0

End Function

 

 

'Function to introduce in TestPlan Module

Function Test_bolCanDeleteFolder

On Error Resume Next

Dim Res

Res = True

 

if Not(User.IsInGroup("TDAdmin")) then

 'Check that we're positioned on a folder son of Subject Root

 if instr(objFold_TP.Path,"\") > 0 then

   if Ubound(split(objFold_TP.Path,"\")) < 2 then

      Res = False

   end if

  else

   'If user is positioned on Subject the deletion is forbidden

   Res = False

 end if

end if

 

if Not(Res) then

  msgbox "Folder Deletion is Forbidden", vbCritical + vbSystemModal, "Quality Center - Action Forbidden"

end if

 

Test_bolCanDeleteFolder = Res

On Error Goto 0

End Function

 

 

Pag: <<    <    >    >>