DotNetNuke User Profile v5.4 - Issue 58
Last Post 06/27/2011 6:08 PM by Joseph Craig. 4 Replies.
Author Messages
Lee Sykes
DNN Creative Staff
Nuke Master VI
Nuke Master VI
Posts:4945


--
06/30/2010 10:38 AM
    Add any comments or questions regarding the DotNetNuke User Profile v5.4 tutorial from Issue 58
    Lee Sykes
    Site Administrator
    Subscribe to the website : DotNetNuke Video Tutorials : The Skinning Toolkit : DotNetNuke Podcasts

    Twitter: www.twitter.com/DNNCreative

    Lee Sykes's Facebook Profile
    jerimiahpettigrew
    Nuke Newbie
    Nuke Newbie
    Posts:2


    --
    07/29/2010 11:05 AM
    How do you make the "my folder" option the only visible option for the profile image upload....instead of seeing all of the other folders...giving users the options to upload their images to folders that you dont want images stored in
    Joseph Craig
    DNN MVP
    Posts:11667


    --
    07/29/2010 9:29 PM
    In the file manager, set the permissions so that logged in users (registered users) have write permission only to that folder.  You might want to hide most folders from all but admins, but make sure that doing so doesn't break anything on your site.

    Joe Craig, Patapsco Research Group
    Complete DNN Support
    d_atl
    Nuke Newbie
    Nuke Newbie
    Posts:2


    --
    06/27/2011 2:25 PM
    Is there a way to show the user profiles for a role?
    IE. I have a role "Manager" and want a page Managers that list each user profile name, picture, description for the role "Managers"
    Joseph Craig
    DNN MVP
    Posts:11667


    --
    06/27/2011 6:08 PM
    No, that functionality doesn't exist.

    However ...it wouldn't be too terribly hard to do. You'll have to know some programming. I'd start with Joe Brinkman's article at http://blog.theaccidentalgeek.com/p...Nuke.aspx. This shows you how to display a single profile. I'd wrap that inside something that selects all of the users in a role.

    I've actually "sort of" done this for another application (using Razor). Here is my sloppy Razor code. You can install a Razor Host module on an administrative page, and paste the code in as a new script. The first line of the script shows how to specify the role, in this case it is "subscribers." You'll have to work a little bit harder if you want to have the role selectable.


    @using DotNetNuke.Security.Roles
    @using DotNetNuke.Entities.Users
    @using DotNetNuke.Common.Utilities
    @using DotNetNuke.Common
    @using DotNetNuke.Entities.Profile
    @using DotNetNuke.Entities.Portals
    @using System.Web

    @{
    var users = (new RoleController()).GetUsersByRoleName(Dnn.Portal.PortalId, "Subscribers");
    }


    @foreach (UserInfo user in users)
    {


    Profile Photo for @user.DisplayName

    @user.FirstName @user.LastName
    @GetFormattedCityState(user.Profile, " ( {0} )")


    @GetFormattedProfileProperty(user.Profile, "JobTitle", @"
    {0}
    ")



    @Server.HtmlDecode(@GetFormattedProfileProperty(user.Profile, "Biography", "
    {0}
    "))

    }


    @functions {
    public static string GetProfileUrl(UserProfile profile)
    {
    string strPhotoURL = Globals.ApplicationPath + "/images/no_avatar.gif";
    ProfilePropertyDefinition objProperty = profile.GetProperty("Photo");
    if (objProperty != null &&
    string.IsNullOrEmpty(objProperty.PropertyValue) == false &&
    objProperty.Visibility == UserVisibilityMode.AllUsers)
    {
    DotNetNuke.Services.FileSystem.FileController objFiles = new DotNetNuke.Services.FileSystem.FileController();
    DotNetNuke.Services.FileSystem.FileInfo objFile = objFiles.GetFileById(int.Parse(objProperty.PropertyValue), objProperty.PortalId);

    // There is a bug in the Photo profile property that stores the host photo
    // in the Current Portal and not in the host portal (-1). To overcome this
    // bug we just look in the current Portal if we can't find a photo in the Profile Portal
    if (objFile == null)
    {
    objFile = objFiles.GetFileById(int.Parse(objProperty.PropertyValue), objProperty.PortalId);
    }

    if (objFile != null)
    {
    PortalInfo objPortal = (new PortalController()).GetPortal(objFile.PortalId);
    if (objPortal != null)
    {
    strPhotoURL = string.Format("{0}/{1}/{2}", Globals.ApplicationPath, objPortal.HomeDirectory, objFile.RelativePath);
    }
    }
    }
    return strPhotoURL;
    }

    public static string GetProfileProperty(UserProfile profile, string propertyName)
    {
    ProfilePropertyDefinition objProperty = profile.GetProperty(propertyName);
    if (objProperty == null || string.IsNullOrEmpty(objProperty.PropertyValue)) return string.Empty;

    return objProperty.PropertyValue;
    }

    public static string GetFormattedProfileProperty(UserProfile profile, string propertyName, string tagformat)
    {
    string propertyval = GetProfileProperty(profile, propertyName);
    if (propertyval != string.Empty)
    {
    return string.Format(tagformat, @propertyval);
    }

    return string.Empty;
    }

    public static string GetFormattedCityState(UserProfile profile, string tagformat)
    {
    string theCity = GetProfileProperty(profile, "City");
    string theState = GetProfileProperty(profile, "Region");
    string theString = string.Empty;

    if( theCity != string.Empty )
    {
    theString = theCity;
    if( theState != string.Empty )
    {
    theString += ", " + theState;
    }
    else theString = theState;
    }

    if (theString != string.Empty)
    {
    return string.Format(tagformat, @theString);
    }

    return string.Empty;
    }

    }




    Joe Craig, Patapsco Research Group
    Complete DNN Support


    ---