Merge branch 'master' of bitbucket.org:colosa/processmaker

This commit is contained in:
Brayan Osmar Pereyra Suxo
2014-05-29 15:39:48 -04:00
19 changed files with 2271 additions and 40 deletions

View File

@@ -25,7 +25,7 @@ task :build => [:required] do
if mode == "production"
targetDir = publicDir + "/lib"
pmUIFontsDir = targetDir + "/css/fonts"
pmUIFontsDir = targetDir + "/fonts"
else
targetDir = publicDir + "/lib-dev"
pmUIFontsDir = pmUIDir + "/fonts"
@@ -112,7 +112,7 @@ def buildPmUi(homeDir, targetDir, mode)
puts "\nCopying font files into: #{pmUIFontsDir}".bold
theme = "mafe"
copyFiles({"#{homeDir}/themes/#{theme}/fonts/*" => "#{targetDir}"})
copyFiles({"#{homeDir}/themes/#{theme}/fonts/*" => "#{pmUIFontsDir}"})
puts "\nPMUI Build Finished".magenta
end
@@ -169,10 +169,9 @@ end
def getVersion(path)
if File.exists? path + '/VERSION.txt'
version = File.read path + '/VERSION.txt'
else
version = "(unknown)"
version = ""
Dir.chdir(path) do
version = `rake version`
end
return version.strip
@@ -180,7 +179,11 @@ end
def getHash(path)
hash = `git rev-parse --short HEAD`
hash = ""
Dir.chdir(path) do
hash = `git rev-parse --short HEAD`
end
return hash.strip
end
@@ -278,12 +281,12 @@ end
def getCssIncludeFiles
return [
"gulliver/js/codemirror/lib/codemirror.css",
"gulliver/js/tinymce/jscripts/tiny_mce/themes/advanced/skins/o2k7/ui.css",
"gulliver/js/tinymce/jscripts/tiny_mce/themes/advanced/skins/o2k7/ui_silver.css",
"gulliver/js/tinymce/jscripts/tiny_mce/plugins/inlinepopups/skins/clearlooks2/window.css",
"gulliver/js/tinymce/jscripts/tiny_mce/themes/advanced/skins/o2k7/content.css",
# DEPRECATED
# "gulliver/js/tinymce/jscripts/tiny_mce/themes/advanced/skins/o2k7/ui.css",
# "gulliver/js/tinymce/jscripts/tiny_mce/themes/advanced/skins/o2k7/ui_silver.css",
# "gulliver/js/tinymce/jscripts/tiny_mce/plugins/inlinepopups/skins/clearlooks2/window.css",
# "gulliver/js/tinymce/jscripts/tiny_mce/themes/advanced/skins/o2k7/content.css",
#
"workflow/public_html/lib/pmUI/pmui.min.css",
"workflow/public_html/lib/mafe/mafe.min.css"
]
@@ -309,3 +312,4 @@ class String
def bold; "\033[1m#{self}\033[22m" end
def reverse_color; "\033[7m#{self}\033[27m" end
end

View File

@@ -0,0 +1,230 @@
@ProcessMakerMichelangelo @RestAPI
Feature: Roles
Background:
Given that I have a valid access_token
Scenario: Get list of Roles
Given I request "role"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "array"
And the response has 3 records
Scenario: Get a single Role
Given I request "role/00000000000000000000000000000002"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "object"
Scenario Outline: Create new Role
Given POST this data:
"""
{
"rol_code": "<rol_code>",
"rol_name": "<rol_name>",
"rol_status": "<rol_status>"
}
"""
And I request "role"
Then the response status code should be 201
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "object"
And store "rol_uid" in session array as variable "rol_uid_<rol_uid_number>"
Examples:
| test_description | rol_uid_number | rol_code | rol_name | rol_status |
| Create Role with name short | 1 | PROCESSMAKER_OPERATOR1 | sample | ACTIVE |
#Assign users to role
#Scenario: List assigned Users to Role & List available Users to assign to Role
# Given I request "role/00000000000000000000000000000003/users"
# Then the response status code should be 200
# And the response charset is "UTF-8"
# And the content type is "application/json"
# And the type is "array"
# And the response has 61 records
#
#Scenario: Assign User to Role
# Given POST this data:
# """
# {
# "usr_uid": "310985970530cbfa4ec0593063369294"
# }
# """
# And I request "role/00000000000000000000000000000003/user"
# Then the response status code should be 201
# And the response charset is "UTF-8"
# And the content type is "application/json"
# And the type is "object"
#
#
#Scenario: Get list of Roles
# Given I request "roles"
# Then the response status code should be 200
# And the response charset is "UTF-8"
# And the content type is "application/json"
# And the type is "array"
# And the response has 62 records
#
#
#Scenario: Unassign User of the Role
# Given that I want to delete a resource with the key "310985970530cbfa4ec0593063369294"
# And I request "role/00000000000000000000000000000003/user/310985970530cbfa4ec0593063369294"
# And the content type is "application/json"
# Then the response status code should be 200
# And the response charset is "UTF-8"
#
#
#Scenario: Get list of Roles
# Given I request "roles"
# Then the response status code should be 200
# And the response charset is "UTF-8"
# And the content type is "application/json"
# And the type is "array"
# And the response has 61 records
#Culminacion de los endpoint de asignacion de usuarios
#Role and Permission
Scenario: List assigned Permissions to Role & List available Permissions to assign to Role
Given I request "role/00000000000000000000000000000003/permissions"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "array"
And the response has 3 records
Scenario: List assigned Permissions to Role & List available Permissions to assign to Role
Given I request "role/00000000000000000000000000000003/available-permissions"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "array"
And the response has 14 recordsuser
Scenario: Assign Permission "PM_DASHBOARD" to Role
Given POST this data:
"""
{
"per_uid": "00000000000000000000000000000011"
}
"""
And I request "role/00000000000000000000000000000003/permission"
Then the response status code should be 201
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "object"
Scenario: List assigned Permissions to Role & List available Permissions to assign to Role
Given I request "role/00000000000000000000000000000003/permissions"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "array"
And the response has 4 records
Scenario: List assigned Permissions to Role & List available Permissions to assign to Role
Given I request "role/00000000000000000000000000000003/available-permissions"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "array"
And the response has 15 records
Scenario: Unassign Permission of the Role
Given that I want to delete a resource with the key ""
And I request "role/00000000000000000000000000000003/permission/00000000000000000000000000000011"
And the content type is "application/json"
Then the response status code should be 200
And the response charset is "UTF-8"
Scenario: List assigned Permissions to Role & List available Permissions to assign to Role
Given I request "role/00000000000000000000000000000003/permissions"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "array"
And the response has 3 records
Scenario: List assigned Permissions to Role & List available Permissions to assign to Role
Given I request "role/00000000000000000000000000000003/available-permissions"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "array"
And the response has 14 records
#Culminacion de behat para Role and Permission
Scenario Outline: Update Role
Given PUT this data:
"""
{
"rol_code": "<rol_code>",
"rol_name": "<rol_name>",
"rol_status": "<rol_status>"
}
"""
And that I want to update a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
And I request "role"
And the content type is "application/json"
Then the response status code should be 200
And the response charset is "UTF-8"
Examples:
| test_description | rol_uid_number | rol_code | rol_name | rol_status |
| Update name of role created in this script | 1 | PROCESSMAKER_OPERATOR1 | update_sample | INACTIVE |
Scenario Outline: Get a single Role created in this script
Given that I want to get a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
Given I request "role"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "object"
And that "rol_code" is set to "<rol_code>"
And that "rol_name" is set to "<rol_name>"
And that "rol_status" is set to "<rol_status>"
Examples:
| test_description | rol_uid_number | rol_code | rol_name | rol_status |
| Update name of role created in this script | 1 | PROCESSMAKER_OPERATOR1 | update_sample | INACTIVE |
Scenario Outline: Delete all roles created in this scritp
Given that I want to delete a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
And I request "role"
And the content type is "application/json"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "object"
Examples:
| rol_uid_number |
| 1 |
Scenario: Get list of Roles
Given I request "roles"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "array"
And the response has 3 records

View File

