コード例 #1
0
 private void customTableForm_OnBeforeDataRetrieval(object sender, EventArgs e)
 {
     // If editing item
     if (ItemId > 0)
     {
         // Check 'Modify' permission
         if (!dci.CheckPermissions(PermissionsEnum.Modify, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser))
         {
             // Show error message
             customTableForm.MessagesPlaceHolder.ClearLabels();
             customTableForm.ShowError(String.Format(GetString("customtable.permissiondenied.modify"), dci.ClassName));
             customTableForm.StopProcessing = true;
         }
     }
     else
     {
         // Check 'Create' permission
         if (!dci.CheckPermissions(PermissionsEnum.Create, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser))
         {
             // Show error message
             customTableForm.MessagesPlaceHolder.ClearLabels();
             customTableForm.ShowError(String.Format(GetString("customtable.permissiondenied.create"), dci.ClassName));
             customTableForm.StopProcessing = true;
         }
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        PageTitle.TitleText = GetString("customtable.data.viewitemtitle");
        Page.Title          = PageTitle.TitleText;
        // Get custom table id from url
        int customTableId = QueryHelper.GetInteger("customtableid", 0);
        // Get custom table item id
        int itemId = QueryHelper.GetInteger("itemid", 0);

        DataClassInfo dci = DataClassInfoProvider.GetDataClassInfo(customTableId);

        // Set edited object
        EditedObject = dci;

        if (dci == null)
        {
            return;
        }

        // Check 'Read' permission
        if (!dci.CheckPermissions(PermissionsEnum.Read, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser))
        {
            RedirectToAccessDenied("cms.customtables", "Read");
        }

        CustomTableItem item = CustomTableItemProvider.GetItem(itemId, dci.ClassName);

        customTableViewItem.CustomTableItem = item;
    }
    private void CheckReadPermissions(DataClassInfo customTable)
    {
        // Check 'Read' permission
        if (customTable.CheckPermissions(PermissionsEnum.Read, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser))
        {
            return;
        }

        // Show error message
        form.MessagesPlaceHolder.ClearLabels();
        form.ShowError(String.Format(GetString("customtable.permissiondenied.read"), customTable.ClassName));
        form.StopProcessing = true;
    }
コード例 #4
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            repItems.StopProcessing = true;
        }
        else
        {
            // Setup the control
            repItems.ControlContext = ControlContext;

            // Get appropriate class
            DataClassInfo dci = DataClassInfoProvider.GetDataClassInfo(CustomTable);
            if (dci != null)
            {
                // Public
                repItems.HideControlForZeroRows = HideControlForZeroRows;
                repItems.ZeroRowsText           = ZeroRowsText;

                // Check permissions if necessary
                if (CheckPermissions && !dci.CheckPermissions(PermissionsEnum.Read, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser))
                {
                    return;
                }

                // Properties
                repItems.CacheItemName              = CacheItemName;
                repItems.CacheDependencies          = CacheDependencies;
                repItems.CacheMinutes               = CacheMinutes;
                repItems.OrderBy                    = OrderBy;
                repItems.SelectTopN                 = SelectTopN;
                repItems.WhereCondition             = WhereCondition;
                repItems.ItemSeparator              = ItemSeparator;
                repItems.FilterName                 = FilterName;
                repItems.SelectedQueryStringKeyName = SelectedQueryStringKeyName;
                repItems.SelectedDatabaseColumnName = SelectedDatabaseColumnName;
                repItems.SelectedValidationType     = SelectedValidationType;

                // Pager
                repItems.EnablePaging = EnablePaging;
                repItems.PageSize     = PageSize;
                repItems.PagerControl.PagerPosition        = PagerPosition;
                repItems.PagerControl.QueryStringKey       = QueryStringKey;
                repItems.PagerControl.PagingMode           = PagingMode;
                repItems.PagerControl.BackNextLocation     = BackNextLocation;
                repItems.PagerControl.ShowFirstLast        = ShowFirstLast;
                repItems.PagerControl.PagerHTMLBefore      = PagerHTMLBefore;
                repItems.PagerControl.PagerHTMLAfter       = PagerHTMLAfter;
                repItems.PagerControl.ResultsLocation      = ResultsPosition;
                repItems.PagerControl.PageNumbersSeparator = PageNumbersSeparator;

                // Binding
                repItems.DataBindByDefault = DataBindByDefault;

                // Transformations
                repItems.AlternatingTransformationName  = AlternatingTransformationName;
                repItems.TransformationName             = TransformationName;
                repItems.SelectedItemTransformationName = SelectedItemTransformationName;

                // Effect properties
                repItems.RepeaterHTMLBefore    = RepeaterHTMLBefore;
                repItems.RepeaterHTMLAfter     = RepeaterHTMLAfter;
                repItems.ItemHTMLBefore        = ItemHTMLBefore;
                repItems.ItemHTMLAfter         = ItemHTMLAfter;
                repItems.HideLayoutForZeroRows = HideLayoutForZeroRows;
                repItems.ScriptFiles           = ScriptFiles;
                repItems.InitScript            = InitScript;
                repItems.CSSFiles  = CSSFiles;
                repItems.InlineCSS = InlineCSS;

                // Query
                repItems.QueryName = dci.ClassName + ".selectall";
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get custom table id from url
        customTableId = QueryHelper.GetInteger("customtableid", 0);

        dci = DataClassInfoProvider.GetDataClassInfo(customTableId);

        // Set edited object
        EditedObject = dci;

        // If class exists and is custom table
        if ((dci != null) && dci.ClassIsCustomTable)
        {
            // Ensure that object belongs to current site or user has access to site manager
            if (!CurrentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin) && (dci.AssignedSites[SiteContext.CurrentSiteName] == null))
            {
                RedirectToInformation(GetString("general.notassigned"));
            }

            PageTitle.TitleText = GetString("customtable.data.selectdisplayedfields");
            CurrentMaster.DisplayActionsPanel = true;

            // Check 'Read' permission
            if (!dci.CheckPermissions(PermissionsEnum.Read, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser))
            {
                ShowError(String.Format(GetString("customtable.permissiondenied.read"), dci.ClassName));
                plcContent.Visible = false;
                return;
            }

            HeaderActions.AddAction(new HeaderAction
            {
                Text = GetString("UniSelector.SelectAll"),
                OnClientClick = "ChangeFields(true); return false;",
                ButtonStyle = ButtonStyle.Default,
            });

            HeaderActions.AddAction(new HeaderAction
            {
                Text = GetString("UniSelector.DeselectAll"),
                OnClientClick = "ChangeFields(false); return false;",
                ButtonStyle = ButtonStyle.Default,
            });

            if (!RequestHelper.IsPostBack())
            {
                Hashtable reportFields = new Hashtable();

                // Get report fields
                if (!String.IsNullOrEmpty(dci.ClassShowColumns))
                {
                    reportFields.Clear();

                    foreach (string field in dci.ClassShowColumns.Split(';'))
                    {
                        // Add field key to hastable
                        reportFields[field] = null;
                    }
                }

                // Get columns names
                FormInfo fi = FormHelper.GetFormInfo(dci.ClassName, false);
                var columnNames = fi.GetColumnNames(false);

                if (columnNames != null)
                {
                    MacroResolver resolver = MacroResolverStorage.GetRegisteredResolver(FormHelper.FORM_PREFIX + dci.ClassName);
                    FormFieldInfo ffi;
                    ListItem item;
                    foreach (string name in columnNames)
                    {
                        ffi = fi.GetFormField(name);

                        // Add checkboxes to the list
                        item = new ListItem(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(GetFieldCaption(ffi, name, resolver))), name);
                        if (reportFields.Contains(name))
                        {
                            // Select checkbox if field is reported
                            item.Selected = true;
                        }
                        chkListFields.Items.Add(item);
                    }
                }
            }
        }
        else
        {
            ShowError(GetString("customtable.notcustomtable"));
            CurrentMaster.FooterContainer.Visible = false;
        }
    }
