Ejemplo n.º 1
0
    public override bool LoadData(ActivityInfo ai)
    {
        if ((ai == null) || !ModuleEntry.IsModuleLoaded(ModuleEntry.COMMUNITY))
        {
            return(false);
        }

        switch (ai.ActivityType)
        {
        case PredefinedActivityType.JOIN_GROUP:
        case PredefinedActivityType.LEAVE_GROUP:
            break;

        default:
            return(false);
        }

        if (ai.ActivityItemID > 0)
        {
            BaseInfo binfo = ModuleCommands.CommunityGetGroupInfo(ai.ActivityItemID);
            if (binfo != null)
            {
                string groupDisplayName = binfo.GetStringValue("GroupDisplayName", GetString("general.na"));
                ucDetails.AddRow("om.activitydetails.groupname", groupDisplayName);
            }
        }

        return(true);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Reload data.
    /// </summary>
    public override void ReloadData()
    {
        requestedGroupId = ValidationHelper.GetInteger(ContextMenu.Parameter, 0);

        DataTable table = new DataTable();

        table.Columns.Add("ActionIcon");
        table.Columns.Add("ActionDisplayName");
        table.Columns.Add("ActionScript");

        // Add only if community is present
        if (CommunityPresent)
        {
            // Get resource strings prefix
            string resourcePrefix = ContextMenu.ResourcePrefix;

            // View group profile
            string profileUrl = "";

            // Get group profile URL
            GeneralizedInfo infoObj = ModuleCommands.CommunityGetGroupInfo(requestedGroupId);
            if (infoObj != null)
            {
                profileUrl = ResolveUrl(CMSContext.GetUrl(ModuleCommands.CommunityGetGroupProfilePath(infoObj.ObjectCodeName, CMSContext.CurrentSiteName)));
            }

            table.Rows.Add(new object[] { "groupprofile.png", ResHelper.GetString(resourcePrefix + ".viewgroup|group.viewgroup"), "window.location.replace('" + profileUrl + "');" });
            if (!currentUser.IsGroupMember(requestedGroupId))
            {
                table.Rows.Add(new object[] { "jointhegroup.png", ResHelper.GetString(resourcePrefix + ".joingroup|group.joingroup"), !currentUser.IsPublic() ? "ContextJoinTheGroup(GetContextMenuParameter('" + ContextMenu.MenuID + "'))" : "ContextRedirectToSignInUrl()" });
            }
            else
            {
                table.Rows.Add(new object[] { "leavethegroup.png", ResHelper.GetString(resourcePrefix + ".leavegroup|group.leavegroup"), !currentUser.IsPublic() ? "ContextLeaveTheGroup(GetContextMenuParameter('" + ContextMenu.MenuID + "'))" : "ContextRedirectToSignInUrl()" });
            }

            if (infoObj != null)
            {
                // Display Manage the group link if user is logged as group administrator and user is visiting a group page
                if (currentUser.IsGroupAdministrator(requestedGroupId) || currentUser.IsGlobalAdministrator)
                {
                    string managementUrl = ResolveUrl(TreePathUtils.GetUrl(ModuleCommands.CommunityGetGroupManagementPath(infoObj.ObjectCodeName, CMSContext.CurrentSiteName)));

                    table.Rows.Add(new object[] { "managegroup.png", ResHelper.GetString(resourcePrefix + ".managegroup|group.managegroup"), !currentUser.IsPublic() ? " window.location.replace('" +
                                                  managementUrl + "');" : "ContextRedirectToSignInUrl()" });
                }
            }
        }

        // Add count column
        DataColumn countColumn = new DataColumn();

        countColumn.ColumnName   = "Count";
        countColumn.DefaultValue = table.Rows.Count;

        table.Columns.Add(countColumn);
        repItem.DataSource = table;
        repItem.DataBind();
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Returns groupguid for community group specified as an URL parameter of the current request.
    /// </summary>
    private static Guid GetCurrentGroupGuid()
    {
        // Try to get the group info from the request items collection
        BaseInfo gi = (BaseInfo)RequestStockHelper.GetItem("CurrentGroup", true);

        if (gi == null)
        {
            // Try to get group by its GroupID first
            int groupId = QueryHelper.GetInteger("groupid", 0);
            if (groupId > 0)
            {
                gi = ModuleCommands.CommunityGetGroupInfo(groupId);
            }

            // If group was not found by its GroupID
            if (gi == null)
            {
                // Try to get group by its GroupName
                string groupName = QueryHelper.GetString("groupname", "");
                if (groupName != "")
                {
                    gi = ModuleCommands.CommunityGetGroupInfoByName(groupName, CMSContext.CurrentSiteName);
                }
            }

            if (gi == null)
            {
                // Try to get group by its GroupName
                Guid groupGuid = QueryHelper.GetGuid("groupguid", Guid.Empty);
                if (groupGuid != Guid.Empty)
                {
                    return(groupGuid);
                }
            }

            // If group was not found
            if ((gi == null) && (CMSContext.CurrentPageInfo != null))
            {
                // Try to get group from current document
                groupId = CMSContext.CurrentPageInfo.NodeGroupID;
                if (groupId > 0)
                {
                    gi = ModuleCommands.CommunityGetGroupInfo(groupId);
                }
            }

            // Save the group to the request items if new group was loaded from DB
            RequestStockHelper.Add("CurrentGroup", gi, true);
        }

        return(gi.Generalized.ObjectGUID);
    }
Ejemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Initialize javascripts
        ScriptHelper.RegisterDialogScript(Page);
        btnChange.OnClientClick = "modalDialog('" + ResolveUrl("~/CMSAdminControls/UI/Dialogs/ChangeGroup.aspx") + "?nodeid=" + mNodeId + "&siteid=" + mSiteId + "&groupid=" + Value + "','GroupSelector', 780, 190); return false;";
        ltlScript.Text          = ScriptHelper.GetScript("function ReloadOwner(){" + Page.ClientScript.GetPostBackEventReference(btnHidden, string.Empty) + "}");

        int groupId = ValidationHelper.GetInteger(Value, 0);

        if (groupId > 0)
        {
            // Display current owner
            GeneralizedInfo gi = ModuleCommands.CommunityGetGroupInfo(groupId);
            if (gi != null)
            {
                txtGroups.Text = ValidationHelper.GetString(gi.GetValue("GroupDisplayName"), String.Empty);
            }
        }
    }
    /// <summary>
    /// Check whether user is group administrator or has manage permission.
    /// </summary>
    /// <param name="groupId">Comunnity group ID</param>
    /// <param name="permissionName">Permission name</param>
    private static void CheckGroupPermissions(int groupId, string permissionName)
    {
        // Get current group
        GeneralizedInfo group = ModuleCommands.CommunityGetGroupInfo(groupId);

        if (group != null)
        {
            // Check if group is placed on current site
            int groupSiteID = ValidationHelper.GetInteger(group.GetProperty("GroupSiteID"), 0);
            if (groupSiteID != SiteContext.CurrentSiteID)
            {
                RedirectToAccessDenied(ResHelper.GetString("community.group.notassigned"));
            }
        }

        if (!MembershipContext.AuthenticatedUser.IsGroupAdministrator(groupId))
        {
            // Check permissions
            if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("CMS.Groups", permissionName))
            {
                RedirectToAccessDenied("CMS.Groups", permissionName);
            }
        }
    }