@@ -0,0 +1,631 @@
@ProcessMakerMichelangelo @RestAPI
Feature: Roles Main Tests
Requirements:
a workspace with the three roles created already loaded
Background:
Given that I have a valid access_token
Scenario: Get list of Roles
Given I request "roles"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "array"
And the response has 3 records
Scenario Outline: Get list of Roles using different filters
Given I request "roles?filter=<filter>&start=<start>&limit=<limit>"
Then the response status code should be <http_code>
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "<type>"
And the response has <records> records
Examples:
| test_description | filter | start | limit | records | http_code | type |
| lowercase | admin | 0 | 1 | 1 | 200 | array |
| uppercase | ADMIN | 0 | 1 | 1 | 200 | array |
| limit=3 | a | 0 | 3 | 3 | 200 | array |
| limit and start | a | 1 | 2 | 2 | 200 | array |
| high number for start | a | 1000 | 1 | 0 | 200 | array |
| high number for start | a | 1000 | 0 | 0 | 200 | array |
| empty result | xyz | 0 | 0 | 0 | 200 | array |
| empty string | | 0 | 10000 | 3 | 200 | array |
| empty string | | 1 | 2 | 2 | 200 | array |
| invalid start | a | b | c | 0 | 400 | string |
| invalid limit | a | 0 | c | 0 | 400 | string |
| search 0 | 0 | 0 | 0 | 0 | 200 | array |
| search 0 | 0 | 0 | 100 | 0 | 200 | array |
| negative numbers | a | -10 | -20 | 0 | 400 | string |
| real numbers | a | 0.0 | 1.0 | 1 | 200 | string |
| real numbers | a | 0.0 | 0.0 | 0 | 200 | string |
| real numbers | a | 0.1 | 1.4599 | 0 | 400 | string |
| real numbers | a | 1.5 | 1.4599 | 0 | 400 | string |
Scenario Outline: Get a single Role created in this script
Given that I want to get a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
Given I request "role/<rol_uid>"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "object"
And that "rol_code" is set to "<rol_code>"
And that "rol_name" is set to "<rol_name>"
And that "rol_status" is set to "<rol_status>"
Examples:
| test_description | rol_uid | rol_code | rol_name | rol_status |
| Review rol PROCESSMAKER_ADMIN | 00000000000000000000000000000002 | PROCESSMAKER_ADMIN | System Administrator | ACTIVE |
| Review rol PROCESSMAKER_OPERATOR | 00000000000000000000000000000003 | PROCESSMAKER_OPERATOR | Operator | ACTIVE |
| Review rol PROCESSMAKER_MANAGER | 00000000000000000000000000000004 | PROCESSMAKER_MANAGER | Manager | ACTIVE |
Scenario Outline: Create new Role
Given POST this data:
"""
{
"rol_code": "<rol_code>",
"rol_name": "<rol_name>",
"rol_status": "<rol_status>"
}
"""
And I request "role"
Then the response status code should be 201
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "object"
And store "rol_uid" in session array as variable "rol_uid_<rol_uid_number>"
Examples:
| test_description | rol_uid_number | rol_code | rol_name | rol_status |
| Create Role with name short | 1 | PROCESSMAKER_OPERATOR | s | ACTIVE |
| Create Role with name large | 2 | PROCESSMAKER_OPERATOR | Esta es una prueba de un rol con nombre largo | ACTIVE |
| Create Role with Code Adminsitrator | 3 | PROCESSMAKER_ADMINISTRATOR | Rol con code administrator | ACTIVE |
| Create Role with Code Manager | 4 | PROCESSMAKER_MANAGER | Rol con code manager | ACTIVE |
| Create Role with Code Adminsitrator/inactive | 5 | PROCESSMAKER_ADMINISTRATOR | Rol con code administrator/inactive | INACTIVE |
| Create Role with Code Operator/inactive | 6 | PROCESSMAKER_OPERATOR | Rol con code operator/inactive | INACTIVE |
| Create Role with Code Manager/inactive | 7 | PROCESSMAKER_MANAGER | Rol con code manager/inactive | INACTIVE |
| Create Role with character special | 8 | PROCESSMAKER_ADMINISTRATOR | Rol !@##$%&*()'][' 123 | ACTIVE |
Scenario: Get list of Roles
Given I request "roles"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "array"
And the response has 11 records
#Assign users to role
#Scenario Outline: List assigned Users to Role & List available Users to assign to Role
# Given that I want to get a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
# And I request "role/<rol_uid_number>/users"
# Then the response status code should be 200
# And the response charset is "UTF-8"
# And the content type is "application/json"
# And the type is "array"
# And the response has <records> records
#
# Examples:
#
# | rol_uid_number | records |
# | 1 | 0 |
# | 2 | 0 |
# | 3 | 0 |
# | 4 | 0 |
# | 5 | 0 |
# | 6 | 0 |
# | 7 | 0 |
# | 8 | 0 |
#
#
#Scenario Outline: List assigned Users to Role & List available Users to assign to Role, using different filters
# Given I request "roles/00000000000000000000000000000003/users?filter=<filter>&start=<start>&limit=<limit>"
# Then the response status code should be <http_code>
# And the response charset is "UTF-8"
# And the content type is "application/json"
# And the type is "<type>"
# And the response has <records> records
#
# Examples:
#
# | test_description | filter | start | limit | records | http_code | type |
# | lowercase | amy | 0 | 1 | 1 | 200 | array |
# | uppercase | AMY | 0 | 1 | 1 | 200 | array |
# | limit=3 | a | 0 | 3 | 3 | 200 | array |
# | limit and start | a | 1 | 2 | 2 | 200 | array |
# | high number for start | a | 1000 | 1 | 0 | 200 | array |
# | high number for start | a | 1000 | 0 | 0 | 200 | array |
# | empty result | xyz | 0 | 0 | 0 | 200 | array |
# | empty string | | 0 | 10000 | 61 | 200 | array |
# | empty string | | 1 | 2 | 2 | 200 | array |
# | invalid start | a | b | c | 0 | 400 | string |
# | invalid limit | a | 0 | c | 0 | 400 | string |
# | search 0 | 0 | 0 | 0 | 0 | 200 | array |
# | search 0 | 0 | 0 | 100 | 0 | 200 | array |
# | negative numbers | a | -10 | -20 | 0 | 400 | string |
# | real numbers | a | 0.0 | 1.0 | 1 | 200 | string |
# | real numbers | a | 0.0 | 0.0 | 0 | 200 | string |
# | real numbers | a | 0.1 | 1.4599 | 0 | 400 | string |
# | real numbers | a | 1.5 | 1.4599 | 0 | 400 | string |
#
#
#Scenario Outline: List assigned Users to Role & List available Users to assign to Role, using different filters
# Given I request "roles/00000000000000000000000000000002/available-users?filter=<filter>&start=<start>&limit=<limit>"
# Then the response status code should be <http_code>
# And the response charset is "UTF-8"
# And the content type is "application/json"
# And the type is "<type>"
# And the response has <records> records
#
# Examples:
#
# | test_description | filter | start | limit | records | http_code | type |
# | lowercase | amy | 0 | 1 | 1 | 200 | array |
# | uppercase | AMY | 0 | 1 | 1 | 200 | array |
# | limit=3 | a | 0 | 3 | 3 | 200 | array |
# | limit and start | a | 1 | 2 | 2 | 200 | array |
# | high number for start | a | 1000 | 1 | 0 | 200 | array |
# | high number for start | a | 1000 | 0 | 0 | 200 | array |
# | empty result | xyz | 0 | 0 | 0 | 200 | array |
# | empty string | | 0 | 10000 | 61 | 200 | array |
# | empty string | | 1 | 2 | 2 | 200 | array |
# | invalid start | a | b | c | 0 | 400 | string |
# | invalid limit | a | 0 | c | 0 | 400 | string |
# | search 0 | 0 | 0 | 0 | 0 | 200 | array |
# | search 0 | 0 | 0 | 100 | 0 | 200 | array |
# | negative numbers | a | -10 | -20 | 0 | 400 | string |
# | real numbers | a | 0.0 | 1.0 | 1 | 200 | string |
# | real numbers | a | 0.0 | 0.0 | 0 | 200 | string |
# | real numbers | a | 0.1 | 1.4599 | 0 | 400 | string |
# | real numbers | a | 1.5 | 1.4599 | 0 | 400 | string |
#
#
#Scenario Outline: Assign User to Role
# Given POST this data:
# """
# {
# "usr_uid": "<usr_uid>"
# }
# """
# And I request "role/rol_uid/user" with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
# Then the response status code should be 201
# And the response charset is "UTF-8"
# And the content type is "application/json"
# And the type is "object"
#
# Examples:
#
# | Description | rol_uid_number | usr_uid |
# | Assign user "aaron" | 1 | 51049032352d56710347233042615067 |
# | Assign user "adam" | 2 | 44811996752d567110634a1013636964 |
# | Assign user "alexis" | 3 | 61364466452d56711adb378002702791 |
# | Assign user "amy" | 4 | 25286582752d56713231082039265791 |
# | Assign user "brianna" | 5 | 86021298852d56716b85f73067566944 |
# | Assign user "carter" | 6 | 32444503652d5671778fd20059078570 |
# | Assign user "emily" | 7 | 34289569752d5673d310e82094574281 |
# | Assign user "olivia" | 8 | 73005191052d56727901138030694610 |
#
#
#Scenario Outline: List assigned Users to Role & List available Users to assign to Role
# Given that I want to get a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
# And I request "role/<rol_uid_number>/users"
# Then the response status code should be 200
# And the response charset is "UTF-8"
# And the content type is "application/json"
# And the type is "array"
# And the response has <records> records
#
# Examples:
#
# | rol_uid_number | records |
# | 1 | 1 |
# | 2 | 1 |
# | 3 | 1 |
# | 4 | 1 |
# | 5 | 1 |
# | 6 | 1 |
# | 7 | 1 |
# | 8 | 1 |
#
#
#Scenario Outline: Unassign User of the Role
# Given that I want to delete a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
# And I request "role/rol_uid/users/<usr_uid>"
# And the content type is "application/json"
# Then the response status code should be 200
# And the response charset is "UTF-8"
#
# Examples:
#
# | Description | rol_uid_number | usr_uid |
# | Unassign user "aaron" | 1 | 51049032352d56710347233042615067 |
# | Unassign user "adam" | 2 | 44811996752d567110634a1013636964 |
# | Unassign user "alexis" | 3 | 61364466452d56711adb378002702791 |
# | Unassign user "amy" | 4 | 25286582752d56713231082039265791 |
# | Unassign user "brianna" | 5 | 86021298852d56716b85f73067566944 |
# | Unassign user "carter" | 6 | 32444503652d5671778fd20059078570 |
# | Unassign user "emily" | 7 | 34289569752d5673d310e82094574281 |
# | Unassign user "olivia" | 8 | 73005191052d56727901138030694610 |
#
#
#Scenario Outline: List assigned Users to Role & List available Users to assign to Role
# Given that I want to get a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
# And I request "role/<rol_uid_number>/users"
# Then the response status code should be 200
# And the response charset is "UTF-8"
# And the content type is "application/json"
# And the type is "array"
# And the response has <records> records
#
# Examples:
#
# | rol_uid_number | records |
# | 1 | 0 |
# | 2 | 0 |
# | 3 | 0 |
# | 4 | 0 |
# | 5 | 0 |
# | 6 | 0 |
# | 7 | 0 |
# | 8 | 0 |
#Culminacion de los endpoint de asignacion de usuarios
#Role and Permission
Scenario Outline: List assigned Permissions to Role & List available Permissions to assign to Role
Given that I want to get a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
And I request "role/rol_uid/permissions"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "array"
And the response has <records> records
Examples:
| rol_uid_number | records |
| 1 | 0 |
| 2 | 0 |
| 3 | 0 |
| 4 | 0 |
| 5 | 0 |
| 6 | 0 |
| 7 | 0 |
| 8 | 0 |
Scenario Outline: List assigned Permissions to Role & List available Permissions to assign to Role, using different filters
Given I request "roles/00000000000000000000000000000004/users?filter=<filter>&start=<start>&limit=<limit>"
Then the response status code should be <http_code>
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "<type>"
And the response has <records> records
Examples:
| test_description | filter | start | limit | records | http_code | type |
| lowercase | cases | 0 | 1 | 1 | 200 | array |
| uppercase | CASES | 0 | 1 | 1 | 200 | array |
| limit=3 | a | 0 | 3 | 3 | 200 | array |
| limit and start | a | 1 | 2 | 2 | 200 | array |
| high number for start | a | 1000 | 1 | 0 | 200 | array |
| high number for start | a | 1000 | 0 | 0 | 200 | array |
| empty result | xyz | 0 | 0 | 0 | 200 | array |
| empty string | | 0 | 10000 | 13 | 200 | array |
| empty string | | 1 | 2 | 2 | 200 | array |
| invalid start | a | b | c | 0 | 400 | string |
| invalid limit | a | 0 | c | 0 | 400 | string |
| search 0 | 0 | 0 | 0 | 0 | 200 | array |
| search 0 | 0 | 0 | 100 | 0 | 200 | array |
| negative numbers | a | -10 | -20 | 0 | 400 | string |
| real numbers | a | 0.0 | 1.0 | 1 | 200 | string |
| real numbers | a | 0.0 | 0.0 | 0 | 200 | string |
| real numbers | a | 0.1 | 1.4599 | 0 | 400 | string |
| real numbers | a | 1.5 | 1.4599 | 0 | 400 | string |
Scenario Outline: List assigned Permissions to Role & List available Permissions to assign to Role, using different filters
Given I request "roles/00000000000000000000000000000003/available-users?filter=<filter>&start=<start>&limit=<limit>"
Then the response status code should be <http_code>
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "<type>"
And the response has <records> records
Examples:
| test_description | filter | start | limit | records | http_code | type |
| lowercase | add | 0 | 1 | 1 | 200 | array |
| uppercase | ADD | 0 | 1 | 1 | 200 | array |
| limit=3 | a | 0 | 3 | 3 | 200 | array |
| limit and start | a | 1 | 2 | 2 | 200 | array |
| high number for start | a | 1000 | 1 | 0 | 200 | array |
| high number for start | a | 1000 | 0 | 0 | 200 | array |
| empty result | xyz | 0 | 0 | 0 | 200 | array |
| empty string | | 0 | 10000 | 14 | 200 | array |
| empty string | | 1 | 2 | 2 | 200 | array |
| invalid start | a | b | c | 0 | 400 | string |
| invalid limit | a | 0 | c | 0 | 400 | string |
| search 0 | 0 | 0 | 0 | 0 | 200 | array |
| search 0 | 0 | 0 | 100 | 0 | 200 | array |
| negative numbers | a | -10 | -20 | 0 | 400 | string |
| real numbers | a | 0.0 | 1.0 | 1 | 200 | string |
| real numbers | a | 0.0 | 0.0 | 0 | 200 | string |
| real numbers | a | 0.1 | 1.4599 | 0 | 400 | string |
| real numbers | a | 1.5 | 1.4599 | 0 | 400 | string |
Scenario Outline: List assigned Permissions to Role & List available Permissions to assign to Role
Given that I want to get a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
And I request "role/rol_uid/available-permissions"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "array"
And the response has <records> records
Examples:
| rol_uid_number | records |
| 1 | 17 |
| 2 | 17 |
| 3 | 17 |
| 4 | 17 |
| 5 | 17 |
| 6 | 17 |
| 7 | 17 |
| 8 | 17 |
Scenario Outline: Assign Permission "PM_DASHBOARD" to Role
Given POST this data:
"""
{
"per_uid": "<per_uid>"
}
"""
And I request "role/rol_uid/permission" with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
Then the response status code should be 201
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "object"
Examples:
| Description | rol_uid_number | per_uid |
| Assign Permissions "PM_LOGIN" to rol 1 | 1 | 00000000000000000000000000000001 |
| Assign Permissions "PM_SETUP" to rol 1 | 1 | 00000000000000000000000000000002 |
| Assign Permissions "PM_USERS" to rol 1 | 1 | 00000000000000000000000000000003 |
| Assign Permissions "PM_FACTORY" to rol 1 | 1 | 00000000000000000000000000000004 |
| Assign Permissions "PM_CASES" to rol 1 | 1 | 00000000000000000000000000000005 |
| Assign Permissions "PM_LOGIN" to rol 2 | 2 | 00000000000000000000000000000001 |
| Assign Permissions "PM_ALLCASES" to rol 2 | 2 | 00000000000000000000000000000006 |
| Assign Permissions "PM_REPORTS" to rol 2 | 2 | 00000000000000000000000000000008 |
| Assign Permissions "PM_REASSIGNCASE" to rol 2 | 2 | 00000000000000000000000000000007 |
| Assign Permissions "PM_SUPERVISOR" to rol 2 | 2 | 00000000000000000000000000000009 |
| Assign Permissions "PM_SETUP_ADVANCE" to rol 3 | 3 | 00000000000000000000000000000010 |
| Assign Permissions "PM_DASHBOARD" to rol 4 | 4 | 00000000000000000000000000000011 |
| Assign Permissions "PM_WEBDAV" to rol 5 | 5 | 00000000000000000000000000000012 |
| Assign Permissions "PM_DELETECASE" to rol 6 | 6 | 00000000000000000000000000000013 |
| Assign Permissions "PM_EDITPERSONALINFO" to rol 7 | 7 | 00000000000000000000000000000014 |
| Assign Permissions "PM_FOLDERS_VIEW" to rol 8 | 8 | 00000000000000000000000000000015 |
| Assign Permissions "PM_FOLDERS_ADD_FOLDER" to rol 8 | 8 | 00000000000000000000000000000016 |
| Assign Permissions "PM_FOLDERS_ADD_FILE" to rol 8 | 8 | 00000000000000000000000000000017 |
| Assign Permissions "PM_CANCELCASE" to rol 8 | 8 | 00000000000000000000000000000018 |
| Assign Permissions "PM_FOLDER_DEL" to rol 8 | 8 | 00000000000000000000000000000019 |
Scenario Outline: List assigned Permissions to Role & List available Permissions to assign to Role
Given that I want to get a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
And I request "role/rol_uid/permissions"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "array"
And the response has <records> records
Examples:
| rol_uid_number | records |
| 1 | 5 |
| 2 | 5 |
| 3 | 1 |
| 4 | 1 |
| 5 | 1 |
| 6 | 1 |
| 7 | 1 |
| 8 | 5 |
Scenario Outline: List assigned Permissions to Role & List available Permissions to assign to Role
Given that I want to get a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
And I request "role/rol_uid/available-permissions"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "array"
And the response has <records> records
Examples:
| rol_uid_number | records |
| 1 | 12 |
| 2 | 12 |
| 3 | 16 |
| 4 | 16 |
| 5 | 16 |
| 6 | 16 |
| 7 | 16 |
| 8 | 12 |
Scenario Outline: Unassign Permission of the Role
Given that I want to delete a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
And I request "role/rol_uid/permission/per_uid"
And the content type is "application/json"
Then the response status code should be 200
And the response charset is "UTF-8"
Examples:
| Description | rol_uid_number | per_uid |
| Unassign Permissions "PM_LOGIN" to rol 1 | 1 | 00000000000000000000000000000001 |
| Unassign Permissions "PM_SETUP" to rol 1 | 1 | 00000000000000000000000000000002 |
| Unassign Permissions "PM_USERS" to rol 1 | 1 | 00000000000000000000000000000003 |
| Unassign Permissions "PM_FACTORY" to rol 1 | 1 | 00000000000000000000000000000004 |
| Unassign Permissions "PM_CASES" to rol 1 | 1 | 00000000000000000000000000000005 |
| Unassign Permissions "PM_LOGIN" to rol 2 | 2 | 00000000000000000000000000000001 |
| Unassign Permissions "PM_ALLCASES" to rol 2 | 2 | 00000000000000000000000000000006 |
| Unassign Permissions "PM_REPORTS" to rol 2 | 2 | 00000000000000000000000000000008 |
| Unassign Permissions "PM_REASSIGNCASE" to rol 2 | 2 | 00000000000000000000000000000007 |
| Unassign Permissions "PM_SUPERVISOR" to rol 2 | 2 | 00000000000000000000000000000009 |
| Unassign Permissions "PM_SETUP_ADVANCE" to rol 3 | 3 | 00000000000000000000000000000010 |
| Unassign Permissions "PM_DASHBOARD" to rol 4 | 4 | 00000000000000000000000000000011 |
| Unassign Permissions "PM_WEBDAV" to rol 5 | 5 | 00000000000000000000000000000012 |
| Unassign Permissions "PM_DELETECASE" to rol 6 | 6 | 00000000000000000000000000000013 |
| Unassign Permissions "PM_EDITPERSONALINFO" to rol 7 | 7 | 00000000000000000000000000000014 |
| Unassign Permissions "PM_FOLDERS_VIEW" to rol 8 | 8 | 00000000000000000000000000000015 |
| Unassign Permissions "PM_FOLDERS_ADD_FOLDER" to rol 8 | 8 | 00000000000000000000000000000016 |
| Unassign Permissions "PM_FOLDERS_ADD_FILE" to rol 8 | 8 | 00000000000000000000000000000017 |
| Unassign Permissions "PM_CANCELCASE" to rol 8 | 8 | 00000000000000000000000000000018 |
| Unassign Permissions "PM_FOLDER_DEL" to rol 8 | 8 | 00000000000000000000000000000019 |
Scenario Outline: List assigned Permissions to Role & List available Permissions to assign to Role
Given that I want to get a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
And I request "role/rol_uid/permissions"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "array"
And the response has <records> records
Examples:
| rol_uid_number | records |
| 1 | 0 |
| 2 | 0 |
| 3 | 0 |
| 4 | 0 |
| 5 | 0 |
| 6 | 0 |
| 7 | 0 |
| 8 | 0 |
Scenario Outline: List assigned Permissions to Role & List available Permissions to assign to Role
Given that I want to get a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
And I request "role/rol_uid/available-permissions"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "array"
And the response has <records> records
Examples:
| rol_uid_number | records |
| 1 | 17 |
| 2 | 17 |
| 3 | 17 |
| 4 | 17 |
| 5 | 17 |
| 6 | 17 |
| 7 | 17 |
| 8 | 17 |
#Culminacion de behat para Role and Permission
Scenario Outline: Update Role
Given PUT this data:
"""
{
"rol_code": "<rol_code>",
"rol_name": "<rol_name>",
"rol_status": "<rol_status>"
}
"""
And that I want to update a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
And I request "role"
And the content type is "application/json"
Then the response status code should be 200
And the response charset is "UTF-8"
Examples:
| test_description | rol_uid_number | rol_code | rol_name | rol_status |
| Update name of role created in this script | 1 | PROCESSMAKER_OPERATOR | update_sample | INACTIVE |
| Update name of role created in this script | 5 | PROCESSMAKER_ADMINISTRATOR | update2 | ACTIVE |
| Update name of role created in this script | 8 | PROCESSMAKER_ADMINISTRATOR | update*'123 | INACTIVE |
Scenario Outline: Get a single Role created in this script
Given that I want to get a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
Given I request "role"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "object"
And that "rol_code" is set to "<rol_code>"
And that "rol_name" is set to "<rol_name>"
And that "rol_status" is set to "<rol_status>"
Examples:
| test_description | rol_uid_number | rol_code | rol_name | rol_status |
| Update name of role created in this script | 1 | PROCESSMAKER_OPERATOR | update_sample | INACTIVE |
| Update name of role created in this script | 5 | PROCESSMAKER_ADMINISTRATOR | update2 | ACTIVE |
| Update name of role created in this script | 8 | PROCESSMAKER_ADMINISTRATOR | update*'123 | INACTIVE |
Scenario: Get list of Roles
Given I request "roles"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "array"
And the response has 11 records
Scenario Outline: Delete all roles created in this scritp
Given that I want to delete a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
And I request "role"
And the content type is "application/json"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "object"
Examples:
| rol_uid_number |
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
Scenario: Get list of Roles
Given I request "roles"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "array"
And the response has 3 records