コード例 #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get custom table id from url
        customTableId = QueryHelper.GetInteger("customtableid", 0);

        dci = DataClassInfoProvider.GetDataClassInfo(customTableId);

        // Set edited object
        EditedObject = dci;

        // If class exists and is custom table
        if ((dci != null) && dci.ClassIsCustomTable)
        {
            // Ensure that object belongs to current site or user has access to site manager
            if (!CurrentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin) && (dci.AssignedSites[SiteContext.CurrentSiteName] == null))
            {
                RedirectToInformation(GetString("general.notassigned"));
            }

            PageTitle.TitleText = GetString("customtable.data.selectdisplayedfields");
            CurrentMaster.DisplayActionsPanel = true;

            // Check 'Read' permission
            if (!dci.CheckPermissions(PermissionsEnum.Read, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser))
            {
                ShowError(String.Format(GetString("customtable.permissiondenied.read"), dci.ClassName));
                plcContent.Visible = false;
                return;
            }

            HeaderActions.AddAction(new HeaderAction
            {
                Text          = GetString("UniSelector.SelectAll"),
                OnClientClick = "ChangeFields(true); return false;",
                ButtonStyle   = ButtonStyle.Default,
            });

            HeaderActions.AddAction(new HeaderAction
            {
                Text          = GetString("UniSelector.DeselectAll"),
                OnClientClick = "ChangeFields(false); return false;",
                ButtonStyle   = ButtonStyle.Default,
            });

            if (!RequestHelper.IsPostBack())
            {
                Hashtable reportFields = new Hashtable();

                // Get report fields
                if (!String.IsNullOrEmpty(dci.ClassShowColumns))
                {
                    reportFields.Clear();

                    foreach (string field in dci.ClassShowColumns.Split(';'))
                    {
                        // Add field key to hastable
                        reportFields[field] = null;
                    }
                }

                // Get columns names
                FormInfo fi          = FormHelper.GetFormInfo(dci.ClassName, false);
                var      columnNames = fi.GetColumnNames(false);

                if (columnNames != null)
                {
                    MacroResolver resolver = MacroResolverStorage.GetRegisteredResolver(FormHelper.FORM_PREFIX + dci.ClassName);
                    FormFieldInfo ffi;
                    ListItem      item;
                    foreach (string name in columnNames)
                    {
                        ffi = fi.GetFormField(name);

                        // Add checkboxes to the list
                        item = new ListItem(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(GetFieldCaption(ffi, name, resolver))), name);
                        if (reportFields.Contains(name))
                        {
                            // Select checkbox if field is reported
                            item.Selected = true;
                        }
                        chkListFields.Items.Add(item);
                    }
                }
            }
        }
        else
        {
            ShowError(GetString("customtable.notcustomtable"));
            CurrentMaster.FooterContainer.Visible = false;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        string newItemPage = "~/CMSModules/CustomTables/Tools/CustomTable_Data_EditItem.aspx";

        // Get form ID from url
        customTableId = QueryHelper.GetInteger("objectid", 0);

        // Running in site manager?
        bool siteManager = QueryHelper.GetInteger("sm", 0) == 1;

        DataClassInfo dci = null;

        // Read data only if user is site manager global admin or table is bound to current site
        if (CurrentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin) || (ClassSiteInfoProvider.GetClassSiteInfo(customTableId, SiteContext.CurrentSiteID) != null))
        {
            // Get CustomTable class
            dci = DataClassInfoProvider.GetDataClassInfo(customTableId);
        }

        // Set edited object
        EditedObject = dci;

        if ((dci != null) && dci.ClassIsCustomTable)
        {
            customTableDataList.CustomTableClassInfo         = dci;
            customTableDataList.EditItemPageAdditionalParams = (siteManager ? "sm=1" : String.Empty);
            customTableDataList.ViewItemPageAdditionalParams = (siteManager ? "sm=1" : String.Empty);
            // Set alternative form and data container
            customTableDataList.UniGrid.FilterFormName = dci.ClassName + ".filter";
            customTableDataList.UniGrid.FilterFormData = CustomTableItem.New(dci.ClassName);

            // Set custom pages
            if (dci.ClassEditingPageURL != String.Empty)
            {
                customTableDataList.EditItemPage = dci.ClassEditingPageURL;
            }
            if (dci.ClassNewPageURL != String.Empty)
            {
                newItemPage = dci.ClassNewPageURL;
            }
            if (dci.ClassViewPageUrl != String.Empty)
            {
                customTableDataList.ViewItemPage = dci.ClassViewPageUrl;
            }

            ScriptHelper.RegisterDialogScript(this);
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "SelectFields", ScriptHelper.GetScript("function SelectFields() { modalDialog('" +
                                                                                                                ResolveUrl("~/CMSModules/CustomTables/Tools/CustomTable_Data_SelectFields.aspx") + "?customtableid=" + customTableId + "'  ,'CustomTableFields', 500, 500); }"));

            if (!siteManager)
            {
                PageTitle.TitleText = GetString("customtable.edit.header");
            }

            // Check 'Read' permission
            if (!dci.CheckPermissions(PermissionsEnum.Read, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser))
            {
                ShowError(String.Format(GetString("customtable.permissiondenied.read"), dci.ClassName));
                plcContent.Visible = false;
                return;
            }

            // New item link
            bool canCreate = dci.CheckPermissions(PermissionsEnum.Create, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser);
            HeaderActions.AddAction(new HeaderAction
            {
                Text        = GetString("customtable.data.newitem"),
                RedirectUrl = ResolveUrl(newItemPage + "?new=1&objectid=" + customTableId + (siteManager ? "&sm=1" : "")),
                Enabled     = canCreate,
                Tooltip     = canCreate ? String.Empty : String.Format(GetString("customtable.permissiondenied.create"), dci.ClassName)
            });

            // Select fields link
            HeaderActions.AddAction(new HeaderAction
            {
                Text          = GetString("customtable.data.selectdisplayedfields"),
                OnClientClick = "SelectFields();",
                ButtonStyle   = ButtonStyle.Default,
            });

            if (!siteManager)
            {
                // Initializes page title
                PageBreadcrumbs.AddBreadcrumb(new BreadcrumbItem
                {
                    Text        = GetString("customtable.list.title"),
                    RedirectUrl = "~/CMSModules/Customtables/Tools/CustomTable_List.aspx"
                });
                PageBreadcrumbs.AddBreadcrumb(new BreadcrumbItem
                {
                    Text = dci.ClassDisplayName
                });
            }
        }
        else
        {
            customTableDataList.StopProcessing = true;
            customTableDataList.Visible        = false;

            ShowError(GetString("customtable.notcustomtable"));
        }
    }