Ejemplo n.º 6
0
    /// <summary>
    /// Sets image  url, width and height.
    /// </summary>
    protected void SetImage()
    {
        Visible = false;

        // Only if display picture is allowed
        if (DisplayPicture)
        {
            string imageUrl = ResolveUrl("~/CMSModules/Avatars/CMSPages/GetAvatar.aspx?avatarguid=");

            bool isGravatar = false;

            // Is user id set? => Get user info
            if (mUserId > 0)
            {
                // Get user info
                UserInfo ui = UserInfoProvider.GetUserInfo(mUserId);
                if (ui != null)
                {
                    switch (UserAvatarType)
                    {
                    case AvatarInfoProvider.AVATAR:
                        AvatarID = ui.UserAvatarID;
                        if (AvatarID <= 0)     // Backward compatibility
                        {
                            if (ui.UserPicture != "")
                            {
                                // Get picture filename
                                string filename = ui.UserPicture.Remove(ui.UserPicture.IndexOfCSafe('/'));
                                string ext      = Path.GetExtension(filename);
                                imageUrl += filename.Substring(0, (filename.Length - ext.Length));
                                imageUrl += "&extension=" + ext;
                                Visible   = true;
                            }
                            else if (UseDefaultAvatar)
                            {
                                UserGenderEnum gender = (UserGenderEnum)ValidationHelper.GetInteger(ui.UserSettings.UserGender, 0);
                                AvatarInfo     ai     = AvatarInfoProvider.GetDefaultAvatar(gender);

                                if (ai != null)
                                {
                                    AvatarID = ai.AvatarID;
                                }
                            }
                        }
                        break;

                    case AvatarInfoProvider.GRAVATAR:
                        int sideSize = mWidth > 0 ? mWidth : SettingsKeyInfoProvider.GetIntValue(SiteContext.CurrentSiteName + ".CMSAvatarMaxSideSize");
                        imageUrl   = AvatarInfoProvider.CreateGravatarLink(ui.Email, ui.UserSettings.UserGender, sideSize, SiteContext.CurrentSiteName);
                        isGravatar = true;
                        Visible    = true;
                        AvatarID   = 0;
                        break;
                    }
                }
            }
            else
            {
                // If user is public try get his gravatar
                if (UserAvatarType == AvatarInfoProvider.GRAVATAR)
                {
                    int sideSize = mWidth > 0 ? mWidth : SettingsKeyInfoProvider.GetIntValue(SiteContext.CurrentSiteName + ".CMSAvatarMaxSideSize");
                    imageUrl   = AvatarInfoProvider.CreateGravatarLink(UserEmail, (int)UserGenderEnum.Unknown, sideSize, SiteContext.CurrentSiteName);
                    isGravatar = true;
                    Visible    = true;
                    AvatarID   = 0;
                }
            }

            // Is group id set? => Get group info
            if (mGroupId > 0)
            {
                // Get group info trough module commands
                GeneralizedInfo gi = ModuleCommands.CommunityGetGroupInfo(mGroupId);
                if (gi != null)
                {
                    AvatarID = ValidationHelper.GetInteger(gi.GetValue("GroupAvatarID"), 0);
                }

                if ((AvatarID <= 0) && UseDefaultAvatar)
                {
                    AvatarInfo ai = AvatarInfoProvider.GetDefaultAvatar(DefaultAvatarTypeEnum.Group);
                    if (ai != null)
                    {
                        AvatarID = ai.AvatarID;
                    }
                }
            }

            if (AvatarID > 0)
            {
                AvatarInfo ai = AvatarInfoProvider.GetAvatarInfoWithoutBinary(AvatarID);
                if (ai != null)
                {
                    imageUrl += ai.AvatarGUID.ToString();
                    Visible   = true;
                }
            }


            // If item was found
            if (Visible)
            {
                if (!isGravatar)
                {
                    if (KeepAspectRatio)
                    {
                        imageUrl += "&maxsidesize=" + (Width > Height ? Width : Height);
                    }
                    else
                    {
                        imageUrl += "&width=" + Width + "&height=" + Height;
                    }
                }

                imageUrl      = URLHelper.EncodeQueryString(imageUrl);
                ltlImage.Text = "<img alt=\"" + GetString("general.avatar") + "\" src=\"" + imageUrl + "\" />";

                // Render outer div with specific CSS class
                if (RenderOuterDiv)
                {
                    ltlImage.Text = "<div class=\"" + OuterDivCSSClass + "\">" + ltlImage.Text + "</div>";
                }
            }
        }
    }
