diff --git a/src/main/java/org/olat/portfolio/manager/EPFrontendManager.java b/src/main/java/org/olat/portfolio/manager/EPFrontendManager.java index 065fe02b2b6ef1c26e69f0a0a66b1d443c0332f0..7809b1b2bb12c789d20d5d4288bfd1c1adc3c49b 100755 --- a/src/main/java/org/olat/portfolio/manager/EPFrontendManager.java +++ b/src/main/java/org/olat/portfolio/manager/EPFrontendManager.java @@ -1211,7 +1211,22 @@ public class EPFrontendManager extends BasicManager { return "n/a"; } - + /** + * returns the first OwnerIdentity for the given Map. + * + * @param map + * @return + */ + public static Identity getFirstOwnerIdentity(PortfolioStructureMap map){ + List<Identity> ownerIdents = BaseSecurityManager.getInstance().getIdentitiesOfSecurityGroup(map.getOwnerGroup()); + if (ownerIdents.size() > 0) { + Identity id = ownerIdents.get(0); + return id; + } else { + throw new AssertException("OwnerGroup of given ePortfolioMap (" + map.getResourceableId() + ") is empty!"); + } + } + // not yet available public void archivePortfolio() {} diff --git a/src/main/java/org/olat/portfolio/ui/structel/EPMapViewController.java b/src/main/java/org/olat/portfolio/ui/structel/EPMapViewController.java index cbb2f8512084be92da06123792866c371479a705..5416df6b68a5609a7b9871b9c194721735bd93e3 100644 --- a/src/main/java/org/olat/portfolio/ui/structel/EPMapViewController.java +++ b/src/main/java/org/olat/portfolio/ui/structel/EPMapViewController.java @@ -35,6 +35,7 @@ import org.olat.core.gui.control.generic.dtabs.Activateable2; import org.olat.core.gui.control.generic.modal.DialogBoxController; import org.olat.core.gui.control.generic.modal.DialogBoxUIFactory; import org.olat.core.helpers.Settings; +import org.olat.core.id.Identity; import org.olat.core.id.OLATResourceable; import org.olat.core.id.context.ContextEntry; import org.olat.core.id.context.StateEntry; @@ -58,6 +59,7 @@ import org.olat.portfolio.model.structel.StructureStatusEnum; import org.olat.portfolio.ui.structel.edit.EPStructureTreeAndDetailsEditController; import org.olat.repository.RepositoryEntry; import org.olat.repository.RepositoryManager; +import org.olat.user.DisplayPortraitController; import org.olat.util.logging.activity.LoggingResourceable; /** @@ -124,14 +126,10 @@ public class EPMapViewController extends BasicController implements Activateable protected void initForm(UserRequest ureq) { + Identity ownerIdentity = EPFrontendManager.getFirstOwnerIdentity(map); + DisplayPortraitController portraitCtr = new DisplayPortraitController(ureq, getWindowControl(), ownerIdentity, false,true,true,false); mainVc.contextPut("map", map); - //FXOLAT-429 :: display the owner of the map (if its not me) -// EPSecurityCallback secCallback = EPSecurityCallbackFactory.getSecurityCallback(ureq, map, ePFMgr); -// if(secCallback.isOwner()) -// mainVc.contextPut("mapowner",""); -// else - mainVc.contextPut("mapowner", EPFrontendManager.getAllOwnersAsString(map)); - + mainVc.put("ownerportrait", portraitCtr.getInitialComponent()); mainVc.contextPut("style", ePFMgr.getValidStyleName(map)); Boolean editMode = editButton == null ? Boolean.FALSE : (Boolean)editButton.getUserObject(); diff --git a/src/main/java/org/olat/portfolio/ui/structel/_content/mapview.html b/src/main/java/org/olat/portfolio/ui/structel/_content/mapview.html index d9aac73c7ea52205bc202b19d417cf43b72661a0..3a22becd1e66cc700f7215361a9a4be1f1904227 100644 --- a/src/main/java/org/olat/portfolio/ui/structel/_content/mapview.html +++ b/src/main/java/org/olat/portfolio/ui/structel/_content/mapview.html @@ -30,7 +30,7 @@ #if(!$r.available("editor")) <div class="b_eportfolio_mapdescr">$map.description</div> - #if($mapowner!="")<div class="b_eportfolio_mapowner">$r.translate('map.owners',$mapowner)</div>#end + <div class="b_eportfolio_mapowner">$r.translate("map.owners","") $r.render("ownerportrait")</div> <div class="b_clearfix"></div> diff --git a/src/main/java/org/olat/user/DisplayPortraitController.java b/src/main/java/org/olat/user/DisplayPortraitController.java index 56364ca79d5677ec282f001122da1183a5f225ec..0fedf2e65b0a2ff6e03566c2a425f0bc510d3ad6 100644 --- a/src/main/java/org/olat/user/DisplayPortraitController.java +++ b/src/main/java/org/olat/user/DisplayPortraitController.java @@ -45,63 +45,108 @@ import org.olat.user.propertyhandlers.GenderPropertyHandler; /** * Initial Date: Sept 08, 2005 * + * Displays a Portrait-Image and/or Full Name of a given User (Identity).<br /> + * the portrait and fullname can be linked to the VCard (which opens in a new browser window / popup) + * * @author Alexander Schneider * - * Comment: */ public class DisplayPortraitController extends BasicController { private VelocityContainer myContent; private Identity portraitIdent; + /** + * most common used constructor<br /> + * will display portrait, no username + * * @param ureq * @param wControl - * @param portrait + * @param portraitIdent + * the identity to display + * @param useLarge + * if set to true, the portrait-image is displayed as "big" + * @param canLinkToHomePage + * if set to true, the portrait is linked to the users homepage */ public DisplayPortraitController(UserRequest ureq, WindowControl wControl, Identity portraitIdent, boolean useLarge, boolean canLinkToHomePage) { + this(ureq,wControl,portraitIdent,useLarge,canLinkToHomePage,false,true); + } + + + + /** + * constructor with more config options<br /> + * use this if you want to display the full name of the user (additionally + * or only) + * + * @param ureq + * @param wControl + * @param portraitIdent + * the identity to display + * @param useLarge + * if set to true, the portrait-image is displayed as "big" + * @param canLinkToHomePage + * if set to true, the portrait is linked to the users homepage + * @param displayUserFullName + * if set to true, the users full name ("firstname lastname") is + * displayed as well + * @param displayPortraitImage + * if set to false, the portrait image will not be displayed + */ + public DisplayPortraitController(UserRequest ureq, WindowControl wControl, Identity portraitIdent, boolean useLarge, boolean canLinkToHomePage, boolean displayUserFullName, boolean displayPortraitImage ) { super(ureq, wControl); myContent = createVelocityContainer("displayportrait"); myContent.contextPut("canLinkToHomePage", canLinkToHomePage ? Boolean.TRUE : Boolean.FALSE); if (portraitIdent == null) throw new AssertException("identity can not be null!"); this.portraitIdent = portraitIdent; - ImageComponent ic = null; - - GenderPropertyHandler genderHander = (GenderPropertyHandler) UserManager.getInstance().getUserPropertiesConfig().getPropertyHandler(UserConstants.GENDER); - String gender = "-"; // use as default - if (genderHander != null) { - gender = genderHander.getInternalValue(portraitIdent.getUser()); - } MediaResource portrait = null; - if (useLarge){ - portrait = DisplayPortraitManager.getInstance().getPortrait(portraitIdent, DisplayPortraitManager.PORTRAIT_BIG_FILENAME); - if (gender.equals("-")) { - myContent.contextPut("portraitCssClass", DisplayPortraitManager.DUMMY_BIG_CSS_CLASS); - } else if (gender.equals("male")) { - myContent.contextPut("portraitCssClass", DisplayPortraitManager.DUMMY_MALE_BIG_CSS_CLASS); - } else if (gender.equals("female")) { - myContent.contextPut("portraitCssClass", DisplayPortraitManager.DUMMY_FEMALE_BIG_CSS_CLASS); + if(displayPortraitImage){ + ImageComponent ic = null; + + GenderPropertyHandler genderHander = (GenderPropertyHandler) UserManager.getInstance().getUserPropertiesConfig().getPropertyHandler(UserConstants.GENDER); + String gender = "-"; // use as default + if (genderHander != null) { + gender = genderHander.getInternalValue(portraitIdent.getUser()); } - } else { - portrait = DisplayPortraitManager.getInstance().getPortrait(portraitIdent, DisplayPortraitManager.PORTRAIT_SMALL_FILENAME); - if (gender.equals("-")) { - myContent.contextPut("portraitCssClass", DisplayPortraitManager.DUMMY_SMALL_CSS_CLASS); - } else if (gender.equals("male")) { - myContent.contextPut("portraitCssClass", DisplayPortraitManager.DUMMY_MALE_SMALL_CSS_CLASS); - } else if (gender.equals("female")) { - myContent.contextPut("portraitCssClass", DisplayPortraitManager.DUMMY_FEMALE_SMALL_CSS_CLASS); + + if (useLarge){ + portrait = DisplayPortraitManager.getInstance().getPortrait(portraitIdent, DisplayPortraitManager.PORTRAIT_BIG_FILENAME); + if (gender.equals("-")) { + myContent.contextPut("portraitCssClass", DisplayPortraitManager.DUMMY_BIG_CSS_CLASS); + } else if (gender.equals("male")) { + myContent.contextPut("portraitCssClass", DisplayPortraitManager.DUMMY_MALE_BIG_CSS_CLASS); + } else if (gender.equals("female")) { + myContent.contextPut("portraitCssClass", DisplayPortraitManager.DUMMY_FEMALE_BIG_CSS_CLASS); + } + } else { + portrait = DisplayPortraitManager.getInstance().getPortrait(portraitIdent, DisplayPortraitManager.PORTRAIT_SMALL_FILENAME); + if (gender.equals("-")) { + myContent.contextPut("portraitCssClass", DisplayPortraitManager.DUMMY_SMALL_CSS_CLASS); + } else if (gender.equals("male")) { + myContent.contextPut("portraitCssClass", DisplayPortraitManager.DUMMY_MALE_SMALL_CSS_CLASS); + } else if (gender.equals("female")) { + myContent.contextPut("portraitCssClass", DisplayPortraitManager.DUMMY_FEMALE_SMALL_CSS_CLASS); + } } - } - myContent.contextPut("hasPortrait", (portrait != null) ? Boolean.TRUE : Boolean.FALSE); - myContent.contextPut("identityKey", portraitIdent.getKey().toString()); - - if (portrait != null){ + + if (portrait != null){ ic = new ImageComponent("image"); ic.setMediaResource(portrait); myContent.put(ic); + } } + + myContent.contextPut("hasPortrait", (portrait != null) ? Boolean.TRUE : Boolean.FALSE); + myContent.contextPut("identityKey", portraitIdent.getKey().toString()); + myContent.contextPut("displayUserFullName", displayUserFullName); + myContent.contextPut("firstname", portraitIdent.getUser().getProperty(UserConstants.FIRSTNAME, null)); + myContent.contextPut("lastname",portraitIdent.getUser().getProperty(UserConstants.LASTNAME, null)); + + putInitialPanel(myContent); } diff --git a/src/main/java/org/olat/user/_content/displayportrait.html b/src/main/java/org/olat/user/_content/displayportrait.html index 44b83f5c6454122108f3d79c30199c623d7f1a17..b335efe7c5131f3e9236069661d816c8ae422b51 100644 --- a/src/main/java/org/olat/user/_content/displayportrait.html +++ b/src/main/java/org/olat/user/_content/displayportrait.html @@ -1,3 +1,13 @@ +#if ($displayUserFullName) + #if ($canLinkToHomePage) + <a href="javascript:void(o_openPopUp('$r.commandURI("showuserinfo")', '${identityKey}', '900', '600', false))"> + $firstname $lastname + </a> + #else + $firstname $lastname + #end +#end + #if ($hasPortrait) #if ($canLinkToHomePage) <a href="javascript:void(o_openPopUp('$r.commandURI("showuserinfo")', '${identityKey}', '900', '600', false))">