예제 #1
0
    /// <summary>
    /// Gets score for specified contacts.
    /// </summary>
    private DataSet GetScore(DataSet ds)
    {
        ds.Tables[0].Columns.Add("Score");

        StringBuilder contacts = new StringBuilder();

        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            int contactID = ValidationHelper.GetInteger(dr["SessionContactID"], 0);
            if (contactID > 0)
            {
                contacts.Append(contactID + ",");
            }
        }
        string contactList = contacts.ToString();

        if (!String.IsNullOrEmpty(contactList))
        {
            contactList = contactList.Substring(0, contactList.Length - 1);
            GeneralizedInfo contactScore = CMSObjectHelper.GetReadOnlyObject("om.contactscorelist");
            DataSet         result       = contactScore.GetData(null, String.Format("ContactID IN ({0}) AND ScoreID = {1}", contactList, filter.SelectedScore), null, -1, "ContactID,ScoreValue", false);

            if (!DataHelper.DataSourceIsEmpty(result))
            {
                foreach (DataRow dr in result.Tables[0].Rows)
                {
                    DataRow[] row = ds.Tables[0].Select("SessionContactID =" + dr["ContactID"]);
                    row[0]["Score"] = dr["ScoreValue"];
                }
            }
        }
        return(ds);
    }
예제 #2
0
    private void InitializeTitleLabel()
    {
        BaseInfo bindingType = CMSObjectHelper.GetReadOnlyObject(BindingObjectType);

        if (bindingType != null)
        {
            string otherSide     = bindingType.TypeInfo.ParentObjectType;
            string safeOtherSide = TranslationHelper.GetSafeClassName(otherSide);
            string friendlyType  = GetString("objecttasks." + safeOtherSide);

            if (friendlyType.Length > 0)
            {
                char firstChar = friendlyType[0];
                if (char.IsUpper(firstChar))
                {
                    if (friendlyType.Length > 1)
                    {
                        char secondChar = friendlyType[1];
                        if (!char.IsUpper(secondChar))
                        {
                            friendlyType = friendlyType.ToLowerCSafe();
                        }
                    }
                }
            }
            lblAvialable.Text = string.Format(GetString("site_edit_siteobjects.objectsavailable"), friendlyType);
        }
    }
예제 #3
0
    /// <summary>
    /// Loads variables and objects.
    /// </summary>
    private void LoadControls()
    {
        // Display default name filter
        if (useDefaultNameFilter)
        {
            lblSearch.ResourceString = resourcePrefix + ".entersearch|general.entersearch";
            btnSearch.ResourceString = "general.search";

            pnlSearch.Visible = true;

            if (!RequestHelper.IsPostBack())
            {
                ScriptHelper.RegisterStartupScript(this, typeof(string), "Focus", ScriptHelper.GetScript("try{document.getElementById('" + txtSearch.ClientID + "').focus();}catch(err){}"));
            }
        }

        // Load objects
        if (!String.IsNullOrEmpty(objectType))
        {
            iObjectType = CMSObjectHelper.GetReadOnlyObject(objectType);
            if (iObjectType == null)
            {
                throw new Exception("[UniSelector.SelectionDialog]: Object type '" + objectType + "' not found.");
            }

            if (returnColumnName == null)
            {
                returnColumnName = iObjectType.IDColumn;
            }
        }

        if (!RequestHelper.IsPostBack())
        {
            uniGrid.Pager.DefaultPageSize = itemsPerPage;
        }

        uniGrid.GridName = dialogGridName;
        uniGrid.GridView.EnableViewState = false;

        // Show the OK button if needed
        switch (selectionMode)
        {
        case SelectionModeEnum.Multiple:
        case SelectionModeEnum.MultipleTextBox:
        case SelectionModeEnum.MultipleButton:
        {
            pnlAll.Visible = true;

            lnkSelectAll.Text   = GetString("UniSelector.SelectAll");
            lnkDeselectAll.Text = GetString("UniSelector.DeselectAll");
        }
        break;
        }
    }
    /// <summary>
    /// Setup controls
    /// </summary>
    private void SetupControls()
    {
        if (!RequestHelper.IsPostBack())
        {
            LoadDropDown();
            chkDisplayAllData.Checked = !ObjectDataOnly;
        }

        drpCompareTo.SelectedIndexChanged += drpCompareTo_SelectedIndexChanged;

        if (!NoComparison)
        {
            ObjectDataOnly = !chkDisplayAllData.Checked;
        }

        SyncHelper sh = SyncHelper.GetInstance();

        sh.OperationType = OperationTypeEnum.Versioning;

        // Get object version DataSet
        DataSet dsObject  = sh.GetDataSet(Version.VersionXML, TaskTypeEnum.UpdateObject, Version.VersionObjectType);
        DataSet dsCompare = null;

        // Get object compare version DataSet
        if (VersionCompare != null)
        {
            dsCompare = sh.GetDataSet(VersionCompare.VersionXML, TaskTypeEnum.UpdateObject, VersionCompare.VersionObjectType);
        }

        // Filter out data if necessary
        if (ObjectDataOnly)
        {
            // Get object data table name
            GeneralizedInfo obj         = CMSObjectHelper.GetReadOnlyObject(Version.VersionObjectType);
            string          objectTable = CMSObjectHelper.GetTableName(obj);

            dsObject  = CreateTableDataSet(dsObject, objectTable, obj);
            dsCompare = CreateTableDataSet(dsCompare, objectTable, obj);
        }

        // Switch version data to ensure lower version is on the left side
        if ((Version != null) && (VersionCompare != null) && (VersionCompare.VersionID < Version.VersionID))
        {
            viewDataSet.DataSet        = dsCompare;
            viewDataSet.CompareDataSet = dsObject;
        }
        else
        {
            viewDataSet.DataSet        = dsObject;
            viewDataSet.CompareDataSet = dsCompare;
        }
    }