Ejemplo n.º 7
0
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Check MODIFY permission for forums
        if (!CheckPermissions("cms.forums", PERMISSION_MODIFY))
        {
            return;
        }

        // Get community group identificators
        int  communityGroupId   = 0;
        Guid communityGroupGuid = Guid.Empty;

        if ((ForumGroup != null) && LicenseKeyInfoProvider.IsFeatureAvailable(FeatureEnum.Groups))
        {
            BaseInfo communityGroup = ModuleCommands.CommunityGetGroupInfo(ForumGroup.GroupGroupID);

            if (communityGroup != null)
            {
                communityGroupId   = communityGroup.Generalized.ObjectID;
                communityGroupGuid = communityGroup.Generalized.ObjectGUID;
            }
        }

        string codeName = txtForumName.Text.Trim();

        // Get safe code name for simple display mode
        if (DisplayMode == ControlDisplayModeEnum.Simple)
        {
            codeName = ValidationHelper.GetCodeName(txtForumDisplayName.Text.Trim(), 50) + "_group_" + communityGroupGuid;
        }

        // Check required fields
        string errorMessage = new Validator().NotEmpty(txtForumDisplayName.Text, GetString("Forum_General.EmptyDisplayName")).NotEmpty(codeName, GetString("Forum_General.EmptyCodeName")).Result;

        if (errorMessage == String.Empty && !ValidationHelper.IsCodeName(codeName))
        {
            errorMessage = GetString("general.errorcodenameinidentifierformat");
        }

        if (String.IsNullOrEmpty(errorMessage))
        {
            if (SiteContext.CurrentSite != null)
            {
                // If forum with given name already exists show error message
                if (ForumInfoProvider.GetForumInfo(codeName, SiteContext.CurrentSiteID, communityGroupId) != null)
                {
                    ShowError(GetString("Forum_Edit.ForumAlreadyExists"));
                    return;
                }

                // Set properties to newly created object
                Forum.ForumSiteID   = SiteContext.CurrentSite.SiteID;
                Forum.ForumIsLocked = chkForumLocked.Checked;
                Forum.ForumOpen     = chkForumOpen.Checked;
                chkForumDisplayEmails.SetThreeStateValue(Forum, "ForumDisplayEmails");
                Forum.ForumDescription = txtForumDescription.Text.Trim();
                chkForumRequireEmail.SetThreeStateValue(Forum, "ForumRequireEmail");
                Forum.ForumDisplayName     = txtForumDisplayName.Text.Trim();
                Forum.ForumName            = codeName;
                Forum.ForumGroupID         = mGroupId;
                Forum.ForumModerated       = chkForumModerated.Checked;
                Forum.ForumAccess          = 40000;
                Forum.ForumPosts           = 0;
                Forum.ForumThreads         = 0;
                Forum.ForumPostsAbsolute   = 0;
                Forum.ForumThreadsAbsolute = 0;
                Forum.ForumOrder           = 0;
                chkCaptcha.SetThreeStateValue(Forum, "ForumUseCAPTCHA");
                Forum.ForumCommunityGroupID = communityGroupId;

                // For simple display mode skip some properties
                if (DisplayMode != ControlDisplayModeEnum.Simple)
                {
                    Forum.ForumBaseUrl           = txtBaseUrl.Text.Trim();
                    Forum.ForumUnsubscriptionUrl = txtUnsubscriptionUrl.Text.Trim();
                    chkUseHTML.SetThreeStateValue(Forum, "ForumHTMLEditor");

                    if (chkInheritBaseUrl.Checked)
                    {
                        Forum.ForumBaseUrl = null;
                    }

                    if (chkInheritUnsubscribeUrl.Checked)
                    {
                        Forum.ForumUnsubscriptionUrl = null;
                    }
                }

                // Check license
                if (ForumInfoProvider.LicenseVersionCheck(RequestContext.CurrentDomain, FeatureEnum.Forums, ObjectActionEnum.Insert))
                {
                    ForumInfoProvider.SetForumInfo(Forum);
                    mForumId = Forum.ForumID;
                    RaiseOnSaved();
                }
                else
                {
                    ShowError(GetString("LicenseVersionCheck.Forums"));
                }
            }
        }
        else
        {
            ShowError(errorMessage);
        }
    }
