Details
-
Bug
-
Resolution: Fixed
-
Minor
-
1.9
-
None
-
usertype, isAdvanced, profile, patch
-
Description
When a user with administrative access looks at another user's profile, the option to switch from simple to advanced user reflects the logged in user's setting and not the profile's
This is the code involved:
from frequentlyUsedDocs.vm, set crtUserDoc to the currently logged in user doc
#set($crtUserDoc = $!xwiki.getDocument($context.user))
in xwikivars.vm determine the isAdvanced var from the $crtUserDoc
#set($userObj = $!crtUserDoc.getObject("XWiki.XWikiUsers",0))
-
- =====================================================================================
- Advanced users are:
- - super admin
- - user documents who have their usertype property set to "Advanced"
- - guest users who have admin rights (i.e. when the wiki is empty with no rights set)
- =====================================================================================
#if($context.user == "XWiki.superadmin")
#set($isAdvancedUser = true)
#elseif($isGuest && $hasAdmin)
#set($isAdvancedUser = true)
#elseif(!$userObj.getProperty("usertype").value)
#set($isAdvancedUser = false)
#else
#set($isAdvancedUser = ($userObj.getProperty("usertype").value == "Advanced"))
#end
And finally in XWIkiUserSheet, if the user is advanced, show the switch to simple.
#if($isAdvancedUser)
- <img alt="" src="$xwiki.getSkinFile("icons/simpleuser.png")"/> <a href="$doc.getURL("save", "XWiki.XWikiUsers_${obj.number}_usertype=Simple")">$msg.get("platform.core.profile.switchSimple")</a>
#else - <img alt="" src="$xwiki.getSkinFile("icons/advanceduser.png")"/> <a href="$doc.getURL("save", "XWiki.XWikiUsers_${obj.number}_usertype=Advanced")">$msg.get("platform.core.profile.switchAdvanced")</a>
#end
I think part of the reason this happened is because the comment above this section is incorrect. It states that the whole section is shown only for the current user ( ## Note: This menu is only displayed if the current profile page is
-
- that of the currently logged user), but in fact it is also shown for administrative users ( #if($isMyProfile || $xwiki.hasAdminRights()))
An different issue is that XWikiUser defines the values for this property to be Basic and Advanced but the profile editor sets it to either Simple or Advanced.