/// <summary>
    /// Returns correct WHERE condition.
    /// </summary>
    private string GetWhere()
    {
        UniGrid parent = ControlsHelper.GetParentControl(this, typeof(UniGrid)) as UniGrid;

        if (parent != null)
        {
            string resourceName = ValidationHelper.GetString(parent.GetValue("ResourceName"), "");
            if (resourceName == String.Empty)
            {
                var uiContext = UIContextHelper.GetUIContext(this);
                // Check special parameter first
                resourceName = ValidationHelper.GetString(uiContext["MacroRuleResourceName"], String.Empty);
                if (resourceName == String.Empty)
                {
                    // If not set, use element's resource name
                    resourceName = ValidationHelper.GetString(uiContext["resourcename"], String.Empty);
                }
            }

            if (!string.IsNullOrEmpty(resourceName))
            {
                string where = "MacroRuleResourceName = N'" + SqlHelper.GetSafeQueryString(resourceName, false) + "'";

                // Show also global rules for global administrator if requested
                if (drpOptions.SelectedIndex == 1)
                {
                    where = SqlHelper.AddWhereCondition(where, "MacroRuleResourceName = '' OR MacroRuleResourceName IS NULL", "OR");
                }
                return(where);
            }
        }

        // Only global rules should be displayed
        return("MacroRuleResourceName = '' OR MacroRuleResourceName IS NULL");
    }
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        string menuId       = ContextMenu.MenuID;
        string parentElemId = ContextMenu.ParentElementClientID;

        var uiContext = UIContextHelper.GetUIContext(this);
        var info      = uiContext.EditedObject as BaseInfo;

        if ((info != null) && info.CheckPermissions(PermissionsEnum.Modify, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser))
        {
            pnlRestoreChilds.Attributes.Add("onclick", "if(confirm(" + ScriptHelper.GetLocalizedString("objectversioning.versionlist.confirmfullrollback") + ")) { ContextVersionAction_" + parentElemId + "('fullrollback', GetContextMenuParameter('" + menuId + "'));} return false;");
        }
        else
        {
            pnlRestoreChilds.AddCssClass("ItemDisabled");
        }
    }
    /// <summary>
    /// OnInit event.
    /// </summary>
    protected override void OnInit(EventArgs e)
    {
        int querySiteID = QueryHelper.GetInteger("siteid", 0);

        // Do not allow other than current site ID out of global scope.
        var uiContext = UIContextHelper.GetUIContext(this);

        SiteID = ApplicationUIHelper.IsAccessibleOnlyByGlobalAdministrator(uiContext.UIElement) ? querySiteID : SiteContext.CurrentSiteID;

        if (DisplayScore && SettingsKeyInfoProvider.GetBoolValue(SiteContext.CurrentSiteName + ".CMSEnableOnlineMarketing"))
        {
            Control ctrl = LoadUserControl(SCORE_SELECTOR_PATH);
            if (ctrl != null)
            {
                ctrl.ID        = "selectScore";
                mScoreSelector = ctrl as FormEngineUserControl;
                if (mScoreSelector != null)
                {
                    plcUpdateContent.Controls.Add(mScoreSelector);
                    mScoreSelector.SetValue("AllowAll", false);
                    mScoreSelector.SetValue("AllowEmpty", true);
                }
            }
        }
        else
        {
            plcScore.Visible             = false;
            lblScore.AssociatedControlID = null;
        }

        InitializeDropDownLists();

        base.OnInit(e);

        plcDisplayAnonymous.Visible = ContactManagementPermission && EnableDisplayingGuests;
        if (!RequestHelper.IsPostBack())
        {
            chkDisplayAnonymous.Checked = DisplayGuestsByDefault;
        }

        siteSelector.DropDownSingleSelect.AutoPostBack = true;
    }