Ejemplo n.º 8
0
    /// <summary>
    /// OnLoad override - check wheter filter is set.
    /// </summary>
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        // Hide default site filter label
        siteFilter.ShowLabel = false;
        siteFilter.Selector.OnSelectionChanged += Filter_Changed;

        // Check if site filter should be displayed
        if (ShowSiteFilter)
        {
            lblSite.ResourceString = "general.site";
            lblSite.DisplayColon   = true;
        }
        else
        {
            plcSite.Visible = false;
        }

        // Check if group filter should be displayed
        if (GroupID > 0)
        {
            // Initialize DDL
            if (!RequestHelper.IsPostBack())
            {
                string          groupName = String.Empty;
                GeneralizedInfo gi        = ModuleCommands.CommunityGetGroupInfo(GroupID);
                if (gi != null)
                {
                    groupName = ValidationHelper.GetString(gi.GetValue("GroupDisplayName"), "");
                }

                // Initialize DDL using obtained group name
                switch (siteFilter.FilterMode)
                {
                case "user":
                    drpGroup.Items.Add(new ListItem(ResHelper.GetString("sitegroupselector.generalusers"), "0"));
                    if (!String.IsNullOrEmpty(groupName))
                    {
                        drpGroup.Items.Add(new ListItem(groupName, GroupID.ToString()));
                    }
                    break;

                case "role":
                    drpGroup.Items.Add(new ListItem(ResHelper.GetString("sitegroupselector.generalroles"), "0"));
                    if (!String.IsNullOrEmpty(groupName))
                    {
                        drpGroup.Items.Add(new ListItem(groupName, GroupID.ToString()));
                    }
                    break;
                }
            }

            // Initialize group label
            lblGroup.Visible        = true;
            lblGroup.ResourceString = "general.group";
            lblGroup.DisplayColon   = true;
        }
        else
        {
            plcGroup.Visible = false;
        }

        // Generate current where condition
        if (ShowSiteFilter)
        {
            WhereCondition = SqlHelper.AddWhereCondition(siteFilter.WhereCondition, GenerateWhereCondition(SelectedGroupID));
        }
        else
        {
            WhereCondition = GenerateWhereCondition(SelectedGroupID);
        }
    }
