Advanced Techniques - Display Intrexx Share profile pictures in applications

1. General

Every user can add a picture to their profile in Intrexx Share. This workshop demonstrates how these profile pictures can also be used in other applications - e.g. the profile picture of the current user or of the user who last edited a data record. Background knowledge application development are of an advantage here.

2. Display the profile picture of the current user

Before the profile pictures can be shown in applications, two conditions need to be checked:
  1. Does the portal have Intrexx Share?
  2. If yes, does the user have a profile?


Create a grouping for displaying the profile picture and define that it should only bedisplayed if a condition is met. Two if conditions are used here to check whether the portal has Intrexx Share. If yes, it then checks whether the current user has an Intrexx Share. Copy the following Velocity script and replace the name of the "simplegroup" with the corresponding name of the grouping in your application:
#if($RtCache.existsApplication("AB4B031834F042FCADB595DF1923B768C7773F00"))
   #set($share = $ShareCallable)
   #set($l_strUserGuid = $User.getGuid())
   #set($profileId = $share.getProfileId($ProcessingContext, $l_strUserGuid))
   #set($hasShareProfile = $share.hasProfile($ProcessingContext, $profileId))
   #if($hasShareProfile)
      #set($show_simplegroup28B85008 = true)
   #else
      #set($show_simplegroup28B85008 = false)
   #end
#end


Drag a VTL include with the following script into the grouping to identify the Share profile picture of the current user via their ID / GUID and then display this.
#set( $recentAppGuid = $Request.get("rq_AppGuid") )
#parse("internal/application/resource/${recentAppGuid}/makro.vmi")
#set( $srcAnonymousImageLink    = "images/assets/share/anonymous_profile.png")
#set( $recentUser = ($User.getId()))
#set( $recentUserGuid = $User.getGuid())
#set( $recentUserName= $User.getFullName())
#if( !$ObjectHelper.isNull($recentUserGuid) )
   #getUserInfo( $recentUserGuid $recentUserName "big")
#else
   <img class="Share_Container_Image_Border" src="${srcAnonymousImageLink}" border="0" width="55" height="55"  #if( !$ObjectHelper.isNull($p_strUsername) ) alt="${p_strUsername}" title="${p_strUsername}" #end/>
#end


Before the application can be published and tested, we need to create a file called "makro.vmi" with the following script:
#set( $srcDefaultImageLink = "images/assets/share/dummy_man.png")
#set( $srcAnonymousImageLink = "images/assets/share/anonymous_profile.png")
#set( $shareAppGuid = "AB4B031834F042FCADB595DF1923B768C7773F00" )
#set( $isShareAvailable = !$ObjectHelper.isNull($RtCache.getApplication($shareAppGuid)) )

##########################
### Userinfo
##########################
#macro(getUserInfo $p_strUserGuid $p_strUsername $p_strSize )
#if( $p_strSize == "big")
   #set( $imageWidth = 55 )
   #set( $imageHeight = 55 )
 #elseif( $p_strSize == "small" )
   #set( $imageWidth = 30 )
   #set( $imageHeight = 30 )
    #else
       #set( $imageWidth = 40 )
       #set( $imageHeight = 40 )
    #end

#set( $CurrUser = $DS.getUser().getUserFromGuid($DbConnection, $p_strUserGuid) )
#set( $strUserMailBiz = $CurrUser.getEmailBiz() )
#set( $iUserID = $CurrUser.getId() )
#set( $userImage = $FileUrlBuilder.getDownloadUrl($ProcessingContext, "419575A135C829CE5D0C16251A1D2A84B18B4F3C", "${iUserID}"))

