/// <summary> /// Handles the UniGrid's OnAction event. /// </summary> /// <param name="actionName">Name of item (button) that throws event</param> /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param> protected void uniGrid_OnAction(string actionName, object actionArgument) { if (actionName == "edit") { SelectedItemID = Convert.ToInt32(actionArgument); RaiseOnEdit(); } else if (actionName == "delete") { if (!AllowEdit) { return; } if (GroupId > 0) { CMSGroupPage.CheckGroupPermissions(GroupId, PERMISSION_MANAGE); } // Delete PollAnswerInfo object from database PollAnswerInfoProvider.DeletePollAnswerInfo(Convert.ToInt32(actionArgument)); ReloadData(true); } else if (actionName == "moveup") { if (!AllowEdit) { return; } if (GroupId > 0) { CMSGroupPage.CheckGroupPermissions(GroupId, PERMISSION_MANAGE); } // Move the answer up in order PollAnswerInfoProvider.MoveAnswerUp(PollId, Convert.ToInt32(actionArgument)); ReloadData(true); } else if (actionName == "movedown") { if (!AllowEdit) { return; } if (GroupId > 0) { CMSGroupPage.CheckGroupPermissions(GroupId, PERMISSION_MANAGE); } // Move the answer down in order PollAnswerInfoProvider.MoveAnswerDown(PollId, Convert.ToInt32(actionArgument)); ReloadData(true); } }
protected void gridPosts_OnAction(string actionName, object actionArgument) { int postId = ValidationHelper.GetInteger(actionArgument, 0); if (actionName.ToLowerCSafe() == "delete") { if (CommunityGroupID == 0) { // Check forums modify permissions if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.forums", PERMISSION_MODIFY)) { RedirectToAccessDenied("cms.forums", PERMISSION_MODIFY); } } else { // Check group permissions CMSGroupPage.CheckGroupPermissions(CommunityGroupID, PERMISSION_MANAGE); } ForumPostInfoProvider.DeleteForumPostInfo(postId); } }
protected void btnOk_Click(object sender, EventArgs e) { if (CommunityGroupID == 0) { // Check forums modify permissions if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.forums", PERMISSION_MODIFY)) { RedirectToAccessDenied("cms.forums", PERMISSION_MODIFY); } } else { // Check group permissions CMSGroupPage.CheckGroupPermissions(CommunityGroupID, PERMISSION_MANAGE); } Action action = (Action)ValidationHelper.GetInteger(drpAction.SelectedValue, 0); What what = What.Selected; //(What)ValidationHelper.GetInteger(drpWhat.SelectedValue, 0); List <int> items = new List <int>(); switch (what) { // Only selected posts case What.Selected: foreach (string item in gridPosts.SelectedItems) { items.Add(ValidationHelper.GetInteger(item, 0)); } break; // On posts in unigrid case What.All: DataSet ds = gridPosts.GridView.DataSource as DataSet; if (!DataHelper.DataSourceIsEmpty(ds)) { foreach (DataRow dr in ds.Tables[0].Rows) { int postId = ValidationHelper.GetInteger(dr["PostId"], 0); items.Add(postId); } } break; } // For all specified forum posts foreach (int postId in items) { ForumPostInfo fpi = ForumPostInfoProvider.GetForumPostInfo(postId); if (fpi != null) { switch (action) { // Approve post case Action.Approve: fpi.Approve(); break; // Approve subtree case Action.ApproveSubTree: fpi.Approve(MembershipContext.AuthenticatedUser.UserID, true); break; // Reject post case Action.Reject: fpi.Reject(); break; // Reject subtree case Action.RejectSubTree: fpi.Reject(true); break; // Delete post case Action.Delete: ForumPostInfoProvider.DeleteForumPostInfo(fpi); break; } } } // If something happened if (items.Count > 0) { // Get rid of selection gridPosts.ResetSelection(); // Reload unigrid to see changes gridPosts.ReloadData(); // Force refresh post tree ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "RefreshPostTree", ScriptHelper.GetScript("SelectInTree(" + PostId + ", true);")); } }