Ejemplo n.º 9
0
    /// <summary>
    /// Initializes form controls.
    /// </summary>
    private void SetupControls()
    {
        // Button
        btnOk.Text = GetString("general.ok");

        // Set tooltips
        lblProjectDisplayName.ToolTip   = GetString("pm.project.tooltip.displayname");
        lblProjectName.ToolTip          = GetString("pm.project.tooltip.codename");
        lblProjectDescription.ToolTip   = GetString("pm.project.tooltip.description");
        lblProjectStartDate.ToolTip     = GetString("pm.project.tooltip.startdate");
        lblProjectDeadline.ToolTip      = GetString("pm.project.tooltip.deadline");
        lblProjectProgress.ToolTip      = GetString("pm.project.tooltip.progress");
        lblProjectOwner.ToolTip         = GetString("pm.project.tooltip.owner");
        lblProjectStatusID.ToolTip      = GetString("pm.project.tooltip.status");
        lblProjectPage.ToolTip          = GetString("pm.project.tooltip.page");
        lblProjectAllowOrdering.ToolTip = GetString("pm.project.tooltip.allowOrdering");

        // Disable validators if it is required
        if (DisableOnSiteValidators)
        {
            this.rfvProjectName.Enabled        = false;
            this.rfvProjectDisplayName.Enabled = false;
        }

        // Validator texts
        this.rfvProjectName.ErrorMessage        = GetString("general.requirescodename");
        this.rfvProjectDisplayName.ErrorMessage = GetString("general.requiresdisplayname");

        this.pageSelector.IsLiveSite          = this.IsLiveSite;
        this.pageSelector.EnableSiteSelection = false;

        // Page selector - show only documents of the current group
        if (CommunityGroupID > 0)
        {
            GeneralizedInfo infoObj = ModuleCommands.CommunityGetGroupInfo(CommunityGroupID);
            if (infoObj != null)
            {
                Guid groupNodeGUID = ValidationHelper.GetGuid(infoObj.GetValue("GroupNodeGUID"), Guid.Empty);

                if (groupNodeGUID != Guid.Empty)
                {
                    TreeProvider treeProvider = new TreeProvider();
                    TreeNode     node         = treeProvider.SelectSingleNode(groupNodeGUID, TreeProvider.ALL_CULTURES, CMSContext.CurrentSiteName);
                    if (node != null)
                    {
                        this.pageSelector.ContentStartingPath = node.NodeAliasPath;
                    }
                }
                else
                {
                    this.pageSelector.Enabled = false;
                }
            }
        }

        this.userSelector.IsLiveSite             = this.IsLiveSite;
        this.userSelector.SiteID                 = CMSContext.CurrentSiteID;
        this.userSelector.ShowSiteFilter         = false;
        this.userSelector.GroupID                = CommunityGroupID;
        this.userSelector.ApplyValueRestrictions = false;

        // Hide hidden & disabled user on live site
        if (this.IsLiveSite)
        {
            this.userSelector.HideHiddenUsers      = true;
            this.userSelector.HideDisabledUsers    = true;
            this.userSelector.HideNonApprovedUsers = true;
        }

        // Hide page selector on live site
        if (!this.ShowPageSelector)
        {
            this.plcProjectPage.Visible = false;
        }

        // Hide codename textbox for simple display mode
        if (DisplayMode == ControlDisplayModeEnum.Simple)
        {
            plcCodeName.Visible = false;
        }

        // Display 'Changes were saved' message if required
        if (QueryHelper.GetBoolean("saved", false))
        {
            this.lblInfo.Text = GetString("general.changessaved");
        }
    }