예제 #5
0
    /// <summary>
    /// Registers NamedDataSource to a given resolver under the specified name.
    /// </summary>
    /// <param name="resolver">Resolver object</param>
    /// <param name="name">Name of the macro - object will be accessible by this name in the resolver</param>
    /// <param name="className">Class name of the object (for the AutoCompletion to work properly)</param>
    private static void RegisterObject(this MacroResolver resolver, string name, string className)
    {
        BaseInfo obj = CMSObjectHelper.GetReadOnlyObject(className);

        if (obj != null)
        {
            resolver.SetNamedSourceData(name, obj);
        }
        else
        {
            resolver.SetNamedSourceData(name, new SimpleDataClass(className));
        }
    }
예제 #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (StopProcessing)
     {
         // Do not load the data
     }
     else
     {
         // Get the base object
         GeneralizedInfo info = CMSObjectHelper.GetReadOnlyObject(ObjectType);
         if (info != null)
         {
             DataSet ds = info.GetData(null, info.IDColumn + " = " + this.ObjectID, null, 0, null, false);
             if (!DataHelper.DataSourceIsEmpty(ds))
             {
                 ds.Tables[0].TableName = ValidationHelper.GetIdentifier(info.ObjectClassName);
                 DisplayData(ds);
             }
         }
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Excluded binding types
        string[] excludedBindingObjects = { SiteObjectType.CULTURESITE.ToLowerCSafe() };

        // Get site bindings
        string[] otherBindingTypes = SiteInfo.TYPEINFO.OtherBindingObjectTypes.Split(';');

        for (int i = 0; i < otherBindingTypes.Length; i++)
        {
            string type = otherBindingTypes[i];
            if (!excludedBindingObjects.Contains(type.ToLowerCSafe()))
            {
                // Create binding object out of type
                BaseInfo bindingType = CMSObjectHelper.GetReadOnlyObject(type);
                if ((bindingType != null) && bindingType.TypeInfo.IsSiteBinding)
                {
                    // Get other side of the site binding
                    string otherSide     = bindingType.TypeInfo.ParentObjectType;
                    string safeOtherSide = TranslationHelper.GetSafeClassName(otherSide);

                    // Build URL
                    string url = "Site_SiteObjects_Content.aspx?siteid=" + QueryHelper.GetInteger("siteid", 0) + "&objecttype=" + otherSide + "&bindingtype=" + type;
                    url = URLHelper.AddParameterToUrl(url, "hash", QueryHelper.GetHash(url));

                    // Initialize tab
                    TabItem tab = new TabItem
                    {
                        Text        = GetString("objecttasks." + safeOtherSide),
                        RedirectUrl = url
                    };

                    CurrentMaster.Tabs.AddTab(tab);
                }
            }
        }

        CurrentMaster.Tabs.UrlTarget = "content";
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        backup = QueryHelper.GetBoolean("backup", false);

        // Check permissions
        if (backup)
        {
            if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.globalpermissions", "BackupObjects", CMSContext.CurrentSiteName))
            {
                RedirectToCMSDeskAccessDenied("cms.globalpermissions", "BackupObjects");
            }
        }
        else if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.globalpermissions", "ExportObjects", CMSContext.CurrentSiteName))
        {
            RedirectToCMSDeskAccessDenied("cms.globalpermissions", "ExportObjects");
        }

        // Register script for pendingCallbacks repair
        ScriptHelper.FixPendingCallbacks(Page);

        // Async control events binding
        ucAsyncControl.OnFinished += ucAsyncControl_OnFinished;
        ucAsyncControl.OnError    += ucAsyncControl_OnError;

        if (!IsCallback)
        {
            try
            {
                // Delete temporary files
                ExportProvider.DeleteTemporaryFiles();
            }
            catch (Exception ex)
            {
                DisplayError(ex);
            }

            if (backup)
            {
                SetTitle("CMSModules/CMS_ImportExport/backupobject.png", GetString("BackupObject.Title"), null, null);
            }
            else
            {
                SetTitle("CMSModules/CMS_ImportExport/exportobject.png", GetString("ExportObject.Title"), null, null);
            }

            // Display BETA warning
            lblBeta.Visible = CMSContext.IsBetaVersion();
            lblBeta.Text    = string.Format(GetString("export.BETAwarning"), CMSContext.GetFriendlySystemVersion(false));

            // Get data from parameters
            objectId   = ValidationHelper.GetInteger(Request.QueryString["objectId"], 0);
            objectType = ValidationHelper.GetString(Request.QueryString["objectType"], "");

            // Get the object
            infoObj = CMSObjectHelper.GetReadOnlyObject(objectType);

            if (infoObj == null)
            {
                plcExportDetails.Visible = false;
                lblIntro.Text            = GetString("ExportObject.ObjectTypeNotFound");
                lblIntro.CssClass        = "ErrorLabel";
                return;
            }

            // Get exported object
            exportObj = infoObj.GetObject(objectId);
            if (exportObj == null)
            {
                plcExportDetails.Visible = false;
                lblIntro.Text            = GetString("ExportObject.ObjectNotFound");
                lblIntro.CssClass        = "ErrorLabel";
                btnOk.Visible            = false;
                return;
            }

            // Store display name
            exportObjectDisplayName = HTMLHelper.HTMLEncode(exportObj.ObjectDisplayName);

            if (backup)
            {
                lblIntro.Text = string.Format(GetString("BackupObject.Intro"), ResHelper.LocalizeString(exportObjectDisplayName));
            }
            else
            {
                lblIntro.Text = string.Format(GetString("ExportObject.Intro"), ResHelper.LocalizeString(exportObjectDisplayName));
            }

            btnOk.Click += btnOk_Click;

            if (!RequestHelper.IsPostBack())
            {
                lblIntro.Visible    = true;
                lblFileName.Visible = true;
                txtFileName.Text    = GetExportFileName(exportObj, backup);
                if (backup)
                {
                    btnOk.Text = GetString("General.backup");
                }
                else
                {
                    btnOk.Text = GetString("General.export");
                }
                btnCancel.Text = GetString("General.Close");
            }

            string path = null;
            if (backup)
            {
                path         = ImportExportHelper.GetObjectBackupFolder(exportObj);
                targetFolder = Server.MapPath(path);

                targetUrl = ResolveUrl(path) + "/" + txtFileName.Text;
            }
            else
            {
                targetFolder = ImportExportHelper.GetSiteUtilsFolder() + "Export";
                path         = ImportExportHelper.GetSiteUtilsFolderRelativePath();
                if (path != null)
                {
                    string externalUrl = null;
                    string fullPath    = path + "Export/" + txtFileName.Text;

                    // Handle external storage URL
                    if (StorageHelper.IsExternalStorage(fullPath))
                    {
                        externalUrl = File.GetFileUrl(fullPath, CMSContext.CurrentSiteName);
                    }

                    // Ensure default target URL if not set
                    if (string.IsNullOrEmpty(externalUrl))
                    {
                        targetUrl = ResolveUrl(path) + "Export/" + txtFileName.Text;
                    }
                    else
                    {
                        targetUrl = externalUrl;
                    }
                }
                else
                {
                    targetUrl = null;
                }
            }
        }
    }
