Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            LiHyperLink.SetNameToCompare(Context, "settings");

            LogViews.ActiveViewIndex = Int32.Parse(Request.QueryString["type"] ?? "1") - 1;

            Query q = Log.CreateQuery();

            q.AndWhere(Log.Columns.Type, Request.QueryString["type"] ?? "1");
            q.PageSize  = 15;
            q.PageIndex = Int32.Parse(Request.QueryString["p"] ?? "1");
            q.OrderByDesc(Log.Columns.CreatedOn);

            LogCollection logs = LogCollection.FetchByQuery(q);

            LogList.DataSource = logs;
            LogList.DataBind();

            if (logs.Count > 0)
            {
                pager.Text =
                    Util.Pager(q.PageIndex, q.PageSize, q.GetRecordCount(), null,
                               Request.QueryString["type"] == null ? null : "?type=" + Request.QueryString["type"], "← Older Logs",
                               "Newer Logs →");
                ;
            }
        }
Esempio n. 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        LiHyperLink.SetNameToCompare(Context, "presentation");

        Widget widget = Widgets.Fetch(new Guid(Request.QueryString["id"]));

        if (widget == null)
        {
            throw new Exception("The widget does not exist");
        }

        if (!Graffiti.Core.Util.AreEqualIgnoreCase("Edit.aspx", widget.EditUrl))
        {
            Response.Redirect(widget.EditUrl + "?id=" + Request.QueryString["id"]);
        }

        PageTitle.Text  = widget.FormName;
        this.Page.Title = "Widget: " + widget.FormName;

        if (!IsPostBack)
        {
            FormRegion.Text = widget.BuildForm();
        }
        else
        {
            FormRegion.Text = widget.BuildForm(Request.Form);
        }
    }
Esempio n. 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        LiHyperLink.SetNameToCompare(Context, "settings");

        if (!IsPostBack)
        {
            SiteSettings settings = SiteSettings.Get();

            chkUseExternalJQuery.Checked  = settings.UseExternalJQuery;
            chkUseProxy.Checked           = settings.UseProxyServer;
            txtProxyHost.Text             = settings.ProxyHost;
            txtProxyPort.Text             = settings.ProxyPort.ToString();
            txtProxyUsername.Text         = settings.ProxyUsername;
            txtProxyPassword.Text         = settings.ProxyPassword;
            chkBypassProxyOnLocal.Checked = settings.ProxyBypassOnLocal;
            chkCacheViews.Checked         = settings.CacheViews;
            txtDateFormat.Text            = settings.DateFormat;
            txtTimeFormat.Text            = settings.TimeFormat;
            chkFilterUncategorizedPostsFromLists.Checked = !settings.FilterUncategorizedPostsFromLists;
            chkIncludeChildPosts.Checked = settings.IncludeChildPosts;
            txtPageSize.Text             = settings.PageSize.ToString();
            chkGenerateFolders.Checked   = settings.GenerateFolders;
        }

        string display = chkUseProxy.Checked ? "display: block; padding-left: 20px;" : "display: none; padding-left: 20px;";

        proxySettings.Attributes.Add("style", display);
    }
Esempio n. 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        LiHyperLink.SetNameToCompare(Context, "settings");

        if (!IsPostBack)
        {
            CommentSettings settings = CommentSettings.Get();
            EnableComments.Checked = settings.EnableCommentsDefault;
            CommentDays.Items.FindByValue(settings.CommentDays.ToString()).Selected = true;
            txtEmail.Text     = settings.Email;
            txtSpamScore.Text = settings.SpamScore.ToString();

            txtAkismetId.Text    = settings.AkismetId;
            txtAkismetScore.Text = settings.AkismetScore.ToString();

            chkUseAkismet.Checked = settings.UseAkismet;

            if (settings.CommentDays > 0 && String.IsNullOrEmpty(settings.AkismetId))
            {
                Message.Text = "We noticed you have enabled new comments, but have not added Akismet. Hopefully that is what you are doing right now, if not, please think about it.";
                Message.Type = StatusType.Warning;
            }
        }

        string display = chkUseAkismet.Checked ? "display: block; padding-left: 20px;" : "display: none; padding-left: 20px;";

        akismetSettings.Attributes.Add("style", display);
    }
Esempio n. 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Util.CanWriteRedirect(Context);

            LiHyperLink.SetNameToCompare(Context, "settings");
        }


        if (!IsPostBack)
        {
            //EnableHomeSort.Checked = SiteSettings.Get().UseCustomHomeList;

            Posts.Items.Clear();

            DataBuddy.Query query = Post.CreateQuery();
            query.AndWhere(Post.Columns.IsHome, true);
            query.OrderByAsc(Post.Columns.HomeSortOrder);

            string itemFormat = "<div style=\"border: solid 1px #999; padding: 4px;\"><strong>{0}</strong></div>";
            foreach (Post p in PostCollection.FetchByQuery(query))
            {
                Posts.Items.Add(new Telligent.Glow.OrderedListItem(string.Format(itemFormat, p.Title), p.Title, p.Id.ToString()));
            }
        }
    }
Esempio n. 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        switch (_catalogType)
        {
        case CatalogType.Widgets:
            LiHyperLink.SetNameToCompare(Context, "presentation");
            PageBreadcrumbs.SectionName = Breadcrumbs.Section.WidgetMarketplace;
            _itemTypeName = "Widget";
            break;

        case CatalogType.Themes:
            LiHyperLink.SetNameToCompare(Context, "presentation");
            PageBreadcrumbs.SectionName = Breadcrumbs.Section.ThemeMarketplace;
            _itemTypeName = "Theme";
            break;

        case CatalogType.Plugins:
            LiHyperLink.SetNameToCompare(Context, "settings");
            PageBreadcrumbs.SectionName = Breadcrumbs.Section.PluginMarketplace;
            _itemTypeName = "Plugin";
            break;

        case CatalogType.All:
            Response.Redirect(new Urls().AdminMarketplaceHome);
            break;
        }

        SetControlVisibility();
    }
Esempio n. 7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        LiHyperLink.SetNameToCompare(Context, "presentation");
        if (!IsPostBack)
        {
            AvailableWidgets.Items.Clear();
            AvailableWidgets.Items.Add(new DropDownListItem("(Configure Widgets)", ""));
            foreach (WidgetDescription w in Widgets.GetAvailableWidgets())
            {
                AvailableWidgets.Items.Add(new DropDownListItem(w.Name, w.Name, w.UniqueId));
            }

            string widgetFormat =
                "<div style=\"border: solid 1px #999; padding: 4px;\"><b>{0}</b><div style=\"text-align:right;\"><a title=\"Edit Widget\" href=\"javascript:void();\" onclick=\"window.location=\'Edit.aspx?id={1}\'\">Edit</a> | <a title=\"Delete Widget\" href=\"javascript:void();\" onclick=\"javascript:deleteWidget(&#39;{1}&#39;); return false;\">Delete</a></div></div>";

            foreach (Widget w in Widgets.FetchByLocation(WidgetLocation.Queue))
            {
                qbar.Items.Add(new OrderedListItem(string.Format(widgetFormat, w.Name, w.Id), w.Name, w.Id.ToString()));
            }

            foreach (Widget w in Widgets.FetchByLocation(WidgetLocation.Left))
            {
                lbar.Items.Add(new OrderedListItem(string.Format(widgetFormat, w.Name, w.Id), w.Name, w.Id.ToString()));
            }

            foreach (Widget w in Widgets.FetchByLocation(WidgetLocation.Right))
            {
                rbar.Items.Add(new OrderedListItem(string.Format(widgetFormat, w.Name, w.Id), w.Name, w.Id.ToString()));
            }

            switch (GetSideBarLayout())
            {
            case "left":

                ClientScript.RegisterStartupScript(GetType(), "hidebar", "$('right-sidebar').hide();", true);
                break;

            case "right":

                ClientScript.RegisterStartupScript(GetType(), "hidebar", "$('left-sidebar').hide();", true);
                break;
            }

            string widgetSaved = Request.QueryString["ws"];

            if (!String.IsNullOrEmpty(widgetSaved))
            {
                Widget widget = Widgets.Fetch(new Guid(Request.QueryString["ws"]));

                if (widget == null)
                {
                    throw new Exception("The widget does not exist");
                }

                Message.Text = "The widget, <b>" + widget.Name + "</b> was updated.";
                Message.Type = StatusType.Success;
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        LiHyperLink.SetNameToCompare(Context, "presentation");
        if (!IsPostBack)
        {
            PageWidget widget = Widgets.Fetch(new Guid(Request.QueryString["id"])) as PageWidget;
            if (widget == null)
            {
                throw new Exception("The widget does not exist");
            }

            BindData(widget);
        }
    }
Esempio n. 9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        LiHyperLink.SetNameToCompare(Context, "settings");

        EventDetails ed = Graffiti.Core.Events.GetEvent(Request.QueryString["t"]);


        PageTitle.Text = ed.Event.Name;
        Page.Title     = "Plug-in: " + ed.Event.Name;

        if (!IsPostBack)
        {
            FormRegion.Text = ed.Event.BuildForm();
        }
        else
        {
            FormRegion.Text = ed.Event.BuildForm(Request.Form);
        }
    }
