Beispiel #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            prevPage = Request.UrlReferrer.ToString();
            bool UseAuthentication = false;// Convert.ToBoolean(ConfigurationManager.AppSettings["UseAuthentication"]);

            m_PageName = Request.QueryString["PageName"];

            Page.Title      = "COPaKB Wiki Edit: " + m_PageName;
            lbPageName.Text = m_PageName;

            if (UseAuthentication &&
                ((WikiOperations.IsPagePrivate(m_PageName) && !User.IsInRole("Super User")) ||
                 (!User.Identity.IsAuthenticated && !WikiOperations.AllowAnonymousEdit(m_PageName))))
            {
                //They don't have rights to view this page
                Response.Redirect("~/Login.aspx");
            }

            LoadPage();
        }
        else
        {
            m_PageName = (string)ViewState["PageName"];

            Page.Title = "Edit: " + m_PageName;

            bool UseAuthentication = false;// Convert.ToBoolean(ConfigurationManager.AppSettings["UseAuthentication"]);

            if (UseAuthentication && WikiOperations.IsPagePrivate(m_PageName) && !User.IsInRole("Super User"))
            {
                //They don't have rights to view this page
                Response.Redirect("~/Login.aspx");
            }
        }
    }
Beispiel #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        GetWikiPageName();
        if (m_PageName == "")
        {
            lbPageName.Text = "COPaKB Wiki Home";
            m_PageName      = "COPaKB Wiki Home";
            //lbEdit.Visible = false;
            //lbViewHistory.Visible = false;
            WikiPage wikiPage = GetWikiPage();
            if (wikiPage != null)
            {
                SetPageContent(wikiPage);
            }
            LoadNewPages();
        }
        else
        {
            Page.Title        = "COPaKB Wiki:" + m_PageName;
            lbPageName.Text   = m_PageName;
            pNewPages.Visible = false;

            bool UseAuthentication = Convert.ToBoolean(ConfigurationManager.AppSettings["UseAuthentication"]);

            if (UseAuthentication && WikiOperations.IsPagePrivate(m_PageName) && !User.IsInRole("Super User"))
            {
                //They don't have rights to view this page
                Response.Redirect("~/Login.aspx");
            }

            WikiPage wikiPage = GetWikiPage();
            if (wikiPage != null)
            {
                SetPageContent(wikiPage);
            }
            else
            {
                bool AllowAnonCreate = Convert.ToBoolean(ConfigurationManager.AppSettings["AllowAnonymousPageCreation"]);

                if (UseAuthentication && !AllowAnonCreate && !User.Identity.IsAuthenticated)
                {
                    Response.Redirect("~/Login.aspx");
                }

                wikiPage               = new WikiPage();
                wikiPage.PageName      = m_PageName;
                wikiPage.PageContent   = string.Format("There is no Wiki page on record for '{0}', please feel free to create one.", m_PageName);
                wikiPage.ModifiedBy    = User.Identity.IsAuthenticated ? User.Identity.Name : "Anonymous";
                wikiPage.LastModified  = DateTime.Now;
                wikiPage.Created       = DateTime.Now;
                wikiPage.IsPrivate     = User.Identity.IsAuthenticated ? true : false;
                wikiPage.AllowAnonEdit = User.Identity.IsAuthenticated ? false : true;

                /*if (WikiOperations.CreateWikiPage(wikiPage) == 1)
                 * {
                 *  SetPageContent(wikiPage);
                 * }
                 * else
                 * {
                 *  litContent.Text = "Error creating page";
                 * }*/
                SetPageContent(wikiPage);
            }
        }
    }