From a866b5daf45997a2bc9482f55ad84df675c63fbe Mon Sep 17 00:00:00 2001 From: j2blake Date: Sun, 30 Oct 2011 17:15:53 +0000 Subject: [PATCH] NIHVIVO-2343 A user should not be allowed as a proxy for his own profile. --- .../controller/accounts/user/UserAccountsMyAccountPage.java | 1 + webapp/web/js/account/accountProxyCommon.js | 6 ++++-- webapp/web/js/account/accountProxyProxiesPanel.js | 4 +++- .../body/accounts/userAccounts-myProxiesPanel.ftl | 3 ++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsMyAccountPage.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsMyAccountPage.java index 2d53610f4..08e24bea8 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsMyAccountPage.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsMyAccountPage.java @@ -147,6 +147,7 @@ public class UserAccountsMyAccountPage extends UserAccountsPage { body.put("proxies", buildOriginalProxyList()); } body.put("formUrls", buildUrlsMap()); + body.put("myAccountUri", userAccount.getUri()); // Could I do this without exposing this mechanism? But how to search // for an associated profile in AJAX? diff --git a/webapp/web/js/account/accountProxyCommon.js b/webapp/web/js/account/accountProxyCommon.js index 08680f577..7669245ef 100644 --- a/webapp/web/js/account/accountProxyCommon.js +++ b/webapp/web/js/account/accountProxyCommon.js @@ -74,6 +74,7 @@ function proxyInfoElement(template, uri, label, classLabel, imageUrl, removeInfo * You provide: * parms -- a map containing the URL of the AJAX controller, the query, and * the model selector. + * excludedUris -- these URIs are always filtered out of the results. * getProxyInfos -- a function that will return an array of proxyInfoElements * that are already present in the list and so should be filtered out of * the autocomplete response. @@ -94,7 +95,7 @@ function proxyInfoElement(template, uri, label, classLabel, imageUrl, removeInfo * -- calling addProxyInfo() and clearing the field when a value is selected. * ---------------------------------------------------------------------------- */ -function proxyAutocomplete(parms, getProxyInfos, addProxyInfo, reportSearchStatus) { +function proxyAutocomplete(parms, excludedUris, getProxyInfos, addProxyInfo, reportSearchStatus) { var cache = []; var filterResults = function(parsed) { @@ -103,7 +104,8 @@ function proxyAutocomplete(parms, getProxyInfos, addProxyInfo, reportSearchStatu return p.uri; }); $.each(parsed, function(i, p) { - if (-1 == $.inArray(p.uri, existingUris)) { + if ((-1 == $.inArray(p.uri, existingUris)) + && (-1 == $.inArray(p.uri, excludedUris))) { filtered.push(p); } }); diff --git a/webapp/web/js/account/accountProxyProxiesPanel.js b/webapp/web/js/account/accountProxyProxiesPanel.js index 5807bf1d1..aea4b7e65 100644 --- a/webapp/web/js/account/accountProxyProxiesPanel.js +++ b/webapp/web/js/account/accountProxyProxiesPanel.js @@ -43,6 +43,8 @@ function proxyProxiesPanel(p) { var self = this; + var excludedUris = [proxyMechanism.myAccountUri]; + var removeProxyInfo = function(info) { self.removeProxyInfo(info) } @@ -153,7 +155,7 @@ function proxyProxiesPanel(p) { url: proxyMechanism.sparqlQueryUrl }; var reportSearchStatus = new searchStatusField(this.searchStatusField, 3).setText; - this.addAutoCompleteField.autocomplete(new proxyAutocomplete(parms, this.getProxyInfos, this.addProxyInfo, reportSearchStatus)); + this.addAutoCompleteField.autocomplete(new proxyAutocomplete(parms, excludedUris, this.getProxyInfos, this.addProxyInfo, reportSearchStatus)); } this.setupAutoCompleteFields(); diff --git a/webapp/web/templates/freemarker/body/accounts/userAccounts-myProxiesPanel.ftl b/webapp/web/templates/freemarker/body/accounts/userAccounts-myProxiesPanel.ftl index 6580b9e99..8dff93db9 100644 --- a/webapp/web/templates/freemarker/body/accounts/userAccounts-myProxiesPanel.ftl +++ b/webapp/web/templates/freemarker/body/accounts/userAccounts-myProxiesPanel.ftl @@ -56,7 +56,8 @@ ${stylesheets.add('