/// <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 user is authorized per project access. /// </summary> public bool IsAuthorizedPerProjectAccess() { // Keep current user CurrentUserInfo cui = CMSContext.CurrentUser; // Switch by create project option switch (ProjectAccess.ToLowerCSafe()) { // All users case "all": return(true); // Authenticated users case "authenticated": if (!cui.IsPublic()) { return(true); } break; // Group members case "groupmember": if (CommunityGroupID > 0) { return(cui.IsGroupMember(CommunityGroupID)); } break; // Authorized roles case "authorized": // Check whether roles are defined if (!String.IsNullOrEmpty(AuthorizedRoles)) { // Check whether user is valid group member if current project is assigned to some group if (CommunityGroupID > 0) { if (!cui.IsGroupMember(CommunityGroupID)) { return(false); } } // Keep site name string siteName = CMSContext.CurrentSiteName; // Split roles by semicolon string[] roles = AuthorizedRoles.Split(';'); // Loop thru all roles and check if user is assigned at leat to one role foreach (string role in roles) { // If user is in role, break current cycle and return true if (cui.IsInRole(role, siteName)) { return(true); } } } break; // Nobody case "nobody": default: return(false); } return(false); }