protected void btnDelete_Click(object sender, EventArgs e) { article_id = Convert.ToInt32(Request.QueryString["articleID"]); qLrn_Article article = new qLrn_Article(article_id); article.Available = "No"; article.MarkAsDelete = 1; article.Update(); if (Request.QueryString["edit-mode"] == "in-place") Response.Redirect(Request.QueryString["returnURL"]); else Response.Redirect("articles-list.aspx"); }
protected void btnSave_OnClick(object sender, System.EventArgs e) { int user_id = Convert.ToInt32(Context.Items["UserID"]); if (!String.IsNullOrEmpty(Request.QueryString["articleID"])) { article_id = Convert.ToInt32(Request.QueryString["articleID"]); qLrn_Article article = new qLrn_Article(article_id); article.Title = txtTitle.Text; article.Description = txtSummary.Text; article.Body = reContent.Content; article.LastModified = DateTime.Now; article.LastModifiedBy = user_id; if (!String.IsNullOrEmpty(ddlAuthor.SelectedValue)) { article.AuthorID = Convert.ToInt32(ddlAuthor.SelectedValue); article.OrganizationAuthorID = Convert.ToInt32(ddlAuthor.SelectedValue); } if (!String.IsNullOrEmpty(ddlLanguage.SelectedValue)) article.Language = ddlLanguage.SelectedValue; else article.Language = "en"; if (!String.IsNullOrEmpty(ddlTheme.SelectedValue)) article.ThemeID = Convert.ToInt32(ddlTheme.SelectedValue); article.Available = rblAvailable.SelectedValue; if (plhArticleType.Visible == true) article.ArticleType = ddlArticleType.SelectedValue; article.Update(); } else { qLrn_Article article = new qLrn_Article(); article.ScopeID = 1; article.Created = DateTime.Now; article.CreatedBy = user_id; article.LastModified = DateTime.Now; article.LastModifiedBy = user_id; article.Available = "Yes"; article.MarkAsDelete = 0; article.Title = txtTitle.Text; article.Description = txtSummary.Text; article.Body = reContent.Content; article.LastModified = DateTime.Now; article.LastModifiedBy = user_id; if (!String.IsNullOrEmpty(ddlAuthor.SelectedValue)) { article.AuthorID = Convert.ToInt32(ddlAuthor.SelectedValue); article.OrganizationAuthorID = Convert.ToInt32(ddlAuthor.SelectedValue); } if (!String.IsNullOrEmpty(ddlLanguage.SelectedValue)) article.Language = ddlLanguage.SelectedValue; else article.Language = "en"; if (!String.IsNullOrEmpty(ddlTheme.SelectedValue)) article.ThemeID = Convert.ToInt32(ddlTheme.SelectedValue); if (plhArticleType.Visible == true) article.ArticleType = ddlArticleType.SelectedValue; article.Available = rblAvailable.SelectedValue; article.Insert(); article_id = article.ArticleID; } string user_name = (new qPtl_User(user_id)).UserName; // add keywords string owner_keywords = string.Empty; qPtl_KeywordReference.DeleteKeywordReferencesByContent((int)qSoc_ContentType.Types.Article, article_id); foreach (ListItem item in cblKeywords.Items) { if (item.Selected) { if (!String.IsNullOrEmpty(owner_keywords)) owner_keywords += "," + item.Text; else owner_keywords += item.Text; qPtl_KeywordReference keyword = new qPtl_KeywordReference(); keyword.Available = "Yes"; keyword.ScopeID = Convert.ToInt32(Context.Items["ScopeID"]); keyword.KeywordID = Convert.ToInt32(item.Value); keyword.ContentTypeID = (int)qSoc_ContentType.Types.Article; keyword.ReferenceID = article_id; keyword.Created = DateTime.Now; keyword.LastModified = DateTime.Now; keyword.CreatedBy = Convert.ToInt32(Context.Items["UserID"]); keyword.LastModifiedBy = Convert.ToInt32(Context.Items["UserID"]); keyword.MarkAsDelete = 0; keyword.Insert(); } } string reserved_keywords = string.Empty; foreach (ListItem item in chkTopics.Items) { if (item.Selected) { if (!String.IsNullOrEmpty(reserved_keywords)) reserved_keywords += "," + item.Text; else reserved_keywords += item.Text; } } qSoc_Feed feed = new qSoc_Feed((int)qSoc_ContentType.Types.Article, article_id); if (!chkDisplayInFeed.Checked && !chkDisplayInExplore.Checked) { if (feed != null) { if (feed.FeedID > 0) { feed.MarkAsDelete = 1; feed.Available = "No"; feed.ReservedKeywords = reserved_keywords; if (!chkDisplayInFeed.Checked) feed.VisibleFeed = false; if (!chkDisplayInExplore.Checked) feed.VisibleExplore = false; feed.Update(); } } } else if (chkDisplayInFeed.Checked || chkDisplayInExplore.Checked || !string.IsNullOrEmpty(reserved_keywords)) { qLrn_Article article = new qLrn_Article(article_id); int p_user_id = user_id; if (post_as_user_id > 0) p_user_id = post_as_user_id; qPtl_User user = new qPtl_User(p_user_id); var u_space = qSoc_UserSpace_View.GetUserSpaces(article.CreatedBy); // evaluate title and description string p_title = q_Helper.replaceSpecialCharacters(article.Title); string p_description = q_Helper.replaceSpecialCharacters(article.Description); if (feed != null) { if (feed.FeedID > 0) { feed.CreatedBy = user.UserID; feed.Available = article.Available; if (chkMoveToTop.Checked) feed.LastModified = DateTime.Now; feed.LastModifiedBy = user.UserID; feed.MarkAsDelete = article.MarkAsDelete; feed.OwnerMarkAsDelete = article.MarkAsDelete; feed.ContentTypeID = (int)qSoc_ContentType.Types.Article; feed.ReferenceID = article_id; feed.OwnerID = user.UserID; feed.OwnerName = user.UserName; feed.OwnerProfilePic = user.ProfilePict; feed.Type = "article"; feed.Title = p_title; feed.Description = p_description; feed.Body = p_description; feed.OwnerRole = user.HighestRole; feed.OwnerRoleID = user.HighestRank; feed.OwnerKeywords = owner_keywords; feed.ReservedKeywords = reserved_keywords; feed.UploadedFrom = "manager"; if (!String.IsNullOrEmpty(ddlTheme.SelectedValue)) { feed.ThemeID = Convert.ToInt32(ddlTheme.SelectedValue); feed.ThemeName = Convert.ToString(ddlTheme.SelectedItem); } if (chkDisplayInFeed.Checked) feed.VisibleFeed = true; else feed.VisibleFeed = false; if (chkDisplayInExplore.Checked) feed.VisibleExplore = true; else feed.VisibleExplore = false; feed.Update(); } else { // create new feed item if (u_space != null) { foreach (var s in u_space) { feed.SpaceID = s.SpaceID; feed.SpaceName = s.SpaceShortName; } } feed.ScopeID = Convert.ToInt32(Context.Items["ScopeID"]); feed.Available = article.Available; feed.Created = DateTime.Now; feed.CreatedBy = user.UserID; feed.LastModified = DateTime.Now; feed.LastModifiedBy = user.UserID; feed.MarkAsDelete = article.MarkAsDelete; feed.OwnerMarkAsDelete = article.MarkAsDelete; feed.ContentTypeID = (int)qSoc_ContentType.Types.Article; feed.ReferenceID = article_id; feed.OwnerID = user.UserID; feed.OwnerName = user.UserName; feed.OwnerProfilePic = user.ProfilePict; feed.Type = "article"; feed.Title = p_title; feed.Description = p_description; feed.Body = p_description; feed.OwnerRole = user.HighestRole; feed.OwnerRoleID = user.HighestRank; feed.VisibleAll = true; feed.VisibleFriends = true; feed.VisibleFollowers = true; feed.VisibleSpace = true; feed.VisiblePrivate = true; feed.VisibleFeed = true; feed.VisibleOwnerFeed = true; feed.VisibleOwnerProfile = true; if (!String.IsNullOrEmpty(ddlTheme.SelectedValue)) { feed.ThemeID = Convert.ToInt32(ddlTheme.SelectedValue); feed.ThemeName = Convert.ToString(ddlTheme.SelectedItem); } feed.ReservedKeywords = reserved_keywords; if (!String.IsNullOrEmpty(owner_keywords)) { feed.OwnerKeywords = owner_keywords; } feed.UploadedFrom = "manager"; if (chkDisplayInFeed.Checked) feed.VisibleFeed = true; else feed.VisibleFeed = false; if (chkDisplayInExplore.Checked) feed.VisibleExplore = true; else feed.VisibleExplore = false; feed.Insert(); } } } // redirect to page to add theme + keywords //Response.Redirect("~/qLrn/articles-list.aspx"); if (!String.IsNullOrEmpty(Request.QueryString["articleID"])) { lblMessage.Text = "*** Record Successfully Updated ***"; lblMessageBottom.Text = "*** Record Successfully Updated ***"; if (Request.QueryString["edit-mode"] == "in-place") { string return_redirect = Request.QueryString["returnURL"]; if (!String.IsNullOrEmpty(Request.QueryString["location"])) return_redirect += "&location=" + Request.QueryString["location"]; Response.Redirect(return_redirect); } else Response.Redirect("articles-list.aspx"); } else { Response.Redirect(Request.Url.ToString() + "?mode=add-successful&articleID=" + article_id); } }