View File

@@ -0,0 +1,66 @@
@ProcessMakerMichelangelo @RestAPI
Feature: Roles Negative Tests
Background:
Given that I have a valid access_token
Scenario Outline: Create new Role (NEGATIVE TESTS)
Given POST this data:
"""
{
"rol_code": "<rol_code>",
"rol_name": "<rol_name>",
"rol_status": "<rol_status>"
}
"""
And I request "role"
Then the response status code should be <error_code>
And the response status message should have the following text "<error_message>"
Examples:
| test_description | rol_code | rol_name | rol_status | error_code | error_message |
| Create Role with same name | PROCESSMAKER_OPERATOR | Operator | ACTIVE | 400 | already_exists |
| Create Role without fill required fields "rol_code" | | sample | | 400 | required_fields |
| Create Role without fill required fields "rol_name" | PROCESSMAKER_ADMINISTRATOR1 | | ACTIVE | 400 | required_fields |
| Create Role without fill required fields "rol_status" | PROCESSMAKER_MANAGER1 | Rol con code manager | | 400 | required_fields |
| Create Role with wrong field rol_status | PROCESSMAKER_ADMINISTRATOR2 | Rol con code administrator/inactive | SAMPLE | 400 | rol_status |
#Scenario Outline: Assign User to Role (NEGATIVE TESTS)
# Given POST this data:
# """
# {
# "usr_uid": "<usr_uid>"
# }
# """
# And I request "role/rol_uid/user"
# Then the response status code should be <error_code>
# And the response status message should have the following text "<error_message>"
#
# Examples:
#
# | Description | rol_uid | usr_uid | error_code | error_message |
# | Without rol_uid | 00000000000000000000000000000004 | 51049032352d56710347233042615067 | 400 | rol_uid |
# | Without usr_uid | 00000000000000000000000000000004 | | 400 | usr_uid |
# | Assign same user to rol | 00000000000000000000000000000002 | 00000000000000000000000000000001 | 400 | usr_uid |
Scenario Outline: Assign Permission "PM_DASHBOARD" to Role (NEGATIVE TESTS)
Given POST this data:
"""
{
"per_uid": "<per_uid>"
}
"""
And I request "role/rol_uid/permission"
Then the response status code should be <error_code>
And the response status message should have the following text "<error_message>"
Examples:
| Description | rol_uid | per_uid | error_code | error_message |
| Assign same permissions in rol "PROCESSMAKER_MANAGER" | 00000000000000000000000000000004 | 00000000000000000000000000000001 | 400 | per_uid |
| Create rol without rol_uid | | 00000000000000000000000000000002 | 400 | rol_uid |
| Create rol without per_uid | 00000000000000000000000000000004 | | 400 | per_uid |