Ejemplo n.º 10
0
    /// <summary>
    /// Sets image  url, width and height.
    /// </summary>
    protected void SetImage()
    {
        Visible = false;

        // Only if display picture is allowed
        if (DisplayPicture)
        {
            string imageUrl = ResolveUrl("~/CMSModules/Avatars/CMSPages/GetAvatar.aspx?avatarguid=");

            // Is user id set? => Get user info
            if (mUserId > 0)
            {
                // Get user info
                UserInfo ui = UserInfoProvider.GetUserInfo(mUserId);
                if (ui != null)
                {
                    AvatarID = ui.UserAvatarID;
                    if (AvatarID <= 0)   // Backward compatibility
                    {
                        if (ui.UserPicture != "")
                        {
                            // Get picture filename
                            string filename = ui.UserPicture.Remove(ui.UserPicture.IndexOf('/'));
                            string ext      = Path.GetExtension(filename);
                            imageUrl += filename.Substring(0, (filename.Length - ext.Length));
                            imageUrl += "&extension=" + ext;
                            Visible   = true;
                        }
                        else if (UseDefaultAvatar)
                        {
                            DefaultAvatarTypeEnum defAvatar = DefaultAvatarTypeEnum.User;

                            // Get default avatar type according to user gender
                            UserGenderEnum gender = (UserGenderEnum)ValidationHelper.GetInteger(ui.GetValue("UserGender"), 0);
                            switch (gender)
                            {
                            case UserGenderEnum.Female:
                                defAvatar = DefaultAvatarTypeEnum.Female;
                                break;

                            case UserGenderEnum.Male:
                                defAvatar = DefaultAvatarTypeEnum.Male;
                                break;
                            }

                            AvatarInfo ai = AvatarInfoProvider.GetDefaultAvatar(defAvatar);

                            // Avatar not specified for current gender, get user default avatar
                            if (ai == null)
                            {
                                ai = AvatarInfoProvider.GetDefaultAvatar(DefaultAvatarTypeEnum.User);
                            }

                            if (ai != null)
                            {
                                AvatarID = ai.AvatarID;
                            }
                        }
                    }
                }
            }

            // Is group id set? => Get group info
            if (mGroupId > 0)
            {
                // Get group info trough module commands
                GeneralizedInfo gi = ModuleCommands.CommunityGetGroupInfo(mGroupId);
                if (gi != null)
                {
                    AvatarID = ValidationHelper.GetInteger(gi.GetValue("GroupAvatarID"), 0);
                }

                if ((AvatarID <= 0) && UseDefaultAvatar)
                {
                    AvatarInfo ai = AvatarInfoProvider.GetDefaultAvatar(DefaultAvatarTypeEnum.Group);
                    if (ai != null)
                    {
                        AvatarID = ai.AvatarID;
                    }
                }
            }

            if (AvatarID > 0)
            {
                AvatarInfo ai = AvatarInfoProvider.GetAvatarInfoWithoutBinary(AvatarID);
                if (ai != null)
                {
                    imageUrl += ai.AvatarGUID.ToString();
                    Visible   = true;
                }
            }

            // If item was found
            if (Visible)
            {
                if (KeepAspectRatio)
                {
                    imageUrl += "&maxsidesize=" + (Width > Height ? Width : Height);
                }
                else
                {
                    imageUrl += "&width=" + Width + "&height=" + Height;
                }
                imageUrl      = URLHelper.EncodeQueryString(imageUrl);
                ltlImage.Text = "<img alt=\"" + GetString("general.avatar") + "\" src=\"" + imageUrl + "\" />";

                // Render outer div with specific CSS class
                if (RenderOuterDiv)
                {
                    ltlImage.Text = "<div class=\"" + OuterDivCSSClass + "\">" + ltlImage.Text + "</div>";
                }
            }
        }
    }