Esempio n. 10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        LiHyperLink.SetNameToCompare(Context, "settings");

        if (!IsPostBack)
        {
            SiteSettings settings = SiteSettings.Get();
            txtTitle.Text         = Server.HtmlDecode(settings.Title);
            txtTagline.Text       = Server.HtmlDecode(settings.TagLine);
            txtCopyright.Text     = settings.CopyRight;
            txtFeedBurner.Text    = settings.ExternalFeedUrl;
            txtStats.Text         = settings.WebStatistics;
            txtHeader.Text        = settings.Header;
            txtMetaScription.Text = Server.HtmlDecode(settings.MetaDescription ?? string.Empty);
            txtKeywords.Text      = Server.HtmlDecode(settings.MetaKeywords ?? string.Empty);

            DateTime dt = DateTime.Now;
            // there are timezones which differ by 15 minutes
            for (double i = -24; i < 24; i = i + .25)
            {
                ListItem li = new ListItem(dt.AddHours(i).ToString("ddd, dd MMMM yyyy HH:mm"), i.ToString());
                TimeOffSet.Items.Add(li);
            }

            ListItem liSelected = TimeOffSet.Items.FindByValue(settings.TimeZoneOffSet.ToString());
            if (liSelected != null)
            {
                liSelected.Selected = true;
            }
            else
            {
                TimeOffSet.Items.FindByValue("0").Selected = true;
            }

            GraffitiLogo.Checked = settings.DisplayGraffitiLogo;
        }
    }
Esempio n. 11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        LiHyperLink.SetNameToCompare(Context, "settings");

        ClientScript.RegisterStartupScript(this.GetType(), "set-fields", "toggleServerAuthFields()", true);
        if (!IsPostBack)
        {
            SiteSettings settings = SiteSettings.Get();
            txtServerName.Text             = settings.EmailServer;
            txtFrom.Text                   = settings.EmailFrom;
            RequiresAuthentication.Checked = settings.EmailServerRequiresAuthentication;
            UseSSL.Checked                 = settings.EmailRequiresSSL;
            txtPort.Text                   = settings.EmailPort.ToString();

            if (RequiresAuthentication.Checked)
            {
                txtUser.Text     = settings.EmailUser;
                txtPassword.Text = settings.EmailPassword;
            }

            PageTemplateToolboxContext ptc = new PageTemplateToolboxContext();
            ptc.Put("comment", this);
        }
    }
