Skip to content
Snippets Groups Projects
Commit d4c24662 authored by strentini's avatar strentini
Browse files

FXOLAT-431 : add link to VCard of mapauthor -> extend...

FXOLAT-431 : add link to VCard of mapauthor -> extend displayPortraitController to optionally display full name
parent 32218684
No related branches found
No related tags found
No related merge requests found
......@@ -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() {}
......
......@@ -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();
......
......@@ -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>
......
......@@ -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);
}
......
#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))">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment