public HttpResponseMessage ApproveGroup(NotificationDTO postData) { try { var recipient = InternalMessagingController.Instance.GetMessageRecipient(postData.NotificationId, this.UserInfo.UserID); if (recipient == null) { return(this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Unable to locate recipient")); } var notification = NotificationsController.Instance.GetNotification(postData.NotificationId); this.ParseKey(notification.Context); if (this._roleInfo == null) { return(this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Unable to locate role")); } if (!this.IsMod()) { return(this.Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "Not Authorized!")); } this._roleInfo.Status = RoleStatus.Approved; RoleController.Instance.UpdateRole(this._roleInfo); var roleCreator = UserController.GetUserById(this.PortalSettings.PortalId, this._roleInfo.CreatedByUserID); // Update the original creator's role RoleController.Instance.UpdateUserRole(this.PortalSettings.PortalId, roleCreator.UserID, this._roleInfo.RoleID, RoleStatus.Approved, true, false); GroupUtilities.CreateJournalEntry(this._roleInfo, roleCreator); var notifications = new Notifications(); var siteAdmin = UserController.GetUserById(this.PortalSettings.PortalId, this.PortalSettings.AdministratorId); notifications.AddGroupNotification(Constants.GroupApprovedNotification, this._tabId, this._moduleId, this._roleInfo, siteAdmin, new List <RoleInfo> { this._roleInfo }); NotificationsController.Instance.DeleteAllNotificationRecipients(postData.NotificationId); return(this.Request.CreateResponse(HttpStatusCode.OK, new { Result = "success" })); } catch (Exception exc) { Logger.Error(exc); return(this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc)); } }
public ActionResult ApproveGroup(int notificationId) { try { var recipient = InternalMessagingController.Instance.GetMessageRecipient(notificationId, UserInfo.UserID); if (recipient == null) { return(Json(new { Result = "error" })); } var notification = NotificationsController.Instance.GetNotification(notificationId); ParseKey(notification.Context); if (roleInfo == null) { return(Json(new { Result = "error" })); } if (!IsMod()) { return(Json(new { Result = "access denied" })); } var roleController = new RoleController(); roleInfo.Status = RoleStatus.Approved; roleController.UpdateRole(roleInfo); var roleCreator = UserController.GetUserById(PortalSettings.PortalId, roleInfo.CreatedByUserID); //Update the original creator's role roleController.UpdateUserRole(PortalSettings.PortalId, roleCreator.UserID, roleInfo.RoleID, RoleStatus.Approved, true, false); GroupUtilities.CreateJournalEntry(roleInfo, roleCreator); var notifications = new Notifications(); var siteAdmin = UserController.GetUserById(PortalSettings.PortalId, PortalSettings.AdministratorId); notifications.AddGroupNotification(Constants.GroupApprovedNotification, TabId, ModuleId, roleInfo, siteAdmin, new List <RoleInfo> { roleInfo }); NotificationsController.Instance.DeleteAllNotificationRecipients(notificationId); return(Json(new { Result = "success" })); } catch (Exception exc) { DnnLog.Error(exc); return(Json(new { Result = "error" })); } }
public HttpResponseMessage RejectGroup(NotificationDTO postData) { try { var recipient = InternalMessagingController.Instance.GetMessageRecipient(postData.NotificationId, UserInfo.UserID); if (recipient == null) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Unable to locate recipient")); } var notification = NotificationsController.Instance.GetNotification(postData.NotificationId); ParseKey(notification.Context); if (_roleInfo == null) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Unable to locate role")); } if (!IsMod()) { return(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "Not Authorized!")); } var notifications = new Notifications(); var roleCreator = UserController.GetUserById(PortalSettings.PortalId, _roleInfo.CreatedByUserID); var siteAdmin = UserController.GetUserById(PortalSettings.PortalId, PortalSettings.AdministratorId); notifications.AddGroupNotification(Constants.GroupRejectedNotification, _tabId, _moduleId, _roleInfo, siteAdmin, new List <RoleInfo> { _roleInfo }, roleCreator); var role = RoleController.Instance.GetRole(PortalSettings.PortalId, r => r.RoleID == _roleId); RoleController.Instance.DeleteRole(role); NotificationsController.Instance.DeleteAllNotificationRecipients(postData.NotificationId); return(Request.CreateResponse(HttpStatusCode.OK, new { Result = "success" })); } catch (Exception exc) { Logger.Error(exc); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc)); } }
public ActionResult RejectGroup(int notificationId) { try { var recipient = InternalMessagingController.Instance.GetMessageRecipient(notificationId, UserInfo.UserID); if (recipient == null) { return(Json(new { Result = "error" })); } var notification = NotificationsController.Instance.GetNotification(notificationId); ParseKey(notification.Context); if (roleInfo == null) { return(Json(new { Result = "error" })); } if (!IsMod()) { return(Json(new { Result = "access denied" })); } var notifications = new Notifications(); var roleCreator = UserController.GetUserById(PortalSettings.PortalId, roleInfo.CreatedByUserID); var siteAdmin = UserController.GetUserById(PortalSettings.PortalId, PortalSettings.AdministratorId); notifications.AddGroupNotification(Constants.GroupRejectedNotification, TabId, ModuleId, roleInfo, siteAdmin, new List <RoleInfo> { roleInfo }, roleCreator); var roleController = new RoleController(); roleController.DeleteRole(RoleId, PortalSettings.PortalId); NotificationsController.Instance.DeleteAllNotificationRecipients(notificationId); return(Json(new { Result = "success" })); } catch (Exception exc) { DnnLog.Error(exc); return(Json(new { Result = "error" })); } }
private void Create_Click(object sender, EventArgs e) { RoleController roleController = new RoleController(); Security.PortalSecurity ps = new Security.PortalSecurity(); txtGroupName.Text = ps.InputFilter(txtGroupName.Text, Security.PortalSecurity.FilterFlag.NoScripting); txtGroupName.Text = ps.InputFilter(txtGroupName.Text, Security.PortalSecurity.FilterFlag.NoMarkup); txtDescription.Text = ps.InputFilter(txtDescription.Text, Security.PortalSecurity.FilterFlag.NoScripting); txtDescription.Text = ps.InputFilter(txtDescription.Text, Security.PortalSecurity.FilterFlag.NoMarkup); if (roleController.GetRoleByName(PortalId, txtGroupName.Text) != null) { lblInvalidGroupName.Visible = true; return; } var modRoles = new List <RoleInfo>(); var modUsers = new List <UserInfo>(); foreach (ModulePermissionInfo modulePermissionInfo in ModulePermissionController.GetModulePermissions(ModuleId, TabId)) { if (modulePermissionInfo.PermissionKey == "MODGROUP" && modulePermissionInfo.AllowAccess) { if (modulePermissionInfo.RoleID > int.Parse(Globals.glbRoleNothing)) { modRoles.Add(roleController.GetRole(modulePermissionInfo.RoleID, PortalId)); } else if (modulePermissionInfo.UserID > Null.NullInteger) { modUsers.Add(UserController.GetUserById(PortalId, modulePermissionInfo.UserID)); } } } var roleInfo = new RoleInfo() { PortalID = PortalId, RoleName = txtGroupName.Text, Description = txtDescription.Text, SecurityMode = SecurityMode.SocialGroup, Status = RoleStatus.Approved, IsPublic = rdAccessTypePublic.Checked }; var userRoleStatus = RoleStatus.Pending; if (GroupModerationEnabled) { roleInfo.Status = RoleStatus.Pending; userRoleStatus = RoleStatus.Pending; } else { userRoleStatus = RoleStatus.Approved; } var objModulePermissions = new ModulePermissionCollection(CBO.FillCollection(DataProvider.Instance().GetModulePermissionsByModuleID(ModuleId, -1), typeof(ModulePermissionInfo))); if (ModulePermissionController.HasModulePermission(objModulePermissions, "MODGROUP")) { roleInfo.Status = RoleStatus.Approved; userRoleStatus = RoleStatus.Approved; } roleInfo.RoleGroupID = DefaultRoleGroupId; roleInfo.RoleID = roleController.AddRole(roleInfo); roleInfo = roleController.GetRole(roleInfo.RoleID, PortalId); var groupUrl = Globals.NavigateURL(GroupViewTabId, "", new String[] { "groupid=" + roleInfo.RoleID.ToString() }); if (groupUrl.StartsWith("http://") || groupUrl.StartsWith("https://")) { const int startIndex = 8; // length of https:// groupUrl = groupUrl.Substring(groupUrl.IndexOf("/", startIndex, StringComparison.InvariantCultureIgnoreCase)); } roleInfo.Settings.Add("URL", groupUrl); roleInfo.Settings.Add("GroupCreatorName", UserInfo.DisplayName); roleInfo.Settings.Add("ReviewMembers", chkMemberApproved.Checked.ToString()); TestableRoleController.Instance.UpdateRoleSettings(roleInfo, true); if (inpFile.PostedFile != null && inpFile.PostedFile.ContentLength > 0) { IFileManager _fileManager = FileManager.Instance; IFolderManager _folderManager = FolderManager.Instance; var rootFolderPath = PathUtils.Instance.FormatFolderPath(PortalSettings.HomeDirectory); IFolderInfo groupFolder = _folderManager.GetFolder(PortalSettings.PortalId, "Groups/" + roleInfo.RoleID); if (groupFolder == null) { groupFolder = _folderManager.AddFolder(PortalSettings.PortalId, "Groups/" + roleInfo.RoleID); } if (groupFolder != null) { var fileName = Path.GetFileName(inpFile.PostedFile.FileName); var fileInfo = _fileManager.AddFile(groupFolder, fileName, inpFile.PostedFile.InputStream, true); roleInfo.IconFile = "FileID=" + fileInfo.FileId; roleController.UpdateRole(roleInfo); } } var notifications = new Notifications(); roleController.AddUserRole(PortalId, UserId, roleInfo.RoleID, userRoleStatus, true, Null.NullDate, Null.NullDate); if (roleInfo.Status == RoleStatus.Pending) { //Send notification to Group Moderators to approve/reject group. notifications.AddGroupNotification(Constants.GroupPendingNotification, GroupViewTabId, ModuleId, roleInfo, UserInfo, modRoles, modUsers); } else { //Send notification to Group Moderators informing of new group. notifications.AddGroupNotification(Constants.GroupCreatedNotification, GroupViewTabId, ModuleId, roleInfo, UserInfo, modRoles, modUsers); //Add entry to journal. GroupUtilities.CreateJournalEntry(roleInfo, UserInfo); } Response.Redirect(Globals.NavigateURL(GroupViewTabId, "", new String[] { "groupid=" + roleInfo.RoleID.ToString() })); }