Esempio n. 12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        LiHyperLink.SetNameToCompare(Context, "presentation");

        NavigationSettings settings = NavigationSettings.Get();
        CategoryCollection cc       = new CategoryController().GetTopLevelCachedCategories();

        foreach (Category c in cc)
        {
            bool found = false;
            foreach (DynamicNavigationItem di in settings.SafeItems())
            {
                if (di.NavigationType == DynamicNavigationType.Category && di.CategoryId == c.Id)
                {
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                the_Categories.Items.Add(new ListItem(c.Name, "Category-" + c.UniqueId));
            }
        }


        Query q = Post.CreateQuery();

        q.AndWhere(Post.Columns.CategoryId, CategoryController.UnCategorizedId);
        q.AndWhere(Post.Columns.IsDeleted, false);
        q.AndWhere(Post.Columns.Status, 1);

        PostCollection pc = new PostCollection();

        pc.LoadAndCloseReader(q.ExecuteReader());

        foreach (Post p in pc)
        {
            bool found = false;
            foreach (DynamicNavigationItem di in settings.SafeItems())
            {
                if (di.NavigationType == DynamicNavigationType.Post && di.PostId == p.Id)
                {
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                the_Posts.Items.Add(new ListItem(p.Title, "Post-" + p.UniqueId));
            }
        }

        // 0 - Title, 1 - Type, 2 - LID
        string itemFormat =
            "<div style=\"border: solid 1px #999; padding: 4px;\"><strong>{0} ({1})</strong><div style=\"text-align:right;\"><a title=\"Delete Link\" href=\"javascript:void();\" onclick=\"remove_Link( &#39;{1}&#39;,&#39;{0}&#39;, &#39;{2}&#39;); return false;\">Delete</a></div></div>";

        foreach (DynamicNavigationItem dni in settings.SafeItems())
        {
            lbar.Items.Add(
                new OrderedListItem(string.Format(itemFormat, dni.Name, dni.NavigationType.ToString(), dni.Id),
                                    dni.Name, dni.NavigationType.ToString() + "-" + dni.Id.ToString()));
        }
    }
Esempio n. 13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        LiHyperLink.SetNameToCompare(Context, "UserManagement");

        IGraffitiUser currentUser = GraffitiUsers.Current;


        if (Request.QueryString["user"] != null)
        {
            if (!IsPostBack)
            {
                user = GraffitiUsers.GetUser(Request.QueryString["user"]);


                if (user == null)
                {
                    throw new Exception("This user does not exist or cannot be edited.");
                }

                if (!GraffitiUsers.IsAdmin(currentUser) && user.Name != currentUser.Name)
                {
                    throw new SecurityException("You do not have permission to edit this user");
                }


                if (Request.QueryString["new"] != null && !IsPostBack)
                {
                    Message.Text = "The user <strong>" + user.Name + "</strong> was created.";
                    Message.Type = StatusType.Success;
                }
                PageText.Text            = "Update " + user.ProperName + "'s profile.";
                AdminUserLinks.Visible   = true;
                PasswordLink.NavigateUrl = string.Format("~/graffiti-admin/user-management/users/changepassword.aspx?user={0}", Request.QueryString["user"]);
                if (GraffitiUsers.CanRenameUsers && GraffitiUsers.IsAdmin(GraffitiUsers.Current))
                {
                    AdminUserLinksDelim.Visible = true;
                    RenameLink.Visible          = true;
                    RenameLink.NavigateUrl      = string.Format("javascript:Telligent_Modal.Open('RenameUser.aspx?user={0}', 400, 200, null);", Request.QueryString["user"]);
                }
                txtExistingUserName.Text = Server.HtmlDecode(user.Name);
                txtProperName.Text       = Server.HtmlDecode(user.ProperName);
                txtExistingEmail.Text    = user.Email;
                txtAvatar.Text           = user.Avatar;
                Editor.Text     = user.Bio;
                txtWebsite.Text = string.IsNullOrEmpty(user.WebSite)
                                                                                         ? new Macros().FullUrl(new Urls().Home)
                                                                                         : Server.HtmlEncode(user.WebSite);

                bool isAdmin = GraffitiUsers.IsUserInRole(GraffitiUsers.Current.Name, GraffitiUsers.AdminRole);

                role_section.Visible = isAdmin;
                AllRoles.Visible     = isAdmin;

                if (!isAdmin)
                {
                    Cancel_Edit.NavigateUrl = "~/graffiti-admin/";
                }

                if (isAdmin)
                {
                    RolePermissionsCollection rp = RolePermissionManager.GetRolePermissions();

                    RolePermissionsCollection newrp = new RolePermissionsCollection();
                    newrp.AddRange(rp);

                    RolePermissions temp = newrp.Find(delegate(RolePermissions r)
                    {
                        return(r.RoleName == GraffitiUsers.EveryoneRole);
                    });

                    if (temp != null)
                    {
                        newrp.Remove(temp);
                    }

                    newrp.Sort(delegate(RolePermissions rp1, RolePermissions rp2)
                    {
                        return(Comparer <string> .Default.Compare(rp1.RoleName, rp2.RoleName));
                    });

                    Roles.DataSource = newrp;
                    Roles.DataBind();

                    foreach (string role in user.Roles)
                    {
                        if (role == GraffitiUsers.AdminRole)
                        {
                            chkAdmin.Checked = true;

                            if (GraffitiUsers.Current.Name == user.Name)
                            {
                                chkAdmin.Enabled = false;
                            }
                        }
                    }
                }
            }

            new_user_container.Visible = false;
            User_List.Visible          = false;
            user_edit_form.Visible     = true;
        }
        else
        {
            if (!GraffitiUsers.IsUserInRole(currentUser.Name, GraffitiUsers.AdminRole))
            {
                Response.Redirect("?user="******"*");

            User_List.DataSource = users;
            User_List.DataBind();

            // filter out everyone if they are not a content publisher for licensing
            List <IGraffitiUser> filteredUsers = new List <IGraffitiUser>();
            filteredUsers.AddRange(users);

            bool isEveryonePublisher = RolePermissionManager.IsEveryoneAContentPublisher();

            if (!isEveryonePublisher)
            {
                foreach (IGraffitiUser user in users)
                {
                    if (user.Roles != null && user.Roles[0] == GraffitiUsers.EveryoneRole)
                    {
                        filteredUsers.Remove(user);
                    }
                }
            }
        }
    }
Esempio n. 14
0
    protected void Page_Load(object sender, EventArgs e)
    {
        LiHyperLink.SetNameToCompare(Context, "settings");

        _category = int.Parse(Request.QueryString["category"] ?? "-1");

        if (Request.QueryString["id"] != null)
        {
            if (Request.QueryString["new"] != null)
            {
                if (!IsPostBack)
                {
                    Message.Text = "Your field was successfully added.";
                    Message.Type = StatusType.Success;
                }
            }

            if (!IsPostBack)
            {
                Cancel_Edit.NavigateUrl = "?category=" + _category.ToString();

                Master.FindControl("SideBarRegion").Visible = false;

                CustomFormSettings csf = CustomFormSettings.Get(_category, false);

                CustomField cf = null;
                Guid        g  = new Guid(Request.QueryString["id"]);
                foreach (CustomField cfx in csf.Fields)
                {
                    if (cfx.Id == g)
                    {
                        cf = cfx;
                        break;
                    }
                }

                if (cf != null)
                {
                    FormViews.SetActiveView(EditFieldView);

                    ExistingName.Text        = cf.Name;
                    ExistingDescription.Text = cf.Description;

                    if (cf.FieldType == FieldType.CheckBox)
                    {
                        CheckboxRegion.Visible   = true;
                        ExistingCheckBox.Checked = cf.Checked;
                    }
                    else if (cf.FieldType == FieldType.List)
                    {
                        ListRegion.Visible = true;
                        if (cf.ListOptions != null && cf.ListOptions.Count > 0)
                        {
                            foreach (ListItemFormElement li in cf.ListOptions)
                            {
                                ExistingListOptions.Text += (li.Text + "\n");
                            }
                        }
                    }
                }
            }
        }
        else
        {
            if (!IsPostBack)
            {
                Master.FindControl("SideBarRegion").Visible = true;

                if (_category != -1)
                {
                    Category c = new Category(_category);
                    lblCategory.Text = c.Name;
                }
                else
                {
                    lblCategory.Text = "Global";
                }

                LoadCategories();

                LoadCustomFields();
            }
        }
    }
Esempio n. 15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            LiHyperLink.SetNameToCompare(Context, "settings");

            DeleteButton.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this file? This action cannot be undone!');");

            string rootPath = Server.MapPath("~/");
            string path     = Request.QueryString["path"] ?? "";

            if (!path.ToLower().StartsWith(basicFilesMediaPath) && !GraffitiUsers.IsAdmin(GraffitiUsers.Current))
            {
                Response.Redirect(Request.Url.AbsolutePath + "?path=" + basicFilesMediaPath, true);
            }

            path = Path.Combine(rootPath, Util.NormalizePath(path));
            string fileName = Request.QueryString["f"];

            DirectoryInfo di = new DirectoryInfo(path);

            if (!di.FullName.ToLower().StartsWith(rootPath.ToLower()))
            {
                Log.Error("FileBrowser", "A request was made to an invalid directory {0}. If this persists, you should contact your ISP", di.FullName);
                throw new Exception("Bad Path");
            }

            SetBreadCrumbs(fileName);
            SetFolders(di, rootPath);

            if (string.IsNullOrEmpty(fileName))
            {
                FileViews.SetActiveView(FileLists);
                SetFileList(di);
            }
            else
            {
                FileInfo fi = new FileInfo(Path.Combine(path, fileName));
                if (!fi.Exists)
                {
                    Log.Warn("FileBrowser", "A requested file {0} does not exist", fi.FullName);
                    throw new Exception("File does not exist");
                }

                if (!FileFilters.IsValidFile(fi.Name))
                {
                    Log.Error("FileBrowser",
                              "A forbidden file {0} was requested by the FileBrowser. Access to view/edit this file has been denied.",
                              fi.FullName);
                    throw new Exception("File does not exist");
                }


                if (Request.QueryString["edit"] != "true")
                {
                    SetFileDetails(fi);
                }
                else
                {
                    SetFileEdit(fi);
                }
            }
        }