예제 #9
0
    /// <summary>
    /// Bind the data.
    /// </summary>
    public void Bind()
    {
        if (!string.IsNullOrEmpty(ObjectType))
        {
            pnlGrid.Visible  = true;
            selectionEnabled = ((ObjectType != LicenseObjectType.LICENSEKEY) || !Settings.IsOlderVersion);

            lblTasks.Text = GetString("Export.Tasks");

            if (selectionEnabled)
            {
                // Initilaize strings
                btnAllTasks.Text  = GetString("ImportExport.All");
                btnNoneTasks.Text = GetString("export.none");
            }

            pnlTaskLinks.Visible = selectionEnabled;

            // Get object info
            GeneralizedInfo info = CMSObjectHelper.GetReadOnlyObject(ObjectType);
            if (info != null)
            {
                plcGrid.Visible       = true;
                codeNameColumnName    = info.CodeNameColumn;
                displayNameColumnName = info.DisplayNameColumn;

                // Task fields
                TemplateField taskCheckBoxField = (TemplateField)gvTasks.Columns[0];
                taskCheckBoxField.HeaderText = GetString("General.Process");

                BoundField titleField = (BoundField)gvTasks.Columns[1];
                titleField.HeaderText = GetString("Export.TaskTitle");

                BoundField typeField = (BoundField)gvTasks.Columns[2];
                typeField.HeaderText = GetString("general.type");

                BoundField timeField = (BoundField)gvTasks.Columns[3];
                timeField.HeaderText = GetString("Export.TaskTime");

                // Load tasks
                DataSet ds = DataSource;
                if (!DataHelper.DataSourceIsEmpty(ds) && !DataHelper.DataSourceIsEmpty(ds.Tables["Export_Task"]) && (ValidationHelper.GetBoolean(Settings.GetSettings(ImportExportHelper.SETTINGS_TASKS), true)))
                {
                    plcTasks.Visible   = true;
                    gvTasks.DataSource = ds.Tables["Export_Task"];

                    // Set correct ID for direct page contol
                    pagerElem.DirectPageControlID = ((float)ds.Tables["Export_Task"].Rows.Count / pagerElem.CurrentPageSize > 20.0f) ? "txtPage" : "drpPage";

                    // Call page binding event
                    if (OnPageBinding != null)
                    {
                        OnPageBinding(this, null);
                    }

                    gvTasks.DataBind();
                }
                else
                {
                    plcTasks.Visible = false;
                }
            }
            else
            {
                plcGrid.Visible = false;
            }

            // Disable license selection
            bool enable = !((ObjectType == LicenseObjectType.LICENSEKEY) && Settings.IsOlderVersion);
            gvTasks.Enabled      = enable;
            pnlTaskLinks.Enabled = enable;
        }
        else
        {
            pnlGrid.Visible = false;
        }
    }
