Index: impl/src/java/org/sakaiproject/profile2/service/ProfileImageServiceImpl.java =================================================================== --- impl/src/java/org/sakaiproject/profile2/service/ProfileImageServiceImpl.java (revision 64987) +++ impl/src/java/org/sakaiproject/profile2/service/ProfileImageServiceImpl.java (working copy) @@ -77,8 +77,8 @@ return false; } - //check currentUser and object uuid match - if(!StringUtils.equals(currentUserUuid, userUuid)) { + //check admin, or the currentUser and object uuid match + if(!sakaiProxy.isSuperUser() && !StringUtils.equals(currentUserUuid, userUuid)) { throw new SecurityException("Not allowed to save."); } @@ -147,8 +147,8 @@ return false; } - //check currentUser and object uuid match - if(!StringUtils.equals(currentUserUuid, userUuid)) { + //check admin, or the currentUser and object uuid match + if(!sakaiProxy.isSuperUser() || !StringUtils.equals(currentUserUuid, userUuid)) { throw new SecurityException("Not allowed to save."); } Index: impl/src/java/org/sakaiproject/profile2/logic/ProfileLogicImpl.java =================================================================== --- impl/src/java/org/sakaiproject/profile2/logic/ProfileLogicImpl.java (revision 64987) +++ impl/src/java/org/sakaiproject/profile2/logic/ProfileLogicImpl.java (working copy) @@ -1834,8 +1834,8 @@ for(Iterator i = userUuids.iterator(); i.hasNext();){ String userUuid = (String)i.next(); - //if user is in the list of invisible users, skip - if(sakaiProxy.getInvisibleUsers().contains(userUuid)){ + //if user is in the list of invisible users, skip unless current user is admin + if(!sakaiProxy.isSuperUser() && sakaiProxy.getInvisibleUsers().contains(userUuid)){ continue; } @@ -1872,20 +1872,27 @@ //get privacy record ProfilePrivacy privacy = getPrivacyRecordForUser(userUuid); - //is this user visible in searches by this user? if not, skip - if(!isUserXVisibleInSearchesByUserY(userUuid, privacy, userId, friend)) { + //is this user visible in searches by this user? if not, skip unless admin user + if(!sakaiProxy.isSuperUser() && !isUserXVisibleInSearchesByUserY(userUuid, privacy, userId, friend)) { continue; } //is profile photo visible to this user - boolean profileImageAllowed = isUserXProfileImageVisibleByUserY(userUuid, privacy, userId, friend); - + boolean profileImageAllowed; //is status visible to this user - boolean statusVisible = isUserXStatusVisibleByUserY(userUuid, privacy, userId, friend); - + boolean statusVisible; //is friends list visible to this user - boolean friendsListVisible = isUserXFriendsListVisibleByUserY(userUuid, privacy, userId, friend); + boolean friendsListVisible; + if (sakaiProxy.isSuperUser()) { + profileImageAllowed = true; + statusVisible = true; + friendsListVisible = true; + } else { + profileImageAllowed = isUserXProfileImageVisibleByUserY(userUuid, privacy, userId, friend); + statusVisible = isUserXStatusVisibleByUserY(userUuid, privacy, userId, friend); + friendsListVisible = isUserXFriendsListVisibleByUserY(userUuid, privacy, userId, friend); + } //make object SearchResult searchResult = new SearchResult( Index: impl/src/java/org/sakaiproject/profile2/logic/SakaiProxyImpl.java =================================================================== --- impl/src/java/org/sakaiproject/profile2/logic/SakaiProxyImpl.java (revision 64987) +++ impl/src/java/org/sakaiproject/profile2/logic/SakaiProxyImpl.java (working copy) @@ -1006,5 +1006,21 @@ this.serverConfigurationService = serverConfigurationService; } + private transient boolean isSuperUserProxyUser = false; + public boolean isSuperUserProxyUser() { + return isSuperUserProxyUser; + } + public void setSuperUserProxyUser(boolean isSuperUserProxyUser) { + this.isSuperUserProxyUser = isSuperUserProxyUser; + } + + private transient String proxyUserUuid = null; + public String getProxyUserUuid() { + return proxyUserUuid; + } + + public void setProxyUserUuid(String proxyUserUuid) { + this.proxyUserUuid = proxyUserUuid; + } } Index: api/src/java/org/sakaiproject/profile2/logic/SakaiProxy.java =================================================================== --- api/src/java/org/sakaiproject/profile2/logic/SakaiProxy.java (revision 64987) +++ api/src/java/org/sakaiproject/profile2/logic/SakaiProxy.java (working copy) @@ -403,5 +403,39 @@ * @return */ public List getInvisibleUsers(); + + /** + * Is a super user acting as a proxy user? + * + * @return true if the super user is a proxy user, false + * if the super user is not currently a proxy user. + */ + public boolean isSuperUserProxyUser(); + /** + * Gives a super user proxy user ability i.e. the ability to edit + * another user's profile. + * + * @param isProxyUser set to true to give the super user proxy user ability. + * Set false to remove proxy user ability. + */ + public void setSuperUserProxyUser(boolean isSuperUserProxyUser); + + /** + * Returns the UUID of the user a super user is acting as proxy for. + * + * @return the UUID of the user the super user is acting as proxy for. + * Returns null if the super user is not currently a proxy user. + */ + public String getProxyUserUuid(); + + /** + * Sets the UUID of the user a super user is acting as proxy for. + * + * @param proxyUserUuid the UUID of the user the super user is acting as proxy for. + * Set to null if super user not acting as proxy. + */ + public void setProxyUserUuid(String proxyUserUuid); + + } Index: tool/src/java/org/sakaiproject/profile2/tool/pages/MyFriends.java =================================================================== --- tool/src/java/org/sakaiproject/profile2/tool/pages/MyFriends.java (revision 64987) +++ tool/src/java/org/sakaiproject/profile2/tool/pages/MyFriends.java (working copy) @@ -22,7 +22,12 @@ log.debug("MyFriends()"); //get current user - final String userId = sakaiProxy.getCurrentUserId(); + final String userId; + if (sakaiProxy.isSuperUser() && sakaiProxy.isSuperUserProxyUser()) { + userId = sakaiProxy.getProxyUserUuid(); + } else { + userId = sakaiProxy.getCurrentUserId(); + } //friend requests panel requestedFriends = new RequestedFriends("requestedFriends", this, userId); Index: tool/src/java/org/sakaiproject/profile2/tool/pages/panels/MyAcademicEdit.java =================================================================== --- tool/src/java/org/sakaiproject/profile2/tool/pages/panels/MyAcademicEdit.java (revision 64987) +++ tool/src/java/org/sakaiproject/profile2/tool/pages/panels/MyAcademicEdit.java (working copy) @@ -100,7 +100,7 @@ protected void onSubmit(AjaxRequestTarget target, Form form) { //save() form, show message, then load display panel - if(save(form)) { + if(save(form, userProfile)) { //post update event sakaiProxy.postEvent(ProfileConstants.EVENT_PROFILE_INTERESTS_UPDATE, "/profile/"+userProfile.getUserId(), true); @@ -150,15 +150,12 @@ } //called when the form is to be saved - private boolean save(Form form) { + private boolean save(Form form, UserProfile userProfile) { - //get the backing model - UserProfile userProfile = (UserProfile) form.getModelObject(); - - //get sakaiProxy, then get userId from sakaiProxy, then get sakaiperson for that userId + //get sakaiProxy, then get userId from userProfile, then get sakaiPerson for that userId SakaiProxy sakaiProxy = getSakaiProxy(); - String userId = sakaiProxy.getCurrentUserId(); + String userId = userProfile.getUserId(); SakaiPerson sakaiPerson = sakaiProxy.getSakaiPerson(userId); //get values and set into SakaiPerson Index: tool/src/java/org/sakaiproject/profile2/tool/pages/panels/MyInfoEdit.java =================================================================== --- tool/src/java/org/sakaiproject/profile2/tool/pages/panels/MyInfoEdit.java (revision 64987) +++ tool/src/java/org/sakaiproject/profile2/tool/pages/panels/MyInfoEdit.java (working copy) @@ -126,7 +126,7 @@ protected void onSubmit(AjaxRequestTarget target, Form form) { //save() form, show message, then load display panel - if(save(form)) { + if(save(form, userProfile)) { //post update event sakaiProxy.postEvent(ProfileConstants.EVENT_PROFILE_INFO_UPDATE, "/profile/"+userProfile.getUserId(), true); @@ -186,16 +186,12 @@ } //called when the form is to be saved - private boolean save(Form form) { + private boolean save(Form form, UserProfile userProfile) { - - //get the backing model - UserProfile userProfile = (UserProfile) form.getModelObject(); - - //get sakaiProxy, then get userId from sakaiProxy, then get sakaiperson for that userId + //get sakaiProxy, then get userId from userProfile, then get sakaiPerson for that userId SakaiProxy sakaiProxy = getSakaiProxy(); - String userId = sakaiProxy.getCurrentUserId(); + String userId = userProfile.getUserId(); SakaiPerson sakaiPerson = sakaiProxy.getSakaiPerson(userId); //set the attributes from userProfile that this form dealt with, into sakaiPerson Index: tool/src/java/org/sakaiproject/profile2/tool/pages/panels/ChangeProfilePictureUpload.java =================================================================== --- tool/src/java/org/sakaiproject/profile2/tool/pages/panels/ChangeProfilePictureUpload.java (revision 64987) +++ tool/src/java/org/sakaiproject/profile2/tool/pages/panels/ChangeProfilePictureUpload.java (working copy) @@ -45,8 +45,13 @@ public void onSubmit(){ - //get userid and sakaiperson for this user - String userId = getSakaiProxy().getCurrentUserId(); + //get userId + String userId; + if (getSakaiProxy().isSuperUser() && getSakaiProxy().isSuperUserProxyUser()) { + userId = getSakaiProxy().getProxyUserUuid(); + } else { + userId = getSakaiProxy().getCurrentUserId(); + } //get file that was uploaded FileUpload upload = uploadField.getFileUpload(); Index: tool/src/java/org/sakaiproject/profile2/tool/pages/panels/MyContactEdit.java =================================================================== --- tool/src/java/org/sakaiproject/profile2/tool/pages/panels/MyContactEdit.java (revision 64987) +++ tool/src/java/org/sakaiproject/profile2/tool/pages/panels/MyContactEdit.java (working copy) @@ -156,7 +156,7 @@ protected void onSubmit(AjaxRequestTarget target, Form form) { //save() form, show message, then load display panel - if(save(form)) { + if(save(form, userProfile)) { //post update event sakaiProxy.postEvent(ProfileConstants.EVENT_PROFILE_CONTACT_UPDATE, "/profile/"+userProfile.getUserId(), true); @@ -208,15 +208,12 @@ } //called when the form is to be saved - private boolean save(Form form) { + private boolean save(Form form, UserProfile userProfile) { - //get the backing model - UserProfile userProfile = (UserProfile) form.getModelObject(); - - //get sakaiProxy, then get userId from sakaiProxy, then get sakaiperson for that userId + //get sakaiProxy, then get userId from userProfile, then get sakaiPerson for that userId SakaiProxy sakaiProxy = getSakaiProxy(); - String userId = sakaiProxy.getCurrentUserId(); + String userId = userProfile.getUserId(); SakaiPerson sakaiPerson = sakaiProxy.getSakaiPerson(userId); //set the attributes from userProfile that this form dealt with, into sakaiPerson Index: tool/src/java/org/sakaiproject/profile2/tool/pages/panels/ChangeProfilePictureUrl.java =================================================================== --- tool/src/java/org/sakaiproject/profile2/tool/pages/panels/ChangeProfilePictureUrl.java (revision 64987) +++ tool/src/java/org/sakaiproject/profile2/tool/pages/panels/ChangeProfilePictureUrl.java (working copy) @@ -42,7 +42,12 @@ profileLogic = getProfileLogic(); //get userId - final String userId = sakaiProxy.getCurrentUserId(); + final String userId; + if (getSakaiProxy().isSuperUser() && getSakaiProxy().isSuperUserProxyUser()) { + userId = getSakaiProxy().getProxyUserUuid(); + } else { + userId = getSakaiProxy().getCurrentUserId(); + } //setup SimpleText object to back the single form field SimpleText simpleText = new SimpleText(); Index: tool/src/java/org/sakaiproject/profile2/tool/pages/MyProfile.java =================================================================== --- tool/src/java/org/sakaiproject/profile2/tool/pages/MyProfile.java (revision 64987) +++ tool/src/java/org/sakaiproject/profile2/tool/pages/MyProfile.java (working copy) @@ -31,8 +31,8 @@ private static final long serialVersionUID = 1L; private static final Logger log = Logger.getLogger(MyProfile.class); - - public MyProfile() { + + public MyProfile() { log.debug("MyProfile()"); @@ -42,7 +42,12 @@ feedbackPanel.setVisible(false); //hide by default //get user for this profile - String userUuid = sakaiProxy.getCurrentUserId(); + String userUuid; + if (sakaiProxy.isSuperUser() && sakaiProxy.isSuperUserProxyUser()) { + userUuid = sakaiProxy.getProxyUserUuid(); + } else { + userUuid = sakaiProxy.getCurrentUserId(); + } //get SakaiPerson for this user SakaiPerson sakaiPerson = sakaiProxy.getSakaiPerson(userUuid); Index: tool/src/java/org/sakaiproject/profile2/tool/pages/BasePage.java =================================================================== --- tool/src/java/org/sakaiproject/profile2/tool/pages/BasePage.java (revision 64987) +++ tool/src/java/org/sakaiproject/profile2/tool/pages/BasePage.java (working copy) @@ -28,7 +28,7 @@ //super(); log.debug("BasePage()"); - + //get SakaiProxy API sakaiProxy = getSakaiProxy(); @@ -37,10 +37,13 @@ //set Locale - all pages will inherit this. setUserPreferredLocale(); - + //profile link Link myProfileLink = new Link("myProfileLink") { public void onClick() { + // reset any proxy settings, so proxy user returns to own profile + sakaiProxy.setSuperUserProxyUser(false); + sakaiProxy.setProxyUserUuid(null); setResponsePage(new MyProfile()); } }; Index: tool/src/java/org/sakaiproject/profile2/tool/pages/MyPreferences.java =================================================================== --- tool/src/java/org/sakaiproject/profile2/tool/pages/MyPreferences.java (revision 64987) +++ tool/src/java/org/sakaiproject/profile2/tool/pages/MyPreferences.java (working copy) @@ -32,13 +32,18 @@ private static final Logger log = Logger.getLogger(MyPreferences.class); private transient ProfilePreferences profilePreferences; - + public MyPreferences() { log.debug("MyPreferences()"); //get current user - final String userUuid = sakaiProxy.getCurrentUserId(); + final String userUuid; + if (sakaiProxy.isSuperUser() && sakaiProxy.isSuperUserProxyUser()) { + userUuid = sakaiProxy.getProxyUserUuid(); + } else { + userUuid = sakaiProxy.getCurrentUserId(); + } //get the preferences object for this user from the database profilePreferences = profileLogic.getPreferencesRecordForUser(userUuid); Index: tool/src/java/org/sakaiproject/profile2/tool/pages/MyPrivacy.java =================================================================== --- tool/src/java/org/sakaiproject/profile2/tool/pages/MyPrivacy.java (revision 64987) +++ tool/src/java/org/sakaiproject/profile2/tool/pages/MyPrivacy.java (working copy) @@ -38,8 +38,13 @@ log.debug("MyPrivacy()"); - //get current user - final String userUuid = sakaiProxy.getCurrentUserId(); + //get userId + final String userUuid; + if (sakaiProxy.isSuperUser() && sakaiProxy.isSuperUserProxyUser()) { + userUuid = sakaiProxy.getProxyUserUuid(); + } else { + userUuid = sakaiProxy.getCurrentUserId(); + } //get the privacy object for this user from the database profilePrivacy = profileLogic.getPrivacyRecordForUser(userUuid); Index: tool/src/java/org/sakaiproject/profile2/tool/pages/ViewProfile.java =================================================================== --- tool/src/java/org/sakaiproject/profile2/tool/pages/ViewProfile.java (revision 64987) +++ tool/src/java/org/sakaiproject/profile2/tool/pages/ViewProfile.java (working copy) @@ -36,8 +36,7 @@ private static final Logger log = Logger.getLogger(ViewProfile.class); - public ViewProfile(String userUuid) { - + public ViewProfile(String userUuid) { log.debug("ViewProfile()"); //setup model to store the actions in the modal windows @@ -51,6 +50,16 @@ log.warn("ViewProfile: user " + userUuid + " accessed ViewProfile for self. Redirecting..."); throw new RestartResponseException(new MyProfile()); } + //check if super user, to grant editing rights to another user's profile + else if (sakaiProxy.isSuperUser() && !userUuid.equals(currentUserId)) { + sakaiProxy.setSuperUserProxyUser(true); + sakaiProxy.setProxyUserUuid(userUuid); + + throw new RestartResponseException(new MyProfile()); + } else { + sakaiProxy.setSuperUserProxyUser(false); + sakaiProxy.setProxyUserUuid(null); + } //post view event sakaiProxy.postEvent(ProfileConstants.EVENT_PROFILE_VIEW_OTHER, "/profile/"+userUuid, false);