#if( $isShareAvailable == true )
   ### Check, if User has share-profile
   #set( $hasShareProfile = $ShareCallable.hasProfile( $ProcessingContext, $p_strUserGuid ))
   #if( $hasShareProfile == true)
      #set( $userProfile = $ShareCallable.getProfileFromGuid( $ProcessingContext, $p_strUserGuid ))
      #if( !$ObjectHelper.isNull( $userProfile.getImage().getFirstFile() ) )
      $ShareCallable.getImageLink($ProcessingContext, "Share_Container_Image_Border", $userProfile.getImage(), $p_strUserGuid, "share.profile.page.viewByOther", "${I18N.SHARE_PERSONAL_FEED}: $!{p_strUsername}", false, $imageWidth, $imageHeight)
      #else
         #if( !$ObjectHelper.isNull($userImage) )
            <img class="" src="${userImage}" border="0" width="${imageWidth}" height="${imageHeight}"  
            #if( !$ObjectHelper.isNull($p_strUsername) ) alt="${p_strUsername}" title="${p_strUsername}" 
            #end/>
         #else
            <a href="mailto:${strUserMailBiz}" ><img class="Share_Container_Image_Border" src="${srcAnonymousImageLink}" border="0" width="${imageWidth}" height="${imageHeight}" alt="mailto:${strUserMailBiz}" title="mailto:${strUserMailBiz}" /></a>
      #end
   #end
#else
   #if( !$ObjectHelper.isNull($userImage) )
      <img class="" src="${userImage}" border="0" width="${imageWidth}" height="${imageHeight}"  #if( !$ObjectHelper.isNull($p_strUsername) ) alt="${p_strUsername}" title="${p_strUsername}" #end/>
   #else
	<a href="mailto:${strUserMailBiz}" ><img class="Share_Container_Image_Border" src="${srcAnonymousImageLink}" border="0" width="${imageWidth}" height="${imageHeight}" alt="mailto:${strUserMailBiz}" title="mailto:${strUserMailBiz}" /></a>
#end
#end
#else
   #if( !$ObjectHelper.isNull($userImage) )
      <img class="" src="${userImage}" border="0" width="${imageWidth}" height="${imageHeight}"  #if( !$ObjectHelper.isNull($p_strUsername) ) alt="${p_strUsername}" title="${p_strUsername}" #end/>
#else
   <img class="Share_Container_Image_Border" src="${srcDefaultImageLink}" border="0" width="${imageWidth}" height="${imageHeight}"  #if( !$ObjectHelper.isNull($p_strUsername) ) alt="${p_strUsername}" title="${p_strUsername}" #end/>
         #end
      #end
   #end
The file "makro.vmi" can be created directly in the Velocity file manager. The file "script.vmi", which we created in the previous step, is still defined in the "Refer to a file in the application package" option. Afterwards, the application can be published and tested.

3. Display the profile picture of last editor




To display the profile picture of the user who last edited the data record, add a button column to the respective table. Edit the column and remove the predefined image.



Go to the Options section of the General tab in the button properties and activate the setting "Display if condition met". Insert the following script beneath the first line:
#if($RtCache.existsApplication("AB4B031834F042FCADB595DF1923B768C7773F00"))
   #set( $recentAppGuid = $Request.get("rq_AppGuid") )
   #parse("internal/application/resource/${recentAppGuid}/makro.vmi")
   #set( $srcAnonymousImageLink    = "images/assets/share/anonymous_profile.png")
   #set( $recentUser = $DS.getUser().getUserFromId($DbConnection, $TextUtil.parseInt($drRecord.getUserId())) )
   #set( $recentUserGuid = $recentUser.getGuid())
   #set( $recentUserName= $recentUser.getFullName())
   #if( !$ObjectHelper.isNull($recentUserGuid) )
      #getUserInfo( $recentUserGuid $recentUserName "big")
   #else
      <img class="Share_Container_Image_Border" src="${srcAnonymousImageLink}" border="0" width="55" height="55"
	  #if( !$ObjectHelper.isNull($p_strUsername) ) alt="${p_strUsername}" title="${p_strUsername}" #end/>
   #end
#end
In this case as well, the code begins by checking whether the portal has Intrexx Share. Afterwards, the user ID of the user who last edited the record is used to identify and display their Intrexx Share profile picture. Instead of the profile picture of the last editor, you can also display the profile picture of the data record creator/owner. Modify the script above at line 5 as follows:
#set( $recentUser = $DS.getUser().getUserFromId($DbConnection, $drRecord.getRecordOwner()))