Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                MainSecurity objSecu       = new MainSecurity();
                Role         objRole       = objSecu.GetRole(Page.User.Identity.Name, DFISYS.API.Config.CurrentChannel);
                Permission   objPermission = objSecu.GetPermission(Page.User.Identity.Name);



                // Check permission doi voi tung loai thong ke
                if (objPermission.isXuat_Ban_Bai)
                {
                    ltrSumNewsPublished.Text = NewslistHelper.GetCountNews("publishedlist", false).ToString();
                    hplPublished.NavigateUrl = "/office/publishedlist.aspx";
                }
                else
                {
                    hplPublished.Visible = false;
                }

                if (objPermission.isDuyet_Bai)
                {
                    ltrSumNewsWaitingApprove.Text     = NewslistHelper.GetCountNews("approvalwaitlist", false).ToString();
                    hplNewsWaitingApprove.NavigateUrl = "/office/approvalwaitlist.aspx";
                }
                else
                {
                    hplNewsWaitingApprove.Visible = false;
                }


                if (objPermission.isBien_Tap_Bai)
                {
                    ltrSumNewsWaitingEdit.Text     = NewslistHelper.GetCountNews("editwaitlist", false).ToString();
                    hplNewsWaitingEdit.NavigateUrl = "/office/editwaitlist.aspx";
                }
                else
                {
                    hplNewsWaitingEdit.Visible = false;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Check whether current user can edit the news
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static bool isHasPermission(HttpContext context)
        {
            if (context.Request.QueryString["NewsRef"] == null || context.Request.QueryString["NewsRef"] == string.Empty)
            {
                return(true);
            }
            else
            {
                string cpMode = context.Request.QueryString["cpmode"];
                if (!string.IsNullOrEmpty(cpMode))
                {
                    if (cpMode.Contains(","))
                    {
                        cpMode = cpMode.Substring(cpMode.IndexOf(",") + 1);
                    }
                    cpMode = cpMode.ToLower();

                    long   newsId   = long.Parse(context.Request.QueryString["NewsRef"]);
                    string userName = context.User.Identity.Name;
                    if (!string.IsNullOrEmpty(userName) && newsId != 0)
                    {
                        MainSecurity objsecu = new MainSecurity();
                        //Role objrole = objsecu.GetRole(context.User.Identity.Name);

                        NewsRow newsRow = NewsEditHelper.GetNewsInfo_News(newsId, false);
                        if (newsRow != null)
                        {
                            Permission permission = objsecu.GetPermission(userName);
                            MainDB     db         = new MainDB();
                            bool       toReturn   = false;
                            switch (cpMode)
                            {
                            case "templist":
                                toReturn = newsRow.News_Status == (byte)NewsStatus.LuuTam &&
                                           db.StoredProcedures.News_isLastAccessUser(newsId, userName);
                                break;

                            case "editwaitlist":
                                toReturn = newsRow.News_Status == (byte)NewsStatus.ChoBienTap &&
                                           permission.isBien_Tap_Bai &&
                                           db.StoredProcedures.News_isHasPermissionEdit(newsId, CategoryHelper.GetCatIDByUser());
                                break;

                            case "editinglist":
                                toReturn = newsRow.News_Status == (byte)NewsStatus.NhanBienTap &&
                                           permission.isBien_Tap_Bai &&
                                           db.StoredProcedures.News_isLastAccessUser(newsId, userName);
                                break;

                            case "approvalwaitlist":
                                toReturn = newsRow.News_Status == (byte)NewsStatus.ChoDuyet && permission.isDuyet_Bai &&
                                           db.StoredProcedures.News_isHasPermissionEdit(newsId, CategoryHelper.GetCatIDByUser());
                                break;

                            case "approvalwaitspeciallist":
                                toReturn = newsRow.News_Status == (byte)NewsStatus.ChoDuyet && permission.isDuyet_Bai &&
                                           db.StoredProcedures.News_isHasPermissionEdit(newsId, CategoryHelper.GetCatIDByUser());
                                break;

                            case "approvinglist":
                                toReturn = newsRow.News_Status == (byte)NewsStatus.NhanDuyet && permission.isDuyet_Bai &&
                                           db.StoredProcedures.News_isLastAccessUser(newsId, userName);
                                break;

                            case "publishedlist":
                                toReturn = newsRow.News_Status == (byte)NewsStatus.XuatBan && permission.isXuat_Ban_Bai &&
                                           db.StoredProcedures.News_isHasPermissionEdit(newsId, CategoryHelper.GetCatIDByUser());
                                break;

                            case "removedlist":
                                toReturn = newsRow.News_Status == (byte)NewsStatus.GoBo && permission.isXuat_Ban_Bai &&
                                           db.StoredProcedures.News_isHasPermissionEdit(newsId, CategoryHelper.GetCatIDByUser());
                                break;

                            case "backlist":
                                toReturn = newsRow.News_Status == (byte)NewsStatus.TraLai &&
                                           db.StoredProcedures.News_isLastAccessUser(newsId, userName);
                                break;

                            case "dellist":
                                toReturn = newsRow.News_Status == (byte)NewsStatus.XoaTam &&
                                           db.StoredProcedures.News_isLastAccessUser(newsId, userName);
                                break;
                            }
                            return(toReturn);
                        }
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string strcpmode = Request.QueryString["cpmode"].ToString();

            CpMode = strcpmode;
            MainSecurity objSercu = new MainSecurity();
            Permission   objPer   = null;
            Role         objrole  = null;

            //DataTable tblPermissions = objSercu.GetPermissionAsTable(HttpContext.Current.User.Identity.Name);
            //isAllowChamNhuanBut = tblPermissions.Select("Permission_ID=" + PermissionConst.ChamNhuanBut).Length == 1;
            objPer = objSercu.GetPermission(Page.User.Identity.Name);
            isAllowChamNhuanBut = objPer.isChamNhuanBut;

            if (!Page.IsPostBack)
            {
                string strUrlRefer = Request.UrlReferrer != null?Request.UrlReferrer.ToString().ToLower() : "";

                if (strUrlRefer == "" || strUrlRefer.IndexOf("add," + strcpmode) == -1)
                {
                    Session.Remove("ddlChuyenmuc");
                    Session.Remove("txtFromDate");
                    Session.Remove("txtToDate");
                    Session.Remove("txtKeyword");
                    Session.Remove("cboCategory");
                    Session.Remove("cboTieuDiem");
                    Session.Remove("cboIsHot");
                }

                txtFromDate.Attributes.Add("onkeypress", "SetReadOnly()");
                txtToDate.Attributes.Add("onkeypress", "SetReadOnly()");
                txtFromDate.Attributes.Add("onpaste", "return false");
                txtToDate.Attributes.Add("onpaste", "return false");
                txtFromDate.Attributes.Add("oncontextmenu", "return false");
                txtToDate.Attributes.Add("oncontextmenu", "return false");
                txtKeyword.Attributes.Add("onkeypress", "return trapEnterKey(event, '" + btnSearch.ClientID + "')");

                Session["cpmode"] = Request.QueryString["cpmode"];
                string strCats = CategoryHelper.Treebuild(ddlChuyenmuc);
                CategoryHelper.Treebuild(ddlChuyenmuc);

                // Init value
                ddlChuyenmuc.SelectedValue = Session["ddlChuyenmuc"] != null ? Session["ddlChuyenmuc"].ToString() : "0";
                txtToDate.Text             = Session["txtToDate"] != null ? Session["txtToDate"].ToString() : "";
                txtFromDate.Text           = Session["txtFromDate"] != null ? Session["txtFromDate"].ToString() : "";
                //cboCategory.SelectedValue = Session["cboCategory"] != null ? Session["cboCategory"].ToString() : "0";
                txtKeyword.Text = Session["txtKeyword"] != null ? Session["txtKeyword"].ToString() : "";

                //Helper.BindUser(cboApproverBy);
                //Helper.BindUser(cboCreatedBy);

                // End Init Value

                if (string.IsNullOrEmpty(strCats))
                {
                    objListNewsSource.SelectParameters[0].DefaultValue = "News_Status = -2 AND Cat_ID = -2";
                    return;
                }

                // Tu dong Search
                if (Session["ddlChuyenmuc"] != null || (Session["txtToDate"] != null && Session["txtFromDate"] != null))
                {
                    Filter();
                    //return;
                }
                else if (Session["cboCategory"] != null || Session["txtKeyword"] != null)
                {
                    btnSearch_Click(null, null);
                    //return;
                }
                else
                {
                    excutive(strcpmode, strCats, "");
                }



                // show command button, page title depending on cp mode
                switch (strcpmode)
                {
                case "templist":
                    ltrLabel.Text = "Danh sách bài viết lưu tạm";
                    break;

                case "sendlist":
                    ltrLabel.Text      = "Danh sách bài viết đã gửi chờ biên tập";
                    LinkDelete.Visible = false;
                    break;

                case "sendapprovallist":
                    ltrLabel.Text      = "Danh sách bài viết đã gửi chờ duyệt";
                    LinkDelete.Visible = false;

                    break;

                case "dellist":
                    ltrLabel.Text      = "Danh sách bài viết xóa tạm";
                    LinkDelete.Visible = true;

                    break;

                case "editwaitlist":
                    ltrLabel.Text = "Danh sách bài viết chờ biên tập";

                    break;

                case "editinglist":
                    ltrLabel.Text = "Danh sách bài viết nhận biên tập";

                    break;

                case "approvinglist":
                    ltrLabel.Text = "Danh sách bài viết nhận duyệt";


                    break;

                case "approvalwaitlist":
                    ltrLabel.Text = "Danh sách bài viết chờ duyệt";



                    break;

                case "publishedlist":
                    ltrLabel.Text = "Danh sách bài viết đã xuất bản";
                    grdListNews.Columns[2].Visible = true;

                    // LinkDelete.Visible = false;

                    break;

                //voi danh sach bai tra lai.
                case "backlist":
                    ltrLabel.Text = "Danh sách bài viết trả lại";
                    break;

                //voi danh sach bai tra lai.
                case "removedlist":
                    ltrLabel.Text = "Danh sách bài viết đã gỡ bỏ";
                    break;

                case "mypublished":
                    LinkDelete.Visible = false;
                    break;

                default:
                    //xem quyen cua thang dang set

                    break;
                }
            }
        }
        private void BindNewsEdit(long _news_id)
        {
            NewsRow      objNewsRow = NewsEditHelper.GetNewsInfo_NewsExtension(_news_id, false);
            MainSecurity objSercu   = new MainSecurity();
            Permission   objPer     = objSercu.GetPermission(Page.User.Identity.Name);

            if (objPer.isXuat_Ban_Bai)
            {
                //Kiểm tra nếu có quyền xuất bản thì sẽ hiện dầy đủ thông tin
                btnPublish.Visible = true;
                // pnControl.Visible = true;
            }
            else
            {
                btnPublish.Visible = false;
            }
            if (objNewsRow != null)
            {
                if (!objPer.isXuat_Ban_Bai && Page.User.Identity.Name.Trim().ToLower() != objNewsRow.News_Author.Trim().ToLower())
                {
                    throw new SecurityException("Bạn không có quyền truy cập vào trang này");
                    return;
                }



                ltrXuatBan.Text      = "Bài viết do \"" + objNewsRow.News_Approver.ToUpper() + "\" xuất bản lúc " + objNewsRow.News_PublishDate.ToString("dd/MM/yyyy hh:mm");
                lstCat.SelectedValue = objNewsRow.Cat_ID.ToString();
                txtTitle.Text        = objNewsRow.News_Title != null ? objNewsRow.News_Title : "";
                txtSubTitle.Text     = objNewsRow.News_Subtitle != null ? objNewsRow.News_Subtitle : "";
                txtSource.Text       = objNewsRow.News_Source != null ? objNewsRow.News_Source : "";
                txtInit.Text         = objNewsRow.News_InitialContent != null?NewsEditHelper.ReplaceImageSrcToEmoticon(objNewsRow.News_InitialContent) : "";

                txtInit.Text = txtInit.Text.Replace("<br/>", System.Environment.NewLine);
                if (Request.QueryString["redirect"] == null)
                {
                    NewsContent.Text       = objNewsRow.News_Content != null ? objNewsRow.News_Content : "";
                    Session["NewsContent"] = NewsContent.Text;
                }
                else
                {
                    NewsContent.Text = Session["NewsContent"].ToString();
                }
                chkIsFocus.Checked     = objNewsRow.IsNews_isFocusNull != true ? objNewsRow.News_isFocus : false;
                cboIsHot.SelectedValue = objNewsRow.IsNews_ModeNull != true?objNewsRow.News_Mode.ToString() : "0";

                hdRelatNews.Value      = objNewsRow.News_Relation != null ? objNewsRow.News_Relation : "";
                chkShowComment.Checked = objNewsRow.IsisCommentNull != true ? objNewsRow.isComment : false; //Cho phép hiện ảnh hay ko?
                chkShowRate.Checked    = objNewsRow.IsisUserRateNull != true ? objNewsRow.isUserRate : false;
                txtSelectedFile.Text   = objNewsRow.News_Image != null ? objNewsRow.News_Image : "";
                txtImageTitle.Text     = objNewsRow.News_ImageNote != null ? objNewsRow.News_ImageNote : "";
                txtIcon.Text           = objNewsRow.Icon != null ? objNewsRow.Icon : "";
                txtMaCP.Text           = objNewsRow.Extension1 != null ? objNewsRow.Extension1 : "";
                txtExtension2.Text     = objNewsRow.Extension2 != null ? objNewsRow.Extension2 : "";
                txtSourceLink.Text     = objNewsRow.Extension3 != null ? objNewsRow.Extension3 : "";


                ddlAuthor.SelectedValue = objNewsRow.IsExtension4Null != true?objNewsRow.Extension4.ToString() : "0";

                if (objNewsRow.Template != 0)
                {
                    ddlProvinces.SelectedValue = objNewsRow.Template.ToString();
                }

                if (objNewsRow.News_OtherCat != null)
                {
                    string[] strOthers = objNewsRow.News_OtherCat.Split(",".ToCharArray());
                    for (int i = 0; i < lstOtherCat.Items.Count; i++)
                    {
                        foreach (string strItem in strOthers)
                        {
                            if (strItem == lstOtherCat.Items[i].Value)
                            {
                                lstOtherCat.Items[i].Selected = true;
                                break;
                            }
                        }
                    }
                }

                if (!objNewsRow.IsNews_PublishDateNull)
                {
                    SetValueForCombo(cboMonth, objNewsRow.News_PublishDate.Month.ToString());
                    SetValueForCombo(cboDay, objNewsRow.News_PublishDate.Day.ToString());
                    SetValueForCombo(cboYear, objNewsRow.News_PublishDate.Year.ToString());
                    SetValueForCombo(cboSercond, objNewsRow.News_PublishDate.Second.ToString());
                    SetValueForCombo(cboMinute, objNewsRow.News_PublishDate.Minute.ToString());
                    SetValueForCombo(cboHour, objNewsRow.News_PublishDate.Hour.ToString());
                }
                else
                {
                    SetValueForCombo(cboMonth, "0");
                    SetValueForCombo(cboDay, "0");
                    SetValueForCombo(cboYear, "2000");
                    SetValueForCombo(cboSercond, "-1");
                    SetValueForCombo(cboMinute, "-1");
                    SetValueForCombo(cboHour, "-1");
                }

                if (!IsPostBack)
                {
                    hdMedia.Value = DFISYS.BO.Editoral.NewsMedia.NewsMediaHelper.Get_ObjectId_By_NewsId(_news_id);
                    DataTable dtThread = ThreadHelper.SelectThreadByNewsID(_news_id);
                    if (dtThread != null && dtThread.Rows.Count > 0)
                    {
                        hidLuongSuKien.Value = dtThread.Rows[0]["Thread_ID"].ToString();
                    }
                }


                //Load data to Combobox Tin lien quan;
                string str;
                if (hdRelatNews.Value.TrimEnd(',') != "")
                {
                    str = NewsEditHelper.Get_Media_By_ListsId("News_ID", "News_Title", "News", hdRelatNews.Value);
                    BindToDropdown(cboNews, str);
                }


                string strThread;
                if (hidLuongSuKien.Value.TrimEnd(',') != "")
                {
                    strThread = NewsEditHelper.Get_Media_By_ListsId("Thread_ID", "Title", "NewsThread", hidLuongSuKien.Value);
                    BindToDropdown(lstThread, strThread);

                    string[] arrThread = hidLuongSuKien.Value.Split(',');
                    if (arrThread != null && arrThread.Length > 0)
                    {
                        for (int i = 0; i < cblTags.Items.Count; i++)
                        {
                            foreach (string strItem in arrThread)
                            {
                                if (strItem == cblTags.Items[i].Value)
                                {
                                    cblTags.Items[i].Selected = true;
                                    break;
                                }
                            }
                        }
                    }
                }
                if (hdMedia.Value.TrimEnd(',').Length > 0)
                {
                    str = NewsEditHelper.Get_Media_By_ListsId("Object_ID", "Object_Url", "MediaObject", hdMedia.Value);
                    //BindToDropdown(cboMedia, str);
                }

                LoadAttachmentsType(_news_id);
            }
        }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string strcpmode = Request.QueryString["cpmode"].ToString();

            CpMode = strcpmode;
            MainSecurity objSercu = new MainSecurity();
            Permission   objPer   = null;
            Role         objrole  = null;

            //DataTable tblPermissions = objSercu.GetPermissionAsTable(HttpContext.Current.User.Identity.Name);
            //isAllowChamNhuanBut = tblPermissions.Select("Permission_ID=" + PermissionConst.ChamNhuanBut).Length == 1;
            objPer = objSercu.GetPermission(Page.User.Identity.Name);
            isAllowChamNhuanBut = objPer.isChamNhuanBut;

            if (!Page.IsPostBack)
            {
                string strUrlRefer = Request.UrlReferrer != null?Request.UrlReferrer.ToString().ToLower() : "";

                if (strUrlRefer == "" || strUrlRefer.IndexOf("add," + strcpmode) == -1)
                {
                    Session.Remove("ddlChuyenmuc");
                    Session.Remove("txtFromDate");
                    Session.Remove("txtToDate");
                    Session.Remove("txtKeyword");
                    Session.Remove("cboCategory");
                    Session.Remove("cboTieuDiem");
                    Session.Remove("cboIsHot");
                }

                txtFromDate.Attributes.Add("onkeypress", "SetReadOnly()");
                txtToDate.Attributes.Add("onkeypress", "SetReadOnly()");
                txtFromDate.Attributes.Add("onpaste", "return false");
                txtToDate.Attributes.Add("onpaste", "return false");
                txtFromDate.Attributes.Add("oncontextmenu", "return false");
                txtToDate.Attributes.Add("oncontextmenu", "return false");
                txtKeyword.Attributes.Add("onkeypress", "return trapEnterKey(event, '" + btnSearch.ClientID + "')");

                Session["cpmode"] = Request.QueryString["cpmode"];
                string strCats = CategoryHelper.Treebuild(ddlChuyenmuc);
                CategoryHelper.Treebuild(ddlChuyenmuc);

                // Init value
                ddlChuyenmuc.SelectedValue = Session["ddlChuyenmuc"] != null ? Session["ddlChuyenmuc"].ToString() : "0";
                txtToDate.Text             = Session["txtToDate"] != null ? Session["txtToDate"].ToString() : "";
                txtFromDate.Text           = Session["txtFromDate"] != null ? Session["txtFromDate"].ToString() : "";
                //cboCategory.SelectedValue = Session["cboCategory"] != null ? Session["cboCategory"].ToString() : "0";
                txtKeyword.Text = Session["txtKeyword"] != null ? Session["txtKeyword"].ToString() : "";

                //Helper.BindUser(cboApproverBy);
                //Helper.BindUser(cboCreatedBy);

                // End Init Value

                if (string.IsNullOrEmpty(strCats))
                {
                    objListNewsSource.SelectParameters[0].DefaultValue = "News_Status = -2 AND Cat_ID = -2";
                    LinkApproval.Visible    = false; ltrsec2.Visible = false;
                    LinkDisApproval.Visible = false; ltrsec3.Visible = false;
                    lnkRealDel.Visible      = false; ltrsec5.Visible = false;
                    LinkSendAll.Visible     = false;
                    LinkDelete.Visible      = false; ltrsec4.Visible = false;
                    LinkFeedBackAll.Visible = false; ltrsec1.Visible = false;
                    return;
                }

                // Tu dong Search
                if (Session["ddlChuyenmuc"] != null || (Session["txtToDate"] != null && Session["txtFromDate"] != null))
                {
                    Filter();
                    //return;
                }
                else if (Session["cboCategory"] != null || Session["txtKeyword"] != null)
                {
                    btnSearch_Click(null, null);
                    //return;
                }
                else
                {
                    excutive(strcpmode, strCats, "");
                }
                // show command button, page title depending on cp mode
                switch (strcpmode)
                {
                case "approvalwaitspeciallist":
                    ltrLabel.Text           = "Danh sách bài viết chờ duyệt";
                    LinkDisApproval.Visible = false; ltrsec3.Visible = false;
                    lnkRealDel.Visible      = false; ltrsec5.Visible = false;
                    LinkSendAll.Visible     = false;
                    LinkDisApproval.Visible = false; ltrsec3.Visible = false;
                    lnkRealDel.Visible      = false; ltrsec5.Visible = false;

                    objPer = objSercu.GetPermission(Page.User.Identity.Name);
                    if (objPer.isXuat_Ban_Bai)
                    {
                        LinkApproval.Visible = true;
                    }
                    else
                    {
                        LinkApproval.Visible = false;
                        isXuatBan            = "false";
                    }

                    break;

                default:
                    //xem quyen cua thang dang set
                    objSercu = new MainSecurity();
                    objrole  = objSercu.GetRole(Page.User.Identity.Name);
                    if (objrole.isBienTapVien)
                    {
                        LinkApproval.Visible    = false; ltrsec2.Visible = false;
                        LinkDisApproval.Visible = false; ltrsec3.Visible = false;
                        lnkRealDel.Visible      = false; ltrsec5.Visible = false;
                    }
                    if (objrole.isPhongVien)
                    {
                        LinkFeedBackAll.Visible = false; ltrsec1.Visible = false;
                        LinkApproval.Visible    = false; ltrsec2.Visible = false;
                        LinkDisApproval.Visible = false; ltrsec3.Visible = false;
                        lnkRealDel.Visible      = false; ltrsec5.Visible = false;
                    }
                    if (objrole.isThuKyChuyenMuc || objrole.isThuKyToaSoan || objrole.isPhuTrachKenh || objrole.isTongBienTap)
                    {
                        LinkDisApproval.Visible = false; ltrsec3.Visible = false;
                        lnkRealDel.Visible      = false; ltrsec5.Visible = false;
                    }
                    break;
                }
            }
        }