From bd9904adb3a642c0bdd5bbc5eb08547dab96517f Mon Sep 17 00:00:00 2001 From: Nejc Bernot Date: Tue, 4 Jul 2017 14:27:43 +0200 Subject: [PATCH 1/5] Adds support for business servers If the WOPI_BUSINESS_USERS environmental variable is set and true, indicates to Office online that all users are business users when trying to view/edit files --- app/models/asset.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/models/asset.rb b/app/models/asset.rb index ffd2b0432..78dc3bf5f 100644 --- a/app/models/asset.rb +++ b/app/models/asset.rb @@ -380,10 +380,17 @@ class Asset < ActiveRecord::Base action = get_action(file_ext, action) if !action.nil? action_url = action.urlsrc - action_url = action_url.gsub(//, + if (ENV['WOPI_BUSINESS_USERS']) { + action_url = action_url.gsub(//, + 'IsLicensedUser=1&') + action_url = action_url.gsub(//, + 'IsLicensedUser=1') + } else { + action_url = action_url.gsub(//, 'IsLicensedUser=0&') - action_url = action_url.gsub(//, + action_url = action_url.gsub(//, 'IsLicensedUser=0') + } action_url = action_url.gsub(/<.*?=.*?>/, '') rest_url = Rails.application.routes.url_helpers.wopi_rest_endpoint_url( From 91fe7fe4ad178729dbfb3b4ce30b265b2c7f5976 Mon Sep 17 00:00:00 2001 From: Nejc Bernot Date: Tue, 4 Jul 2017 17:13:59 +0200 Subject: [PATCH 2/5] Changes the completely NOT ruby code --- app/models/asset.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/models/asset.rb b/app/models/asset.rb index 78dc3bf5f..90a58a800 100644 --- a/app/models/asset.rb +++ b/app/models/asset.rb @@ -380,17 +380,17 @@ class Asset < ActiveRecord::Base action = get_action(file_ext, action) if !action.nil? action_url = action.urlsrc - if (ENV['WOPI_BUSINESS_USERS']) { + if (ENV['WOPI_BUSINESS_USERS']) action_url = action_url.gsub(//, - 'IsLicensedUser=1&') + 'IsLicensedUser=1&') action_url = action_url.gsub(//, - 'IsLicensedUser=1') - } else { + 'IsLicensedUser=1') + else action_url = action_url.gsub(//, - 'IsLicensedUser=0&') + 'IsLicensedUser=0&') action_url = action_url.gsub(//, - 'IsLicensedUser=0') - } + 'IsLicensedUser=0') + end action_url = action_url.gsub(/<.*?=.*?>/, '') rest_url = Rails.application.routes.url_helpers.wopi_rest_endpoint_url( From 803934e07d06ab1ad367fac450e7c7a66a87596e Mon Sep 17 00:00:00 2001 From: Nejc Bernot Date: Wed, 5 Jul 2017 10:23:10 +0200 Subject: [PATCH 3/5] Changes the host for the download and redirect paths --- app/controllers/wopi_controller.rb | 6 +++--- app/models/asset.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/wopi_controller.rb b/app/controllers/wopi_controller.rb index dd7b30192..7b954c71e 100644 --- a/app/controllers/wopi_controller.rb +++ b/app/controllers/wopi_controller.rb @@ -70,11 +70,11 @@ class WopiController < ActionController::Base UserCanNotWriteRelative: true, CloseUrl: @close_url, DownloadUrl: url_for(controller: 'assets', action: 'download', - id: @asset.id), + id: @asset.id, host: ENV['WOPI_BREADCRUMBS_HOST']), HostEditUrl: url_for(controller: 'assets', action: 'edit', - id: @asset.id), + id: @asset.id, host: ENV['WOPI_BREADCRUMBS_HOST']), HostViewUrl: url_for(controller: 'assets', action: 'view', - id: @asset.id), + id: @asset.id, host: ENV['WOPI_BREADCRUMBS_HOST']), BreadcrumbBrandName: @breadcrumb_brand_name, BreadcrumbBrandUrl: @breadcrumb_brand_url, BreadcrumbFolderName: @breadcrumb_folder_name, diff --git a/app/models/asset.rb b/app/models/asset.rb index 90a58a800..9e674f059 100644 --- a/app/models/asset.rb +++ b/app/models/asset.rb @@ -380,7 +380,7 @@ class Asset < ActiveRecord::Base action = get_action(file_ext, action) if !action.nil? action_url = action.urlsrc - if (ENV['WOPI_BUSINESS_USERS']) + if (ENV['WOPI_BUSINESS_USERS'] && ENV['WOPI_BUSINESS_USERS']=='true' ) action_url = action_url.gsub(//, 'IsLicensedUser=1&') action_url = action_url.gsub(//, From d917cf3340a506a2f16ec82230c3dd6c9b93e968 Mon Sep 17 00:00:00 2001 From: Nejc Bernot Date: Wed, 5 Jul 2017 11:52:36 +0200 Subject: [PATCH 4/5] Renames the WOPI_BREADCRUMBS_HOST env variable to WOPI_USER_HOST --- app/controllers/wopi_controller.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/wopi_controller.rb b/app/controllers/wopi_controller.rb index 7b954c71e..7bd0490b3 100644 --- a/app/controllers/wopi_controller.rb +++ b/app/controllers/wopi_controller.rb @@ -70,11 +70,11 @@ class WopiController < ActionController::Base UserCanNotWriteRelative: true, CloseUrl: @close_url, DownloadUrl: url_for(controller: 'assets', action: 'download', - id: @asset.id, host: ENV['WOPI_BREADCRUMBS_HOST']), + id: @asset.id, host: ENV['WOPI_USER_HOST']), HostEditUrl: url_for(controller: 'assets', action: 'edit', - id: @asset.id, host: ENV['WOPI_BREADCRUMBS_HOST']), + id: @asset.id, host: ENV['WOPI_USER_HOST']), HostViewUrl: url_for(controller: 'assets', action: 'view', - id: @asset.id, host: ENV['WOPI_BREADCRUMBS_HOST']), + id: @asset.id, host: ENV['WOPI_USER_HOST']), BreadcrumbBrandName: @breadcrumb_brand_name, BreadcrumbBrandUrl: @breadcrumb_brand_url, BreadcrumbFolderName: @breadcrumb_folder_name, @@ -286,21 +286,21 @@ class WopiController < ActionController::Base if @protocol.in_module? @close_url = protocols_my_module_url(@protocol.my_module, only_path: false, - host: ENV['WOPI_BREADCRUMBS_HOST']) + host: ENV['WOPI_USER_HOST']) project = @protocol.my_module.experiment.project @breadcrumb_brand_name = project.name @breadcrumb_brand_url = project_url(project, only_path: false, - host: ENV['WOPI_BREADCRUMBS_HOST']) + host: ENV['WOPI_USER_HOST']) @breadcrumb_folder_name = @protocol.my_module.name else @close_url = protocols_url(only_path: false, - host: ENV['WOPI_BREADCRUMBS_HOST']) + host: ENV['WOPI_USER_HOST']) @breadcrump_brand_name = 'Projects' @breadcrumb_brand_url = root_url(only_path: false, - host: ENV['WOPI_BREADCRUMBS_HOST']) + host: ENV['WOPI_USER_HOST']) @breadcrumb_folder_name = 'Protocol managament' end @breadcrumb_folder_url = @close_url @@ -310,12 +310,12 @@ class WopiController < ActionController::Base @close_url = results_my_module_url(@my_module, only_path: false, - host: ENV['WOPI_BREADCRUMBS_HOST']) + host: ENV['WOPI_USER_HOST']) @breadcrumb_brand_name = @my_module.experiment.project.name @breadcrumb_brand_url = project_url(@my_module.experiment.project, only_path: false, - host: ENV['WOPI_BREADCRUMBS_HOST']) + host: ENV['WOPI_USER_HOST']) @breadcrumb_folder_name = @my_module.name @breadcrumb_folder_url = @close_url end From d746ae254903c0b214535c753c1de236ee153104 Mon Sep 17 00:00:00 2001 From: Nbernot Date: Tue, 11 Jul 2017 13:33:47 +0200 Subject: [PATCH 5/5] Removes parentheses around if conditions --- app/models/asset.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/asset.rb b/app/models/asset.rb index 9e674f059..4ef35b06b 100644 --- a/app/models/asset.rb +++ b/app/models/asset.rb @@ -380,7 +380,7 @@ class Asset < ActiveRecord::Base action = get_action(file_ext, action) if !action.nil? action_url = action.urlsrc - if (ENV['WOPI_BUSINESS_USERS'] && ENV['WOPI_BUSINESS_USERS']=='true' ) + if ENV['WOPI_BUSINESS_USERS'] && ENV['WOPI_BUSINESS_USERS']=='true' action_url = action_url.gsub(//, 'IsLicensedUser=1&') action_url = action_url.gsub(//,