コード例 #8
0
    protected void Page_Init(object sender, EventArgs e)
    {
        RequireSite = false;

        bool accessGranted = true;

        // Get custom table id from url
        int customTableId = QueryHelper.GetInteger("objectid", 0);

        if (customTableId > 0)
        {
            // Get custom table item id
            int itemId = QueryHelper.GetInteger("itemid", 0);

            // Running in site manager?
            bool siteManager = QueryHelper.GetInteger("sm", 0) == 1;

            DataClassInfo dci = DataClassInfoProvider.GetDataClassInfo(customTableId);
            // Set edited object
            EditedObject = dci;

            // If class exists
            if ((dci != null) && dci.ClassIsCustomTable)
            {
                // Ensure that object belongs to current site or user has access to site manager
                if (!CurrentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin) && (dci.AssignedSites[SiteContext.CurrentSiteName] == null))
                {
                    RedirectToInformation(GetString("general.notassigned"));
                }

                // Edit item
                if (itemId > 0)
                {
                    // Check 'Read' permission
                    if (!dci.CheckPermissions(PermissionsEnum.Read, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser))
                    {
                        ShowError(String.Format(GetString("customtable.permissiondenied.read"), dci.ClassName));
                        plcContent.Visible = false;
                        accessGranted      = false;
                    }

                    if (!siteManager)
                    {
                        PageTitle.TitleText = GetString("customtable.data.edititemtitle");
                    }
                }
                // New item
                else
                {
                    if (!siteManager)
                    {
                        PageTitle.TitleText = GetString("customtable.data.newitemtitle");
                    }
                }

                string listPage    = "~/CMSModules/Customtables/Tools/CustomTable_Data_List.aspx";
                string newItemPage = "~/CMSModules/CustomTables/Tools/CustomTable_Data_EditItem.aspx";

                // Set custom pages
                if (dci.ClassListPageURL != String.Empty)
                {
                    listPage = dci.ClassListPageURL;
                }
                else if (dci.ClassNewPageURL != String.Empty)
                {
                    newItemPage = dci.ClassNewPageURL;
                }

                if (QueryHelper.GetString("saved", String.Empty) != String.Empty)
                {
                    // If this was creating of new item show the link again
                    if ((QueryHelper.GetString("new", String.Empty) != String.Empty))
                    {
                        // Create another link
                        CurrentMaster.HeaderActions.AddAction(new HeaderAction
                        {
                            Text        = GetString("customtable.data.createanother"),
                            RedirectUrl = ResolveUrl(newItemPage + "?new=1&objectid=" + customTableId + (siteManager ? "&sm=1" : String.Empty))
                        });
                    }
                }

                // Create breadcrumbs
                CreateBreadcrumbs(siteManager, dci, listPage, customTableId, itemId);

                // Set edit form
                if (accessGranted)
                {
                    customTableForm.CustomTableId = customTableId;
                    customTableForm.ItemId        = itemId;
                    customTableForm.EditItemPageAdditionalParams = (siteManager ? "sm=1" : String.Empty);
                }
            }
            else
            {
                ShowError(GetString("customtable.notcustomtable"));
            }
        }
    }