예제 #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptHelper.RegisterDialogScript(this.Page);
        ScriptHelper.RegisterApplicationConstants(this.Page);

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

        if (param != null)
        {
            string[] parms = param.Split(';');
            objectType = parms[0];
            if (parms.Length == 2)
            {
                groupObject = ValidationHelper.GetBoolean(parms[1], false);
            }
        }

        // Get empty info
        GeneralizedInfo obj = null;

        if (objectType != null)
        {
            obj = CMSObjectHelper.GetReadOnlyObject(objectType);
            // Get correct info for listings
            if (obj.TypeInfo.Inherited)
            {
                obj = CMSObjectHelper.GetReadOnlyObject(obj.TypeInfo.OriginalObjectType);
            }
            obj.ObjectGroupID = groupObject ? 1 : 0;
        }

        if (obj == null)
        {
            this.Visible = false;
            return;
        }

        CurrentUserInfo curUser     = CMSContext.CurrentUser;
        string          curSiteName = CMSContext.CurrentSiteName;

        string menuId = this.ContextMenu.MenuID;

        // Relationships
        if (obj.TypeInfo.HasObjectRelationships)
        {
            this.iRelationships.ImageUrl = UIHelper.GetImageUrl(this.Page, "Design/Controls/UniGrid/Actions/Relationships.png");
            this.iRelationships.Text     = ResHelper.GetString("General.Relationships");
            this.iRelationships.Attributes.Add("onclick", "ContextRelationships(GetContextMenuParameter('" + menuId + "'));");
        }
        else
        {
            this.iRelationships.Visible = false;
        }

        // Export
        if (obj.TypeInfo.AllowSingleExport)
        {
            if (curUser.IsAuthorizedPerResource("cms.globalpermissions", "ExportObjects", curSiteName))
            {
                this.iExport.ImageUrl = UIHelper.GetImageUrl(this.Page, "Design/Controls/UniGrid/Actions/ExportObject.png");
                this.iExport.Text     = ResHelper.GetString("General.Export");
                this.iExport.Attributes.Add("onclick", "ContextExportObject(GetContextMenuParameter('" + menuId + "'), false);");
            }
            else
            {
                this.iExport.Visible = false;
            }

            if (obj.GUIDColumn != TypeInfo.COLUMN_NAME_UNKNOWN)
            {
                if (curUser.IsAuthorizedPerResource("cms.globalpermissions", "BackupObjects", curSiteName))
                {
                    this.iBackup.ImageUrl = UIHelper.GetImageUrl(this.Page, "Design/Controls/UniGrid/Actions/BackupObject.png");
                    this.iBackup.Text     = ResHelper.GetString("General.Backup");
                    this.iBackup.Attributes.Add("onclick", "ContextExportObject(GetContextMenuParameter('" + menuId + "'), true);");
                }
                else
                {
                    this.iBackup.Visible = false;
                }

                if (curUser.IsAuthorizedPerResource("cms.globalpermissions", "RestoreObjects", curSiteName))
                {
                    this.iRestore.ImageUrl = UIHelper.GetImageUrl(this.Page, "Design/Controls/UniGrid/Actions/RestoreObject.png");
                    this.iRestore.Text     = ResHelper.GetString("General.Restore");
                    this.iRestore.Attributes.Add("onclick", "ContextRestoreObject(GetContextMenuParameter('" + menuId + "'), true);");
                }
                else
                {
                    this.iRestore.Visible = false;
                }
            }
            else
            {
                this.iBackup.Visible  = false;
                this.iRestore.Visible = false;
            }
        }
        else
        {
            this.iExport.Visible  = false;
            this.iBackup.Visible  = false;
            this.iRestore.Visible = false;
        }

        // Versioning
        if (obj.AllowRestore && UniGridFunctions.ObjectSupportsDestroy(obj) && curUser.IsAuthorizedPerObject(PermissionsEnum.Destroy, obj.TypeInfo.OriginalObjectType, curSiteName))
        {
            iDestroy.ImageUrl = UIHelper.GetImageUrl(Page, "Design/Controls/UniGrid/Actions/Delete.png");
            iDestroy.Text     = ResHelper.GetString("security.destroy");
            iDestroy.Attributes.Add("onclick", "ContextDestroyObject_" + ClientID + "(GetContextMenuParameter('" + menuId + "'))");
        }
        else
        {
            iDestroy.Visible = false;
        }

        bool ancestor = iRelationships.Visible;

        sep1.Visible = iExport.Visible && ancestor;
        ancestor    |= iExport.Visible;
        sep2.Visible = (iBackup.Visible || iRestore.Visible) && ancestor;
        ancestor    |= (iBackup.Visible || iRestore.Visible);
        sep3.Visible = iDestroy.Visible && ancestor;

        this.Visible = iRelationships.Visible || iExport.Visible || iBackup.Visible || iDestroy.Visible;

        if (Visible)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(@"
function ContextRelationships(definition) {
   var url = applicationUrl + 'CMSModules/AdminControls/Pages/ObjectRelationships.aspx?objecttype=' + escape(definition[0]) + '&objectid=' + escape(definition[1]);
        modalDialog(url, ""relationships"", 900, 600);
    }
    
function ContextExportObject(definition, backup) {
   var query = ''; 
   if (backup) {
       query += '&backup=true';
   }
   modalDialog(applicationUrl + 'CMSModules/ImportExport/SiteManager/ExportObject.aspx?objectType=' + escape(definition[0]) + '&objectId=' + definition[1] + query, 'ExportObject', 750, 200);
}

function ContextRestoreObject(definition, backup) {
    var query = '';
    if (backup) {
       query += '&backup=true';
    }
    modalDialog(applicationUrl + 'CMSModules/ImportExport/SiteManager/RestoreObject.aspx?objectType=' + escape(definition[0]) + '&objectId=' + definition[1] + query, 'RestoreObject', 750, 350);
}");
            // Register general export scripts
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ObjectMenuExportScripts", sb.ToString(), true);

            sb = new StringBuilder();
            sb.Append(@"
function ContextDestroyObject_", ClientID, @"(definition)
{
   if(confirm('", ResHelper.GetString("objectversioning.destroyobjectconfirmation"), @"')) {
      if(UG_DestroyObj_", ContextMenu.ParentElementClientID, @") {
          var param = definition.toString().split(',');
          if((param != null) && (param.length == 2)) {
              UG_DestroyObj_", ContextMenu.ParentElementClientID, @"(param[1]);
          }
      }
   }
}");
            // Register destroy script for particular menu
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ObjectMenuDestroyScript_" + ClientID, sb.ToString(), true);
        }
    }
예제 #11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.globalpermissions", "RestoreObjects", CMSContext.CurrentSiteName))
        {
            RedirectToCMSDeskAccessDenied("cms.globalpermissions", "RestoreObjects");
        }

        // Register script for pendingCallbacks repair
        ScriptHelper.FixPendingCallbacks(Page);

        imgDelete.ImageUrl = GetImageUrl("Design/Controls/EditModeButtons/delete.png");

        // Async control events binding
        ucAsyncControl.OnFinished += ucAsyncControl_OnFinished;
        ucAsyncControl.OnError    += ucAsyncControl_OnError;

        if (!IsCallback)
        {
            try
            {
                // Delete temporary files
                ExportProvider.DeleteTemporaryFiles();
            }
            catch (Exception ex)
            {
                DisplayError(ex);
            }

            SetTitle("CMSModules/CMS_ImportExport/restoreobject.png", GetString("RestoreObject.Title"), null, null);

            // Get data from parameters
            siteId     = ValidationHelper.GetInteger(Request.QueryString["siteId"], 0);
            objectId   = ValidationHelper.GetInteger(Request.QueryString["objectId"], 0);
            objectType = ValidationHelper.GetString(Request.QueryString["objectType"], "");

            // Get the object
            infoObj = CMSObjectHelper.GetReadOnlyObject(objectType);
            if (infoObj == null)
            {
                lblIntro.Text     = GetString("ExportObject.ObjectTypeNotFound");
                lblIntro.CssClass = "ErrorLabel";
                return;
            }

            // Get exported object
            exportObj = infoObj.GetObject(objectId);
            if (exportObj == null)
            {
                lblIntro.Text     = GetString("ExportObject.ObjectNotFound");
                lblIntro.CssClass = "ErrorLabel";
                btnOk.Visible     = false;
                return;
            }

            // Store display name
            exportObjectDisplayName = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(exportObj.ObjectDisplayName));
            codeName = exportObj.ObjectCodeName;

            lblIntro.Text = string.Format(GetString("RestoreObject.Intro"), exportObjectDisplayName);

            targetFolder = ImportExportHelper.GetObjectBackupFolder(exportObj);

            btnOk.Click += btnOk_Click;

            if (!RequestHelper.IsPostBack())
            {
                lblIntro.Visible = true;
                btnOk.Text       = GetString("General.Restore");
                btnCancel.Text   = GetString("General.Close");

                // Load the available backups
                if (lstImports.Items.Count == 0)
                {
                    RefreshPackageList();
                }
            }
        }
    }
    /// <summary>
    /// Generates where condition.
    /// </summary>
    protected string GenerateWhereCondition(int siteId)
    {
        switch (FilterMode)
        {
        case "user":
        {
            // If some site selected filter users
            if (siteId > 0)
            {
                return("UserID IN (SELECT UserID FROM CMS_UserSite WHERE SiteID = " + siteId + ")");
            }
        }
        break;

        case "role":
        {
            // If some site selected filter users
            if (siteId > 0)
            {
                return("SiteID = " + siteId);
            }
            if (siteId.ToString() == siteSelector.GlobalRecordValue)
            {
                return("SiteID IS NULL");
            }
        }
        break;

        case "subscriber":
        {
            // If some site filters subscibers
            if (siteId > 0)
            {
                return("SubscriberSiteID = " + siteId);
            }
        }
        break;

        case "cultures":
        {
            if (siteId > 0)
            {
                return("CultureID IN (SELECT CultureID FROM CMS_SiteCulture WHERE SiteID = " + siteId + ")");
            }
        }
        break;

        case "bizform":
        {
            if (siteId > 0)
            {
                return("FormSiteID = " + siteId);
            }
        }
        break;

        case "notificationtemplate":
        case "notificationtemplateglobal":
        {
            string where = "";

            // Set the prefix for the item
            SiteInfo si = SiteInfoProvider.GetSiteInfo(siteId);
            if (si != null)
            {
                filteredControl.SetValue("ItemPrefix", si.SiteName + ".");
                where = "TemplateSiteID = " + siteId;
            }
            // Add global templates
            else
            {
                filteredControl.SetValue("ItemPrefix", null);
                where = "TemplateSiteID IS NULL";
            }

            return(where);
        }

        case "department":
        {
            // If some site selected filter departments
            if (siteId > 0)
            {
                return("DepartmentSiteID = " + siteId);
            }
            if (siteId.ToString() == siteSelector.GlobalRecordValue)
            {
                return("DepartmentSiteID IS NULL");
            }
        }
        break;

        default:
        {
            // Automatic filtering mode
            if ((siteId > 0) || (siteId == UniSelector.US_GLOBAL_RECORD))
            {
                IObjectTypeDriven filtered = this.FilteredControl as IObjectTypeDriven;
                if (filtered != null)
                {
                    BaseInfo infoObj = CMSObjectHelper.GetReadOnlyObject(filtered.ObjectType);
                    return(infoObj.TypeInfo.GetSiteWhereCondition(siteId, false));
                }
            }
        }
        break;
        }

        return(String.Empty);
    }