View File

@@ -151,7 +151,7 @@ Scenario: Delete a Project created previously in this script
#Import Process
Scenario Outline: Import a process
Given POST upload a project file "<project_file>" to "project/import?option=<import_option>"
Given POST upload a project file "<project_file>" to "project/import?option=<import_option>&option_group=merge"
Then the response status code should be 201
And the response charset is "UTF-8"
And the content type is "application/json"

View File

@@ -13,4 +13,17 @@ Scenario Outline: Import a process negative tests
Examples:
| Description | project_file | import_option | error_code | error_message |
| Import process when the process alredy exists | /home/wendy/uploadfiles/Process_Complete_BPMN.pmx | create | 400 | already exists |
#| Invalid path | /processmaker/sample/Project_invalido.pmx | create | 400 | invalid |
#| Invalid path | /processmaker/sample/Project_invalido.pmx | create | 400 | invalid |
| Field Required project_file | | create | 400 | project_file |
Scenario Outline: Import a process with wrong "option"
Given POST upload a project file "<project_file>" to "project/import?option=<option>&option_group=<option_group>"
Then the response status code should be 400
And the response status message should have the following text "<error_message>"
Examples:
| Description | project_file | option | option_group | error_message |
| Invalid option | /home/wendy/uploadfiles/Process_NewCreate_BPMN.pmx | sample | merge | option |
| Invalid option_group | /home/wendy/uploadfiles/Process_Complete_BPMN.pmx | create | sample | option_group |

View File