Esempio n. 16
0
 protected void Page_Load(object sender, EventArgs e)
 {
     LiHyperLink.SetNameToCompare(Context, "presentation");
     this.DataBind();
 }
Esempio n. 17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        switch (_catalogType)
        {
        case CatalogType.Widgets:
            LiHyperLink.SetNameToCompare(Context, "presentation");
            PageBreadcrumbs.SectionName = Breadcrumbs.Section.WidgetMarketplace;
            break;

        case CatalogType.Themes:
            LiHyperLink.SetNameToCompare(Context, "presentation");
            PageBreadcrumbs.SectionName = Breadcrumbs.Section.ThemeMarketplace;
            break;

        case CatalogType.Plugins:
            LiHyperLink.SetNameToCompare(Context, "settings");
            PageBreadcrumbs.SectionName = Breadcrumbs.Section.PluginMarketplace;
            break;

        case CatalogType.All:
            Response.Redirect(new Urls().AdminMarketplaceHome);
            break;
        }


        if (!IsPostBack)
        {
            try
            {
                CatalogInfo catalog = null;

                if (Marketplace.Catalogs.ContainsKey(_catalogType))
                {
                    catalog = Marketplace.Catalogs[_catalogType];
                }

                MessageInfo messageInfo = null;
                if (catalog.Messages.Count > 0)
                {
                    messageInfo = catalog.Messages[0];
                }
                else if (Marketplace.Messages.Count > 0)
                {
                    messageInfo = Marketplace.Messages[0];
                }

                if (messageInfo != null)
                {
                    MarketplaceMessage.Visible = true;
                    MarketplaceMessage.Type    = StatusType.Information;
                    MarketplaceMessage.Text    = messageInfo.Text;
                }

                categoryList.DataSource = catalog.Categories.Values;
                categoryList.DataBind();

                itemList.DataSource = catalog.Items.Values;
                if (_categoryId > 0)
                {
                    CategoryInfo category = catalog.Categories[_categoryId];
                    itemList.DataSource = category.Items.Values;
                }
                else if (!string.IsNullOrEmpty(_creatorId))
                {
                    CreatorInfo creator = Marketplace.Creators[_creatorId];
                    itemList.DataSource = creator.GetItems(_catalogType).Values;
                }

                itemList.DataBind();
            }
            catch (Exception ex)
            {
                string messageText = "An unexpected error has occurred connecting to the marketplace. The <a href=\"http://extendgraffiti.com/\" target=\"_blank\">Graffiti Marketplace</a> is where you can find new themes, widgets, and plugins. Please try again later.";
                if (ex is System.Security.SecurityException)
                {
                    messageText = "Your security settings do not allow you to access the marketplace from within the Control Panel. To find new themes, widgets, and plugins, please visit the <a href=\"http://extendgraffiti.com/\" target=\"_blank\">Graffiti Marketplace</a>.";
                }

                Message.Type             = StatusType.Error;
                Message.Text             = messageText;
                Message.Visible          = true;
                MarketplaceImage.Visible = true;
                PageBreadcrumbs.Visible  = false;
                categoryList.Visible     = false;
                itemList.Visible         = false;
            }
        }
    }
