engine: Selecting permissions based on app mode

Updated the stored procedure to select the list of permissions for a
user based on application mode as well.

Earlier list of permissions applicable for all the application modes
were getting listed for a user.

Change-Id: I6913bcc0c1c400d29c78856db60961376c2a2ca5
Bug-Url: https://bugzilla.redhat.com/1008870
Signed-off-by: Shubhendu Tripathi <shtripat@redhat.com>