@@ -46,6 +46,19 @@ $noShowTitle = 0;
if (isset( $aProcessFieds['PRO_SHOW_MESSAGE'] )) {
$noShowTitle = $aProcessFieds['PRO_SHOW_MESSAGE'];
}
// getting bpmn projects
$c = new Criteria('workflow');
$c->addSelectColumn(BpmnProjectPeer::PRJ_UID);
$ds = ProcessPeer::doSelectRS($c);
$ds->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$bpmnProjects = array();
while ($ds->next()) {
$row = $ds->getRow();
$bpmnProjects[] = $row['PRJ_UID'];
}
switch (($aCaseTracker['CT_MAP_TYPE'])) {
case 'NONE':
//Nothing
@@ -55,6 +68,15 @@ switch (($aCaseTracker['CT_MAP_TYPE'])) {
G::LoadClass( 'processMap' );
$oCase = new Cases();
$aFields = $oCase->loadCase( $_SESSION['APPLICATION'] );
if (in_array($aFields['PRO_UID'], $bpmnProjects)) {
//bpmb
$_SESSION["APP_UID"] = $aFields["APP_UID"];
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent( 'view', 'tracker/viewMap' );
G::RenderPage( 'publish' );
//note: url processmap "../designer?prj_uid=$_SESSION['PROCESS']&prj_readonly=true&app_uid=$_SESSION['APP_UID']"
break;
}
if (isset( $aFields['TITLE'] )) {
$aFields['APP_TITLE'] = $aFields['TITLE'];
}
@@ -139,6 +161,15 @@ switch (($aCaseTracker['CT_MAP_TYPE'])) {
G::LoadClass( 'case' );
$oCase = new Cases();
$aFields = $oCase->loadCase( $_SESSION['APPLICATION'] );
if (in_array($aFields['PRO_UID'], $bpmnProjects)) {
//bpmb
$_SESSION["APP_UID"] = $aFields["APP_UID"];
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent( 'view', 'tracker/viewMap' );
G::RenderPage( 'publish' );
//note: url processmap "../designer?prj_uid=$_SESSION['PROCESS']&prj_readonly=true&app_uid=$_SESSION['APP_UID']"
break;
}
if (isset( $aFields['TITLE'] )) {
$aFields['APP_TITLE'] = $aFields['TITLE'];
}

View File

@@ -644,7 +644,10 @@ class Calendar
$criteria = $this->getCalendarCriteria();
if (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["filter"]) && trim($arrayFilterData["filter"]) != "") {
$criteria->add(\CalendarDefinitionPeer::CALENDAR_NAME, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE);
$criteria->add(
$criteria->getNewCriterion(\CalendarDefinitionPeer::CALENDAR_NAME, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE)->addOr(
$criteria->getNewCriterion(\CalendarDefinitionPeer::CALENDAR_DESCRIPTION, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE))
);
}
//Number records total

View File

@@ -0,0 +1,645 @@
<?php
namespace ProcessMaker\BusinessModel;
require_once(PATH_RBAC . "model" . PATH_SEP . "Roles.php");
class Role
{
private $arrayFieldDefinition = array(
"ROL_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "roleUid"),
"ROL_CODE" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "roleCode"),
"ROL_NAME" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "roleName"),
"ROL_STATUS" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array("ACTIVE", "INACTIVE"), "fieldNameAux" => "roleStatus")
);
private $formatFieldNameInUppercase = true;
private $arrayFieldNameForException = array(
"filter" => "FILTER",
"start" => "START",
"limit" => "LIMIT"
);
/**
* Constructor of the class
*
* return void
*/
public function __construct()
{
try {
foreach ($this->arrayFieldDefinition as $key => $value) {
$this->arrayFieldNameForException[$value["fieldNameAux"]] = $key;
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Set the format of the fields name (uppercase, lowercase)
*
* @param bool $flag Value that set the format
*
* return void
*/
public function setFormatFieldNameInUppercase($flag)
{
try {
$this->formatFieldNameInUppercase = $flag;
$this->setArrayFieldNameForException($this->arrayFieldNameForException);
} catch (\Exception $e) {
throw $e;
}
}
/**
* Set exception messages for fields
*
* @param array $arrayData Data with the fields
*
* return void
*/
public function setArrayFieldNameForException(array $arrayData)
{
try {
foreach ($arrayData as $key => $value) {
$this->arrayFieldNameForException[$key] = $this->getFieldNameByFormatFieldName($value);
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Get the name of the field according to the format
*
* @param string $fieldName Field name
*
* return string Return the field name according the format
*/
public function getFieldNameByFormatFieldName($fieldName)
{
try {
return ($this->formatFieldNameInUppercase)? strtoupper($fieldName) : strtolower($fieldName);
} catch (\Exception $e) {
throw $e;
}
}
/**
* Verify if exists the code of a Role
*
* @param string $roleCode Code
* @param string $roleSystemUid Unique id of System (00000000000000000000000000000001: RBAC, 00000000000000000000000000000002: PROCESSMAKER)
* @param string $roleUidExclude Unique id of Role to exclude
*
* return bool Return true if exists the code of a Role, false otherwise
*/
public function existsCode($roleCode, $roleSystemUid, $roleUidExclude = "")
{
try {
$criteria = new \Criteria("rbac");
$criteria->addSelectColumn(\RolesPeer::ROL_UID);
$criteria->add(\RolesPeer::ROL_SYSTEM, $roleSystemUid, \Criteria::EQUAL);
if ($roleUidExclude != "") {
$criteria->add(\RolesPeer::ROL_UID, $roleUidExclude, \Criteria::NOT_EQUAL);
}
$criteria->add(\RolesPeer::ROL_CODE, $roleCode, \Criteria::EQUAL);
$rsCriteria = \RolesPeer::doSelectRS($criteria);
if ($rsCriteria->next()) {
return true;
} else {
return false;
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Verify if exists the name of a Role
*
* @param string $roleName Name
* @param string $roleSystemUid Unique id of System (00000000000000000000000000000001: RBAC, 00000000000000000000000000000002: PROCESSMAKER)
* @param string $roleUidExclude Unique id of Role to exclude
*
* return bool Return true if exists the name of a Role, false otherwise
*/
public function existsName($roleName, $roleSystemUid, $roleUidExclude = "")
{
try {
//Set variables
$content = new \Content();
$role = new \Roles();
$arrayContentByRole = $content->getAllContentsByRole();
//SQL
$criteria = new \Criteria("rbac");
$criteria->addSelectColumn(\RolesPeer::ROL_UID);
$criteria->add(\RolesPeer::ROL_SYSTEM, $roleSystemUid, \Criteria::EQUAL);
if ($roleUidExclude != "") {
$criteria->add(\RolesPeer::ROL_UID, $roleUidExclude, \Criteria::NOT_EQUAL);
}
$rsCriteria = \RolesPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
while ($rsCriteria->next()) {
$row = $rsCriteria->getRow();
$roleUid = $row["ROL_UID"];
if (isset($arrayContentByRole[$roleUid])) {
$roleNameAux = $arrayContentByRole[$roleUid];
} else {
$rowAux = $role->load($roleUid);
$roleNameAux = $rowAux["ROL_NAME"];
}
if ($roleNameAux == $roleName) {
return true;
}
}
return false;
} catch (\Exception $e) {
throw $e;
}
}
/**
* Verify if does not exist the Role in table ROLES
*
* @param string $roleUid Unique id of Role
* @param string $fieldNameForException Field name for the exception
*
* return void Throw exception if does not exist the Role in table ROLES
*/
public function throwExceptionIfNotExistsRole($roleUid, $fieldNameForException)
{
try {
$obj = \RolesPeer::retrieveByPK($roleUid);
if (is_null($obj)) {
throw new \Exception(\G::LoadTranslation("ID_ROLE_DOES_NOT_EXIST", array($fieldNameForException, $roleUid)));
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Verify if exists the code of a Role
*
* @param string $roleCode Code
* @param string $roleSystemUid Unique id of System (00000000000000000000000000000001: RBAC, 00000000000000000000000000000002: PROCESSMAKER)
* @param string $fieldNameForException Field name for the exception
* @param string $roleUidExclude Unique id of Role to exclude
*
* return void Throw exception if exists the code of a Role
*/
public function throwExceptionIfExistsCode($roleCode, $roleSystemUid, $fieldNameForException, $roleUidExclude = "")
{
try {
if ($this->existsCode($roleCode, $roleSystemUid, $roleUidExclude)) {
throw new \Exception(\G::LoadTranslation("ID_ROLE_CODE_ALREADY_EXISTS", array($fieldNameForException, $roleCode)));
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Verify if exists the name of a Role
*
* @param string $roleName Name
* @param string $roleSystemUid Unique id of System (00000000000000000000000000000001: RBAC, 00000000000000000000000000000002: PROCESSMAKER)
* @param string $fieldNameForException Field name for the exception
* @param string $roleUidExclude Unique id of Role to exclude
*
* return void Throw exception if exists the name of a Role
*/
public function throwExceptionIfExistsName($roleName, $roleSystemUid, $fieldNameForException, $roleUidExclude = "")
{
try {
if ($this->existsName($roleName, $roleSystemUid, $roleUidExclude)) {
throw new \Exception(\G::LoadTranslation("ID_ROLE_NAME_ALREADY_EXISTS", array($fieldNameForException, $roleName)));
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Validate the data if they are invalid (INSERT and UPDATE)
*
* @param string $roleUid Unique id of Role
* @param array $arrayData Data
*
* return void Throw exception if data has an invalid value
*/
public function throwExceptionIfDataIsInvalid($roleUid, array $arrayData)
{
try {
//Set variables
$arrayRoleData = ($roleUid == "")? array() : $this->getRole($roleUid, true);
$flagInsert = ($roleUid == "")? true : false;
$arrayDataMain = array_merge($arrayRoleData, $arrayData);
//Verify data - Field definition
$process = new \ProcessMaker\BusinessModel\Process();
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, $flagInsert);
//Verify data
if (isset($arrayData["ROL_CODE"]) && !preg_match("/^\w+$/", $arrayData["ROL_CODE"])) {
throw new \Exception(\G::LoadTranslation("ID_ROLE_FIELD_CANNOT_CONTAIN_SPECIAL_CHARACTERS", array($this->arrayFieldNameForException["roleCode"])));
}
if (isset($arrayData["ROL_CODE"])) {
$this->throwExceptionIfExistsCode($arrayData["ROL_CODE"], $arrayDataMain["ROL_SYSTEM"], $this->arrayFieldNameForException["roleCode"], $roleUid);
}
if (isset($arrayData["ROL_NAME"])) {
$this->throwExceptionIfExistsName($arrayData["ROL_NAME"], $arrayDataMain["ROL_SYSTEM"], $this->arrayFieldNameForException["roleName"], $roleUid);
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Create Role
*
* @param array $arrayData Data
*
* return array Return data of the new Role created
*/
public function create(array $arrayData)
{
try {
//Verify data
$process = new \ProcessMaker\BusinessModel\Process();
$validator = new \ProcessMaker\BusinessModel\Validator();
$validator->throwExceptionIfDataIsNotArray($arrayData, "\$arrayData");
$validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData");
//Set data
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
unset($arrayData["ROL_UID"]);
$arrayData["ROL_SYSTEM"] = "00000000000000000000000000000002"; //PROCESSMAKER
//Verify data
$this->throwExceptionIfDataIsInvalid("", $arrayData);
//Create
$role = new \Roles();
$roleUid = \ProcessMaker\Util\Common::generateUID();
$arrayData["ROL_UID"] = $roleUid;
$arrayData["ROL_STATUS"] = (isset($arrayData["ROL_STATUS"]))? (($arrayData["ROL_STATUS"] == "ACTIVE")? 1 : 0) : 1;
$arrayData["ROL_CREATE_DATE"] = date("Y-M-d H:i:s");
$result = $role->createRole($arrayData);
//Return
return $this->getRole($roleUid);
} catch (\Exception $e) {
throw $e;
}
}
/**
* Update Role
*
* @param string $roleUid Unique id of Role
* @param array $arrayData Data
*
* return array Return data of the Role updated
*/
public function update($roleUid, array $arrayData)
{
try {
$arrayDataBackup = $arrayData;
//Verify data
$process = new \ProcessMaker\BusinessModel\Process();
$validator = new \ProcessMaker\BusinessModel\Validator();
$validator->throwExceptionIfDataIsNotArray($arrayData, "\$arrayData");
$validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData");
//Set data
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
$arrayRoleData = $this->getRole($roleUid);
//Verify data
$this->throwExceptionIfNotExistsRole($roleUid, $this->arrayFieldNameForException["roleUid"]);
$this->throwExceptionIfDataIsInvalid($roleUid, $arrayData);
//Update
$role = new \Roles();
$arrayData["ROL_UID"] = $roleUid;
$arrayData["ROL_UPDATE_DATE"] = date("Y-M-d H:i:s");
if (!isset($arrayData["ROL_NAME"])) {
$arrayData["ROL_NAME"] = $arrayRoleData[$this->getFieldNameByFormatFieldName("ROL_NAME")];
}
if (isset($arrayData["ROL_STATUS"])) {
$arrayData["ROL_STATUS"] = ($arrayData["ROL_STATUS"] == "ACTIVE")? 1 : 0;
}
$result = $role->updateRole($arrayData);
$arrayData = $arrayDataBackup;
//Return
if (!$this->formatFieldNameInUppercase) {
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
}
return $arrayData;
} catch (\Exception $e) {
throw $e;
}
}
/**
* Delete Role
*
* @param string $roleUid Unique id of Role
*
* return void
*/
public function delete($roleUid)
{
try {
$role = new \Roles();
//Verify data
$this->throwExceptionIfNotExistsRole($roleUid, $this->arrayFieldNameForException["roleUid"]);
if ($role->numUsersWithRole($roleUid) > 0) {
throw new \Exception(\G::LoadTranslation("ID_ROLES_CAN_NOT_DELETE"));
}
//Delete
$result = $role->removeRole($roleUid);
} catch (\Exception $e) {
throw $e;
}
}
/**
* Get criteria for Role
*
* return object
*/
public function getRoleCriteria()
{
try {
$criteria = new \Criteria("rbac");
$criteria->addSelectColumn(\RolesPeer::ROL_UID);
$criteria->addSelectColumn(\RolesPeer::ROL_PARENT);
$criteria->addSelectColumn(\RolesPeer::ROL_CODE);
$criteria->addSelectColumn(\RolesPeer::ROL_STATUS);
$criteria->addSelectColumn(\RolesPeer::ROL_SYSTEM);
$criteria->addSelectColumn(\RolesPeer::ROL_CREATE_DATE);
$criteria->addSelectColumn(\RolesPeer::ROL_UPDATE_DATE);
$criteria->add(\RolesPeer::ROL_SYSTEM, "00000000000000000000000000000002", \Criteria::EQUAL); //PROCESSMAKER
return $criteria;
} catch (\Exception $e) {
throw $e;
}
}
/**
* Get data of a Role from a record
*
* @param array $record Record
*
* return array Return an array with data Role
*/
public function getRoleDataFromRecord(array $record)
{
try {
$conf = new \Configurations();
$confEnvSetting = $conf->getFormats();
$dateTime = new \DateTime($record["ROL_CREATE_DATE"]);
$roleCreateDate = $dateTime->format($confEnvSetting["dateFormat"]);
$roleUpdateDate = "";
if (!empty($record["ROL_UPDATE_DATE"])) {
$dateTime = new \DateTime($record["ROL_UPDATE_DATE"]);
$roleUpdateDate = $dateTime->format($confEnvSetting["dateFormat"]);
}
return array(
$this->getFieldNameByFormatFieldName("ROL_UID") => $record["ROL_UID"],
$this->getFieldNameByFormatFieldName("ROL_CODE") => $record["ROL_CODE"],
$this->getFieldNameByFormatFieldName("ROL_NAME") => $record["ROL_NAME"],
$this->getFieldNameByFormatFieldName("ROL_STATUS") => ($record["ROL_STATUS"] . "" == "1")? "ACTIVE" : "INACTIVE",
$this->getFieldNameByFormatFieldName("ROL_SYSTEM") => $record["ROL_SYSTEM"],
$this->getFieldNameByFormatFieldName("ROL_CREATE_DATE") => $roleCreateDate,
$this->getFieldNameByFormatFieldName("ROL_UPDATE_DATE") => $roleUpdateDate,
$this->getFieldNameByFormatFieldName("ROL_TOTAL_USERS") => (int)($record["ROL_TOTAL_USERS"])
);
} catch (\Exception $e) {
throw $e;
}
}
/**
* Get all Roles
*
* @param array $arrayFilterData Data of the filters
* @param string $sortField Field name to sort
* @param string $sortDir Direction of sorting (ASC, DESC)
* @param int $start Start
* @param int $limit Limit
*
* return array Return an array with all Roles
*/
public function getRoles(array $arrayFilterData = null, $sortField = null, $sortDir = null, $start = null, $limit = null)
{
try {
$arrayRole = array();
//Verify data
$process = new \ProcessMaker\BusinessModel\Process();
$process->throwExceptionIfDataNotMetPagerVarDefinition(array("start" => $start, "limit" => $limit), $this->arrayFieldNameForException);
//Get data
if (!is_null($limit) && $limit . "" == "0") {
return $arrayRole;
}
//Set variables
$content = new \Content();
$role = new \Roles();
$arrayContentByRole = $content->getAllContentsByRole();
//SQL
$criteria = $this->getRoleCriteria();
$criteria->addAsColumn("ROL_TOTAL_USERS", "(SELECT COUNT(" . \UsersRolesPeer::ROL_UID . ") FROM " . \UsersRolesPeer::TABLE_NAME . " WHERE " . \UsersRolesPeer::ROL_UID . " = " . \RolesPeer::ROL_UID . ")");
if (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["filter"]) && trim($arrayFilterData["filter"]) != "") {
$criteria->add(\RolesPeer::ROL_CODE, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE);
}
//Number records total
$criteriaCount = clone $criteria;
$criteriaCount->clearSelectColumns();
$criteriaCount->addAsColumn("NUM_REC", "COUNT(" . \RolesPeer::ROL_UID . ")");
$rsCriteriaCount = \RolesPeer::doSelectRS($criteriaCount);
$rsCriteriaCount->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$rsCriteriaCount->next();
$row = $rsCriteriaCount->getRow();
$numRecTotal = $row["NUM_REC"];
//SQL
if (!is_null($sortField) && trim($sortField) != "") {
$sortField = strtoupper($sortField);
if (in_array($sortField, array("ROL_UID", "ROL_PARENT", "ROL_STATUS", "ROL_SYSTEM", "ROL_CREATE_DATE", "ROL_UPDATE_DATE"))) {
$sortField = \RolesPeer::TABLE_NAME . "." . $sortField;
} else {
$sortField = \RolesPeer::ROL_CODE;
}
} else {
$sortField = \RolesPeer::ROL_CODE;
}
if (!is_null($sortDir) && trim($sortDir) != "" && strtoupper($sortDir) == "DESC") {
$criteria->addDescendingOrderByColumn($sortField);
} else {
$criteria->addAscendingOrderByColumn($sortField);
}
if (!is_null($start)) {
$criteria->setOffset((int)($start));
}
if (!is_null($limit)) {
$criteria->setLimit((int)($limit));
}
$rsCriteria = \RolesPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
while ($rsCriteria->next()) {
$row = $rsCriteria->getRow();
$roleUid = $row["ROL_UID"];
if (isset($arrayContentByRole[$roleUid])) {
$roleName = $arrayContentByRole[$roleUid];
} else {
$rowAux = $role->load($roleUid);
$roleName = $rowAux["ROL_NAME"];
}
$row["ROL_NAME"] = $roleName;
$arrayRole[] = $this->getRoleDataFromRecord($row);
}
//Return
return $arrayRole;
} catch (\Exception $e) {
throw $e;
}
}
/**
* Get data of a Role
*
* @param string $roleUid Unique id of Role
* @param bool $flagGetRecord Value that set the getting
*
* return array Return an array with data of a Role
*/
public function getRole($roleUid, $flagGetRecord = false)
{
try {
//Verify data
$this->throwExceptionIfNotExistsRole($roleUid, $this->arrayFieldNameForException["roleUid"]);
//Set variables
if (!$flagGetRecord) {
$content = new \Content();
$role = new \Roles();
$arrayContentByRole = $content->getAllContentsByRole();
}
//Get data
//SQL
$criteria = $this->getRoleCriteria();
if (!$flagGetRecord) {
$criteria->addAsColumn("ROL_TOTAL_USERS", "(SELECT COUNT(" . \UsersRolesPeer::ROL_UID . ") FROM " . \UsersRolesPeer::TABLE_NAME . " WHERE " . \UsersRolesPeer::ROL_UID . " = " . \RolesPeer::ROL_UID . ")");
}
$criteria->add(\RolesPeer::ROL_UID, $roleUid, \Criteria::EQUAL);
$rsCriteria = \RolesPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$rsCriteria->next();
$row = $rsCriteria->getRow();
if (!$flagGetRecord) {
if (isset($arrayContentByRole[$roleUid])) {
$roleName = $arrayContentByRole[$roleUid];
} else {
$rowAux = $role->load($roleUid);
$roleName = $rowAux["ROL_NAME"];
}
$row["ROL_NAME"] = $roleName;
}
//Return
return (!$flagGetRecord)? $this->getRoleDataFromRecord($row) : $row;
} catch (\Exception $e) {
throw $e;
}
}
}

View File

@@ -0,0 +1,408 @@
<?php
namespace ProcessMaker\BusinessModel\Role;
class User
{
private $arrayFieldDefinition = array(
"ROL_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "roleUid"),
"USR_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "userUid")
);
private $formatFieldNameInUppercase = true;
private $arrayFieldNameForException = array(
"filter" => "FILTER",
"start" => "START",
"limit" => "LIMIT"
);
/**
* Constructor of the class
*
* return void
*/
public function __construct()
{
try {
foreach ($this->arrayFieldDefinition as $key => $value) {
$this->arrayFieldNameForException[$value["fieldNameAux"]] = $key;
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Set the format of the fields name (uppercase, lowercase)
*
* @param bool $flag Value that set the format
*
* return void
*/
public function setFormatFieldNameInUppercase($flag)
{
try {
$this->formatFieldNameInUppercase = $flag;
$this->setArrayFieldNameForException($this->arrayFieldNameForException);
} catch (\Exception $e) {
throw $e;
}
}
/**
* Set exception messages for fields
*
* @param array $arrayData Data with the fields
*
* return void
*/
public function setArrayFieldNameForException(array $arrayData)
{
try {
foreach ($arrayData as $key => $value) {
$this->arrayFieldNameForException[$key] = $this->getFieldNameByFormatFieldName($value);
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Get the name of the field according to the format
*
* @param string $fieldName Field name
*
* return string Return the field name according the format
*/
public function getFieldNameByFormatFieldName($fieldName)
{
try {
return ($this->formatFieldNameInUppercase)? strtoupper($fieldName) : strtolower($fieldName);
} catch (\Exception $e) {
throw $e;
}
}
/**
* Verify if it's assigned the User to Role
*
* @param string $roleUid Unique id of Role
* @param string $userUid Unique id of User
* @param string $fieldNameForException Field name for the exception
*
* return void Throw exception if it's assigned the User to Role
*/
public function throwExceptionIfItsAssignedUserToRole($roleUid, $userUid, $fieldNameForException)
{
try {
$obj = \UsersRolesPeer::retrieveByPK($userUid, $roleUid);
if (!is_null($obj)) {
throw new \Exception(\G::LoadTranslation("ID_ROLE_USER_IS_ALREADY_ASSIGNED", array($fieldNameForException, $userUid)));
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Verify if not it's assigned the User to Role
*
* @param string $roleUid Unique id of Role
* @param string $userUid Unique id of User
* @param string $fieldNameForException Field name for the exception
*
* return void Throw exception if not it's assigned the User to Role
*/
public function throwExceptionIfNotItsAssignedUserToRole($roleUid, $userUid, $fieldNameForException)
{
try {
$obj = \UsersRolesPeer::retrieveByPK($userUid, $roleUid);
if (is_null($obj)) {
throw new \Exception(\G::LoadTranslation("ID_ROLE_USER_IS_NOT_ASSIGNED", array($fieldNameForException, $userUid)));
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Assign User to Role
*
* @param string $roleUid Unique id of Role
* @param array $arrayData Data
*
* return array Return data of the User assigned to Role
*/
public function create($roleUid, array $arrayData)
{
try {
//Verify data
$process = new \ProcessMaker\BusinessModel\Process();
$validator = new \ProcessMaker\BusinessModel\Validator();
$validator->throwExceptionIfDataIsNotArray($arrayData, "\$arrayData");
$validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData");
//Set data
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
unset($arrayData["ROL_UID"]);
//Verify data
$role = new \ProcessMaker\BusinessModel\Role();
$role->throwExceptionIfNotExistsRole($roleUid, $this->arrayFieldNameForException["roleUid"]);
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true);
$process->throwExceptionIfNotExistsUser($arrayData["USR_UID"], $this->arrayFieldNameForException["userUid"]);
$this->throwExceptionIfItsAssignedUserToRole($roleUid, $arrayData["USR_UID"], $this->arrayFieldNameForException["userUid"]);
if ($arrayData["USR_UID"] == "00000000000000000000000000000001") {
throw new \Exception(\G::LoadTranslation("ID_ADMINISTRATOR_ROLE_CANT_CHANGED"));
}
//Create
$role = new \Roles();
$arrayData = array_merge(array("ROL_UID" => $roleUid), $arrayData);
$role->assignUserToRole($arrayData);
//Return
if (!$this->formatFieldNameInUppercase) {
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
}
return $arrayData;
} catch (\Exception $e) {
throw $e;
}
}
/**
* Unassign User of the Role
*
* @param string $roleUid Unique id of Role
* @param string $userUid Unique id of User
*
* return void
*/
public function delete($roleUid, $userUid)
{
try {
//Verify data
$process = new \ProcessMaker\BusinessModel\Process();
$role = new \ProcessMaker\BusinessModel\Role();
$role->throwExceptionIfNotExistsRole($roleUid, $this->arrayFieldNameForException["roleUid"]);
$process->throwExceptionIfNotExistsUser($userUid, $this->arrayFieldNameForException["userUid"]);
$this->throwExceptionIfNotItsAssignedUserToRole($roleUid, $userUid, $this->arrayFieldNameForException["userUid"]);
if ($roleUid == "00000000000000000000000000000002" && $userUid == "00000000000000000000000000000001") {
throw new \Exception(\G::LoadTranslation("ID_ADMINISTRATOR_ROLE_CANT_CHANGED"));
}
//Delete
$role = new \Roles();
$role->deleteUserRole($roleUid, $userUid);
} catch (\Exception $e) {
throw $e;
}
}
/**
* Get criteria for User
*
* @param string $roleUid Unique id of Role
* @param array $arrayUserUidExclude Unique id of Users to exclude
*
* return object
*/
public function getUserCriteria($roleUid, array $arrayUserUidExclude = null)
{
try {
$criteria = new \Criteria("rbac");
$criteria->addSelectColumn(\RbacUsersPeer::USR_UID);
$criteria->addSelectColumn(\RbacUsersPeer::USR_USERNAME);
$criteria->addSelectColumn(\RbacUsersPeer::USR_FIRSTNAME);
$criteria->addSelectColumn(\RbacUsersPeer::USR_LASTNAME);
$criteria->addSelectColumn(\RbacUsersPeer::USR_STATUS);
if ($roleUid != "") {
$criteria->addJoin(\UsersRolesPeer::USR_UID, \RbacUsersPeer::USR_UID, \Criteria::LEFT_JOIN);
$criteria->add(\UsersRolesPeer::ROL_UID, $roleUid, \Criteria::EQUAL);
}
$criteria->add(\RbacUsersPeer::USR_USERNAME, "", \Criteria::NOT_EQUAL);
if (!is_null($arrayUserUidExclude) && is_array($arrayUserUidExclude)) {
$criteria->add(\RbacUsersPeer::USR_UID, $arrayUserUidExclude, \Criteria::NOT_IN);
}
return $criteria;
} catch (\Exception $e) {
throw $e;
}
}
/**
* Get data of a User from a record
*
* @param array $record Record
*
* return array Return an array with data User
*/
public function getUserDataFromRecord(array $record)
{
try {
return array(
$this->getFieldNameByFormatFieldName("USR_UID") => $record["USR_UID"],
$this->getFieldNameByFormatFieldName("USR_USERNAME") => $record["USR_USERNAME"],
$this->getFieldNameByFormatFieldName("USR_FIRSTNAME") => $record["USR_FIRSTNAME"] . "",
$this->getFieldNameByFormatFieldName("USR_LASTNAME") => $record["USR_LASTNAME"] . "",
$this->getFieldNameByFormatFieldName("USR_STATUS") => ($record["USR_STATUS"] . "" == "1")? "ACTIVE" : "INACTIVE"
);
} catch (\Exception $e) {
throw $e;
}
}
/**
* Get all Users of a Role
*
* @param string $roleUid Unique id of Role
* @param string $option Option (USERS, AVAILABLE-USERS)
* @param array $arrayFilterData Data of the filters
* @param string $sortField Field name to sort
* @param string $sortDir Direction of sorting (ASC, DESC)
* @param int $start Start
* @param int $limit Limit
*
* return array Return an array with all Users of a Role
*/
public function getUsers($roleUid, $option, array $arrayFilterData = null, $sortField = null, $sortDir = null, $start = null, $limit = null)
{
try {
$arrayUser = array();
//Verify data
$process = new \ProcessMaker\BusinessModel\Process();
$role = new \ProcessMaker\BusinessModel\Role();
$role->throwExceptionIfNotExistsRole($roleUid, $this->arrayFieldNameForException["roleUid"]);
$process->throwExceptionIfDataNotMetFieldDefinition(
array("OPTION" => $option),
array("OPTION" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array("USERS", "AVAILABLE-USERS"), "fieldNameAux" => "option")),
array("option" => "\$option"),
true
);
$process->throwExceptionIfDataNotMetPagerVarDefinition(array("start" => $start, "limit" => $limit), $this->arrayFieldNameForException);
//Get data
if (!is_null($limit) && $limit . "" == "0") {
return $arrayUser;
}
//SQL
switch ($option) {
case "USERS":
//Criteria
$criteria = $this->getUserCriteria($roleUid);
break;
case "AVAILABLE-USERS":
//Get Uids
$arrayUid = array();
$criteria = $this->getUserCriteria($roleUid);
$rsCriteria = \RbacUsersPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
while ($rsCriteria->next()) {
$row = $rsCriteria->getRow();
$arrayUid[] = $row["USR_UID"];
}
//Criteria
$criteria = $this->getUserCriteria("", $arrayUid);
break;
}
if (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["filter"]) && trim($arrayFilterData["filter"]) != "") {
$criteria->add(
$criteria->getNewCriterion(\RbacUsersPeer::USR_USERNAME, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE)->addOr(
$criteria->getNewCriterion(\RbacUsersPeer::USR_FIRSTNAME, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE)->addOr(
$criteria->getNewCriterion(\RbacUsersPeer::USR_LASTNAME, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE)))
);
}
//Number records total
$criteriaCount = clone $criteria;
$criteriaCount->clearSelectColumns();
$criteriaCount->addAsColumn("NUM_REC", "COUNT(" . \RbacUsersPeer::USR_UID . ")");
$rsCriteriaCount = \RbacUsersPeer::doSelectRS($criteriaCount);
$rsCriteriaCount->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$rsCriteriaCount->next();
$row = $rsCriteriaCount->getRow();
$numRecTotal = $row["NUM_REC"];
//SQL
if (!is_null($sortField) && trim($sortField) != "") {
$sortField = strtoupper($sortField);
if (in_array($sortField, array("USR_UID", "USR_USERNAME", "USR_FIRSTNAME", "USR_LASTNAME", "USR_STATUS"))) {
$sortField = \RbacUsersPeer::TABLE_NAME . "." . $sortField;
} else {
$sortField = \RbacUsersPeer::USR_USERNAME;
}
} else {
$sortField = \RbacUsersPeer::USR_USERNAME;
}
if (!is_null($sortDir) && trim($sortDir) != "" && strtoupper($sortDir) == "DESC") {
$criteria->addDescendingOrderByColumn($sortField);
} else {
$criteria->addAscendingOrderByColumn($sortField);
}
if (!is_null($start)) {
$criteria->setOffset((int)($start));
}
if (!is_null($limit)) {
$criteria->setLimit((int)($limit));
}
$rsCriteria = \RbacUsersPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
while ($rsCriteria->next()) {
$row = $rsCriteria->getRow();
$arrayUser[] = $this->getUserDataFromRecord($row);
}
//Return
return $arrayUser;
} catch (\Exception $e) {
throw $e;
}
}
}

View File

@@ -67,7 +67,7 @@ class WebEntry
*
* return void
*/
public function setArrayFieldNameForException($arrayData)
public function setArrayFieldNameForException(array $arrayData)
{
try {
foreach ($arrayData as $key => $value) {
@@ -175,9 +175,9 @@ class WebEntry
public function throwExceptionIfNotExistsWebEntry($webEntryUid, $fieldNameForException)
{
try {
$webEntry = \WebEntryPeer::retrieveByPK($webEntryUid);
$obj = \WebEntryPeer::retrieveByPK($webEntryUid);
if (is_null($webEntry)) {
if (is_null($obj)) {
throw new \Exception(\G::LoadTranslation("ID_WEB_ENTRY_DOES_NOT_EXIST", array($fieldNameForException, $webEntryUid)));
}
} catch (\Exception $e) {
@@ -215,7 +215,7 @@ class WebEntry
*
* return void Throw exception if data has an invalid value
*/
public function throwExceptionIfDataIsInvalid($webEntryUid, $processUid, $arrayData)
public function throwExceptionIfDataIsInvalid($webEntryUid, $processUid, array $arrayData)
{
try {
//Set variables
@@ -537,7 +537,7 @@ class WebEntry
*
* return array Return data of the new Web Entry created
*/
public function create($processUid, $userUidCreator, $arrayData)
public function create($processUid, $userUidCreator, array $arrayData)
{
try {
//Verify data
@@ -566,7 +566,7 @@ class WebEntry
$webEntry->fromArray($arrayData, \BasePeer::TYPE_FIELDNAME);
$webEntryUid = \G::generateUniqueID();
$webEntryUid = \ProcessMaker\Util\Common::generateUID();
$webEntry->setWeUid($webEntryUid);
$webEntry->setProUid($processUid);
@@ -622,7 +622,7 @@ class WebEntry
*
* return array Return data of the Web Entry updated
*/
public function update($webEntryUid, $userUidUpdater, $arrayData)
public function update($webEntryUid, $userUidUpdater, array $arrayData)
{
try {
//Verify data
@@ -797,7 +797,7 @@ class WebEntry
*
* return array Return an array with data Web Entry
*/
public function getWebEntryDataFromRecord($record)
public function getWebEntryDataFromRecord(array $record)
{
try {
if ($record["WE_METHOD"] == "WS") {
@@ -833,7 +833,7 @@ class WebEntry
$this->getFieldNameByFormatFieldName("WE_CREATE_USR_UID") => $record["WE_CREATE_USR_UID"],
$this->getFieldNameByFormatFieldName("WE_UPDATE_USR_UID") => $record["WE_UPDATE_USR_UID"] . "",
$this->getFieldNameByFormatFieldName("WE_CREATE_DATE") => $webEntryCreateDate,
$this->getFieldNameByFormatFieldName("WE_UPDATE_DATE") => $webEntryUpdateDate . ""
$this->getFieldNameByFormatFieldName("WE_UPDATE_DATE") => $webEntryUpdateDate
);
} catch (\Exception $e) {
throw $e;

View File

@@ -5,7 +5,7 @@ use \ProcessMaker\Services\Api;
use \Luracast\Restler\RestException;
/**
* Group Api Controller
* Calendar Api Controller
*
* @protected
*/

View File

@@ -71,7 +71,7 @@ class WebEntry extends Api
*
* @status 201
*/
public function doPostWebEntry($prj_uid, $request_data)
public function doPostWebEntry($prj_uid, array $request_data)
{
try {
$arrayData = $this->webEntry->create($prj_uid, $this->getUserId(), $request_data);
@@ -91,7 +91,7 @@ class WebEntry extends Api
* @param string $we_uid {@min 32}{@max 32}
* @param array $request_data
*/
public function doPutWebEntry($prj_uid, $we_uid, $request_data)
public function doPutWebEntry($prj_uid, $we_uid, array $request_data)
{
try {
$arrayData = $this->webEntry->update($we_uid, $this->getUserId(), $request_data);

View File

@@ -0,0 +1,111 @@
<?php
namespace ProcessMaker\Services\Api;
use \ProcessMaker\Services\Api;
use \Luracast\Restler\RestException;
/**
* Role Api Controller
*
* @protected
*/
class Role extends Api
{
private $role;
/**
* Constructor of the class
*
* return void
*/
public function __construct()
{
try {
$this->role = new \ProcessMaker\BusinessModel\Role();
$this->role->setFormatFieldNameInUppercase(false);
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* @url GET
*/
public function index($filter = null, $start = null, $limit = null)
{
try {
$response = $this->role->getRoles(array("filter" => $filter), null, null, $start, $limit);
return $response;
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* @url GET /:rol_uid
*
* @param string $rol_uid {@min 32}{@max 32}
*/
public function doGet($rol_uid)
{
try {
$response = $this->role->getRole($rol_uid);
return $response;
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* @url POST
*
* @param array $request_data
*
* @status 201
*/
public function doPost(array $request_data)
{
try {
$arrayData = $this->role->create($request_data);
$response = $arrayData;
return $response;
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* @url PUT /:rol_uid
*
* @param string $rol_uid {@min 32}{@max 32}
* @param array $request_data
*/
public function doPut($rol_uid, array $request_data)
{
try {
$arrayData = $this->role->update($rol_uid, $request_data);
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* @url DELETE /:rol_uid
*
* @param string $rol_uid {@min 32}{@max 32}
*/
public function doDelete($rol_uid)
{
try {
$this->role->delete($rol_uid);
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
}

View File

@@ -0,0 +1,81 @@
<?php
namespace ProcessMaker\Services\Api\Role;
use \ProcessMaker\Services\Api;
use \Luracast\Restler\RestException;
/**
* Role\User Api Controller
*
* @protected
*/
class User extends Api
{
private $roleUser;
/**
* Constructor of the class
*
* return void
*/
public function __construct()
{
try {
$this->roleUser = new \ProcessMaker\BusinessModel\Role\User();
$this->roleUser->setFormatFieldNameInUppercase(false);
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* @url GET /:rol_uid/users
* @url GET /:rol_uid/available-users
*
* @param string $rol_uid {@min 32}{@max 32}
*/
public function doGetUsers($rol_uid, $filter = null, $start = null, $limit = null)
{
try {
$response = $this->roleUser->getUsers($rol_uid, (preg_match("/^.*\/users$/", $this->restler->url))? "USERS" : "AVAILABLE-USERS", array("filter" => $filter), null, null, $start, $limit);
return $response;
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* @url POST /:rol_uid/user
*
* @param string $rol_uid {@min 32}{@max 32}
* @param array $request_data
*
* @status 201
*/
public function doPostUser($rol_uid, array $request_data)
{
try {
$arrayData = $this->roleUser->create($rol_uid, $request_data);
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* @url DELETE /:rol_uid/user/:usr_uid
*
* @param string $rol_uid {@min 32}{@max 32}
* @param string $usr_uid {@min 32}{@max 32}
*/
public function doDeleteUser($rol_uid, $usr_uid)
{
try {
$this->roleUser->delete($rol_uid, $usr_uid);
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
}

View File

@@ -70,3 +70,11 @@ debug = 1
input-document = "ProcessMaker\Services\Api\Cases\InputDocument"
output-document = "ProcessMaker\Services\Api\Cases\OutputDocument"
[alias: role]
role = "ProcessMaker\Services\Api\Role"
user = "ProcessMaker\Services\Api\Role\User"
permission = "ProcessMaker\Services\Api\Role\Permission"
[alias: roles]
role = "ProcessMaker\Services\Api\Role"

View File

@@ -122,6 +122,9 @@
</li>
</ul>
</div>
<div class="bpmn_shapes_legend">
<div class="head"></div>
</div>
</section>
</body>

View File

@@ -0,0 +1,5 @@
<!--<iframe name="casesFrame" id="casesFrame" src ="../designer?prj_uid=<?php echo $_SESSION['PROCESS']; ?>&prj_readonly=true&app_uid=<?php echo $_SESSION['APP_UID']; ?>" width="99%" height="768" frameborder="0">
<p>Your browser does not support iframes.</p>
</iframe>
-->
Not supported yet.

View File

@@ -5,6 +5,10 @@
try {
$rootDir = realpath(__DIR__ . "/../../") . DIRECTORY_SEPARATOR;
require $rootDir . "framework/src/Maveriks/Util/ClassLoader.php";
$loader = Maveriks\Util\ClassLoader::getInstance();
$loader->add($rootDir . 'framework/src/', "Maveriks");
if (! is_dir($rootDir . 'vendor')) {
if (file_exists($rootDir . 'composer.phar')) {
throw new Exception(
@@ -22,18 +26,6 @@ try {
}
}
if (! file_exists($rootDir . 'vendor' . DIRECTORY_SEPARATOR . "autoload.php")) {
throw new Exception(
"ERROR: Problems with Vendors!" . PHP_EOL .
"Please execute the following command to repair vendors:" .PHP_EOL.PHP_EOL.
"$>php composer.phar update"
);
}
require $rootDir . "framework/src/Maveriks/Util/ClassLoader.php";
$loader = Maveriks\Util\ClassLoader::getInstance();
$loader->add($rootDir . 'framework/src/', "Maveriks");
$loader->add($rootDir . 'workflow/engine/src/', "ProcessMaker");
//$loader->add($rootDir . "workflow/engine/classes/model/");
$loader->add($rootDir . 'workflow/engine/src/');