private void messageEditElem_OnCheckPermissions(string permissionType, CMSAdminControl sender) { // Check 'Manage' permission if (!cu.IsGroupAdministrator(mGroupId) && !MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.groups", CMSAdminControl.PERMISSION_MANAGE)) { RedirectToAccessDenied("cms.groups", CMSAdminControl.PERMISSION_MANAGE); } }
protected void Page_Load(object sender, EventArgs e) { cu = MembershipContext.AuthenticatedUser; // Check 'Manage' permission if (!cu.IsGroupAdministrator(mGroupId) && !MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.groups", CMSAdminControl.PERMISSION_MANAGE)) { RedirectToAccessDenied("cms.groups", CMSAdminControl.PERMISSION_MANAGE); } messageEditElem.AdvancedMode = true; messageEditElem.MessageID = mMessageId; messageEditElem.MessageBoardID = mBoardId; messageEditElem.OnCheckPermissions += messageEditElem_OnCheckPermissions; messageEditElem.OnBeforeMessageSaved += messageEditElem_OnBeforeMessageSaved; messageEditElem.OnAfterMessageSaved += messageEditElem_OnAfterMessageSaved; // initializes page title control if (mMessageId > 0) { PageTitle.TitleText = GetString("Board.MessageEdit.title"); } else { PageTitle.TitleText = GetString("Board.MessageNew.title"); } if (!RequestHelper.IsPostBack()) { messageEditElem.ReloadData(); } }
protected void Page_Load(object sender, EventArgs e) { cu = MembershipContext.AuthenticatedUser; // Check 'Manage' permission if (!cu.IsGroupAdministrator(mGroupId) && !MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.groups", CMSAdminControl.PERMISSION_MANAGE)) { RedirectToAccessDenied("cms.groups", CMSAdminControl.PERMISSION_MANAGE); } messageEditElem.AdvancedMode = true; messageEditElem.MessageID = mMessageId; messageEditElem.MessageBoardID = mBoardId; messageEditElem.OnCheckPermissions += new CMSAdminControl.CheckPermissionsEventHandler(messageEditElem_OnCheckPermissions); messageEditElem.OnBeforeMessageSaved += new OnBeforeMessageSavedEventHandler(messageEditElem_OnBeforeMessageSaved); messageEditElem.OnAfterMessageSaved += new OnAfterMessageSavedEventHandler(messageEditElem_OnAfterMessageSaved); // initializes page title control if (mMessageId > 0) { PageTitle.TitleText = GetString("Board.MessageEdit.title"); } else { PageTitle.TitleText = GetString("Board.MessageNew.title"); } if (!URLHelper.IsPostback()) { messageEditElem.ReloadData(); } }
/// <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(); }
/// <summary> /// Checks whether current user can edit the project. /// </summary> protected bool IsAuthorizedPerProjectEdit() { // Keep current user info object CurrentUserInfo cui = CMSContext.CurrentUser; // Global admin is allowed for all actions if (cui.IsGlobalAdministrator) { return(true); } // Get project info object ProjectInfo pi = ProjectInfoProvider.GetProjectInfo(ProjectID); bool result = false; // Check whether project info is available, if not, user can't edit project if (pi != null) { // Project owner can edit the project if (pi.ProjectOwner == cui.UserID) { result = true; } // Community admin and group admin can edit project on group pages else if (pi.ProjectGroupID > 0) { result = cui.IsGroupAdministrator(pi.ProjectGroupID); } // Project managmnet admin can edt projects on regular pages else { result = cui.IsAuthorizedPerResource("CMS.ProjectManagement", PERMISSION_MANAGE); } } // Check project access if (!result) { return(IsAuthorizedPerProjectAccess()); } return(result); ; }
protected void Page_Load(object sender, EventArgs e) { cu = CMSContext.CurrentUser; // Check 'Manage' permission if (!cu.IsGroupAdministrator(this.mGroupId) && !CMSContext.CurrentUser.IsAuthorizedPerResource("cms.groups", CMSAdminControl.PERMISSION_MANAGE)) { RedirectToAccessDenied("cms.groups", CMSAdminControl.PERMISSION_MANAGE); } this.messageEditElem.AdvancedMode = true; this.messageEditElem.MessageID = mMessageId; this.messageEditElem.MessageBoardID = mBoardId; this.messageEditElem.OnCheckPermissions += new CMSAdminControl.CheckPermissionsEventHandler(messageEditElem_OnCheckPermissions); this.messageEditElem.OnBeforeMessageSaved += new OnBeforeMessageSavedEventHandler(messageEditElem_OnBeforeMessageSaved); this.messageEditElem.OnAfterMessageSaved += new OnAfterMessageSavedEventHandler(messageEditElem_OnAfterMessageSaved); // initializes page title control if (this.mMessageId > 0) { this.CurrentMaster.Title.TitleText = GetString("Board.MessageEdit.title"); this.CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Board_Message/object.png"); } else { this.CurrentMaster.Title.TitleText = GetString("Board.MessageNew.title"); this.CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Board_Message/new.png"); } this.CurrentMaster.Title.HelpTopicName = "messages_edit"; this.CurrentMaster.Title.HelpName = "helpTopic"; if (!URLHelper.IsPostback()) { this.messageEditElem.ReloadData(); } }
protected void Page_Load(object sender, EventArgs e) { cu = CMSContext.CurrentUser; // Check 'Manage' permission if (!cu.IsGroupAdministrator(mGroupId) && !CMSContext.CurrentUser.IsAuthorizedPerResource("cms.groups", CMSAdminControl.PERMISSION_MANAGE)) { RedirectToAccessDenied("cms.groups", CMSAdminControl.PERMISSION_MANAGE); } messageEditElem.AdvancedMode = true; messageEditElem.MessageID = mMessageId; messageEditElem.MessageBoardID = mBoardId; messageEditElem.OnCheckPermissions += new CMSAdminControl.CheckPermissionsEventHandler(messageEditElem_OnCheckPermissions); messageEditElem.OnBeforeMessageSaved += new OnBeforeMessageSavedEventHandler(messageEditElem_OnBeforeMessageSaved); messageEditElem.OnAfterMessageSaved += new OnAfterMessageSavedEventHandler(messageEditElem_OnAfterMessageSaved); // initializes page title control if (mMessageId > 0) { CurrentMaster.Title.TitleText = GetString("Board.MessageEdit.title"); CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Board_Message/object.png"); } else { CurrentMaster.Title.TitleText = GetString("Board.MessageNew.title"); CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Board_Message/new.png"); } CurrentMaster.Title.HelpTopicName = "messages_edit"; CurrentMaster.Title.HelpName = "helpTopic"; if (!URLHelper.IsPostback()) { messageEditElem.ReloadData(); } }
/// <summary> /// Checks whether current user can create new project. /// </summary> protected bool IsAuthorizedPerCreateProject() { // Keep current user info object CurrentUserInfo cui = CMSContext.CurrentUser; // Global admin is allowed for all actions if (cui.IsGlobalAdministrator) { return(true); } bool result = false; // Check whether page info is available, if not, user can't create new project if (pi != null) { // Community admin and group admin can create project on group pages if (pi.NodeGroupID > 0) { result = cui.IsGroupAdministrator(pi.NodeGroupID); } // Project management admin can create projects on regular pages else { result = cui.IsAuthorizedPerResource("CMS.ProjectManagement", PERMISSION_MANAGE); } } // Try combine with webpart settings if (!result) { return(ucProjectEdit.IsAuthorizedPerProjectAccess()); } return(result); }
/// <summary> /// On PreRender. /// </summary> protected override void OnPreRender(EventArgs e) { if (StopProcessing) { return; } // Security CurrentUserInfo currentUser = CMSContext.CurrentUser; if (SelectGroupWidgets) { // Shows group widgets without other security checks string where = "WidgetForGroup = 1"; // But user must be group admin, otherwise show nothing if (!currentUser.IsGroupAdministrator(GroupID) && ((CMSContext.ViewMode != ViewModeEnum.Design) || ((CMSContext.ViewMode == ViewModeEnum.Design) && (!currentUser.IsAuthorizedPerResource("CMS.Design", "Design"))))) { flatElem.ErrorText = GetString("widget.notgroupadmin"); } flatElem.WhereCondition = SqlHelperClass.AddWhereCondition(flatElem.WhereCondition, where); } else { // Create security where condition string securityWhere = String.Empty; if (SelectEditorWidgets) { securityWhere += "WidgetForEditor = 1 "; } else if (SelectUserWidgets) { securityWhere += "WidgetForUser = 1 "; } else if (SelectDashboardWidgets) { securityWhere += "WidgetForDashboard = 1 "; } else if (SelectInlineWidgets) { securityWhere += " WidgetForInline = 1 "; } else { securityWhere += " 1 = 2 "; } securityWhere += CreateAuthWhereCondition(); flatElem.WhereCondition = SqlHelperClass.AddWhereCondition(flatElem.WhereCondition, securityWhere); } // Restrict to items in selected category (if not root) if ((SelectedCategory != null) && (SelectedCategory.WidgetCategoryParentID > 0)) { flatElem.WhereCondition = SqlHelperClass.AddWhereCondition(flatElem.WhereCondition, "WidgetCategoryID = " + SelectedCategory.WidgetCategoryID + " OR WidgetCategoryID IN (SELECT WidgetCategoryID FROM CMS_WidgetCategory WHERE WidgetCategoryPath LIKE '" + SelectedCategory.WidgetCategoryPath + "/%')"); } // Recently used items if (TreeSelectedItem.ToLowerCSafe() == "recentlyused") { flatElem.WhereCondition = SqlHelperClass.AddWhereCondition(flatElem.WhereCondition, SqlHelperClass.GetWhereCondition("WidgetName", currentUser.UserSettings.UserUsedWidgets.Split(';'))); } // Description area and recently used litCategory.Text = ShowInDescriptionArea(SelectedItem); base.OnPreRender(e); }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { // Initialize properties string script = ""; // Set current user currentUser = MembershipContext.AuthenticatedUser; // Get Enable Friends setting bool friendsEnabled = UIHelper.IsFriendsModuleEnabled(SiteContext.CurrentSiteName); // Initialize strings lnkSignIn.Text = SignInText; lnkJoinCommunity.Text = JoinCommunityText; lnkMyProfile.Text = MyProfileText; lnkEditMyProfile.Text = EditMyProfileText; btnSignOut.Text = SignOutText; lnkCreateNewGroup.Text = CreateNewGroupText; lnkCreateNewBlog.Text = CreateNewBlogText; lnkJoinGroup.Text = JoinGroupText; lnkLeaveGroup.Text = LeaveGroupText; lnkRejectFriendship.Text = RejectFriendshipText; requestFriendshipElem.LinkText = RequestFriendshipText; lnkSendMessage.Text = SendMessageText; lnkAddToContactList.Text = AddToContactListText; lnkAddToIgnoreList.Text = AddToIgnoreListText; lnkInviteToGroup.Text = InviteGroupText; lnkManageGroup.Text = ManageGroupText; lnkMyMessages.Text = MyMessagesText; lnkMyFriends.Text = MyFriendsText; lnkMyInvitations.Text = MyInvitationsText; lnkMyTasks.Text = MyTasksText; // If current user is public... if (currentUser.IsPublic()) { // Display Sign In link if set so if (DisplaySignIn) { // SignInPath returns URL - because of settings value lnkSignIn.NavigateUrl = MacroResolver.ResolveCurrentPath(SignInPath); pnlSignIn.Visible = true; pnlSignInOut.Visible = true; } // Display Join the community link if set so if (DisplayJoinCommunity) { lnkJoinCommunity.NavigateUrl = GetUrl(JoinCommunityPath); pnlJoinCommunity.Visible = true; pnlPersonalLinks.Visible = true; } } // If user is logged in else { // Display Sign out link if set so if (DisplaySignOut && !RequestHelper.IsWindowsAuthentication()) { pnlSignOut.Visible = true; pnlSignInOut.Visible = true; } // Display Edit my profile link if set so if (DisplayEditMyProfileLink) { lnkEditMyProfile.NavigateUrl = URLHelper.ResolveUrl(DocumentURLProvider.GetUrl(GroupMemberInfoProvider.GetMemberManagementPath(currentUser.UserName, SiteContext.CurrentSiteName))); pnlEditMyProfile.Visible = true; pnlProfileLinks.Visible = true; } // Display My profile link if set so if (DisplayMyProfileLink) { lnkMyProfile.NavigateUrl = URLHelper.ResolveUrl(DocumentURLProvider.GetUrl(GroupMemberInfoProvider.GetMemberProfilePath(currentUser.UserName, SiteContext.CurrentSiteName))); pnlMyProfile.Visible = true; pnlProfileLinks.Visible = true; } // Display Create new group link if set so if (DisplayCreateNewGroup) { lnkCreateNewGroup.NavigateUrl = GetUrl(CreateNewGroupPath); pnlCreateNewGroup.Visible = true; pnlGroupLinks.Visible = true; } // Display Create new blog link if set so if (DisplayCreateNewBlog) { // Check that Community Module is present var entry = ModuleManager.GetModule(ModuleName.BLOGS); if (entry != null) { lnkCreateNewBlog.NavigateUrl = GetUrl(CreateNewBlogPath); pnlCreateNewBlog.Visible = true; pnlBlogLinks.Visible = true; } } // Display My messages link if (DisplayMyMessages) { lnkMyMessages.NavigateUrl = GetUrl(MyMessagesPath); pnlMyMessages.Visible = true; pnlPersonalLinks.Visible = true; } // Display My friends link if (DisplayMyFriends && friendsEnabled) { lnkMyFriends.NavigateUrl = GetUrl(MyFriendsPath); pnlMyFriends.Visible = true; pnlPersonalLinks.Visible = true; } // Display My invitations link if (DisplayMyInvitations) { lnkMyInvitations.NavigateUrl = GetUrl(MyInvitationsPath); pnlMyInvitations.Visible = true; pnlPersonalLinks.Visible = true; } // Display My tasks link if (DisplayMyTasks) { lnkMyTasks.NavigateUrl = GetUrl(MyTasksPath); pnlMyTasks.Visible = true; pnlPersonalLinks.Visible = true; } GroupMemberInfo gmi = null; if (CommunityContext.CurrentGroup != null) { // Get group info from community context GroupInfo currentGroup = CommunityContext.CurrentGroup; if (DisplayGroupLinks) { script += "function ReloadPage(){" + ControlsHelper.GetPostBackEventReference(this, "") + "}"; // Display Join group link if set so and user is visiting a group page gmi = GetGroupMember(MembershipContext.AuthenticatedUser.UserID, currentGroup.GroupID); if (gmi == null) { if (String.IsNullOrEmpty(JoinGroupPath)) { script += "function JoinToGroupRequest() {\n" + "modalDialog('" + AuthenticationHelper.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/JoinTheGroup.aspx") + "?groupid=" + currentGroup.GroupID + "','requestJoinToGroup', 500, 180); \n" + " } \n"; lnkJoinGroup.Attributes.Add("onclick", "JoinToGroupRequest();return false;"); lnkJoinGroup.NavigateUrl = RequestContext.CurrentURL; } else { lnkJoinGroup.NavigateUrl = GetUrl(JoinGroupPath); } pnlJoinGroup.Visible = true; pnlGroupLinks.Visible = true; } else if ((gmi.MemberStatus == GroupMemberStatus.Approved) || (MembershipContext.AuthenticatedUser.IsGlobalAdministrator)) // Display Leave the group link if user is the group member { if (String.IsNullOrEmpty(LeaveGroupPath)) { script += "function LeaveTheGroupRequest() {\n" + "modalDialog('" + AuthenticationHelper.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/LeaveTheGroup.aspx") + "?groupid=" + currentGroup.GroupID + "','requestLeaveThGroup', 500, 180); \n" + " } \n"; lnkLeaveGroup.Attributes.Add("onclick", "LeaveTheGroupRequest();return false;"); lnkLeaveGroup.NavigateUrl = RequestContext.CurrentURL; } else { lnkLeaveGroup.NavigateUrl = GetUrl(LeaveGroupPath); } pnlLeaveGroup.Visible = true; pnlGroupLinks.Visible = true; } } // Display Manage the group link if set so and user is logged as group administrator and user is visiting a group page if (DisplayManageGroup && (currentUser.IsGroupAdministrator(currentGroup.GroupID) || (currentUser.IsGlobalAdministrator))) { lnkManageGroup.NavigateUrl = ResolveUrl(DocumentURLProvider.GetUrl(GroupInfoProvider.GetGroupManagementPath(currentGroup.GroupName, SiteContext.CurrentSiteName))); pnlManageGroup.Visible = true; pnlGroupLinks.Visible = true; } } if (DisplayInviteToGroup) { // Get group info from community context GroupInfo currentGroup = CommunityContext.CurrentGroup; // Get user info from site context UserInfo siteContextUser = MembershipContext.CurrentUserProfile; // Display invite to group link for user who is visiting a group page if (currentGroup != null) { // Get group user if (gmi == null) { gmi = GetGroupMember(MembershipContext.AuthenticatedUser.UserID, currentGroup.GroupID); } if (((gmi != null) && (gmi.MemberStatus == GroupMemberStatus.Approved)) || (MembershipContext.AuthenticatedUser.IsGlobalAdministrator)) { pnlInviteToGroup.Visible = true; if (String.IsNullOrEmpty(InviteGroupPath)) { script += "function InviteToGroup() {\n modalDialog('" + AuthenticationHelper.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/InviteToGroup.aspx") + "?groupid=" + currentGroup.GroupID + "','inviteToGroup', 800, 450); \n } \n"; lnkInviteToGroup.Attributes.Add("onclick", "InviteToGroup();return false;"); lnkInviteToGroup.NavigateUrl = RequestContext.CurrentURL; } else { lnkInviteToGroup.NavigateUrl = GetUrl(InviteGroupPath); } } } // Display invite to group link for user who is visiting another user's page else if ((siteContextUser != null) && (siteContextUser.UserName != currentUser.UserName) && (GroupInfoProvider.GetUserGroupsCount(currentUser, SiteContext.CurrentSite) != 0)) { pnlInviteToGroup.Visible = true; if (String.IsNullOrEmpty(InviteGroupPath)) { script += "function InviteToGroup() {\n modalDialog('" + AuthenticationHelper.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/InviteToGroup.aspx") + "?invitedid=" + siteContextUser.UserID + "','inviteToGroup', 700, 400); \n } \n"; lnkInviteToGroup.Attributes.Add("onclick", "InviteToGroup();return false;"); lnkInviteToGroup.NavigateUrl = RequestContext.CurrentURL; } else { lnkInviteToGroup.NavigateUrl = GetUrl(InviteGroupPath); } } } if (SiteContext.CurrentUser != null) { // Get user info from site context UserInfo siteContextUser = MembershipContext.CurrentUserProfile; // Display Friendship link if set so and user is visiting an user's page if (DisplayFriendshipLinks && (currentUser.UserID != siteContextUser.UserID) && friendsEnabled) { FriendshipStatusEnum status = MembershipContext.AuthenticatedUser.HasFriend(siteContextUser.UserID); switch (status) { case FriendshipStatusEnum.Approved: // Friendship rejection script += "function ShortcutFriendshipReject(id) { \n" + "modalDialog('" + AuthenticationHelper.ResolveDialogUrl("~/CMSModules/Friends/CMSPages/Friends_Reject.aspx") + "?userid=" + currentUser.UserID + "&requestid=' + id , 'rejectFriend', 410, 270); \n" + " } \n"; lnkRejectFriendship.Attributes.Add("onclick", "ShortcutFriendshipReject('" + siteContextUser.UserID + "');return false;"); lnkRejectFriendship.NavigateUrl = RequestContext.CurrentURL; pnlRejectFriendship.Visible = true; pnlFriendshipLinks.Visible = true; break; case FriendshipStatusEnum.None: requestFriendshipElem.UserID = currentUser.UserID; requestFriendshipElem.RequestedUserID = siteContextUser.UserID; pnlFriendshipLink.Visible = true; pnlFriendshipLinks.Visible = true; break; } } // Show messaging links if enabled if (MessagingPresent && (currentUser.UserID != siteContextUser.UserID)) { // Display Send message link if user is visiting an user's page if (DisplaySendMessage) { // Send private message script += "function ShortcutPrivateMessage(id) { \n" + "modalDialog('" + AuthenticationHelper.ResolveDialogUrl("~/CMSModules/Messaging/CMSPages/SendMessage.aspx") + "?userid=" + currentUser.UserID + "&requestid=' + id , 'sendMessage', 390, 390); \n" + " } \n"; lnkSendMessage.Attributes.Add("onclick", "ShortcutPrivateMessage('" + siteContextUser.UserID + "');return false;"); lnkSendMessage.NavigateUrl = RequestContext.CurrentURL; pnlSendMessage.Visible = true; pnlMessageLinks.Visible = true; } // Display Add to contact list link if user is visiting an user's page if (DisplayAddToContactList) { // Check if user is in contact list bool isInContactList = ModuleCommands.MessagingIsInContactList(currentUser.UserID, siteContextUser.UserID); // Add to actions if (!isInContactList) { lnkAddToContactList.Attributes.Add("onclick", "return ShortcutAddToContactList('" + siteContextUser.UserID + "')"); lnkAddToContactList.NavigateUrl = RequestContext.CurrentURL; pnlAddToContactList.Visible = true; pnlMessageLinks.Visible = true; // Add to contact list script += "function ShortcutAddToContactList(usertoadd) { \n" + "var confirmation = confirm(" + ScriptHelper.GetString(GetString("messaging.contactlist.addconfirmation")) + ");" + "if(confirmation)" + "{" + "selectedIdElem = document.getElementById('" + hdnSelectedId.ClientID + "'); \n" + "if (selectedIdElem != null) { selectedIdElem.value = usertoadd;}" + ControlsHelper.GetPostBackEventReference(this, "addtocontactlist", false) + "} return false;}\n"; } } // Display Add to ignore list link if user is visiting an user's page if (DisplayAddToIgnoreList) { // Check if user is in ignore list bool isInIgnoreList = ModuleCommands.MessagingIsInIgnoreList(currentUser.UserID, siteContextUser.UserID); // Add to ignore list if (!isInIgnoreList) { lnkAddToIgnoreList.Attributes.Add("onclick", "return ShortcutAddToIgnoretList('" + siteContextUser.UserID + "')"); lnkAddToIgnoreList.NavigateUrl = RequestContext.CurrentURL; pnlAddToIgnoreList.Visible = true; pnlMessageLinks.Visible = true; // Add to ignore list script += "function ShortcutAddToIgnoretList(usertoadd) { \n" + "var confirmation = confirm(" + ScriptHelper.GetString(GetString("messaging.ignorelist.addconfirmation")) + ");" + "if(confirmation)" + "{" + "selectedIdElem = document.getElementById('" + hdnSelectedId.ClientID + "'); \n" + "if (selectedIdElem != null) { selectedIdElem.value = usertoadd;}" + ControlsHelper.GetPostBackEventReference(this, "addtoignorelist", false) + "} return false; } \n"; } } } } } // Register menu management scripts ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "Shortcuts_" + ClientID, ScriptHelper.GetScript(script)); // Register the dialog script ScriptHelper.RegisterDialogScript(Page); } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> protected void Page_Load(object sender, EventArgs e) { string widgetId = QueryHelper.GetString("widgetid", String.Empty); string aliasPath = QueryHelper.GetString("aliasPath", String.Empty); int templateId = QueryHelper.GetInteger("templateid", 0); string zoneId = QueryHelper.GetString("zoneid", String.Empty); Guid instanceGUID = QueryHelper.GetGuid("instanceguid", Guid.Empty); bool isNewWidget = QueryHelper.GetBoolean("isnew", false); bool inline = QueryHelper.GetBoolean("inline", false); int variantId = QueryHelper.GetInteger("variantid", 0); string culture = QueryHelper.GetString("culture", CMSContext.PreferredCultureCode); // Set page title Page.Title = GetString(isNewWidget ? "widgets.propertiespage.titlenew" : "widgets.propertiespage.title"); // Resize the header (enlarge) to make a space for the tabs header when displaying a widget variant if (variantId > 0) { rowsFrameset.Attributes.Add("rows", "67, *"); } // Ensure correct view mode if (String.IsNullOrEmpty(aliasPath)) { // Ensure the dashboard mode for the dialog if (QueryHelper.Contains("dashboard")) { PortalContext.SetRequestViewMode(ViewModeEnum.DashboardWidgets); PortalContext.DashboardName = QueryHelper.GetString("dashboard", String.Empty); PortalContext.DashboardSiteName = QueryHelper.GetString("sitename", String.Empty); } // Ensure the design mode for the dialog else { PortalContext.SetRequestViewMode(ViewModeEnum.Design); } } if (widgetId != "") { // Get pageinfo PageInfo pi = null; try { pi = CMSWebPartPropertiesPage.GetPageInfo(aliasPath, templateId, culture); } catch (PageNotFoundException) { // Do not throw exception if page info not found (e.g. bad alias path) } if (pi == null) { return; } // Get template instance PageTemplateInstance templateInstance = CMSPortalManager.GetTemplateInstanceForEditing(pi); // Get widget from instance WidgetInfo wi = null; if (!isNewWidget) { // Get the instance of widget WebPartInstance widgetInstance = templateInstance.GetWebPart(instanceGUID, widgetId); if (widgetInstance == null) { return; } // Get widget info by widget name(widget type) wi = WidgetInfoProvider.GetWidgetInfo(widgetInstance.WebPartType); } // Widget instance hasn't created yet else { wi = WidgetInfoProvider.GetWidgetInfo(ValidationHelper.GetInteger(widgetId, 0)); } if (wi != null) { WebPartZoneInstance zone = templateInstance.GetZone(zoneId); if (zone != null) { CurrentUserInfo currentUser = CMSContext.CurrentUser; switch (zone.WidgetZoneType) { // Group zone => Only group widgets and group admin case WidgetZoneTypeEnum.Group: // Should always be, only group widget are allowed in group zone if (!wi.WidgetForGroup || (!currentUser.IsGroupAdministrator(pi.NodeGroupID) && ((CMSContext.ViewMode != ViewModeEnum.Design) || ((CMSContext.ViewMode == ViewModeEnum.Design) && (!currentUser.IsAuthorizedPerResource("CMS.Design", "Design")))))) { RedirectToAccessDenied(GetString("widgets.security.notallowed")); } break; // Widget must be allowed for editor zones case WidgetZoneTypeEnum.Editor: if (!wi.WidgetForEditor) { RedirectToAccessDenied(GetString("widgets.security.notallowed")); } break; // Widget must be allowed for user zones case WidgetZoneTypeEnum.User: if (!wi.WidgetForUser) { RedirectToAccessDenied(GetString("widgets.security.notallowed")); } break; } if ((zone.WidgetZoneType != WidgetZoneTypeEnum.Group) && !WidgetRoleInfoProvider.IsWidgetAllowed(wi, currentUser.UserID, currentUser.IsAuthenticated())) { RedirectToAccessDenied(GetString("widgets.security.notallowed")); } } // If all ok, set up frames frameHeader.Attributes.Add("src", "widgetproperties_header.aspx" + URLHelper.Url.Query); frameContent.Attributes.Add("src", "widgetproperties_properties_frameset.aspx" + URLHelper.Url.Query); } } frameHeader.Attributes.Add("src", "widgetproperties_header.aspx" + URLHelper.Url.Query); if (inline && !isNewWidget) { frameContent.Attributes.Add("src", ResolveUrl("~/CMSPages/Blank.htm")); } else { frameContent.Attributes.Add("src", "widgetproperties_properties_frameset.aspx" + URLHelper.Url.Query); } }
/// <summary> /// Init event handler. /// </summary> protected override void OnInit(EventArgs e) { base.OnInit(e); // Setup basic form on live site formCustom.AllowMacroEditing = false; formCustom.IsLiveSite = IsLiveSite; // Load settings if (!String.IsNullOrEmpty(Request.Form[hdnIsNewWebPart.UniqueID])) { IsNewWidget = ValidationHelper.GetBoolean(Request.Form[hdnIsNewWebPart.UniqueID], false); } if (!String.IsNullOrEmpty(Request.Form[hdnInstanceGUID.UniqueID])) { InstanceGUID = ValidationHelper.GetGuid(Request.Form[hdnInstanceGUID.UniqueID], Guid.Empty); } // Try to find the widget variant in the database and set its VariantID if (IsNewVariant) { Hashtable properties = WindowHelper.GetItem("variantProperties") as Hashtable; if (properties != null) { // Get the variant code name from the WindowHelper string variantName = ValidationHelper.GetString(properties["codename"], string.Empty); // Check if the variant exists in the database int variantIdFromDB = 0; if (VariantMode == VariantModeEnum.MVT) { variantIdFromDB = ModuleCommands.OnlineMarketingGetMVTVariantId(PageTemplateId, variantName); } else if (VariantMode == VariantModeEnum.ContentPersonalization) { variantIdFromDB = ModuleCommands.OnlineMarketingGetContentPersonalizationVariantId(PageTemplateId, variantName); } // Set the variant id from the database if (variantIdFromDB > 0) { VariantID = variantIdFromDB; IsNewVariant = false; } } } EnsureDashboard(); if (!String.IsNullOrEmpty(WidgetId) && !IsInline) { // Get page info try { pi = CMSWebPartPropertiesPage.GetPageInfo(AliasPath, PageTemplateId, CultureCode); } catch (PageNotFoundException) { // Do not throw exception if page info not found (e.g. bad alias path) } if (pi == null) { lblInfo.Text = GetString("Widgets.Properties.aliasnotfound"); lblInfo.Visible = true; pnlFormArea.Visible = false; return; } // Get template instance templateInstance = CMSPortalManager.GetTemplateInstanceForEditing(pi); if (!IsNewWidget) { // Get the instance of widget widgetInstance = templateInstance.GetWebPart(InstanceGUID, WidgetId); if (widgetInstance == null) { lblInfo.Text = GetString("Widgets.Properties.WidgetNotFound"); lblInfo.Visible = true; pnlFormArea.Visible = false; return; } if ((VariantID > 0) && (widgetInstance != null) && (widgetInstance.PartInstanceVariants != null)) { // Check OnlineMarketing permissions. if (CheckPermissions("Read")) { widgetInstance = pi.DocumentTemplateInstance.GetWebPart(InstanceGUID, WidgetId); widgetInstance = widgetInstance.PartInstanceVariants.Find(v => v.VariantID.Equals(VariantID)); // Set the widget variant mode if (widgetInstance != null) { VariantMode = widgetInstance.VariantMode; } } else { // Not authorized for OnlineMarketing - Manage. RedirectToInformation(String.Format(GetString("general.permissionresource"), "Read", (VariantMode == VariantModeEnum.ContentPersonalization) ? "CMS.ContentPersonalization" : "CMS.MVTest")); } } // Get widget info by widget name(widget type) wi = WidgetInfoProvider.GetWidgetInfo(widgetInstance.WebPartType); } // Widget instance hasn't created yet else { wi = WidgetInfoProvider.GetWidgetInfo(ValidationHelper.GetInteger(WidgetId, 0)); } // Keep xml version if (widgetInstance != null) { xmlVersion = widgetInstance.XMLVersion; } CMSPage.EditedObject = wi; zoneType = ZoneType; // Get the zone to which it inserts WebPartZoneInstance zone = templateInstance.GetZone(ZoneId); if ((zoneType == WidgetZoneTypeEnum.None) && (zone != null)) { zoneType = zone.WidgetZoneType; } // Check security CurrentUserInfo currentUser = CMSContext.CurrentUser; switch (zoneType) { // Group zone => Only group widgets and group admin case WidgetZoneTypeEnum.Group: // Should always be, only group widget are allowed in group zone if (!wi.WidgetForGroup || (!currentUser.IsGroupAdministrator(pi.NodeGroupID) && ((CMSContext.ViewMode != ViewModeEnum.Design) || ((CMSContext.ViewMode == ViewModeEnum.Design) && (!currentUser.IsAuthorizedPerResource("CMS.Design", "Design")))))) { if (OnNotAllowed != null) { OnNotAllowed(this, null); } } break; // Widget must be allowed for editor zones case WidgetZoneTypeEnum.Editor: if (!wi.WidgetForEditor) { if (OnNotAllowed != null) { OnNotAllowed(this, null); } } break; // Widget must be allowed for user zones case WidgetZoneTypeEnum.User: if (!wi.WidgetForUser) { if (OnNotAllowed != null) { OnNotAllowed(this, null); } } break; // Widget must be allowed for dashboard zones case WidgetZoneTypeEnum.Dashboard: if (!wi.WidgetForDashboard) { if (OnNotAllowed != null) { OnNotAllowed(this, null); } } break; } // Check security if ((zoneType != WidgetZoneTypeEnum.Group) && !WidgetRoleInfoProvider.IsWidgetAllowed(wi, currentUser.UserID, currentUser.IsAuthenticated())) { if (OnNotAllowed != null) { OnNotAllowed(this, null); } } // Get form schemas wpi = WebPartInfoProvider.GetWebPartInfo(wi.WidgetWebPartID); FormInfo zoneTypeDefinition = PortalFormHelper.GetPositionFormInfo(zoneType); string widgetProperties = FormHelper.MergeFormDefinitions(wpi.WebPartProperties, wi.WidgetProperties); FormInfo fi = PortalFormHelper.GetWidgetFormInfo(wi.WidgetName, Enum.GetName(typeof(WidgetZoneTypeEnum), zoneType), widgetProperties, zoneTypeDefinition, true); if (fi != null) { // Check if there are some editable properties var ffi = fi.GetFields(true, false).ToList <FormFieldInfo>(); if ((ffi == null) || (ffi.Count == 0)) { lblInfo.Visible = true; lblInfo.Text = GetString("widgets.emptyproperties"); } // Get datarows with required columns DataRow dr = PortalHelper.CombineWithDefaultValues(fi, wi); // Load default values for new widget if (IsNewWidget || (xmlVersion > 0)) { fi.LoadDefaultValues(dr, FormResolveTypeEnum.Visible); } if (IsNewWidget) { // Override default value and set title as widget display name DataHelper.SetDataRowValue(dr, "WidgetTitle", ResHelper.LocalizeString(wi.WidgetDisplayName)); } // Load values from existing widget LoadDataRowFromWidget(dr, fi); // Init HTML toolbar if exists InitHTMLToobar(fi); // Init the form InitForm(formCustom, dr, fi); // Set the context name formCustom.ControlContext.ContextName = CMS.SiteProvider.ControlContext.WIDGET_PROPERTIES; } } if (IsInline) { // Load text definition from session string definition = ValidationHelper.GetString(SessionHelper.GetValue("WidgetDefinition"), string.Empty); if (String.IsNullOrEmpty(definition)) { definition = Request.Form[hdnWidgetDefinition.UniqueID]; } else { hdnWidgetDefinition.Value = definition; } Hashtable parameters = null; if (IsNewWidget) { // New widget - load widget info by id if (!String.IsNullOrEmpty(WidgetId)) { wi = WidgetInfoProvider.GetWidgetInfo(ValidationHelper.GetInteger(WidgetId, 0)); } else { // Try to get widget from codename mName = QueryHelper.GetString("WidgetName", String.Empty); wi = WidgetInfoProvider.GetWidgetInfo(mName); } } else { if (definition == null) { DisplayError("widget.failedtoload"); return; } // Parse definition parameters = CMSDialogHelper.GetHashTableFromString(definition); // Trim control name if (parameters["name"] != null) { mName = parameters["name"].ToString(); } wi = WidgetInfoProvider.GetWidgetInfo(mName); } if (wi == null) { DisplayError("widget.failedtoload"); return; } // If widget cant be used as inline if (!wi.WidgetForInline) { DisplayError("widget.cantbeusedasinline"); return; } // Test permission for user CurrentUserInfo currentUser = CMSContext.CurrentUser; if (!WidgetRoleInfoProvider.IsWidgetAllowed(wi, currentUser.UserID, currentUser.IsAuthenticated())) { mIsValidWidget = false; OnNotAllowed(this, null); } // If user is editor, more properties are shown WidgetZoneTypeEnum zoneType = WidgetZoneTypeEnum.User; if (currentUser.IsEditor) { zoneType = WidgetZoneTypeEnum.Editor; } WebPartInfo wpi = WebPartInfoProvider.GetWebPartInfo(wi.WidgetWebPartID); string widgetProperties = FormHelper.MergeFormDefinitions(wpi.WebPartProperties, wi.WidgetProperties); FormInfo zoneTypeDefinition = PortalFormHelper.GetPositionFormInfo(zoneType); FormInfo fi = PortalFormHelper.GetWidgetFormInfo(wi.WidgetName, Enum.GetName(typeof(WidgetZoneTypeEnum), zoneType), widgetProperties, zoneTypeDefinition, true); if (fi != null) { // Check if there are some editable properties mFields = fi.GetFields(true, true); if ((mFields == null) || !mFields.Any()) { lblInfo.Visible = true; lblInfo.Text = GetString("widgets.emptyproperties"); } // Get datarows with required columns DataRow dr = PortalHelper.CombineWithDefaultValues(fi, wi); if (IsNewWidget) { // Load default values for new widget fi.LoadDefaultValues(dr, FormResolveTypeEnum.Visible); } else { foreach (string key in parameters.Keys) { object value = parameters[key]; // Test if given property exists if (dr.Table.Columns.Contains(key) && (value != null)) { try { dr[key] = DataHelper.ConvertValue(value, dr.Table.Columns[key].DataType); } catch { } } } } // Override default value and set title as widget display name DataHelper.SetDataRowValue(dr, "WidgetTitle", wi.WidgetDisplayName); // Init HTML toolbar if exists InitHTMLToobar(fi); // Init the form InitForm(formCustom, dr, fi); // Set the context name formCustom.ControlContext.ContextName = CMS.SiteProvider.ControlContext.WIDGET_PROPERTIES; } } }
protected void Page_Load(object sender, EventArgs e) { // Public user is not allowed for widgets if (!CMSContext.CurrentUser.IsAuthenticated()) { RedirectToAccessDenied(GetString("widgets.security.notallowed")); } string widgetId = QueryHelper.GetString("widgetid", String.Empty); string aliasPath = QueryHelper.GetString("aliasPath", String.Empty); string zoneId = QueryHelper.GetString("zoneid", String.Empty); Guid instanceGUID = QueryHelper.GetGuid("instanceguid", Guid.Empty); bool isNewWidget = QueryHelper.GetBoolean("isnew", false); bool inline = QueryHelper.GetBoolean("inline", false); // Set page title Page.Title = GetString(isNewWidget ? "widgets.propertiespage.titlenew" : "widgets.propertiespage.title"); if ((widgetId != string.Empty) && (aliasPath != string.Empty)) { // Get pageinfo PageInfo pi = null; try { pi = PageInfoProvider.GetPageInfo(CMSContext.CurrentSiteName, aliasPath, CMSContext.PreferredCultureCode, null, CMSContext.CurrentSite.CombineWithDefaultCulture); } catch (PageNotFoundException) { // Do not throw exception if page info not found (e.g. bad alias path) } if (pi == null) { return; } // Get template instance PageTemplateInstance templateInstance = CMSPortalManager.GetTemplateInstanceForEditing(pi); // Get widget from instance WidgetInfo wi = null; if (!isNewWidget) { // Get the instance of widget WebPartInstance widgetInstance = templateInstance.GetWebPart(instanceGUID, widgetId); if (widgetInstance == null) { return; } // Get widget info by widget name(widget type) wi = WidgetInfoProvider.GetWidgetInfo(widgetInstance.WebPartType); } // Widget instance hasn't created yet else { wi = WidgetInfoProvider.GetWidgetInfo(ValidationHelper.GetInteger(widgetId, 0)); } if (wi != null) { WebPartZoneInstance zone = templateInstance.GetZone(zoneId); if (zone != null) { CurrentUserInfo currentUser = CMSContext.CurrentUser; bool checkSecurity = true; // Check security // It is group zone type but widget is not allowed in group if (zone.WidgetZoneType == WidgetZoneTypeEnum.Group) { // Should always be, only group widget are allowed in group zone if (wi.WidgetForGroup) { if (!currentUser.IsGroupAdministrator(pi.NodeGroupID)) { RedirectToAccessDenied(GetString("widgets.security.notallowed")); } // All ok, don't check classic security checkSecurity = false; } } if (checkSecurity && !WidgetRoleInfoProvider.IsWidgetAllowed(wi, currentUser.UserID, currentUser.IsAuthenticated())) { RedirectToAccessDenied(GetString("widgets.security.notallowed")); } } } } // If all ok, set up frames frameHeader.Attributes.Add("src", "widgetproperties_header.aspx" + URLHelper.Url.Query); if (inline && !isNewWidget) { frameContent.Attributes.Add("src", ResolveUrl("~/CMSPages/Blank.htm")); } else { frameContent.Attributes.Add("src", "widgetproperties_properties_frameset.aspx" + URLHelper.Url.Query); } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { pi = CMSContext.CurrentPageInfo; if (pi != null) { CMSPagePlaceholder parentPlaceHolder = PortalHelper.FindParentPlaceholder(this); // Nothing to render, nothing to do if ((!DisplayAddButton && !DisplayResetButton) || ((parentPlaceHolder != null) && (parentPlaceHolder.UsingDefaultPage))) { Visible = false; return; } CurrentUserInfo currentUser = CMSContext.CurrentUser; zoneType = WidgetZoneTypeCode.ToEnum(WidgetZoneType); // Check security if (((zoneType == WidgetZoneTypeEnum.Group) && !currentUser.IsGroupAdministrator(pi.NodeGroupID)) || ((zoneType == WidgetZoneTypeEnum.User || zoneType == WidgetZoneTypeEnum.Dashboard) && !currentUser.IsAuthenticated())) { Visible = false; resetAllowed = false; return; } // Displaying - Editor zone only in edit mode, User/Group zone only in Live site/Preview mode if (((zoneType == WidgetZoneTypeEnum.Editor) && ((CMSContext.ViewMode != ViewModeEnum.Edit) && (CMSContext.ViewMode != ViewModeEnum.EditLive))) || (((zoneType == WidgetZoneTypeEnum.User) || (zoneType == WidgetZoneTypeEnum.Group)) && ((CMSContext.ViewMode != ViewModeEnum.LiveSite) && (CMSContext.ViewMode != ViewModeEnum.Preview))) || ((zoneType == WidgetZoneTypeEnum.Dashboard) && ((CMSContext.ViewMode != ViewModeEnum.DashboardWidgets) || (String.IsNullOrEmpty(PortalContext.DashboardName))))) { Visible = false; resetAllowed = false; return; } // Get current document TreeNode currentNode = DocumentHelper.GetDocument(pi.DocumentID, TreeProvider); if (((zoneType == WidgetZoneTypeEnum.Editor) && (!currentUser.IsEditor || (currentUser.IsAuthorizedPerDocument(currentNode, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied)))) { Visible = false; resetAllowed = false; return; } // If use checkin checkout enabled, check if document is checkout by current user if (zoneType == WidgetZoneTypeEnum.Editor) { if (currentNode != null) { WorkflowManager wm = WorkflowManager.GetInstance(TreeProvider); // Get workflow info WorkflowInfo wi = wm.GetNodeWorkflow(currentNode); // Check if node is under workflow and if use checkin checkout enabled if ((wi != null) && (wi.UseCheckInCheckOut(CMSContext.CurrentSiteName))) { int checkedOutBy = currentNode.DocumentCheckedOutByUserID; // Check if document is checkout by current user if (checkedOutBy != CMSContext.CurrentUser.UserID) { Visible = false; resetAllowed = false; return; } } } } // Find widget zone PageTemplateInfo pti = pi.UsedPageTemplateInfo; // ZodeID specified directly if (!String.IsNullOrEmpty(WidgetZoneID)) { zoneInstance = pti.GetZone(WidgetZoneID); } // Zone not find or specified zone is not of correct type if ((zoneInstance != null) && (zoneInstance.WidgetZoneType != zoneType)) { zoneInstance = null; } // For delete all variants all zones are necessary if (parentPlaceHolder != null) { var zones = parentPlaceHolder.WebPartZones; if (zones != null) { foreach (CMSWebPartZone zone in zones) { if ((zone.ZoneInstance != null) && (zone.ZoneInstance.WidgetZoneType == zoneType)) { zoneInstances.Add(zone.ZoneInstance); if (zoneInstance == null) { zoneInstance = zone.ZoneInstance; } } } } } // No suitable zones on the page, nothing to do if (zoneInstance == null) { Visible = false; resetAllowed = false; return; } // Adding is enabled if (DisplayAddButton) { pnlAdd.Visible = true; lnkAddWidget.Visible = true; lnkAddWidget.Text = HTMLHelper.HTMLEncode(DataHelper.GetNotEmpty(AddButtonText, GetString("widgets.addwidget"))); int templateId = 0; if (pi.UsedPageTemplateInfo != null) { templateId = pi.UsedPageTemplateInfo.PageTemplateId; } addScript = "NewWidget('" + HttpUtility.UrlEncode(zoneInstance.ZoneID) + "', '" + HttpUtility.UrlEncode(pi.NodeAliasPath) + "', '" + templateId + "'); return false;"; lnkAddWidget.Attributes.Add("onclick", addScript); } // Reset is enabled if (DisplayResetButton) { pnlReset.Visible = true; btnReset.Text = HTMLHelper.HTMLEncode(DataHelper.GetNotEmpty(ResetButtonText, GetString("widgets.resettodefault"))); btnReset.Click += new EventHandler(btnReset_Click); // Add confirmation if required if (ResetConfirmationRequired) { btnReset.Attributes.Add("onclick", "if (!confirm('" + GetString("widgets.resetzoneconfirmtext") + "')) return false;"); } } // Set the panel css clas with dependence on actions zone type switch (zoneType) { // Editor case WidgetZoneTypeEnum.Editor: pnlWidgetActions.CssClass = "EditorWidgetActions"; break; // User case WidgetZoneTypeEnum.User: pnlWidgetActions.CssClass = "UserWidgetActions"; break; // Group case WidgetZoneTypeEnum.Group: pnlWidgetActions.CssClass = "GroupWidgetActions"; break; // Dashboard case WidgetZoneTypeEnum.Dashboard: { if (pnlContextHelp.Controls.Count == 0) { // Load help control dynamically (due to faster start compilation) var help = this.LoadUserControl("~/CMSAdminControls/UI/PageElements/Help.ascx") as HelpControl; help.TopicName = "dashboard"; } } break; } } } }
protected void Page_Load(object sender, EventArgs e) { // Keep current user object CurrentUserInfo currentUser = CMSContext.CurrentUser; // Title element settings titleElem.TitleImage = GetImageUrl("Objects/PM_ProjectTask/object.png"); titleElem.TitleText = GetString("pm.projecttask.edit"); #region "Header actions" if (CMSContext.CurrentUser.IsAuthenticated()) { // New task link string[,] actions = new string[1, 7]; actions[0, 0] = HeaderActions.TYPE_LINKBUTTON; actions[0, 1] = GetString("pm.projecttask.newpersonal"); actions[0, 2] = null; actions[0, 4] = null; actions[0, 5] = GetImageUrl("Objects/PM_Project/add.png"); actions[0, 6] = "new_task"; HeaderActions.Actions = actions; HeaderActions.ActionPerformed += new CommandEventHandler(actionsElem_ActionPerformed); HeaderActions.ReloadData(); } #endregion // Switch by display type and set correct list grid name switch (this.TasksDisplayType) { // Project tasks case TasksDisplayTypeEnum.ProjectTasks: ucTaskList.OrderByType = ProjectTaskOrderByEnum.NotSpecified; ucTaskList.Grid.OrderBy = "TaskPriorityOrder ASC,ProjectTaskDeadline DESC"; ucTaskList.Grid.GridName = "~/CMSModules/ProjectManagement/Controls/LiveControls/ProjectTasks.xml"; pnlListActions.Visible = false; break; // Tasks owned by me case TasksDisplayTypeEnum.TasksOwnedByMe: ucTaskList.OrderByType = ProjectTaskOrderByEnum.NotSpecified; ucTaskList.Grid.OrderBy = "TaskPriorityOrder ASC,ProjectTaskDeadline DESC"; ucTaskList.Grid.GridName = "~/CMSModules/ProjectManagement/Controls/LiveControls/TasksOwnedByMe.xml"; break; // Tasks assigned to me case TasksDisplayTypeEnum.TasksAssignedToMe: // Set not specified order by default ucTaskList.OrderByType = ProjectTaskOrderByEnum.NotSpecified; // If sitename is not defined => display task from all sites => use user order if (String.IsNullOrEmpty(this.SiteName)) { ucTaskList.OrderByType = ProjectTaskOrderByEnum.UserOrder; } ucTaskList.Grid.OrderBy = "TaskPriorityOrder ASC,ProjectTaskDeadline DESC"; ucTaskList.Grid.GridName = "~/CMSModules/ProjectManagement/Controls/LiveControls/TasksAssignedToMe.xml"; break; } #region "Force edit by TaskID in querystring" // Check whether is not postback if (!RequestHelper.IsPostBack()) { // Try get value from request stroage which indicates whether force dialog is displayed bool isDisplayed = ValidationHelper.GetBoolean(RequestStockHelper.GetItem("cmspmforceitemdisplayed", true), false); // Try get task id from querystring int forceTaskId = QueryHelper.GetInteger("taskid", 0); if ((forceTaskId > 0) && (!isDisplayed)) { ProjectTaskInfo pti = ProjectTaskInfoProvider.GetProjectTaskInfo(forceTaskId); ProjectInfo pi = ProjectInfoProvider.GetProjectInfo(pti.ProjectTaskProjectID); // Check whether task is defined // and if is assigned to some project, this project is assigned to current site if ((pti != null) && ((pi == null) || (pi.ProjectSiteID == CMSContext.CurrentSiteID))) { bool taskIdValid = false; // Switch by display type switch (this.TasksDisplayType) { // Tasks created by me case TasksDisplayTypeEnum.TasksOwnedByMe: if (pti.ProjectTaskOwnerID == currentUser.UserID) { taskIdValid = true; } break; // Tasks assigned to me case TasksDisplayTypeEnum.TasksAssignedToMe: if (pti.ProjectTaskAssignedToUserID == currentUser.UserID) { taskIdValid = true; } break; // Project task case TasksDisplayTypeEnum.ProjectTasks: if (!String.IsNullOrEmpty(ProjectNames) && (pi != null)) { string projectNames = ";" + ProjectNames.ToLower() + ";"; if (projectNames.Contains(";" + pi.ProjectName.ToLower() + ";")) { // Check whether user can see private task if (!pti.ProjectTaskIsPrivate || ((pti.ProjectTaskOwnerID == currentUser.UserID) || (pti.ProjectTaskAssignedToUserID == currentUser.UserID)) || ((pi.ProjectGroupID > 0) && currentUser.IsGroupAdministrator(pi.ProjectGroupID)) || ((pi.ProjectGroupID == 0) && (currentUser.IsAuthorizedPerResource("CMS.ProjectManagement", CMSAdminControl.PERMISSION_MANAGE)))) { taskIdValid = true; } } } break; } bool displayValid = true; // Check whether do not display finished tasks is required if (!this.ShowFinishedTasks) { ProjectTaskStatusInfo ptsi = ProjectTaskStatusInfoProvider.GetProjectTaskStatusInfo(pti.ProjectTaskStatusID); if ((ptsi != null) && (ptsi.TaskStatusIsFinished)) { displayValid = false; } } // Check whether private task should be edited if (!this.ShowPrivateTasks) { if (pti.ProjectTaskProjectID == 0) { displayValid = false; } } // Check whether ontime task should be edited if (!this.ShowOnTimeTasks) { if ((pti.ProjectTaskDeadline != DateTimeHelper.ZERO_TIME) && (pti.ProjectTaskDeadline < DateTime.Now)) { displayValid = false; } } // Check whether overdue task should be edited if (!this.ShowOverdueTasks) { if ((pti.ProjectTaskDeadline != DateTimeHelper.ZERO_TIME) && (pti.ProjectTaskDeadline > DateTime.Now)) { displayValid = false; } } // Check whether user is allowed to see project if ((pi != null) && (ProjectInfoProvider.IsAuthorizedPerProject(pi.ProjectID, ProjectManagementPermissionType.READ, CMSContext.CurrentUser))) { displayValid = false; } // If task is valid and user has permissions to see this task display edit task dialog if (displayValid && taskIdValid && ProjectTaskInfoProvider.IsAuthorizedPerTask(forceTaskId, ProjectManagementPermissionType.READ, CMSContext.CurrentUser, CMSContext.CurrentSiteID)) { this.ucTaskEdit.ItemID = forceTaskId; this.ucTaskEdit.ReloadData(); // Render dialog this.ucPopupDialog.Visible = true; this.ucPopupDialog.Show(); // Set "force dialog displayed" flag RequestStockHelper.Add("cmspmforceitemdisplayed", true, true); } } } } #endregion #region "Event handlers registration" // Register list action handler ucTaskList.OnAction += new CommandEventHandler(ucTaskList_OnAction); #endregion #region "Pager settings" // Paging if (!EnablePaging) { ucTaskList.Grid.PageSize = "##ALL##"; ucTaskList.Grid.Pager.DefaultPageSize = -1; } else { ucTaskList.Grid.Pager.DefaultPageSize = PageSize; ucTaskList.Grid.PageSize = this.PageSize.ToString(); ucTaskList.Grid.FilterLimit = PageSize; } #endregion // Use postbacks on list actions ucTaskList.UsePostbackOnEdit = true; // Check delete permission ucTaskList.OnCheckPermissionsExtended += new CheckPermissionsExtendedEventHandler(ucTaskList_OnCheckPermissionsExtended); // Dont register JS edit script ucTaskList.RegisterEditScript = false; // Hide default ok button on edit ucTaskEdit.ShowOKButton = false; // Disable on site validators ucTaskEdit.DisableOnSiteValidators = true; // Check modify permission ucTaskEdit.OnCheckPermissionsExtended += new CheckPermissionsExtendedEventHandler(ucTaskEdit_OnCheckPermissionsExtended); // Build condition event ucTaskList.BuildCondition += new CMSModules_ProjectManagement_Controls_UI_ProjectTask_List.BuildConditionEvent(ucTaskList_BuildCondition); }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { // Initialize properties string script = ""; // Set current user currentUser = CMSContext.CurrentUser; // Get Enable Friends setting bool friendsEnabled = UIHelper.IsFriendsModuleEnabled(CMSContext.CurrentSiteName); // Initialize strings lnkSignIn.Text = SignInText; lnkJoinCommunity.Text = JoinCommunityText; lnkMyProfile.Text = MyProfileText; lnkEditMyProfile.Text = EditMyProfileText; btnSignOut.Text = SignOutText; lnkCreateNewGroup.Text = CreateNewGroupText; lnkCreateNewBlog.Text = CreateNewBlogText; lnkJoinGroup.Text = JoinGroupText; lnkLeaveGroup.Text = LeaveGroupText; lnkRejectFriendship.Text = RejectFriendshipText; requestFriendshipElem.LinkText = RequestFriendshipText; lnkSendMessage.Text = SendMessageText; lnkAddToContactList.Text = AddToContactListText; lnkAddToIgnoreList.Text = AddToIgnoreListText; lnkInviteToGroup.Text = InviteGroupText; lnkManageGroup.Text = ManageGroupText; lnkMyMessages.Text = MyMessagesText; lnkMyFriends.Text = MyFriendsText; lnkMyInvitations.Text = MyInvitationsText; lnkMyTasks.Text = MyTasksText; // If current user is public... if (currentUser.IsPublic()) { // Display Sign In link if set so if (DisplaySignIn) { // SignInPath returns URL - because of settings value lnkSignIn.NavigateUrl = CMSContext.ResolveCurrentPath(SignInPath); pnlSignIn.Visible = true; pnlSignInOut.Visible = true; } // Display Join the community link if set so if (DisplayJoinCommunity) { lnkJoinCommunity.NavigateUrl = GetUrl(JoinCommunityPath); pnlJoinCommunity.Visible = true; pnlPersonalLinks.Visible = true; } } // If user is logged in else { // Display Sign out link if set so if (DisplaySignOut && !RequestHelper.IsWindowsAuthentication()) { pnlSignOut.Visible = true; pnlSignInOut.Visible = true; } // Display Edit my profile link if set so if (DisplayEditMyProfileLink) { lnkEditMyProfile.NavigateUrl = URLHelper.ResolveUrl(TreePathUtils.GetUrl(GroupMemberInfoProvider.GetMemberManagementPath(currentUser.UserName, CMSContext.CurrentSiteName))); pnlEditMyProfile.Visible = true; pnlProfileLinks.Visible = true; } // Display My profile link if set so if (DisplayMyProfileLink) { lnkMyProfile.NavigateUrl = URLHelper.ResolveUrl(TreePathUtils.GetUrl(GroupMemberInfoProvider.GetMemberProfilePath(currentUser.UserName, CMSContext.CurrentSiteName))); pnlMyProfile.Visible = true; pnlProfileLinks.Visible = true; } // Display Create new group link if set so if (DisplayCreateNewGroup) { lnkCreateNewGroup.NavigateUrl = GetUrl(CreateNewGroupPath); pnlCreateNewGroup.Visible = true; pnlGroupLinks.Visible = true; } // Display Create new blog link if set so if (DisplayCreateNewBlog) { // Check that Community Module is present ModuleEntry entry = ModuleEntry.GetModuleEntry(ModuleEntry.BLOGS); if (entry != null) { lnkCreateNewBlog.NavigateUrl = GetUrl(CreateNewBlogPath); pnlCreateNewBlog.Visible = true; pnlBlogLinks.Visible = true; } } // Display My messages link if (DisplayMyMessages) { lnkMyMessages.NavigateUrl = GetUrl(MyMessagesPath); pnlMyMessages.Visible = true; pnlPersonalLinks.Visible = true; } // Display My friends link if (DisplayMyFriends && friendsEnabled) { lnkMyFriends.NavigateUrl = GetUrl(MyFriendsPath); pnlMyFriends.Visible = true; pnlPersonalLinks.Visible = true; } // Display My invitations link if (DisplayMyInvitations) { lnkMyInvitations.NavigateUrl = GetUrl(MyInvitationsPath); pnlMyInvitations.Visible = true; pnlPersonalLinks.Visible = true; } // Display My tasks link if (DisplayMyTasks) { lnkMyTasks.NavigateUrl = GetUrl(MyTasksPath); pnlMyTasks.Visible = true; pnlPersonalLinks.Visible = true; } GroupMemberInfo gmi = null; if (CommunityContext.CurrentGroup != null) { // Get group info from community context GroupInfo currentGroup = CommunityContext.CurrentGroup; if (DisplayGroupLinks) { script += "function ReloadPage(){" + ControlsHelper.GetPostBackEventReference(this, "") + "}"; // Display Join group link if set so and user is visiting a group page gmi = GetGroupMember(CMSContext.CurrentUser.UserID, currentGroup.GroupID); if (gmi == null) { if (String.IsNullOrEmpty(JoinGroupPath)) { script += "function JoinToGroupRequest() {\n" + "modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/JoinTheGroup.aspx") + "?groupid=" + currentGroup.GroupID + "','requestJoinToGroup', 500, 180); \n" + " } \n"; lnkJoinGroup.Attributes.Add("onclick", "JoinToGroupRequest();return false;"); lnkJoinGroup.NavigateUrl = URLHelper.CurrentURL; } else { lnkJoinGroup.NavigateUrl = GetUrl(JoinGroupPath); } pnlJoinGroup.Visible = true; pnlGroupLinks.Visible = true; } else if ((gmi.MemberStatus == GroupMemberStatus.Approved) || (CMSContext.CurrentUser.IsGlobalAdministrator)) // Display Leave the group link if user is the group member { if (String.IsNullOrEmpty(LeaveGroupPath)) { script += "function LeaveTheGroupRequest() {\n" + "modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/LeaveTheGroup.aspx") + "?groupid=" + currentGroup.GroupID + "','requestLeaveThGroup', 500, 180); \n" + " } \n"; lnkLeaveGroup.Attributes.Add("onclick", "LeaveTheGroupRequest();return false;"); lnkLeaveGroup.NavigateUrl = URLHelper.CurrentURL; } else { lnkLeaveGroup.NavigateUrl = GetUrl(LeaveGroupPath); } pnlLeaveGroup.Visible = true; pnlGroupLinks.Visible = true; } } // Display Manage the group link if set so and user is logged as group administrator and user is visiting a group page if (DisplayManageGroup && (currentUser.IsGroupAdministrator(currentGroup.GroupID) || (currentUser.IsGlobalAdministrator))) { lnkManageGroup.NavigateUrl = ResolveUrl(TreePathUtils.GetUrl(GroupInfoProvider.GetGroupManagementPath(currentGroup.GroupName, CMSContext.CurrentSiteName))); pnlManageGroup.Visible = true; pnlGroupLinks.Visible = true; } } if (DisplayInviteToGroup) { // Get group info from community context GroupInfo currentGroup = CommunityContext.CurrentGroup; // Get user info from site context UserInfo siteContextUser = SiteContext.CurrentUser; // Display invite to group link for user who is visiting a group page if (currentGroup != null) { // Get group user if (gmi == null) { gmi = GetGroupMember(CMSContext.CurrentUser.UserID, currentGroup.GroupID); } if (((gmi != null) && (gmi.MemberStatus == GroupMemberStatus.Approved)) || (CMSContext.CurrentUser.IsGlobalAdministrator)) { pnlInviteToGroup.Visible = true; if (String.IsNullOrEmpty(InviteGroupPath)) { script += "function InviteToGroup() {\n modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/InviteToGroup.aspx") + "?groupid=" + currentGroup.GroupID + "','inviteToGroup', 500, 345); \n } \n"; lnkInviteToGroup.Attributes.Add("onclick", "InviteToGroup();return false;"); lnkInviteToGroup.NavigateUrl = URLHelper.CurrentURL; } else { lnkInviteToGroup.NavigateUrl = GetUrl(InviteGroupPath); } } } // Display invite to group link for user who is visiting another user's page else if ((siteContextUser != null) && (siteContextUser.UserName != currentUser.UserName) && (GroupInfoProvider.GetUserGroupsCount(currentUser, CMSContext.CurrentSite) != 0)) { pnlInviteToGroup.Visible = true; if (String.IsNullOrEmpty(InviteGroupPath)) { script += "function InviteToGroup() {\n modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/InviteToGroup.aspx") + "?invitedid=" + siteContextUser.UserID + "','inviteToGroup', 500, 310); \n } \n"; lnkInviteToGroup.Attributes.Add("onclick", "InviteToGroup();return false;"); lnkInviteToGroup.NavigateUrl = URLHelper.CurrentURL; } else { lnkInviteToGroup.NavigateUrl = GetUrl(InviteGroupPath); } } } if (SiteContext.CurrentUser != null) { // Get user info from site context UserInfo siteContextUser = SiteContext.CurrentUser; // Display Friendship link if set so and user is visiting an user's page if (DisplayFriendshipLinks && (currentUser.UserID != siteContextUser.UserID) && friendsEnabled) { FriendshipStatusEnum status = CMSContext.CurrentUser.HasFriend(siteContextUser.UserID); switch (status) { case FriendshipStatusEnum.Approved: // Friendship rejection script += "function ShortcutFriendshipReject(id) { \n" + "modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Friends/CMSPages/Friends_Reject.aspx") + "?userid=" + currentUser.UserID + "&requestid=' + id , 'rejectFriend', 410, 270); \n" + " } \n"; lnkRejectFriendship.Attributes.Add("onclick", "ShortcutFriendshipReject('" + siteContextUser.UserID + "');return false;"); lnkRejectFriendship.NavigateUrl = URLHelper.CurrentURL; pnlRejectFriendship.Visible = true; pnlFriendshipLinks.Visible = true; break; case FriendshipStatusEnum.None: requestFriendshipElem.UserID = currentUser.UserID; requestFriendshipElem.RequestedUserID = siteContextUser.UserID; pnlFriendshipLink.Visible = true; pnlFriendshipLinks.Visible = true; break; } } // Show messaging links if enabled if (MessagingPresent && (currentUser.UserID != siteContextUser.UserID)) { // Display Send message link if user is visiting an user's page if (DisplaySendMessage) { // Send private message script += "function ShortcutPrivateMessage(id) { \n" + "modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Messaging/CMSPages/SendMessage.aspx") + "?userid=" + currentUser.UserID + "&requestid=' + id , 'sendMessage', 390, 390); \n" + " } \n"; lnkSendMessage.Attributes.Add("onclick", "ShortcutPrivateMessage('" + siteContextUser.UserID + "');return false;"); lnkSendMessage.NavigateUrl = URLHelper.CurrentURL; pnlSendMessage.Visible = true; pnlMessageLinks.Visible = true; } // Display Add to contact list link if user is visiting an user's page if (DisplayAddToContactList) { // Check if user is in contact list bool isInContactList = ModuleCommands.MessagingIsInContactList(currentUser.UserID, siteContextUser.UserID); // Add to actions if (!isInContactList) { lnkAddToContactList.Attributes.Add("onclick", "return ShortcutAddToContactList('" + siteContextUser.UserID + "')"); lnkAddToContactList.NavigateUrl = URLHelper.CurrentURL; pnlAddToContactList.Visible = true; pnlMessageLinks.Visible = true; // Add to contact list script += "function ShortcutAddToContactList(usertoadd) { \n" + "var confirmation = confirm(" + ScriptHelper.GetString(GetString("messaging.contactlist.addconfirmation")) + ");" + "if(confirmation)" + "{" + "selectedIdElem = document.getElementById('" + hdnSelectedId.ClientID + "'); \n" + "if (selectedIdElem != null) { selectedIdElem.value = usertoadd;}" + ControlsHelper.GetPostBackEventReference(this, "addtocontactlist", false) + "} return false;}\n"; } } // Display Add to ignore list link if user is visiting an user's page if (DisplayAddToIgnoreList) { // Check if user is in ignore list bool isInIgnoreList = ModuleCommands.MessagingIsInIgnoreList(currentUser.UserID, siteContextUser.UserID); // Add to ignore list if (!isInIgnoreList) { lnkAddToIgnoreList.Attributes.Add("onclick", "return ShortcutAddToIgnoretList('" + siteContextUser.UserID + "')"); lnkAddToIgnoreList.NavigateUrl = URLHelper.CurrentURL; pnlAddToIgnoreList.Visible = true; pnlMessageLinks.Visible = true; // Add to ignore list script += "function ShortcutAddToIgnoretList(usertoadd) { \n" + "var confirmation = confirm(" + ScriptHelper.GetString(GetString("messaging.ignorelist.addconfirmation")) + ");" + "if(confirmation)" + "{" + "selectedIdElem = document.getElementById('" + hdnSelectedId.ClientID + "'); \n" + "if (selectedIdElem != null) { selectedIdElem.value = usertoadd;}" + ControlsHelper.GetPostBackEventReference(this, "addtoignorelist", false) + "} return false; } \n"; } } } } } // Register menu management scripts ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "Shortcuts_" + ClientID, ScriptHelper.GetScript(script)); // Register the dialog script ScriptHelper.RegisterDialogScript(this.Page); } }
/// <summary> /// Handles folder actions. /// </summary> public string ProcessFolderAction() { MediaLibraryInfo libInfo = MediaLibraryInfoProvider.GetMediaLibraryInfo(this.LibraryID); if (libInfo != null) { if (this.Action.ToLower().Trim() == "new") { if (this.CheckAdvancedPermissions) { CurrentUserInfo currUser = CMSContext.CurrentUser; // Not a global admin if (!currUser.IsGlobalAdministrator) { // Group library bool isGroupLibrary = (libInfo.LibraryGroupID > 0); if (!(isGroupLibrary && currUser.IsGroupAdministrator(libInfo.LibraryGroupID))) { // Checked resource name string resource = (isGroupLibrary) ? "CMS.Groups" : "CMS.MediaLibrary"; // Check 'CREATE' & 'MANAGE' permissions if (!(currUser.IsAuthorizedPerResource(resource, CMSAdminControl.PERMISSION_MANAGE) || MediaLibraryInfoProvider.IsUserAuthorizedPerLibrary(libInfo, "foldercreate"))) { this.lblError.Text = MediaLibraryHelper.GetAccessDeniedMessage("foldercreate"); this.lblError.Visible = true; return(null); } } } } // Check 'Folder create' permission else if (!MediaLibraryInfoProvider.IsUserAuthorizedPerLibrary(libInfo, "foldercreate")) { this.lblError.Text = MediaLibraryHelper.GetAccessDeniedMessage("foldercreate"); this.lblError.Visible = true; return(null); } } else { // Check 'Folder modify' permission if (!MediaLibraryInfoProvider.IsUserAuthorizedPerLibrary(libInfo, "foldermodify")) { this.lblError.Text = MediaLibraryHelper.GetAccessDeniedMessage("foldermodify"); this.lblError.Visible = true; return(null); } } SiteInfo si = SiteInfoProvider.GetSiteInfo(libInfo.LibrarySiteID); if (si != null) { // Validate form entry string errMsg = ValidateForm(this.Action, si.SiteName); this.ErrorOccurred = !string.IsNullOrEmpty(errMsg); // If validation suceeded if (errMsg == "") { try { // Update info only if folder was renamed if (MediaLibraryHelper.EnsurePath(FolderPath) != MediaLibraryHelper.EnsurePath(mNewFolderPath)) { if (this.Action.ToLower().Trim() == "new") { // Create/Update folder according to action MediaLibraryInfoProvider.CreateMediaLibraryFolder(si.SiteName, LibraryID, mNewFolderPath, false); } else { // Create/Update folder according to action MediaLibraryInfoProvider.RenameMediaLibraryFolder(si.SiteName, LibraryID, FolderPath, mNewFolderPath, false); } // Inform the user on success this.lblInfo.Text = GetString("general.changessaved"); this.lblInfo.Visible = true; // Refresh folder name this.FolderPath = mNewFolderPath; UpdateFolderName(); // Reload media library if (OnFolderChange != null) { OnFolderChange(this.mNewTreePath); } } } catch (Exception ex) { // Display an error to the user this.lblError.Text = GetString("general.erroroccurred") + " " + ex.Message; this.lblError.Visible = true; this.mNewTreePath = null; } } else { // Display an error to the user this.lblError.Text = errMsg; this.lblError.Visible = true; this.mNewTreePath = null; } } } return(this.mNewTreePath); }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { // Initialize properties string script = ""; // Set current user currentUser = MembershipContext.AuthenticatedUser; // Initialize strings lnkSignIn.Text = SignInText; lnkJoinCommunity.Text = JoinCommunityText; lnkMyProfile.Text = MyProfileText; lnkEditMyProfile.Text = EditMyProfileText; btnSignOut.Text = SignOutText; lnkCreateNewGroup.Text = CreateNewGroupText; lnkCreateNewBlog.Text = CreateNewBlogText; lnkJoinGroup.Text = JoinGroupText; lnkLeaveGroup.Text = LeaveGroupText; lnkInviteToGroup.Text = InviteGroupText; lnkManageGroup.Text = ManageGroupText; lnkMyInvitations.Text = MyInvitationsText; // If current user is public... if (currentUser.IsPublic()) { // Display Sign In link if set so if (DisplaySignIn) { // SignInPath returns URL - because of settings value lnkSignIn.NavigateUrl = MacroResolver.ResolveCurrentPath(SignInPath); pnlSignIn.Visible = true; pnlSignInOut.Visible = true; } // Display Join the community link if set so if (DisplayJoinCommunity) { lnkJoinCommunity.NavigateUrl = GetUrl(JoinCommunityPath); pnlJoinCommunity.Visible = true; pnlPersonalLinks.Visible = true; } } // If user is logged in else { // Display Sign out link if set so if (DisplaySignOut && !AuthenticationMode.IsWindowsAuthentication()) { pnlSignOut.Visible = true; pnlSignInOut.Visible = true; } // Display Edit my profile link if set so if (DisplayEditMyProfileLink) { lnkEditMyProfile.NavigateUrl = UrlResolver.ResolveUrl(DocumentURLProvider.GetUrl(GroupMemberInfoProvider.GetMemberManagementPath(currentUser.UserName, SiteContext.CurrentSiteName))); pnlEditMyProfile.Visible = true; pnlProfileLinks.Visible = true; } // Display My profile link if set so if (DisplayMyProfileLink) { lnkMyProfile.NavigateUrl = UrlResolver.ResolveUrl(DocumentURLProvider.GetUrl(GroupMemberInfoProvider.GetMemberProfilePath(currentUser.UserName, SiteContext.CurrentSiteName))); pnlMyProfile.Visible = true; pnlProfileLinks.Visible = true; } // Display Create new group link if set so if (DisplayCreateNewGroup) { lnkCreateNewGroup.NavigateUrl = GetUrl(CreateNewGroupPath); pnlCreateNewGroup.Visible = true; pnlGroupLinks.Visible = true; } // Display Create new blog link if set so if (DisplayCreateNewBlog) { // Check that Community Module is present var entry = ModuleManager.GetModule(ModuleName.BLOGS); if (entry != null) { lnkCreateNewBlog.NavigateUrl = GetUrl(CreateNewBlogPath); pnlCreateNewBlog.Visible = true; pnlBlogLinks.Visible = true; } } // Display My invitations link if (DisplayMyInvitations) { lnkMyInvitations.NavigateUrl = GetUrl(MyInvitationsPath); pnlMyInvitations.Visible = true; pnlPersonalLinks.Visible = true; } GroupMemberInfo gmi = null; if (CommunityContext.CurrentGroup != null) { // Get group info from community context GroupInfo currentGroup = CommunityContext.CurrentGroup; if (DisplayGroupLinks) { // Display Join group link if set so and user is visiting a group page gmi = GetGroupMember(MembershipContext.AuthenticatedUser.UserID, currentGroup.GroupID); if (gmi == null) { if (String.IsNullOrEmpty(JoinGroupPath)) { script += "function JoinToGroupRequest() {\n" + "modalDialog('" + ApplicationUrlHelper.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/JoinTheGroup.aspx") + "?groupid=" + currentGroup.GroupID + "','requestJoinToGroup', 500, 180); \n" + " } \n"; lnkJoinGroup.Attributes.Add("onclick", "JoinToGroupRequest();return false;"); lnkJoinGroup.NavigateUrl = RequestContext.CurrentURL; } else { lnkJoinGroup.NavigateUrl = GetUrl(JoinGroupPath); } pnlJoinGroup.Visible = true; pnlGroupLinks.Visible = true; } else if ((gmi.MemberStatus == GroupMemberStatus.Approved) || (MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin))) // Display Leave the group link if user is the group member { if (String.IsNullOrEmpty(LeaveGroupPath)) { script += "function LeaveTheGroupRequest() {\n" + "modalDialog('" + ApplicationUrlHelper.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/LeaveTheGroup.aspx") + "?groupid=" + currentGroup.GroupID + "','requestLeaveThGroup', 500, 180); \n" + " } \n"; lnkLeaveGroup.Attributes.Add("onclick", "LeaveTheGroupRequest();return false;"); lnkLeaveGroup.NavigateUrl = RequestContext.CurrentURL; } else { lnkLeaveGroup.NavigateUrl = GetUrl(LeaveGroupPath); } pnlLeaveGroup.Visible = true; pnlGroupLinks.Visible = true; } } // Display Manage the group link if set so and user is logged as group administrator and user is visiting a group page if (DisplayManageGroup && (currentUser.IsGroupAdministrator(currentGroup.GroupID) || (currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin)))) { lnkManageGroup.NavigateUrl = ResolveUrl(DocumentURLProvider.GetUrl(GroupInfoProvider.GetGroupManagementPath(currentGroup.GroupName, SiteContext.CurrentSiteName))); pnlManageGroup.Visible = true; pnlGroupLinks.Visible = true; } } // Get user info from site context UserInfo siteContextUser = MembershipContext.CurrentUserProfile; if (DisplayInviteToGroup) { // Get group info from community context GroupInfo currentGroup = CommunityContext.CurrentGroup; // Display invite to group link for user who is visiting a group page if (currentGroup != null) { // Get group user if (gmi == null) { gmi = GetGroupMember(MembershipContext.AuthenticatedUser.UserID, currentGroup.GroupID); } if (((gmi != null) && (gmi.MemberStatus == GroupMemberStatus.Approved)) || (MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin))) { pnlInviteToGroup.Visible = true; if (String.IsNullOrEmpty(InviteGroupPath)) { script += "function InviteToGroup() {\n modalDialog('" + ApplicationUrlHelper.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/InviteToGroup.aspx") + "?groupid=" + currentGroup.GroupID + "','inviteToGroup', 800, 450); \n } \n"; lnkInviteToGroup.Attributes.Add("onclick", "InviteToGroup();return false;"); lnkInviteToGroup.NavigateUrl = RequestContext.CurrentURL; } else { lnkInviteToGroup.NavigateUrl = GetUrl(InviteGroupPath); } } } // Display invite to group link for user who is visiting another user's page else if ((siteContextUser != null) && (siteContextUser.UserName != currentUser.UserName) && (GroupInfoProvider.GetUserGroupsCount(currentUser, SiteContext.CurrentSite) != 0)) { pnlInviteToGroup.Visible = true; if (String.IsNullOrEmpty(InviteGroupPath)) { script += "function InviteToGroup() {\n modalDialog('" + ApplicationUrlHelper.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/InviteToGroup.aspx") + "?invitedid=" + siteContextUser.UserID + "','inviteToGroup', 700, 400); \n } \n"; lnkInviteToGroup.Attributes.Add("onclick", "InviteToGroup();return false;"); lnkInviteToGroup.NavigateUrl = RequestContext.CurrentURL; } else { lnkInviteToGroup.NavigateUrl = GetUrl(InviteGroupPath); } } } } // Register menu management scripts ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "Shortcuts_" + ClientID, ScriptHelper.GetScript(script)); // Register the dialog script ScriptHelper.RegisterDialogScript(Page); } }