protected void Page_Load(object sender, EventArgs e)
        {
            PluggId = Convert.ToInt32(((DotNetNuke.Framework.CDefault)this.Page).Title);
            CultureCode = (Page as DotNetNuke.Framework.PageBase).PageCulture.Name;
            BaseHandler bh = new BaseHandler();
            pc = new PluggContainer(CultureCode, PluggId);
            IsAuthorized = ((this.UserId != -1 && pc.ThePlugg.WhoCanEdit == EWhoCanEdit.Anyone) || pc.ThePlugg.CreatedByUserId == this.UserId || (UserInfo.IsInRole("Administator")));

            if (Request.Form["__EVENTTARGET"] == "btnWhoCanEdit")
            {
                // Fire event
                btnWhoCanEdit_Click(this, new EventArgs());
            }

            if (Request.Form["__EVENTTARGET"] == "btnListed")
            {
                // Fire event
                btnListed_Click(this, new EventArgs());
            }

            UserController uc = new UserController();
            UserInfo u = uc.GetUser(PortalId, pc.ThePlugg.CreatedByUserId);
            hlCreatedBy.Text = u.DisplayName;
            hlCreatedBy.NavigateUrl = DotNetNuke.Common.Globals.UserProfileURL(pc.ThePlugg.CreatedByUserId);
            lbltheCreatedOn.Text = pc.ThePlugg.CreatedOnDate.ToString();
            rblWhoCanEdit.Items.Clear();
            rblWhoCanEdit.Items.Add("Anyone");
            rblWhoCanEdit.Items.Add("Only me");
            rblWhoCanEdit.SelectedValue = "Anyone";
            switch (pc.ThePlugg.WhoCanEdit)
            {
                case EWhoCanEdit.Anyone:
                    lbltheWhoCanEdit.Text = "Anyone";
                    break;
                case EWhoCanEdit.OnlyMe:
                    lbltheWhoCanEdit.Text = "Only me";
                    rblWhoCanEdit.SelectedValue = "Only me";
                    break;
                case EWhoCanEdit.NotSet :
                    lbltheWhoCanEdit.Text = "Not set";
                    break;
            }
            rblListed.Items.Clear();
            rblListed.Items.Add(Localization.GetString("Listed.Text", this.LocalResourceFile));
            rblListed.Items.Add(Localization.GetString("NotListed.Text", this.LocalResourceFile));
            rblListed.SelectedIndex = 0;

            if (pc.ThePlugg.IsListed)
                lblTheListed.Text = "Yes";
            else
            {
                lblTheListed.Text = "No";
                rblListed.SelectedIndex = 1;
            }
            if (pc.ThePlugg.CreatedByUserId == this.UserId)
            {
                btnWhoCanEdit.Visible = true;
                btnListed.Visible = true;
            }
            pc.LoadDescription();
            if (pc.TheDescription != null)
                lbltheDespription.Text = pc.TheDescription.Text;
            else
                lbltheDespription.Text = "-";

            if(pc.ThePlugg.CreatedByUserId == this.UserId || UserInfo.IsInRole("Administator"))
            {
                btnDelete.Visible = true;
            }
        }
Example #2
0
        protected void btnCheckPluggs_Click(object sender, EventArgs e)
        {
            lblPluggInfo.Text = "";
            BaseHandler ph = new BaseHandler();

            //string pluggtext = "12,56,34,45,56";
            string pluggtext = txtAddPlugg.Text.Trim();
            if (!string.IsNullOrEmpty(pluggtext))
            {
                string[] itempluggs = pluggtext.Split(',');

                //Check that entered Pluggs is in the correct format "12,56,34,45,56"
                int num;
                bool isNumeric;
                bool success = true;
                for (int i = 0; i < itempluggs.Length; i++)
                {
                    isNumeric = int.TryParse(itempluggs[i], out num);
                    if (!isNumeric)
                        success = false;
                }
                if (!success)
                {
                    lblPluggInfo.Text = Localization.GetString("IncorrectPluggString.Text", LocalResourceFile);
                    return;
                }

                StringBuilder s = new StringBuilder();
                s.Append("<ul>");
                int pluggId;
                for (int i = 0; i < itempluggs.Length; i++)
                {
                    pluggId = Convert.ToInt32(itempluggs[i]);
                    PluggContainer p = new PluggContainer(Language, pluggId);
                    s.Append("<li><strong>ID</strong>: ").Append(pluggId).Append(". ");
                    if (p.ThePlugg != null)
                    {
                        p.LoadTitle();
                        p.LoadDescription();
                        s.Append("<strong>").Append(Localization.GetString("Title.Text", LocalResourceFile)).Append("</strong>: ");
                        s.Append(p.TheTitle.Text);
                        s.Append(". <strong>").Append(Localization.GetString("Description.Text", LocalResourceFile)).Append("</strong>: ");
                        if(p.TheDescription != null)
                            s.Append(p.TheDescription.Text);
                    }
                    else
                    {
                        s.Append(Localization.GetString("NoPlugg.Text", LocalResourceFile));
                    }
                    s.Append("</li>");
                }
                lblPluggInfo.Text = s.ToString();
            }

            //return ischecked;
        }