コード例 #9
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            gridItems.StopProcessing = true;
        }
        else
        {
            gridItems.ControlContext         = ControlContext;
            gridItems.HideControlForZeroRows = HideControlForZeroRows;
            gridItems.ZeroRowsText           = ZeroRowsText;

            if (DataClassInfo == null)
            {
                return;
            }

            // Check permissions if necessary
            if (CheckPermissions && !DataClassInfo.CheckPermissions(PermissionsEnum.Read, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser))
            {
                return;
            }

            gridItems.CacheItemName     = CacheItemName;
            gridItems.CacheDependencies = CacheDependencies;
            gridItems.CacheMinutes      = CacheMinutes;
            gridItems.OrderBy           = OrderBy;
            gridItems.WhereCondition    = WhereCondition;
            gridItems.FilterName        = FilterName;

            gridItems.SelectTopN      = SelectTopN;
            gridItems.EnableViewState = true;

            gridItems.AllowSorting   = AllowSorting;
            gridItems.ProcessSorting = ProcessSorting;

            if (!RequestHelper.IsPostBack())
            {
                gridItems.SortAscending = SortAscending;
                gridItems.SortField     = SortField;
            }

            gridItems.AllowPaging       = AllowPaging;
            gridItems.PageSize          = PageSize;
            gridItems.AllowCustomPaging = AllowCustomPaging;
            gridItems.PagerStyle.Mode   = PagingMode;
            gridItems.ShowHeader        = ShowHeader;
            gridItems.ShowFooter        = ShowFooter;

            gridItems.ToolTip = ToolTip;

            gridItems.DataBindByDefault = DataBindByDefault;

            gridItems.AutoGenerateColumns = AutoGenerateColumns;

            gridItems.QueryName = QueryName;

            gridItems.SetFirstPageAfterSortChange = SetFirstPageAfterSortChange;

            string mXML = ColumnsSelector;

            // Set SkinID properties
            if (!StandAlone && (PageCycle < PageCycleEnum.Initialized) && (ValidationHelper.GetString(Page.StyleSheetTheme, "") == ""))
            {
                gridItems.SkinID = SkinID;
            }

            LoadFromQuery(gridItems.QueryName);

            if (ColumnSelector(mXML))
            {
                gridItems.AutoGenerateColumns = false;
            }

            if (!DataHelper.DataSourceIsEmpty(gridItems.DataSource))
            {
                gridItems.DataBind();
            }
        }
    }