예제 #13
0
    /// <summary>
    /// Bind the data.
    /// </summary>
    public void Bind()
    {
        if (!string.IsNullOrEmpty(ObjectType))
        {
            pnlGrid.Visible = true;

            // Initialize strings
            btnAll.Text     = GetString("ImportExport.All");
            btnNone.Text    = GetString("export.none");
            btnDefault.Text = GetString("General.Default");

            // Get object info
            GeneralizedInfo info = CMSObjectHelper.GetReadOnlyObject(ObjectType);
            if (info != null)
            {
                plcGrid.Visible       = true;
                codeNameColumnName    = info.CodeNameColumn;
                displayNameColumnName = info.DisplayNameColumn;

                // Get data source
                string where = GenerateWhereCondition();
                string orderBy = GetOrderByExpression(info);

                // Prepare the columns
                string columns = null;
                if (info.CodeNameColumn != TypeInfo.COLUMN_NAME_UNKNOWN)
                {
                    columns += info.CodeNameColumn;
                }
                if ((info.DisplayNameColumn.ToLower() != info.CodeNameColumn.ToLower()) && (info.DisplayNameColumn != TypeInfo.COLUMN_NAME_UNKNOWN))
                {
                    if (columns != null)
                    {
                        columns += ", ";
                    }
                    columns += info.DisplayNameColumn;
                }

                DataSet ds = info.GetData(null, where, orderBy, -1, columns, false, CurrentOffset, CurrentPageSize, ref pagerForceNumberOfResults);

                // Set correct ID for direct page contol
                pagerElem.DirectPageControlID = ((float)pagerForceNumberOfResults / pagerElem.CurrentPageSize > 20.0f) ? "txtPage" : "drpPage";

                // Call page binding event
                if (OnPageBinding != null)
                {
                    OnPageBinding(this, null);
                }

                // Prepare checkbox field
                TemplateField checkBoxField = (TemplateField)gvObjects.Columns[0];
                checkBoxField.HeaderText = GetString("General.Export");

                // Prepare display name field
                TemplateField nameField = (TemplateField)gvObjects.Columns[1];
                nameField.HeaderText = GetString("general.displayname");

                // Load data
                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    plcObjects.Visible   = true;
                    lblNoData.Visible    = false;
                    gvObjects.DataSource = ds;
                    gvObjects.DataBind();
                }
                else
                {
                    plcObjects.Visible = false;
                    lblNoData.Visible  = true;
                    lblNoData.Text     = String.Format(GetString("ExportGridView.NoData"), GetString("objecttype." + ObjectType.Replace(".", "_").Replace("#", "_")));
                }
            }
            else
            {
                plcGrid.Visible = false;
            }
        }
        else
        {
            pnlGrid.Visible      = false;
            gvObjects.DataSource = null;
            gvObjects.DataBind();
        }
    }
    /// <summary>
    /// Reloads all data.
    /// </summary>
    public override void ReloadData(bool forceLoad)
    {
        if (CurrentReport != null)
        {
            // Load labels
            if (!RequestHelper.IsPostBack() || forceLoad)
            {
                // Create query parameters
                string query = "?ObjectID=" + CurrentReport.ReportObjectID;

                // Set link value
                string url = CurrentReport.ReportURL;
                if (CurrentReport.ReportCulture != String.Empty)
                {
                    url = URLHelper.AddParameterToUrl(url, URLHelper.LanguageParameterName, CurrentReport.ReportCulture);
                }
                lnkUrlValue.Text        = HTMLHelper.HTMLEncode(url);
                lnkUrlValue.NavigateUrl = url;
                lnkUrlValue.ToolTip     = HTMLHelper.HTMLEncode(url);
                lnkUrlValue.Target      = "_blank";

                // Set culture value
                System.Globalization.CultureInfo ci = CultureHelper.GetCultureInfo(CurrentReport.ReportCulture);
                lblCultureValue.Text = (ci != null) ? ci.DisplayName : ResHelper.Dash;

                // Set site value
                SiteInfo si = SiteInfoProvider.GetSiteInfo(CurrentReport.ReportSiteID);
                lblSiteValue.Text = (si != null) ? HTMLHelper.HTMLEncode(si.DisplayName) : ResHelper.Dash;

                // Set title
                lblTitleValue.Text = HTMLHelper.HTMLEncode(CurrentReport.ReportTitle);

                // Set labels
                if (!string.IsNullOrEmpty(CurrentReport.ReportObjectType))
                {
                    lblObjectTypeValue.Text = GetString("ObjectType." + ImportExportHelper.GetSafeObjectTypeName(CurrentReport.ReportObjectType));
                    query += "&ObjectType=" + CurrentReport.ReportObjectType;
                    if ((CurrentReport.ReportObjectID > 0) && (CurrentReport.ReportObjectType.ToLower() != TreeObjectType.DOCUMENT))
                    {
                        pnlLink.Visible = true;
                    }
                }
                else
                {
                    lblObjectTypeValue.Text = ResHelper.Dash;
                }

                // Get object display name
                lblObjectNameValue.Text = ResHelper.Dash;
                if ((CurrentReport.ReportObjectID > 0) && (!string.IsNullOrEmpty(CurrentReport.ReportObjectType)))
                {
                    GeneralizedInfo info = CMSObjectHelper.GetReadOnlyObject(CurrentReport.ReportObjectType);
                    if ((info != null) && (CurrentReport.ReportObjectType.ToLower() != TreeObjectType.DOCUMENT.ToLower()))
                    {
                        GeneralizedInfo obj = info.GetObject(CurrentReport.ReportObjectID);
                        if ((obj != null) && !string.IsNullOrEmpty(obj.ObjectDisplayName))
                        {
                            lblObjectNameValue.Text = HTMLHelper.HTMLEncode(obj.ObjectDisplayName);
                        }
                    }
                }

                // Set Reported by label
                lblReportedByValue.Text = ResHelper.Dash;
                if (CurrentReport.ReportUserID != 0)
                {
                    UserInfo ui = UserInfoProvider.GetUserInfo(CurrentReport.ReportUserID);
                    lblReportedByValue.Text = (ui != null) ? HTMLHelper.HTMLEncode(ui.FullName) : GetString("general.NA");
                }

                // Set other parameters
                lblReportedWhenValue.Text = CurrentReport.ReportWhen.ToString();

                if ((CurrentReport.ReportObjectID > 0) && (!string.IsNullOrEmpty(CurrentReport.ReportObjectType)) && AbuseReportInfoProvider.IsObjectTypeSupported(CurrentReport.ReportObjectType))
                {
                    lnkShowDetails.Visible = true;
                    string detailUrl = "~/CMSModules/AbuseReport/AbuseReport_ObjectDetails.aspx" + query;
                    lnkShowDetails.NavigateUrl = URLHelper.AddParameterToUrl(detailUrl, "hash", QueryHelper.GetHash(detailUrl));
                }

                if (ControlsHelper.GetPostBackControl(Page) != btnOk)
                {
                    txtCommentValue.Text = CurrentReport.ReportComment;
                    LoadStatus((int)CurrentReport.ReportStatus);
                }
            }
        }
    }