Ejemplo n.º 11
0
    /// <summary>
    /// Initializes form controls.
    /// </summary>
    private void SetupControls()
    {
        // Button
        btnOk.Text = GetString("general.ok");

        // Set tooltips
        lblProjectDisplayName.ToolTip   = GetString("pm.project.tooltip.displayname");
        lblProjectName.ToolTip          = GetString("pm.project.tooltip.codename");
        lblProjectDescription.ToolTip   = GetString("pm.project.tooltip.description");
        lblProjectStartDate.ToolTip     = GetString("pm.project.tooltip.startdate");
        lblProjectDeadline.ToolTip      = GetString("pm.project.tooltip.deadline");
        lblProjectProgress.ToolTip      = GetString("pm.project.tooltip.progress");
        lblProjectOwner.ToolTip         = GetString("pm.project.tooltip.owner");
        lblProjectStatusID.ToolTip      = GetString("pm.project.tooltip.status");
        lblProjectPage.ToolTip          = GetString("pm.project.tooltip.page");
        lblProjectAllowOrdering.ToolTip = GetString("pm.project.tooltip.allowOrdering");

        // Disable validators if it is required
        if (DisableOnSiteValidators)
        {
            rfvProjectName.Enabled        = false;
            rfvProjectDisplayName.Enabled = false;
        }

        // Validator texts
        rfvProjectName.ErrorMessage        = GetString("general.requirescodename");
        rfvProjectDisplayName.ErrorMessage = GetString("general.requiresdisplayname");

        pageSelector.IsLiveSite          = IsLiveSite;
        pageSelector.EnableSiteSelection = false;

        // Page selector - show only documents of the current group
        if (CommunityGroupID > 0)
        {
            GeneralizedInfo infoObj = ModuleCommands.CommunityGetGroupInfo(CommunityGroupID);
            if (infoObj != null)
            {
                Guid groupNodeGUID = ValidationHelper.GetGuid(infoObj.GetValue("GroupNodeGUID"), Guid.Empty);

                if (groupNodeGUID != Guid.Empty)
                {
                    TreeProvider treeProvider = new TreeProvider();
                    TreeNode     node         = treeProvider.SelectSingleNode(groupNodeGUID, TreeProvider.ALL_CULTURES, SiteContext.CurrentSiteName);
                    if (node != null)
                    {
                        pageSelector.ContentStartingPath = HttpUtility.UrlEncode(node.NodeAliasPath);
                    }
                }
                else
                {
                    pageSelector.Enabled = false;
                }
            }
        }

        userSelector.IsLiveSite             = IsLiveSite;
        userSelector.SiteID                 = SiteContext.CurrentSiteID;
        userSelector.ShowSiteFilter         = false;
        userSelector.GroupID                = CommunityGroupID;
        userSelector.ApplyValueRestrictions = false;

        lstAttachments.ObjectType     = ProjectInfo.OBJECT_TYPE;
        lstAttachments.Category       = ObjectAttachmentsCategories.ATTACHMENT;
        lstAttachments.OnAfterUpload += (s, e) => TouchProjectInfo();
        lstAttachments.OnAfterDelete += (s, e) => TouchProjectInfo();

        // Hide hidden & disabled user on live site
        if (IsLiveSite)
        {
            userSelector.HideHiddenUsers      = true;
            userSelector.HideDisabledUsers    = true;
            userSelector.HideNonApprovedUsers = true;
        }

        // Hide page selector on live site
        if (!ShowPageSelector)
        {
            plcProjectPage.Visible = false;
        }

        // Hide codename textbox for simple display mode
        if (DisplayMode == ControlDisplayModeEnum.Simple)
        {
            plcCodeName.Visible = false;
        }

        // Display 'Changes were saved' message if required
        if (QueryHelper.GetBoolean("saved", false) && !URLHelper.IsPostback())
        {
            ShowChangesSaved();
        }
    }