Esempio n. 18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        LiHyperLink.SetNameToCompare(Context, "UserManagement");

        string role = DecodeFromQS("role");

        if (!Page.IsPostBack)
        {
            SetupTogglePermissionsScript(read, edit, publish, read, "read");
            SetupTogglePermissionsScript(read, edit, publish, edit, "edit");
            SetupTogglePermissionsScript(read, edit, publish, publish, "publish");

            SetupTogglePermissionsScript(readRolePermission, editRolePermission, publishRolePermission, readRolePermission, "read");
            SetupTogglePermissionsScript(readRolePermission, editRolePermission, publishRolePermission, editRolePermission, "edit");
            SetupTogglePermissionsScript(readRolePermission, editRolePermission, publishRolePermission, publishRolePermission, "publish");

            if (!String.IsNullOrEmpty(role))
            {
                RolePermissionsCollection rpc = RolePermissionManager.GetRolePermissions();

                RolePermissions rp = rpc.Find(
                    delegate(RolePermissions rper)
                {
                    return(rper.RoleName.ToLower() == role.ToLower());
                });

                if (rp != null)
                {
                    readRolePermission.Checked    = rp.HasRead;
                    editRolePermission.Checked    = rp.HasEdit;
                    publishRolePermission.Checked = rp.HasPublish;
                }
            }
        }

        if (role != null)
        {
            string encodedRoleName = HttpUtility.HtmlEncode(role);

            if (!IsPostBack)
            {
                if (Request.QueryString["new"] != null)
                {
                    Message.Text = string.Format("The role <strong>{0}</strong> was created.", encodedRoleName);
                    Message.Type = StatusType.Success;
                }

                litExistingRoleName.Text = encodedRoleName;
                PageText.Text            = "Update " + encodedRoleName;

                CategoryList.DataSource = new CategoryController().GetAllCachedCategories();
                CategoryList.DataBind();
            }

            new_role_container.Visible = false;
            Role_List.Visible          = false;
            role_edit_form.Visible     = true;
        }
        else
        {
            if (!Page.IsPostBack)
            {
                RolePermissionsCollection rps = RolePermissionManager.GetRolePermissions();

                rps.Sort(delegate(RolePermissions rp1, RolePermissions rp2)
                {
                    return(Comparer <string> .Default.Compare(rp1.RoleName, rp2.RoleName));
                });

                // move everyone to the top
                RolePermissionsCollection rpss = new RolePermissionsCollection();

                foreach (RolePermissions rp in rps)
                {
                    if (rp.RoleName == GraffitiUsers.EveryoneRole)
                    {
                        rpss.Insert(0, rp);
                    }
                }

                foreach (RolePermissions rp in rps)
                {
                    if (rp.RoleName != GraffitiUsers.EveryoneRole)
                    {
                        rpss.Add(rp);
                    }
                }

                Role_List.DataSource = rpss;
                Role_List.DataBind();

                if (Request.QueryString["roleSaved"] != null)
                {
                    string roleSaved = HttpUtility.UrlDecode(Request.QueryString["roleSaved"]);
                    Message.Text = string.Format("The role <strong>{0}</strong> was updated.", roleSaved);
                    Message.Type = StatusType.Success;
                }
            }

            new_role_container.Visible = true;
            role_edit_form.Visible     = false;
            Role_List.Visible          = true;
        }
    }