예제 #15
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   groupObject = false;

        if (param != null)
        {
            string[] parms = param.Split(';');
            objectType = parms[0];
            if (parms.Length == 2)
            {
                groupObject = ValidationHelper.GetBoolean(parms[1], false);
            }
        }

        // Get empty info
        GeneralizedInfo obj = null;

        if (objectType != null)
        {
            obj = CMSObjectHelper.GetReadOnlyObject(objectType);
            // Get correct info for listings
            if (obj.TypeInfo.Inherited)
            {
                obj = CMSObjectHelper.GetReadOnlyObject(obj.TypeInfo.OriginalObjectType);
            }
        }

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

        CurrentUserInfo curUser     = CMSContext.CurrentUser;
        string          curSiteName = CMSContext.CurrentSiteName;

        string menuId = ContextMenu.MenuID;

        // Relationships
        if (obj.TypeInfo.HasObjectRelationships)
        {
            iRelationships.ImageUrl = UIHelper.GetImageUrl(Page, "Design/Controls/UniGrid/Actions/Relationships.png");
            iRelationships.Text     = ResHelper.GetString("General.Relationships");
            iRelationships.Attributes.Add("onclick", "ContextRelationships(GetContextMenuParameter('" + menuId + "'));");
        }
        else
        {
            iRelationships.Visible = false;
        }

        // Export
        if (obj.TypeInfo.AllowSingleExport)
        {
            if (curUser.IsAuthorizedPerResource("cms.globalpermissions", "ExportObjects", curSiteName))
            {
                iExport.ImageUrl = UIHelper.GetImageUrl(Page, "Design/Controls/UniGrid/Actions/ExportObject.png");
                iExport.Text     = ResHelper.GetString("General.Export");
                iExport.Attributes.Add("onclick", "ContextExportObject(GetContextMenuParameter('" + menuId + "'), false);");
            }
            else
            {
                iExport.Visible = false;
            }

            if (obj.GUIDColumn != TypeInfo.COLUMN_NAME_UNKNOWN)
            {
                if (curUser.IsAuthorizedPerResource("cms.globalpermissions", "BackupObjects", curSiteName))
                {
                    iBackup.ImageUrl = UIHelper.GetImageUrl(Page, "Design/Controls/UniGrid/Actions/BackupObject.png");
                    iBackup.Text     = ResHelper.GetString("General.Backup");
                    iBackup.Attributes.Add("onclick", "ContextExportObject(GetContextMenuParameter('" + menuId + "'), true);");
                }
                else
                {
                    iBackup.Visible = false;
                }

                if (curUser.IsAuthorizedPerResource("cms.globalpermissions", "RestoreObjects", curSiteName))
                {
                    iRestore.ImageUrl = UIHelper.GetImageUrl(Page, "Design/Controls/UniGrid/Actions/RestoreObject.png");
                    iRestore.Text     = ResHelper.GetString("General.Restore");
                    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 (obj.AllowRestore && UniGridFunctions.ObjectSupportsDestroy(obj) && curUser.IsAuthorizedPerObject(PermissionsEnum.Destroy, obj.ObjectType, curSiteName))
        {
            iDestroy.ImageUrl = UIHelper.GetImageUrl(Page, "Design/Controls/UniGrid/Actions/Delete.png");
            iDestroy.Text     = ResHelper.GetString("security.destroy");
            iDestroy.Attributes.Add("onclick", "ContextDestroyObject_" + ClientID + "(GetContextMenuParameter('" + menuId + "'))");
        }
        else
        {
            iDestroy.Visible = false;
        }

        // Clonning
        if (obj.AllowClone)
        {
            iClone.ImageUrl = UIHelper.GetImageUrl(Page, "Design/Controls/UniGrid/Actions/Clone.png");
            iClone.Text     = ResHelper.GetString("general.clone");
            iClone.Attributes.Add("onclick", "ContextCloneObject" + "(GetContextMenuParameter('" + menuId + "'))");
        }
        else
        {
            iClone.Visible = false;
        }

        bool ancestor = iRelationships.Visible;

        sep1.Visible = (iClone.Visible || iDestroy.Visible) && ancestor;
        ancestor    |= (iClone.Visible || iDestroy.Visible);
        sep2.Visible = (iBackup.Visible || iRestore.Visible || iExport.Visible) && ancestor;

        Visible = iRelationships.Visible || iExport.Visible || iBackup.Visible || iDestroy.Visible || iClone.Visible;
    }
예제 #16
0
    /// <summary>
    /// Bind the data.
    /// </summary>
    public void Bind()
    {
        if (!string.IsNullOrEmpty(ObjectType))
        {
            pnlGrid.Visible  = true;
            selectionEnabled = ((ObjectType != LicenseObjectType.LICENSEKEY) || !Settings.IsOlderVersion);

            if (selectionEnabled)
            {
                // Initilaize strings
                btnAll.Text     = GetString("ImportExport.All");
                btnNone.Text    = GetString("export.none");
                btnDefault.Text = GetString("General.Default");
            }

            pnlLinks.Visible = selectionEnabled;

            // Get object info
            GeneralizedInfo info = CMSObjectHelper.GetReadOnlyObject(ObjectType);
            if (info != null)
            {
                plcGrid.Visible       = true;
                codeNameColumnName    = info.CodeNameColumn;
                displayNameColumnName = info.DisplayNameColumn;

                // Get data source
                DataSet ds = DataSource;

                DataTable table = null;
                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    // Get the table
                    string tableName = CMSObjectHelper.GetTableName(info);
                    table = ds.Tables[tableName];

                    // Set correct ID for direct page contol
                    pagerElem.DirectPageControlID = ((float)table.Rows.Count / pagerElem.CurrentPageSize > 20.0f) ? "txtPage" : "drpPage";

                    // Sort data
                    if (!DataHelper.DataSourceIsEmpty(table))
                    {
                        string orderBy = GetOrderByExpression(info);
                        table.DefaultView.Sort = orderBy;

                        if (ValidationHelper.GetString(table.Rows[0][codeNameColumnName], null) == null)
                        {
                            codeNameColumnName = info.GUIDColumn;
                        }
                    }
                }

                // Prepare checkbox column
                TemplateField checkBoxField = (TemplateField)gvObjects.Columns[0];
                checkBoxField.HeaderText = GetString("General.Import");

                // Prepare name field
                TemplateField nameField = (TemplateField)gvObjects.Columns[1];
                nameField.HeaderText = GetString("general.displayname");

                if (!DataHelper.DataSourceIsEmpty(table))
                {
                    plcObjects.Visible   = true;
                    lblNoData.Visible    = false;
                    gvObjects.DataSource = table;

                    // Call page binding event
                    if (OnPageBinding != null)
                    {
                        OnPageBinding(this, null);
                    }

                    PagedDataSource pagedDS = gvObjects.DataSource as PagedDataSource;
                    if (pagedDS != null)
                    {
                        if (pagedDS.PageSize <= 0)
                        {
                            gvObjects.DataSource = table;
                        }
                    }

                    gvObjects.DataBind();
                }
                else
                {
                    plcObjects.Visible = false;
                    lblNoData.Visible  = true;
                    lblNoData.Text     = String.Format(GetString("ImportGridView.NoData"), GetString("objecttype." + ObjectType.Replace(".", "_").Replace("#", "_")));
                }
            }
            else
            {
                plcGrid.Visible = false;
            }

            // Disable license selection
            bool enable = !((ObjectType == LicenseObjectType.LICENSEKEY) && Settings.IsOlderVersion);
            gvObjects.Enabled = enable;
            pnlLinks.Enabled  = enable;
            lblInfo.Text      = enable ? GetString("ImportGridView.Info") : GetString("ImportGridView.Disabled");
        }
        else
        {
            pnlGrid.Visible      = false;
            gvObjects.DataSource = null;
            gvObjects.DataBind();
        }
    }
예제 #17
0
    /// <summary>
    /// Bind the data.
    /// </summary>
    public void Bind()
    {
        sbAvailable = null;

        if (!string.IsNullOrEmpty(ObjectType))
        {
            pnlGrid.Visible = true;

            // Initialize strings
            btnAllTasks.Text  = GetString("ImportExport.All");
            btnNoneTasks.Text = GetString("export.none");
            lblTasks.Text     = GetString("Export.Tasks");

            // Get object info
            GeneralizedInfo info = CMSObjectHelper.GetReadOnlyObject(ObjectType);
            if (info != null)
            {
                plcGrid.Visible       = true;
                codeNameColumnName    = info.CodeNameColumn;
                displayNameColumnName = info.DisplayNameColumn;

                // Task fields
                TemplateField taskCheckBoxField = (TemplateField)gvTasks.Columns[0];
                taskCheckBoxField.HeaderText = GetString("General.Export");

                TemplateField titleField = (TemplateField)gvTasks.Columns[1];
                titleField.HeaderText = GetString("Export.TaskTitle");

                BoundField typeField = (BoundField)gvTasks.Columns[2];
                typeField.HeaderText = GetString("general.type");

                BoundField timeField = (BoundField)gvTasks.Columns[3];
                timeField.HeaderText = GetString("Export.TaskTime");

                // Load tasks
                int siteId = (SiteObject ? Settings.SiteId : 0);

                DataSet ds = ExportTaskInfoProvider.SelectTaskList(siteId, ObjectType, null, "TaskTime DESC", 0, null, CurrentOffset, CurrentPageSize, ref pagerForceNumberOfResults);

                // Set correct ID for direct page contol
                pagerElem.DirectPageControlID = ((float)pagerForceNumberOfResults / pagerElem.CurrentPageSize > 20.0f) ? "txtPage" : "drpPage";

                // Call page binding event
                if (OnPageBinding != null)
                {
                    OnPageBinding(this, null);
                }

                if (!DataHelper.DataSourceIsEmpty(ds) && (ValidationHelper.GetBoolean(Settings.GetSettings(ImportExportHelper.SETTINGS_TASKS), true)))
                {
                    plcTasks.Visible   = true;
                    gvTasks.DataSource = ds;
                    gvTasks.DataBind();
                }
                else
                {
                    plcTasks.Visible = false;
                }
            }
            else
            {
                plcGrid.Visible = false;
            }
        }
        else
        {
            pnlGrid.Visible = false;
        }
    }
예제 #18
0
    /// <summary>
    /// Loads the dictionaries to the data table
    /// </summary>
    private DataTable LoadDictionaries()
    {
        DataTable dt = new DataTable();

        dt.Columns.Add(new DataColumn("TableName", typeof(string)));
        dt.Columns.Add(new DataColumn("ObjectCount", typeof(int)));

        lock (ProviderStringDictionary.Dictionaries)
        {
            // Hashtables
            foreach (DictionaryEntry item in ProviderStringDictionary.Dictionaries)
            {
                if (item.Value is IProviderDictionary)
                {
                    IProviderDictionary dict = (IProviderDictionary)item.Value;

                    DataRow dr           = dt.NewRow();
                    string  resStringKey = "HashTableName." + ValidationHelper.GetIdentifier(item.Key);
                    if (resStringKey.Length > 100)
                    {
                        resStringKey = resStringKey.Substring(0, 100);
                    }

                    // Try to get the resource string name
                    string name = ResHelper.GetString(resStringKey, null, String.Empty);
                    if (String.IsNullOrEmpty(name))
                    {
                        BaseInfo obj = CMSObjectHelper.GetReadOnlyObject(dict.ObjectType);
                        if (obj != null)
                        {
                            string res = null;

                            // Known hashtable columns (ID, GUID, Name)
                            if (dict.ColumnNames.EqualsCSafe(obj.TypeInfo.IDColumn, true))
                            {
                                res = "hashtable.byid";
                            }
                            else if (dict.ColumnNames.StartsWithCSafe(obj.TypeInfo.CodeNameColumn, true))
                            {
                                res = "hashtable.byname";
                            }
                            else if (dict.ColumnNames.StartsWithCSafe(obj.TypeInfo.GUIDColumn, true))
                            {
                                res = "hashtable.byguid";
                            }

                            // Generate the name automatically
                            if (!String.IsNullOrEmpty(res))
                            {
                                name = ResHelper.GetStringFormat(res, GetString("ObjectTasks." + dict.ObjectType.Replace(".", "_")));
                            }
                        }
                    }

                    if (String.IsNullOrEmpty(name))
                    {
                        name = resStringKey;
                    }
                    dr["TableName"]   = name;
                    dr["ObjectCount"] = dict.GetRealCount();

                    dt.Rows.Add(dr);
                }
            }
        }

        return(dt);
    }