Example #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptHelper.RegisterDialogScript(Page);
        ScriptHelper.RegisterApplicationConstants(Page);

        // Get the object type
        string param           = ContextMenu.Parameter;
        string objectType      = null;
        bool   showMoveActions = false;

        if (param != null)
        {
            string[] parameters = param.Split(';');
            objectType = parameters[0];

            showMoveActions = (parameters.Length >= 3) && ValidationHelper.GetBoolean(parameters[2], false);
        }

        // Get empty info
        GeneralizedInfo emptyObject = null;
        ObjectTypeInfo  ti          = null;
        var             uiContext   = UIContextHelper.GetUIContext(this);

        if (objectType != null)
        {
            var uiContextSiteId = ValidationHelper.GetInteger(uiContext["SiteID"], 0);
            emptyObject = UniGridFunctions.GetEmptyObjectWithSiteID(objectType, uiContextSiteId);

            ti = emptyObject.TypeInfo;

            // Get correct info for listings
            if (ti.IsListingObjectTypeInfo)
            {
                emptyObject = UniGridFunctions.GetEmptyObjectWithSiteID(ti.OriginalObjectType, uiContextSiteId);
            }
        }

        if (emptyObject == null)
        {
            Visible = false;
            return;
        }

        var    curUser     = MembershipContext.AuthenticatedUser;
        string curSiteName = SiteContext.CurrentSiteName;

        string menuId = ContextMenu.MenuID;

        if (ti.OrderColumn != ObjectTypeInfo.COLUMN_NAME_UNKNOWN && showMoveActions)
        {
            iMoveUp.Attributes.Add("onclick", "ContextMoveObject_" + ClientID + "('#moveup', GetContextMenuParameter('" + menuId + "'))");
            iMoveDown.Attributes.Add("onclick", "ContextMoveObject_" + ClientID + "('#movedown', GetContextMenuParameter('" + menuId + "'))");
        }
        else
        {
            iMoveUp.Visible   = false;
            iMoveDown.Visible = false;
        }

        // Export
        if (ti.ImportExportSettings.AllowSingleExport)
        {
            if (curUser.IsAuthorizedPerResource("cms.globalpermissions", "ExportObjects", curSiteName))
            {
                iExport.Attributes.Add("onclick", "ContextExportObject(GetContextMenuParameter('" + menuId + "'), false);");
            }
            else
            {
                iExport.Visible = false;
            }

            if (ti.GUIDColumn != ObjectTypeInfo.COLUMN_NAME_UNKNOWN)
            {
                if (curUser.IsAuthorizedPerResource("cms.globalpermissions", "BackupObjects", curSiteName))
                {
                    iBackup.Attributes.Add("onclick", "ContextExportObject(GetContextMenuParameter('" + menuId + "'), true);");
                }
                else
                {
                    iBackup.Visible = false;
                }

                if (curUser.IsAuthorizedPerResource("cms.globalpermissions", "RestoreObjects", curSiteName))
                {
                    iRestore.Attributes.Add("onclick", "ContextRestoreObject(GetContextMenuParameter('" + menuId + "'), true);");
                }
                else
                {
                    iRestore.Visible = false;
                }
            }
            else
            {
                iBackup.Visible  = false;
                iRestore.Visible = false;
            }
        }
        else
        {
            iExport.Visible  = false;
            iBackup.Visible  = false;
            iRestore.Visible = false;
        }

        // Versioning
        if (ObjectVersionManager.AllowObjectRestore(emptyObject) && UniGridFunctions.ObjectSupportsDestroy(emptyObject) && curUser.IsAuthorizedPerObject(PermissionsEnum.Destroy, emptyObject, curSiteName))
        {
            iDestroy.Attributes.Add("onclick", "ContextDestroyObject_" + ClientID + "(GetContextMenuParameter('" + menuId + "'))");
        }
        else
        {
            iDestroy.Visible = false;
        }

        // Clonning
        if ((emptyObject.AllowClone) && (curUser.IsAuthorizedPerObject(PermissionsEnum.Modify, emptyObject, curSiteName)) && (curUser.IsAuthorizedPerObject(PermissionsEnum.Create, emptyObject, curSiteName)))
        {
            iClone.Attributes.Add("onclick", "ContextCloneObject" + "(GetContextMenuParameter('" + menuId + "'))");
        }
        else
        {
            iClone.Visible = false;
        }

        bool ancestor = (iClone.Visible || iDestroy.Visible);

        sepCloneDestroy.Visible = ancestor;
        sepExport.Visible       = (iBackup.Visible || iRestore.Visible || iExport.Visible) && ancestor;
        ancestor       |= (iBackup.Visible || iRestore.Visible || iExport.Visible);
        sepMove.Visible = (iMoveUp.Visible || iMoveDown.Visible) && ancestor;

        Visible = iExport.Visible || iBackup.Visible || iDestroy.Visible || iClone.Visible || iMoveUp.Visible || iMoveDown.Visible;
    }