From 42780b7ef9fda75dba9157be98b4b5da4ea9f0e4 Mon Sep 17 00:00:00 2001 From: rkaldung Date: Sun, 15 Feb 2015 10:12:27 +0100 Subject: [PATCH] replaced literal w/ constant --- app/controllers/channels_controller.rb | 10 +++++----- app/controllers/email_addresses_controller.rb | 6 +++--- app/controllers/getting_started_controller.rb | 10 +++++----- app/controllers/groups_controller.rb | 6 +++--- app/controllers/jobs_controller.rb | 10 +++++----- .../object_manager_attributes_controller.rb | 12 +++++------ app/controllers/organizations_controller.rb | 6 +++--- app/controllers/overviews_controller.rb | 10 +++++----- app/controllers/packages_controller.rb | 6 +++--- .../postmaster_filters_controller.rb | 10 +++++----- app/controllers/roles_controller.rb | 6 +++--- app/controllers/search_controller.rb | 2 +- app/controllers/sessions_controller.rb | 6 +++--- app/controllers/settings_controller.rb | 10 +++++----- app/controllers/signatures_controller.rb | 6 +++--- app/controllers/slas_controller.rb | 10 +++++----- .../ticket_priorities_controller.rb | 6 +++--- app/controllers/users_controller.rb | 20 +++++++++---------- app/models/group.rb | 2 +- app/models/organization.rb | 2 +- app/models/organization/permission.rb | 2 +- app/models/organization/search.rb | 2 +- app/models/role.rb | 2 +- app/models/user.rb | 2 +- app/models/user/permission.rb | 2 +- app/models/user/search.rb | 2 +- 26 files changed, 84 insertions(+), 84 deletions(-) diff --git a/app/controllers/channels_controller.rb b/app/controllers/channels_controller.rb index 88160cdfc..50b4e4537 100644 --- a/app/controllers/channels_controller.rb +++ b/app/controllers/channels_controller.rb @@ -94,7 +94,7 @@ curl http://localhost/api/v1/channels.json -v -u #{login}:#{password} =end def index - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_index_render(Channel, params) end @@ -117,7 +117,7 @@ curl http://localhost/api/v1/channels/#{id}.json -v -u #{login}:#{password} =end def show - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_show_render(Channel, params) end @@ -153,7 +153,7 @@ curl http://localhost/api/v1/channels.json -v -u #{login}:#{password} -H "Conten =end def create - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_create_render(Channel, params) end @@ -190,7 +190,7 @@ curl http://localhost/api/v1/channels.json -v -u #{login}:#{password} -H "Conten =end def update - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_update_render(Channel, params) end @@ -208,7 +208,7 @@ curl http://localhost/api/v1/channels.json -v -u #{login}:#{password} -H "Conten =end def destroy - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_destory_render(Channel, params) end end diff --git a/app/controllers/email_addresses_controller.rb b/app/controllers/email_addresses_controller.rb index d905e71a9..91abc1fdd 100644 --- a/app/controllers/email_addresses_controller.rb +++ b/app/controllers/email_addresses_controller.rb @@ -97,7 +97,7 @@ curl http://localhost/api/v1/email_addresses.json -v -u #{login}:#{password} -H =end def create - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_create_render(EmailAddress, params) end @@ -128,7 +128,7 @@ curl http://localhost/api/v1/email_addresses.json -v -u #{login}:#{password} -H =end def update - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_update_render(EmailAddress, params) end @@ -143,7 +143,7 @@ Test: =end def destroy - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_destory_render(EmailAddress, params) end end diff --git a/app/controllers/getting_started_controller.rb b/app/controllers/getting_started_controller.rb index e24a61ec1..fae0dceab 100644 --- a/app/controllers/getting_started_controller.rb +++ b/app/controllers/getting_started_controller.rb @@ -51,7 +51,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password} def base # check admin permissions - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) # validate url messages = {} @@ -132,7 +132,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password} def email_probe # check admin permissions - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) # validation user = nil @@ -546,7 +546,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password} def email_outbound # check admin permissions - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) # validate params if !params[:adapter] @@ -565,7 +565,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password} def email_inbound # check admin permissions - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) # validate params if !params[:adapter] @@ -585,7 +585,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password} def email_verify # check admin permissions - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) # send verify email to inbox if !params[:subject] diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index f3f12a2a9..8d449a8e3 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -101,7 +101,7 @@ curl http://localhost/api/v1/groups.json -v -u #{login}:#{password} -H "Content- =end def create - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_create_render(Group, params) end @@ -133,7 +133,7 @@ curl http://localhost/api/v1/groups.json -v -u #{login}:#{password} -H "Content- =end def update - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_update_render(Group, params) end @@ -148,7 +148,7 @@ Test: =end def destroy - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_destory_render(Group, params) end end diff --git a/app/controllers/jobs_controller.rb b/app/controllers/jobs_controller.rb index b49c0d307..9ef542c42 100644 --- a/app/controllers/jobs_controller.rb +++ b/app/controllers/jobs_controller.rb @@ -4,27 +4,27 @@ class JobsController < ApplicationController before_filter :authentication_check def index - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_index_render(Job, params) end def show - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_show_render(Job, params) end def create - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_create_render(Job, params) end def update - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_update_render(Job, params) end def destroy - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_destory_render(Job, params) end end \ No newline at end of file diff --git a/app/controllers/object_manager_attributes_controller.rb b/app/controllers/object_manager_attributes_controller.rb index 49f99da77..41112f4f5 100644 --- a/app/controllers/object_manager_attributes_controller.rb +++ b/app/controllers/object_manager_attributes_controller.rb @@ -6,7 +6,7 @@ class ObjectManagerAttributesController < ApplicationController # GET /object_manager_attributes_list def list - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) render :json => { :objects => ObjectManager.listFrontendObjects, } @@ -15,32 +15,32 @@ class ObjectManagerAttributesController < ApplicationController # GET /object_manager_attributes def index - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) render :json => ObjectManager::Attribute.list_full #model_index_render(ObjectManager::Attribute, params) end # GET /object_manager_attributes/1 def show - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_show_render(ObjectManager::Attribute, params) end # POST /object_manager_attributes def create - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_create_render(ObjectManager::Attribute, params) end # PUT /object_manager_attributes/1 def update - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_update_render(ObjectManager::Attribute, params) end # DELETE /object_manager_attributes/1 def destroy - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_destory_render(ObjectManager::Attribute, params) end end diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 53db59afb..f8bdcb9cf 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -50,7 +50,7 @@ curl http://localhost/api/v1/organizations.json -v -u #{login}:#{password} # only allow customer to fetch his own organization organizations = [] - if is_role(Z_ROLENAME_CUSTOMER) && !is_role('Admin') && !is_role('Agent') + if is_role(Z_ROLENAME_CUSTOMER) && !is_role(Z_ROLENAME_ADMIN) && !is_role('Agent') if current_user.organization_id organizations = Organization.where( :id => current_user.organization_id ) end @@ -80,7 +80,7 @@ curl http://localhost/api/v1/organizations/#{id}.json -v -u #{login}:#{password} def show # only allow customer to fetch his own organization - if is_role(Z_ROLENAME_CUSTOMER) && !is_role('Admin') && !is_role('Agent') + if is_role(Z_ROLENAME_CUSTOMER) && !is_role(Z_ROLENAME_ADMIN) && !is_role('Agent') if !current_user.organization_id render :json => {} return @@ -178,7 +178,7 @@ Test: def history # permissin check - if !is_role('Admin') && !is_role('Agent') + if !is_role(Z_ROLENAME_ADMIN) && !is_role('Agent') response_access_deny return end diff --git a/app/controllers/overviews_controller.rb b/app/controllers/overviews_controller.rb index 6e100f694..cdf3962a2 100644 --- a/app/controllers/overviews_controller.rb +++ b/app/controllers/overviews_controller.rb @@ -52,7 +52,7 @@ curl http://localhost/api/v1/overviews.json -v -u #{login}:#{password} =end def index - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_index_render(Overview, params) end @@ -74,7 +74,7 @@ curl http://localhost/api/v1/overviews/#{id}.json -v -u #{login}:#{password} =end def show - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_show_render(Overview, params) end @@ -108,7 +108,7 @@ curl http://localhost/api/v1/overviews.json -v -u #{login}:#{password} -H "Conte =end def create - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_create_render(Overview, params) end @@ -142,7 +142,7 @@ curl http://localhost/api/v1/overviews.json -v -u #{login}:#{password} -H "Conte =end def update - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_update_render(Overview, params) end @@ -160,7 +160,7 @@ curl http://localhost/api/v1/overviews.json -v -u #{login}:#{password} -H "Conte =end def destroy - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_destory_render(Overview, params) end end diff --git a/app/controllers/packages_controller.rb b/app/controllers/packages_controller.rb index e29283ed8..2553e58d2 100644 --- a/app/controllers/packages_controller.rb +++ b/app/controllers/packages_controller.rb @@ -5,7 +5,7 @@ class PackagesController < ApplicationController # GET /api/v1/packages def index - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) packages = Package.all().order('name') render :json => { :packages => packages @@ -14,7 +14,7 @@ class PackagesController < ApplicationController # POST /api/v1/packages def install - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) Package.install( :string => params[:file_upload].read ) @@ -23,7 +23,7 @@ class PackagesController < ApplicationController # DELETE /api/v1/packages def uninstall - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) package = Package.find( params[:id] ) diff --git a/app/controllers/postmaster_filters_controller.rb b/app/controllers/postmaster_filters_controller.rb index e4e4a67c8..ba4f1154b 100644 --- a/app/controllers/postmaster_filters_controller.rb +++ b/app/controllers/postmaster_filters_controller.rb @@ -54,7 +54,7 @@ curl http://localhost/api/v1/postmaster_filters.json -v -u #{login}:#{password} =end def index - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_index_render(PostmasterFilter, params) end @@ -76,7 +76,7 @@ curl http://localhost/api/v1/postmaster_filters/#{id}.json -v -u #{login}:#{pass =end def show - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_show_render(PostmasterFilter, params) end @@ -121,7 +121,7 @@ curl http://localhost/api/v1/postmaster_filters.json -v -u #{login}:#{password} =end def create - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_create_render(PostmasterFilter, params) end @@ -164,7 +164,7 @@ curl http://localhost/api/v1/postmaster_filters.json -v -u #{login}:#{password} =end def update - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_update_render(PostmasterFilter, params) end @@ -179,7 +179,7 @@ Test: =end def destroy - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_destory_render(PostmasterFilter, params) end end diff --git a/app/controllers/roles_controller.rb b/app/controllers/roles_controller.rb index e74aa74dc..a229964aa 100644 --- a/app/controllers/roles_controller.rb +++ b/app/controllers/roles_controller.rb @@ -95,7 +95,7 @@ curl http://localhost/api/v1/roles.json -v -u #{login}:#{password} -H "Content-T =end def create - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_create_render(Role, params) end @@ -124,7 +124,7 @@ curl http://localhost/api/v1/roles.json -v -u #{login}:#{password} -H "Content-T =end def update - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_update_render(Role, params) end @@ -139,7 +139,7 @@ Test: =end def destroy - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_destory_render(Role, params) end end diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 6a7225d81..e02576cd2 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -7,7 +7,7 @@ class SearchController < ApplicationController def search_user_org # enable search only for agents and admins - if !current_user.is_role('Agent') && !current_user.is_role('Admin') + if !current_user.is_role('Agent') && !current_user.is_role(Z_ROLENAME_ADMIN) response_access_deny return true end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 26b0471d8..6f9812d24 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -190,7 +190,7 @@ class SessionsController < ApplicationController # "switch" to user def switch_to_user - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) # check user if !params[:id] @@ -256,7 +256,7 @@ class SessionsController < ApplicationController end def list - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) assets = {} sessions_clean = [] SessionHelper.list.each {|session| @@ -274,7 +274,7 @@ class SessionsController < ApplicationController end def delete - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) SessionHelper::destroy( params[:id] ) render :json => {} end diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb index 43ae842fa..95a67e850 100644 --- a/app/controllers/settings_controller.rb +++ b/app/controllers/settings_controller.rb @@ -5,31 +5,31 @@ class SettingsController < ApplicationController # GET /settings def index - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_index_render(Setting, params) end # GET /settings/1 def show - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_show_render(Setting, params) end # POST /settings def create - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_create_render(Setting, params) end # PUT /settings/1 def update - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_update_render(Setting, params) end # DELETE /settings/1 def destroy - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_destory_render(Setting, params) end end diff --git a/app/controllers/signatures_controller.rb b/app/controllers/signatures_controller.rb index 65dea3ba0..f7febce4f 100644 --- a/app/controllers/signatures_controller.rb +++ b/app/controllers/signatures_controller.rb @@ -96,7 +96,7 @@ curl http://localhost/api/v1/signatures.json -v -u #{login}:#{password} -H "Cont =end def create - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_create_render(Signature, params) end @@ -125,7 +125,7 @@ curl http://localhost/api/v1/signatures.json -v -u #{login}:#{password} -H "Cont =end def update - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_update_render(Signature, params) end @@ -140,7 +140,7 @@ Test: =end def destroy - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_destory_render(Signature, params) end end diff --git a/app/controllers/slas_controller.rb b/app/controllers/slas_controller.rb index 46e0b9b36..4be849765 100644 --- a/app/controllers/slas_controller.rb +++ b/app/controllers/slas_controller.rb @@ -47,7 +47,7 @@ curl http://localhost/api/v1/slas.json -v -u #{login}:#{password} =end def index - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_index_render(Sla, params) end @@ -69,7 +69,7 @@ curl http://localhost/api/v1/slas/#{id}.json -v -u #{login}:#{password} =end def show - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_show_render(Sla, params) end @@ -98,7 +98,7 @@ curl http://localhost/api/v1/slas.json -v -u #{login}:#{password} -H "Content-Ty =end def create - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_create_render(Sla, params) end @@ -127,7 +127,7 @@ curl http://localhost/api/v1/slas.json -v -u #{login}:#{password} -H "Content-Ty =end def update - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_update_render(Sla, params) end @@ -145,7 +145,7 @@ curl http://localhost/api/v1/slas.json -v -u #{login}:#{password} -H "Content-Ty =end def destroy - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_destory_render(Sla, params) end end diff --git a/app/controllers/ticket_priorities_controller.rb b/app/controllers/ticket_priorities_controller.rb index fee707f12..1145b9ca7 100644 --- a/app/controllers/ticket_priorities_controller.rb +++ b/app/controllers/ticket_priorities_controller.rb @@ -15,19 +15,19 @@ class TicketPrioritiesController < ApplicationController # POST /ticket_priorities def create - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_create_render(Ticket::Priority, params) end # PUT /ticket_priorities/1 def update - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_update_render(Ticket::Priority, params) end # DELETE /ticket_priorities/1 def destroy - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_destory_render(Ticket::Priority, params) end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index b3944ad6a..e840158fd 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -15,7 +15,7 @@ class UsersController < ApplicationController def index # only allow customer to fetch him self - if is_role(Z_ROLENAME_CUSTOMER) && !is_role('Admin') && !is_role('Agent') + if is_role(Z_ROLENAME_CUSTOMER) && !is_role(Z_ROLENAME_ADMIN) && !is_role('Agent') users = User.where( :id => current_user.id ) else users = User.all @@ -85,7 +85,7 @@ class UsersController < ApplicationController group_ids = [] role_ids = [] if count <= 2 - Role.where( :name => [ 'Admin', 'Agent'] ).each { |role| + Role.where( :name => [ Z_ROLENAME_ADMIN, 'Agent'] ).each { |role| role_ids.push role.id } Group.all().each { |group| @@ -203,17 +203,17 @@ class UsersController < ApplicationController user.update_attributes( User.param_cleanup(params) ) # only allow Admin's and Agent's - if is_role('Admin') && is_role('Agent') && params[:role_ids] + if is_role(Z_ROLENAME_ADMIN) && is_role('Agent') && params[:role_ids] user.role_ids = params[:role_ids] end # only allow Admin's - if is_role('Admin') && params[:group_ids] + if is_role(Z_ROLENAME_ADMIN) && params[:group_ids] user.group_ids = params[:group_ids] end # only allow Admin's and Agent's - if is_role('Admin') && is_role('Agent') && params[:organization_ids] + if is_role(Z_ROLENAME_ADMIN) && is_role('Agent') && params[:organization_ids] user.organization_ids = params[:organization_ids] end @@ -235,7 +235,7 @@ class UsersController < ApplicationController # @response_message 200 User successfully deleted. # @response_message 401 Invalid session. def destroy - return if deny_if_not_role('Admin') + return if deny_if_not_role(Z_ROLENAME_ADMIN) model_destory_render(User, params) end @@ -260,7 +260,7 @@ class UsersController < ApplicationController # @response_message 401 Invalid session. def search - if is_role(Z_ROLENAME_CUSTOMER) && !is_role('Admin') && !is_role('Agent') + if is_role(Z_ROLENAME_CUSTOMER) && !is_role(Z_ROLENAME_ADMIN) && !is_role('Agent') response_access_deny return end @@ -324,7 +324,7 @@ class UsersController < ApplicationController def history # permissin check - if !is_role('Admin') && !is_role('Agent') + if !is_role(Z_ROLENAME_ADMIN) && !is_role('Agent') response_access_deny return end @@ -715,7 +715,7 @@ curl http://localhost/api/v1/users/avatar -v -u #{login}:#{password} -H "Content end def permission_check_by_role - return true if is_role('Admin') + return true if is_role(Z_ROLENAME_ADMIN) return true if is_role('Agent') response_access_deny @@ -723,7 +723,7 @@ curl http://localhost/api/v1/users/avatar -v -u #{login}:#{password} -H "Content end def permission_check - return true if is_role('Admin') + return true if is_role(Z_ROLENAME_ADMIN) return true if is_role('Agent') # allow to update customer by him self diff --git a/app/models/group.rb b/app/models/group.rb index 3bde3ca40..2ebb08f5b 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -6,6 +6,6 @@ class Group < ApplicationModel belongs_to :signature validates :name, :presence => true - activity_stream_support :role => 'Admin' + activity_stream_support :role => Z_ROLENAME_ADMIN history_support end diff --git a/app/models/organization.rb b/app/models/organization.rb index a0d791fc4..a13cdb512 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -11,7 +11,7 @@ class Organization < ApplicationModel has_many :members, :class_name => 'User' validates :name, :presence => true - activity_stream_support :role => 'Admin' + activity_stream_support :role => Z_ROLENAME_ADMIN history_support search_index_support notify_clients_support diff --git a/app/models/organization/permission.rb b/app/models/organization/permission.rb index 4616a9a2e..b538d5b31 100644 --- a/app/models/organization/permission.rb +++ b/app/models/organization/permission.rb @@ -30,7 +30,7 @@ returns end # check agent - return true if data[:current_user].is_role('Admin') + return true if data[:current_user].is_role(Z_ROLENAME_ADMIN) return true if data[:current_user].is_role('Agent') return false end diff --git a/app/models/organization/search.rb b/app/models/organization/search.rb index d48e5ce15..515450b88 100644 --- a/app/models/organization/search.rb +++ b/app/models/organization/search.rb @@ -26,7 +26,7 @@ returns current_user = params[:current_user] # enable search only for agents and admins - return [] if !current_user.is_role('Agent') && !current_user.is_role('Admin') + return [] if !current_user.is_role('Agent') && !current_user.is_role(Z_ROLENAME_ADMIN) # try search index backend if SearchIndexBackend.enabled? diff --git a/app/models/role.rb b/app/models/role.rb index c07030299..7016fd8ec 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -4,5 +4,5 @@ class Role < ApplicationModel has_and_belongs_to_many :users, :after_add => :cache_update, :after_remove => :cache_update validates :name, :presence => true - activity_stream_support :role => 'Admin' + activity_stream_support :role => Z_ROLENAME_ADMIN end diff --git a/app/models/user.rb b/app/models/user.rb index f3a00e8ff..48211a8ae 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -47,7 +47,7 @@ class User < ApplicationModel store :preferences activity_stream_support( - :role => 'Admin', + :role => Z_ROLENAME_ADMIN, :ignore_attributes => { :last_login => true, :image => true, diff --git a/app/models/user/permission.rb b/app/models/user/permission.rb index b27dd0458..1e9c5b051 100644 --- a/app/models/user/permission.rb +++ b/app/models/user/permission.rb @@ -28,7 +28,7 @@ returns end # check agent - return true if data[:current_user].is_role('Admin') + return true if data[:current_user].is_role(Z_ROLENAME_ADMIN) return true if data[:current_user].is_role('Agent') return false end diff --git a/app/models/user/search.rb b/app/models/user/search.rb index 602e86244..16192d2ae 100644 --- a/app/models/user/search.rb +++ b/app/models/user/search.rb @@ -26,7 +26,7 @@ returns current_user = params[:current_user] # enable search only for agents and admins - return [] if !current_user.is_role('Agent') && !current_user.is_role('Admin') + return [] if !current_user.is_role('Agent') && !current_user.is_role(Z_ROLENAME_ADMIN) # try search index backend if SearchIndexBackend.enabled?