protected void Page_Load(object sender, EventArgs e) { // Register JQuery ScriptHelper.RegisterJQuery(Page); // Use images according to culture if (CultureHelper.IsUICultureRTL()) { this.treeElem.LineImagesFolder = GetImageUrl("RTL/Design/Controls/Tree", false, false); } else { this.treeElem.LineImagesFolder = GetImageUrl("Design/Controls/Tree", false, false); } if (RootCategory != null) { string levelWhere = (MaxRelativeLevel <= 0 ? "" : " AND (CategoryLevel <= " + (RootCategory.CategoryLevel + MaxRelativeLevel) + ")"); // Restrict CategoryChildCount to MaxRelativeLevel. If level < MaxRelativeLevel, use count of non-group childs. string levelColumn = "CASE CategoryLevel WHEN " + MaxRelativeLevel + " THEN 0 ELSE (SELECT COUNT(*) AS CountNonGroup FROM CMS_SettingsCategory AS sc WHERE (sc.CategoryParentID = CMS_SettingsCategory.CategoryID) AND (sc.CategoryIsGroup = 0)) END AS CategoryChildCount"; // Create and set category provider UniTreeProvider provider = new UniTreeProvider(); provider.RootLevelOffset = RootCategory.CategoryLevel; provider.ObjectType = "CMS.SettingsCategory"; provider.DisplayNameColumn = "CategoryDisplayName"; provider.IDColumn = "CategoryID"; provider.LevelColumn = "CategoryLevel"; provider.OrderColumn = "CategoryOrder"; provider.ParentIDColumn = "CategoryParentID"; provider.PathColumn = "CategoryIDPath"; provider.ValueColumn = "CategoryID"; provider.ChildCountColumn = "CategoryChildCount"; provider.WhereCondition = " ((CategoryIsGroup IS NULL) OR (CategoryIsGroup = 0)) " + levelWhere; if (!ShowEmptyCategories) { provider.WhereCondition = SqlHelperClass.AddWhereCondition(provider.WhereCondition, "CategoryID IN (SELECT CategoryParentID FROM CMS_SettingsCategory WHERE (CategoryIsGroup = 0) OR (CategoryIsGroup = 1 AND CategoryID IN (SELECT KeyCategoryID FROM CMS_SettingsKey WHERE ISNULL(SiteID, 0) = " + SiteID + ")))"); } provider.Columns = "CategoryID, CategoryName, CategoryDisplayName, CategoryLevel, CategoryOrder, CategoryParentID, CategoryIDPath, CategoryIconPath, " + levelColumn; if (String.IsNullOrEmpty(JavaScriptHandler)) { treeElem.SelectedNodeTemplate = "<span id=\"node_##NODECODENAME##\" name=\"treeNode\" class=\"ContentTreeItem ContentTreeSelectedItem\" onclick=\"SelectNode('##NODECODENAME##');\">##ICON##<span class=\"Name\">##NODECUSTOMNAME##</span></span>"; treeElem.NodeTemplate = "<span id=\"node_##NODECODENAME##\" name=\"treeNode\" class=\"ContentTreeItem\" onclick=\"SelectNode('##NODECODENAME##');\">##ICON##<span class=\"Name\">##NODECUSTOMNAME##</span></span>"; } else { treeElem.SelectedNodeTemplate = "<span id=\"node_##NODECODENAME##\" name=\"treeNode\" class=\"ContentTreeItem ContentTreeSelectedItem\" onclick=\"SelectNode('##NODECODENAME##'); if (" + JavaScriptHandler + ") { " + JavaScriptHandler + "('##NODECODENAME##',##NODEID##, ##SITEID##, ##PARENTID##); }\">##ICON##<span class=\"Name\">##NODECUSTOMNAME##</span></span>"; treeElem.NodeTemplate = "<span id=\"node_##NODECODENAME##\" name=\"treeNode\" class=\"ContentTreeItem\" onclick=\"SelectNode('##NODECODENAME##'); if (" + JavaScriptHandler + ") { " + JavaScriptHandler + "('##NODECODENAME##',##NODEID##, ##SITEID##, ##PARENTID##); }\">##ICON##<span class=\"Name\">##NODECUSTOMNAME##</span></span>"; } treeElem.UsePostBack = false; treeElem.ProviderObject = provider; treeElem.ExpandPath = RootCategory.CategoryIDPath; treeElem.OnGetImage += treeElem_OnGetImage; treeElem.OnNodeCreated += treeElem_OnNodeCreated; // Create root node string rootName = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(String.IsNullOrEmpty(RootCategory.CategoryDisplayName) ? RootCategory.CategoryName : RootCategory.CategoryDisplayName)); string rootIcon = "<img src=\"" + URLHelper.ResolveUrl(GetImageUrl("/General/DefaultRoot.png")) + "\" style=\"border:none;height:10px;width:1px;\" />"; string rootText = ""; if (!RootIsClickable) { rootText = treeElem.ReplaceMacros("<span id=\"node_##NODECODENAME##\" name=\"treeNode\" class=\"ContentTreeItem ContentTreeSelectedItem\">##ICON##<span class=\"Name\">##NODECUSTOMNAME##</span></span>", RootCategory.CategoryID, RootCategory.CategoryChildCount, HTMLHelper.HTMLEncode(rootName), rootIcon, RootCategory.CategoryParentID, null, null); } else { rootText = treeElem.ReplaceMacros(treeElem.SelectedNodeTemplate, RootCategory.CategoryID, RootCategory.CategoryChildCount, HTMLHelper.HTMLEncode(rootName), rootIcon, RootCategory.CategoryParentID, null, null); } rootText = rootText.Replace("##NODECUSTOMNAME##", HTMLHelper.HTMLEncode(rootName)); rootText = rootText.Replace("##NODECODENAME##", HTMLHelper.HTMLEncode(RootCategory.CategoryName)); rootText = rootText.Replace("##SITEID##", mSiteId.ToString()); rootText = rootText.Replace("##PARENTID##", RootCategory.CategoryParentID.ToString()); treeElem.SetRoot(rootText, RootCategory.CategoryID.ToString(), ResolveUrl(RootCategory.CategoryIconPath), URLHelper.Url + "#", null); currentUser = CMSContext.CurrentUser; } if (!RequestHelper.IsPostBack()) { treeElem.ReloadData(); } }
/// <summary> /// Displays the report /// </summary> /// <param name="reload">If true display reload control is reloaded</param> private void DisplayReport(bool reload) { ucGraphType.ProcessChartSelectors(false); // Prepare report parameters DataTable dtp = new DataTable(); dtp.Columns.Add("FromDate", typeof(DateTime)); dtp.Columns.Add("ToDate", typeof(DateTime)); dtp.Columns.Add("CodeName", typeof(string)); dtp.Columns.Add("MVTestName", typeof(string)); dtp.Columns.Add("ConversionName", typeof(string)); dtp.Columns.Add("CombinationName", typeof(string)); object[] parameters = new object[6]; parameters[0] = ucGraphType.From; parameters[1] = ucGraphType.To; parameters[2] = ""; parameters[3] = ValidationHelper.GetString(ucMVTests.Value, String.Empty); // Conversion String conversion = ValidationHelper.GetString(ucConversions.Value, String.Empty); if (conversion == ucConversions.AllRecordValue) { conversion = String.Empty; } parameters[4] = ValidationHelper.GetString(conversion, String.Empty); // Combination String combination = ValidationHelper.GetString(usCombination.Value, String.Empty); if (combination == usCombination.AllRecordValue) { combination = String.Empty; } parameters[5] = ValidationHelper.GetString(combination, String.Empty); dtp.Rows.Add(parameters); dtp.AcceptChanges(); string reportName = ucGraphType.GetReportName(QueryHelper.GetString("reportCodeName", String.Empty)); // Hide show selectors by report name if (reportName.Contains("mvtestconversionsbycombinations")) { pnlConversion.Visible = false; } else { pnlCultures.Visible = false; pnlCombination.Visible = false; } // Load conversion by mvt code name if (pnlConversion.Visible) { ucConversions.MVTestName = ValidationHelper.GetString(ucMVTests.Value, String.Empty); ucConversions.PostbackOnDropDownChange = true; ucConversions.ReloadData(true); } // Load combination by mvt name if (pnlCombination.Visible) { string name = ValidationHelper.GetString(ucMVTests.Value, String.Empty); if ((name != String.Empty) && (name != ucMVTests.AllRecordValue)) { string cultureWhere = String.Empty; string siteName = CMSContext.CurrentSiteName; MVTestInfo mvt = MVTestInfoProvider.GetMVTestInfo(name, siteName); if (mvt != null) { string culture = ValidationHelper.GetString(usCulture.Value, String.Empty); if ((culture != String.Empty) && (culture != usCulture.AllRecordValue)) { cultureWhere = " AND DocumentCulture = '" + culture.Replace("'", "''") + "'"; } // Get the used page template column string colName = "DocumentPageTemplateID"; PageInfo pi = PageInfoProvider.GetPageInfo(siteName, mvt.MVTestPage, culture, null, SiteInfoProvider.CombineWithDefaultCulture(siteName)); if (pi != null) { colName = pi.GetUsedPageTemplateIdColumn(); } // Prepare where condition string where = String.Format("MVTCombinationPageTemplateID IN (SELECT {0} FROM View_CMS_Tree_Joined WHERE NodeSiteID = {1} AND NodeAliasPath ='{2}'{3})", colName, CMSContext.CurrentSiteID, mvt.MVTestPage, cultureWhere); usCombination.WhereCondition = SqlHelperClass.AddWhereCondition(usCombination.WhereCondition, where); usCombination.ReloadData(true); } } } // Set report ucDisplayReport.ReportName = reportName; if (!ucDisplayReport.IsReportLoaded()) { ShowError(String.Format(GetString("Analytics_Report.ReportDoesnotExist"), reportName)); } else { ucDisplayReport.LoadFormParameters = false; ucDisplayReport.DisplayFilter = false; ucDisplayReport.ReportParameters = dtp.Rows[0]; ucDisplayReport.GraphImageWidth = 100; ucDisplayReport.IgnoreWasInit = true; ucDisplayReport.UseExternalReload = true; ucDisplayReport.UseProgressIndicator = true; ucDisplayReport.SelectedInterval = HitsIntervalEnumFunctions.HitsConversionToString(ucGraphType.SelectedInterval); // Reload data only if parameter is set if (reload) { ucDisplayReport.ReloadData(true); } } }
TreeNode menuElem_OnNodeCreated(UIElementInfo uiElement, TreeNode defaultNode) { String elementName = uiElement.ElementName.ToLower(); // Remove Optimalization node when module OnlineMarketing not present if (elementName == "optimalization") { if (!ModuleEntry.IsModuleLoaded(ModuleEntry.ONLINEMARKETING)) { return(null); } } // Select first intem under node if (!firstElementSelected) { // Resolve hash string url = URLHelper.EnsureHashToQueryParameters(uiElement.ElementTargetURL); // Is a page node (with page url) if (url != "@") { firstElementSelected = true; SelectItem(uiElement.ElementName, url); } // Is a category node (without page url) else { // Try to display a child element if (uiElement.ElementChildCount > 0) { defaultNode.Expanded = true; } } } // Preselect node if (uiElement.ElementName.ToLower() == this.selectedNode.ToLower()) { this.SelectItem(uiElement.ElementName, URLHelper.EnsureHashToQueryParameters(uiElement.ElementTargetURL)); } String imagesUrl = "CMSModules/CMS_WebAnalytics/"; if (uiElement != null) { if (!IsToolsUIElementAvailable(uiElement)) { return(null); } } // Add all custom reports if (elementName == "custom") { customWhereCondition = SqlHelperClass.AddWhereCondition(customWhereCondition, " StatisticsSiteID = " + CMSContext.CurrentSiteID); DataSet ds = StatisticsInfoProvider.GetCodeNames(customWhereCondition, "StatisticsCode ASC", 0, "StatisticsCode"); // If no custom reports found - hide Custom Reports node if (DataHelper.DataSourceIsEmpty(ds)) { return(null); } foreach (DataRow dr in ds.Tables[0].Rows) { TreeNode childNode = new TreeNode(); string codeName = ValidationHelper.GetString(dr["StatisticsCode"], String.Empty).ToLower(); string name = GetString("analytics_codename." + codeName); string dataCodeName = GetDataCodeName(codeName); string reportCodeName = GetReportCodeNames(codeName); string reportUrl = "Analytics_Report.aspx?statCodeName=" + codeName + "&dataCodeName=" + dataCodeName + "&reportCodeName=" + reportCodeName + "&isCustom=1"; childNode.Text = "<span id=\"node_" + codeName + "\" class=\"ContentTreeItem\" name=\"treeNode\" onclick=\"SelectNode('" + codeName + "');parent.frames['analyticsDefault'].location.href = '" + reportUrl + "' ; \"><span class=\"Name\">" + name + "</span></span>"; childNode.NavigateUrl = "~/CMSModules/WebAnalytics/Tools/Analytics_Statistics.aspx#"; // Icon String imgPath = GetImageUrl(imagesUrl + codeName.Replace(".", "_") + ".png"); if (FileHelper.FileExists(imgPath)) { childNode.ImageUrl = imgPath; } else { childNode.ImageUrl = GetImageUrl(imagesUrl + "statistics.png"); } defaultNode.ChildNodes.Add(childNode); } } return(defaultNode); }
/// <summary> /// Returns DataSet according to filter settings. /// </summary> private DataSet GetData() { string filterWhere = null; string filterText = txtFilter.Text.Trim(); // Filter by culture name if (!String.IsNullOrEmpty(filterText)) { filterWhere = "UICultureName LIKE '%" + SqlHelperClass.GetSafeQueryString(filterText, false) + "%'"; } // Filter by site cultures if (chkSiteCultures.Checked) { filterWhere = SqlHelperClass.AddWhereCondition(filterWhere, "UICultureCode IN (SELECT CultureCode FROM CMS_Culture WHERE CultureID IN (SELECT CultureID FROM CMS_SiteCulture WHERE SiteID = " + CMSContext.CurrentSiteID + "))"); } // Filter by string key filterWhere = SqlHelperClass.AddWhereCondition("(StringID = " + hdnID.Value + ")", filterWhere); // Get translated strings DataSet result = ConnectionHelper.ExecuteQuery("cms.resourcestring.selecttranslated", null, filterWhere, null, -1, "UICultureName, UICultureCode, TranslationText"); DataSet missingCultures = null; string existingTranslations = TextHelper.Join("', '", SqlHelperClass.GetStringValues(result.Tables[0], "UICultureCode")); existingTranslations = "'" + existingTranslations + "'"; // Add missing site cultures' translations if (chkSiteCultures.Checked) { filterWhere = "UICultureCode IN (SELECT CultureCode FROM CMS_Culture WHERE CultureID IN (SELECT CultureID FROM CMS_SiteCulture WHERE SiteID = " + CMSContext.CurrentSiteID + ")) AND UICultureCode NOT IN (" + existingTranslations + ")"; } // Add all missing cultures' tranlsations else { filterWhere = "UICultureCode NOT IN (" + existingTranslations + ")"; } // Add filter from header if (!String.IsNullOrEmpty(filterText)) { filterWhere = SqlHelperClass.AddWhereCondition(filterWhere, "UICultureName LIKE '%" + SqlHelperClass.GetSafeQueryString(filterText, false) + "%'"); } // Get missing translations missingCultures = ConnectionHelper.ExecuteQuery("cms.uiculture.selectall", null, filterWhere, null, -1, "UICultureName, UICultureCode"); // Add missing translations to result if (!DataHelper.DataSourceIsEmpty(missingCultures)) { foreach (DataRow dr in missingCultures.Tables[0].Rows) { result.Tables[0].Rows.Add(dr[0], dr[1], null); } } // Sort and bind dataset result.Tables[0].DefaultView.Sort = "UICultureName"; return(result); }
/// <summary> /// Returns where condition for variation selector. /// </summary> private string GetWhereCondition() { string testName = ValidationHelper.GetString(ucABTests.Value, String.Empty); return(String.Format("ABVariantTestID IN (SELECT ABTestID FROM OM_ABTest WHERE ABTestName = N'{0}' AND ABTestSiteID = {1})", SqlHelperClass.GetSafeQueryString(testName, false), CMSContext.CurrentSiteID)); }
protected void Page_Load(object sender, EventArgs e) { if (!QueryHelper.ValidateHash("hash") || Parameters == null) { StopProcessing = true; return; } CurrentMaster.Title.TitleText = GetString("om.contactrole.select"); CurrentMaster.Title.TitleImage = GetImageUrl("Objects/OM_ContactRole/object.png"); Page.Title = CurrentMaster.Title.TitleText; // Check if the dialog was opened from mass actions isMassAction = Parameters.ContainsKey("ismassaction"); if (isMassAction) { siteId = ValidationHelper.GetInteger(Parameters["siteid"], 0); } else { int accountContactId = ValidationHelper.GetInteger(Parameters["accountcontactid"], 0); aci = AccountContactInfoProvider.GetAccountContactInfo(accountContactId); if (aci != null) { AccountInfo ai = AccountInfoProvider.GetAccountInfo(aci.AccountID); if (ai != null) { siteId = ai.AccountSiteID; } } } // Show all global configuration to authorized users .. bool allowGlobal = ConfigurationHelper.AuthorizedReadConfiguration(UniSelector.US_GLOBAL_RECORD, false); // .. but just in SiteManager - fake it in CMSDesk so that even Global Admin sees user configuration // as Site Admins (depending on settings). bool isSiteManager = ValidationHelper.GetBoolean(Parameters["issitemanager"], false); allowGlobal &= (isSiteManager || SettingsKeyProvider.GetBoolValue(SiteInfoProvider.GetSiteName(siteId) + ".cmscmglobalconfiguration")); bool allowSite; if (siteId > 0) { allowSite = ConfigurationHelper.AuthorizedReadConfiguration(siteId, false); } else { allowSite = ConfigurationHelper.AuthorizedReadConfiguration(CMSContext.CurrentSiteID, false); } // Check read permission if ((siteId > 0) && !allowSite && !allowGlobal) { RedirectToAccessDenied("cms.contactmanagement", "ReadConfiguration"); return; } else if ((siteId == 0) && !allowGlobal) { RedirectToAccessDenied("cms.contactmanagement", "ReadGlobalConfiguration"); return; } if (siteId > 0) { if (allowSite) { gridElem.WhereCondition = "ContactRoleSiteID = " + siteId; } // Check if global config is allowed for the site if (allowGlobal) { // Add contact roles from global configuration gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, "ContactRoleSiteID IS NULL", "OR"); } } else if ((siteId == 0) && allowGlobal) { gridElem.WhereCondition = "ContactRoleSiteID IS NULL"; } gridElem.OnExternalDataBound += gridElem_OnExternalDataBound; gridElem.Pager.DefaultPageSize = 10; // Display 'Reset' button when 'none' role is allowed if (ValidationHelper.GetBoolean(Parameters["allownone"], false)) { btnReset.Visible = true; btnReset.Click += btn_Click; btnReset.CommandArgument = "0"; } }
protected void Page_Load(object sender, EventArgs e) { // Register main CMS script file ScriptHelper.RegisterCMS(this); // Fix messages position MessagesPlaceHolder.WrapperControlClientID = pnlContent.ClientID; if (QueryHelper.ValidateHash("hash") && (Parameters != null)) { // Initialize current user currentUser = CMSContext.CurrentUser; // Check permissions if (!currentUser.IsGlobalAdministrator && !currentUser.IsAuthorizedPerResource("CMS.Content", "manageworkflow")) { RedirectToAccessDenied("CMS.Content", "manageworkflow"); } // Set current UI culture currentCulture = CultureHelper.PreferredUICulture; // Initialize current site currentSiteName = CMSContext.CurrentSiteName; currentSiteId = CMSContext.CurrentSiteID; // Initialize events ctlAsync.OnFinished += ctlAsync_OnFinished; ctlAsync.OnError += ctlAsync_OnError; ctlAsync.OnRequestLog += ctlAsync_OnRequestLog; ctlAsync.OnCancel += ctlAsync_OnCancel; if (!IsCallback) { DataSet allDocs = null; TreeProvider tree = new TreeProvider(currentUser); // Current Node ID to delete string parentAliasPath = ValidationHelper.GetString(Parameters["parentaliaspath"], string.Empty); if (string.IsNullOrEmpty(parentAliasPath)) { // Get IDs of nodes string nodeIdsString = ValidationHelper.GetString(Parameters["nodeids"], string.Empty); string[] nodeIdsArr = nodeIdsString.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); foreach (string nodeId in nodeIdsArr) { int id = ValidationHelper.GetInteger(nodeId, 0); if (id != 0) { nodeIds.Add(id); } } } else { string where = "ClassName <> 'CMS.Root'"; if (!string.IsNullOrEmpty(WhereCondition)) { where = SqlHelperClass.AddWhereCondition(where, WhereCondition); } string columns = SqlHelperClass.MergeColumns(TreeProvider.SELECTNODES_REQUIRED_COLUMNS, "NodeParentID, DocumentName,DocumentCheckedOutByUserID"); allDocs = tree.SelectNodes(currentSiteName, parentAliasPath.TrimEnd('/') + "/%", TreeProvider.ALL_CULTURES, true, null, where, "DocumentName", 1, false, 0, columns); if (!DataHelper.DataSourceIsEmpty(allDocs)) { foreach (DataRow row in allDocs.Tables[0].Rows) { nodeIds.Add(ValidationHelper.GetInteger(row["NodeID"], 0)); } } } // Initialize strings based on current action switch (CurrentAction) { case WorkflowAction.Archive: lblQuestion.ResourceString = "content.archivequestion"; chkAllCultures.ResourceString = "content.archiveallcultures"; chkUnderlying.ResourceString = "content.archiveunderlying"; canceledString = GetString("content.archivecanceled"); // Setup title of log titleElemAsync.TitleText = GetString("content.archivingdocuments"); titleElemAsync.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/archive.png"); // Setup page title text and image CurrentMaster.Title.TitleText = GetString("Content.ArchiveTitle"); CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/archive.png"); break; case WorkflowAction.Publish: lblQuestion.ResourceString = "content.publishquestion"; chkAllCultures.ResourceString = "content.publishallcultures"; chkUnderlying.ResourceString = "content.publishunderlying"; canceledString = GetString("content.publishcanceled"); // Setup title of log titleElemAsync.TitleText = GetString("content.publishingdocuments"); titleElemAsync.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/publish.png"); // Setup page title text and image CurrentMaster.Title.TitleText = GetString("Content.PublishTitle"); CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/publish.png"); break; } if (nodeIds.Count == 0) { // Hide if no node was specified pnlContent.Visible = false; return; } btnCancel.Attributes.Add("onclick", ctlAsync.GetCancelScript(true) + "return false;"); // Register the dialog script ScriptHelper.RegisterDialogScript(this); // Set visibility of panels pnlContent.Visible = true; pnlLog.Visible = false; // Set all cultures checkbox DataSet culturesDS = CultureInfoProvider.GetSiteCultures(currentSiteName); if ((DataHelper.DataSourceIsEmpty(culturesDS)) || (culturesDS.Tables[0].Rows.Count <= 1)) { chkAllCultures.Checked = true; plcAllCultures.Visible = false; } if (nodeIds.Count > 0) { pnlDocList.Visible = true; // Create where condition string where = SqlHelperClass.GetWhereCondition("NodeID", nodeIds.ToArray()); string columns = SqlHelperClass.MergeColumns(TreeProvider.SELECTNODES_REQUIRED_COLUMNS, "NodeParentID, DocumentName,DocumentCheckedOutByUserID"); // Select nodes DataSet ds = allDocs ?? tree.SelectNodes(currentSiteName, "/%", TreeProvider.ALL_CULTURES, true, null, where, "DocumentName", TreeProvider.ALL_LEVELS, false, 0, columns); // Enumerate selected documents if (!DataHelper.DataSourceIsEmpty(ds)) { cancelNodeId = ValidationHelper.GetInteger(DataHelper.GetDataRowValue(ds.Tables[0].Rows[0], "NodeParentID"), 0); foreach (DataRow dr in ds.Tables[0].Rows) { AddToList(dr); } // Display enumeration of documents foreach (KeyValuePair <int, string> line in list) { lblDocuments.Text += line.Value; } } } } // Set title for dialog mode string imgUrl = "CMSModules/CMS_Content/Dialogs/publish.png"; string title = GetString("general.publish"); if (CurrentAction == WorkflowAction.Archive) { imgUrl = "CMSModules/CMS_Content/Dialogs/archive.png"; title = GetString("general.archive"); } SetTitle(imgUrl, title, null, null); } else { pnlPublish.Visible = false; ShowError(GetString("dialogs.badhashtext")); } }
protected void chkCssStyle_CheckedChanged(object sender, EventArgs e) { if (chkCssStyle.Checked) { // Set stylesheet to stylesheet selector ctrlSiteSelectStyleSheet.CurrentDropDown.Enabled = false; ctrlSiteSelectStyleSheet.ButtonNew.Enabled = false; string value = PageInfoProvider.GetParentProperty(CMSContext.CurrentSite.SiteID, node.NodeAliasPath, "(DocumentStylesheetID <> -1 OR DocumentStylesheetID IS NULL) AND DocumentCulture = N'" + SqlHelperClass.GetSafeQueryString(node.DocumentCulture, false) + "'", "DocumentStylesheetID"); if (String.IsNullOrEmpty(value)) { // If default site stylesheet not exist edit is set to -1 - disabled if (CMSContext.CurrentSiteStylesheet != null) { ctrlSiteSelectStyleSheet.CurrentDropDown.SelectedValue = "default"; } else { ctrlSiteSelectStyleSheet.CurrentDropDown.SelectedValue = "-1"; } } else { try { ctrlSiteSelectStyleSheet.CurrentDropDown.SelectedValue = value; } catch { } } } else { ctrlSiteSelectStyleSheet.CurrentDropDown.Enabled = true; ctrlSiteSelectStyleSheet.ButtonNew.Enabled = true; } }
/// <summary> /// Reloads the data in the selector. /// </summary> public void ReloadData() { bool authorizedSite = ContactGroupHelper.AuthorizedReadContactGroup(SiteID, false); bool authorizedGlobal = ContactGroupHelper.AuthorizedReadContactGroup(UniSelector.US_GLOBAL_RECORD, false); // Site objects if (ObjectsRange == 0) { if (authorizedSite) { uniSelector.WhereCondition = SqlHelperClass.AddWhereCondition(WhereCondition, "(ContactGroupSiteID = " + SiteID + ")"); } else { uniSelector.WhereCondition = "(1=0)"; } } // Global objects else if (ObjectsRange == UniSelector.US_GLOBAL_RECORD) { if (authorizedGlobal) { uniSelector.WhereCondition = SqlHelperClass.AddWhereCondition(WhereCondition, "(ContactGroupSiteID IS NULL)"); } else { uniSelector.WhereCondition = "(1=0)"; } } // Global or site objects else if (ObjectsRange == UniSelector.US_GLOBAL_OR_SITE_RECORD) { if (authorizedSite && authorizedGlobal) { uniSelector.WhereCondition = "(ContactGroupSiteID IS NULL OR ContactGroupSiteID = " + SiteID + ")"; uniSelector.AddGlobalObjectSuffix = true; } else if (authorizedGlobal) { uniSelector.WhereCondition = "ContactGroupSiteID IS NULL"; } else if (authorizedSite) { uniSelector.WhereCondition = "ContactGroupSiteID = " + SiteID; } else { uniSelector.WhereCondition = "(1=0)"; } } // Display all objects else if ((ObjectsRange == UniSelector.US_ALL_RECORDS) && CMSContext.CurrentUser.UserSiteManagerAdmin) { uniSelector.WhereCondition = "(ContactGroupSiteID IS NULL OR ContactGroupSiteID > 0)"; uniSelector.AddGlobalObjectSuffix = true; } // Not enough permissions else { uniSelector.WhereCondition = "(1=0)"; } // Initialize selector uniSelector.DialogLink.CssClass = "MenuItemEdit Pad"; uniSelector.IsLiveSite = false; uniSelector.ButtonImage = GetImageUrl("/Objects/OM_ContactGroup/add.png"); uniSelector.Reload(true); }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing srcUsers.StopProcessing = true; } else { TreeNode node = null; TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); // Check if path is set if (String.IsNullOrEmpty(Path)) { TreeNode curDoc = CMSContext.CurrentDocument; // Check if current document is department if ((curDoc != null) && (curDoc.NodeClassName.ToLowerCSafe() == DEPARTMENT_CLASS_NAME)) { node = CMSContext.CurrentDocument; } } else { // Obtain document from specified path node = tree.SelectSingleNode(SiteName, Path, CMSContext.PreferredCultureCode, true, DEPARTMENT_CLASS_NAME, false, false, false); } AclProvider aclProv = new AclProvider(tree); // If department document exists and has own ACL continue with initializing controls if ((node != null) && aclProv.HasOwnACL(node)) { // Get users and roles with read permission for department document int aclId = ValidationHelper.GetInteger(node.GetValue("NodeACLID"), 0); DataSet dsRoles = aclProv.GetAllowedRoles(aclId, NodePermissionsEnum.Read, "RoleID"); DataSet dsUsers = aclProv.GetAllowedUsers(aclId, NodePermissionsEnum.Read, "UserID"); string where = null; // Process users dataset to where condition if (!DataHelper.DataSourceIsEmpty(dsUsers)) { // Get allowed users ids IList <string> users = SystemDataHelper.GetStringValues(dsUsers.Tables[0], "UserID"); string userIds = TextHelper.Join(", ", users); // Populate where condition with user condition where = SqlHelperClass.AddWhereCondition("UserID IN (" + userIds + ")", where); } // Process roles dataset to where condition if (!DataHelper.DataSourceIsEmpty(dsRoles)) { // Get allowed roles ids IList <string> roles = SystemDataHelper.GetStringValues(dsRoles.Tables[0], "RoleID"); string roleIds = TextHelper.Join(", ", roles); // Populate where condition with role condition where = SqlHelperClass.AddWhereCondition("UserID IN (SELECT UserID FROM View_CMS_UserRole_MembershipRole_ValidOnly_Joined WHERE RoleID IN (" + roleIds + "))", where, "OR"); } if (!String.IsNullOrEmpty(where)) { // Check if exist where condition and add it to current where condition where = SqlHelperClass.AddWhereCondition(WhereCondition, where); // Set datasource properties srcUsers.WhereCondition = where; srcUsers.OrderBy = OrderBy; srcUsers.TopN = SelectTopN; srcUsers.FilterName = ValidationHelper.GetString(GetValue("WebPartControlID"), ClientID); srcUsers.SourceFilterName = FilterName; srcUsers.SiteName = SiteName; srcUsers.CacheItemName = CacheItemName; srcUsers.CacheDependencies = CacheDependencies; srcUsers.CacheMinutes = CacheMinutes; srcUsers.SelectOnlyApproved = SelectOnlyApproved; srcUsers.SelectHidden = SelectHidden; srcUsers.SelectedColumns = Columns; } else { srcUsers.StopProcessing = true; } } else { srcUsers.StopProcessing = true; } } }
private void ReloadData() { if (node != null) { // Check read permissions if (CMSContext.CurrentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Read) == AuthorizationResultEnum.Denied) { RedirectToAccessDenied(String.Format(GetString("cmsdesk.notauthorizedtoreaddocument"), node.NodeAliasPath)); } else { // Log activities checkboxes if (!RequestHelper.IsPostBack()) { bool?logVisit = node.DocumentLogVisitActivity; chkLogPageVisit.Checked = (logVisit == true); chkPageVisitInherit.Checked = (logVisit == null); chkLogPageVisit.Enabled = !chkPageVisitInherit.Checked; if (logVisit == null) { chkPageVisitInherit_CheckedChanged(null, EventArgs.Empty); } } // Show document group owner selector if (ModuleEntry.IsModuleLoaded(ModuleEntry.COMMUNITY) && canEditOwner && LicenseHelper.CheckFeature(URLHelper.GetCurrentDomain(), FeatureEnum.Groups)) { plcOwnerGroup.Controls.Clear(); // Initialize table TableRow rowOwner = new TableRow(); TableCell cellTitle = new TableCell(); TableCell cellSelector = new TableCell(); // Initialize caption LocalizedLabel lblOwnerGroup = new LocalizedLabel(); lblOwnerGroup.EnableViewState = false; lblOwnerGroup.ResourceString = "community.group.documentowner"; lblOwnerGroup.ID = "lblOwnerGroup"; cellTitle.Controls.Add(lblOwnerGroup); // Initialize selector fcDocumentGroupSelector = (FormEngineUserControl)Page.LoadControl("~/CMSAdminControls/UI/Selectors/DocumentGroupSelector.ascx"); fcDocumentGroupSelector.ID = "fcDocumentGroupSelector"; fcDocumentGroupSelector.StopProcessing = this.pnlUIOwner.IsHidden; cellSelector.Controls.Add(fcDocumentGroupSelector); fcDocumentGroupSelector.Value = ValidationHelper.GetInteger(node.GetValue("NodeGroupID"), 0); fcDocumentGroupSelector.SetValue("siteid", CMSContext.CurrentSiteID); fcDocumentGroupSelector.SetValue("nodeid", nodeId); // Add controls to containers rowOwner.Cells.Add(cellTitle); rowOwner.Cells.Add(cellSelector); plcOwnerGroup.Controls.Add(rowOwner); plcOwnerGroup.Visible = true; } // Check modify permissions if (CMSContext.CurrentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied) { // disable form editing DisableFormEditing(); // show access denied message lblInfo.Text = String.Format(GetString("cmsdesk.notauthorizedtoeditdocument"), node.NodeAliasPath); lblInfo.Visible = true; } // Show owner editing only when authorized to change the permissions if (canEditOwner) { lblOwner.Visible = false; usrOwner.Visible = true; usrOwner.SetValue("AdditionalUsers", new int[] { node.NodeOwner }); } else { usrOwner.Visible = false; } if (!RequestHelper.IsPostBack()) { if (canEditOwner) { usrOwner.Value = node.GetValue("NodeOwner"); } // Search chkExcludeFromSearch.Checked = node.DocumentSearchExcluded; } // Load the data lblName.Text = HttpUtility.HtmlEncode(node.DocumentName); lblNamePath.Text = HttpUtility.HtmlEncode(Convert.ToString(node.GetValue("DocumentNamePath"))); lblAliasPath.Text = Convert.ToString(node.NodeAliasPath); string typeName = DataClassInfoProvider.GetDataClass(node.NodeClassName).ClassDisplayName; lblType.Text = HttpUtility.HtmlEncode(ResHelper.LocalizeString(typeName)); lblNodeID.Text = Convert.ToString(node.NodeID); // Modifier SetUserLabel(lblLastModifiedBy, "DocumentModifiedByUserId"); // Get modified time TimeZoneInfo usedTimeZone = null; DateTime lastModified = ValidationHelper.GetDateTime(node.GetValue("DocumentModifiedWhen"), DateTimeHelper.ZERO_TIME); lblLastModified.Text = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(lastModified, CMSContext.CurrentUser, CMSContext.CurrentSite, out usedTimeZone); ScriptHelper.AppendTooltip(lblLastModified, TimeZoneHelper.GetGMTLongStringOffset(usedTimeZone), "help"); if (!canEditOwner) { // Owner SetUserLabel(lblOwner, "NodeOwner"); } // Creator SetUserLabel(lblCreatedBy, "DocumentCreatedByUserId"); DateTime createdWhen = ValidationHelper.GetDateTime(node.GetValue("DocumentCreatedWhen"), DateTimeHelper.ZERO_TIME); lblCreated.Text = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(createdWhen, CMSContext.CurrentUser, CMSContext.CurrentSite, out usedTimeZone); ScriptHelper.AppendTooltip(lblCreated, TimeZoneHelper.GetGMTLongStringOffset(usedTimeZone), "help"); // URL string liveUrl = node.IsLink ? CMSContext.GetUrl(node.NodeAliasPath, null) : CMSContext.GetUrl(node.NodeAliasPath, node.DocumentUrlPath); lnkLiveURL.Text = ResolveUrl(liveUrl); lnkLiveURL.NavigateUrl = liveUrl; bool isRoot = (node.NodeClassName.ToLower() == "cms.root"); // Preview URL if (!isRoot) { plcPreview.Visible = true; string path = canEdit ? "/CMSModules/CMS_Content/Properties/resetlink.png" : "/CMSModules/CMS_Content/Properties/resetlinkdisabled.png"; btnResetPreviewGuid.ImageUrl = GetImageUrl(path); btnResetPreviewGuid.ToolTip = GetString("GeneralProperties.InvalidatePreviewURL"); btnResetPreviewGuid.ImageAlign = ImageAlign.AbsBottom; btnResetPreviewGuid.Click += new ImageClickEventHandler(btnResetPreviewGuid_Click); btnResetPreviewGuid.OnClientClick = "if(!confirm('" + GetString("GeneralProperties.GeneratePreviewURLConf") + "')){return false;}"; InitPreviewUrl(); } lblGUID.Text = Convert.ToString(node.NodeGUID); lblDocGUID.Text = (node.DocumentGUID == Guid.Empty) ? ResHelper.Dash : node.DocumentGUID.ToString(); lblDocID.Text = Convert.ToString(node.DocumentID); // Culture CultureInfo ci = CultureInfoProvider.GetCultureInfo(node.DocumentCulture); lblCulture.Text = ((ci != null) ? ResHelper.LocalizeString(ci.CultureName) : node.DocumentCulture); lblPublished.Text = (node.IsPublished ? "<span class=\"DocumentPublishedYes\">" + GetString("General.Yes") + "</span>" : "<span class=\"DocumentPublishedNo\">" + GetString("General.No") + "</span>"); if (!RequestHelper.IsPostBack()) { // Init radio buttons for cache settings if (isRoot) { radInherit.Visible = false; chkCssStyle.Visible = false; switch (node.NodeCacheMinutes) { case -1: // Cache is off radNo.Checked = true; radYes.Checked = false; radInherit.Checked = false; txtCacheMinutes.Text = ""; break; case 0: // Cache is off radNo.Checked = true; radYes.Checked = false; radInherit.Checked = false; txtCacheMinutes.Text = ""; break; default: // Cache is enabled radNo.Checked = false; radYes.Checked = true; radInherit.Checked = false; txtCacheMinutes.Text = node.NodeCacheMinutes.ToString(); break; } } else { switch (node.NodeCacheMinutes) { case -1: // Cache setting is inherited radNo.Checked = false; radYes.Checked = false; radInherit.Checked = true; txtCacheMinutes.Text = ""; break; case 0: // Cache is off radNo.Checked = true; radYes.Checked = false; radInherit.Checked = false; txtCacheMinutes.Text = ""; break; default: // Cache is enabled radNo.Checked = false; radYes.Checked = true; radInherit.Checked = false; txtCacheMinutes.Text = node.NodeCacheMinutes.ToString(); break; } } if (!radYes.Checked) { txtCacheMinutes.Enabled = false; } } if (!RequestHelper.IsPostBack()) { if (node.GetValue("DocumentStylesheetID") == null) { // If default site not exist edit is set to -1 - disabled if (CMSContext.CurrentSiteStylesheet != null) { ctrlSiteSelectStyleSheet.Value = "default"; } else { ctrlSiteSelectStyleSheet.Value = -1; } } else { // If stylesheet is inherited from parent document if (ValidationHelper.GetInteger(node.GetValue("DocumentStylesheetID"), 0) == -1) { if (!isRoot) { chkCssStyle.Checked = true; // Get parent stylesheet string value = PageInfoProvider.GetParentProperty(CMSContext.CurrentSite.SiteID, node.NodeAliasPath, "(DocumentStylesheetID <> -1 OR DocumentStylesheetID IS NULL) AND DocumentCulture = N'" + SqlHelperClass.GetSafeQueryString(node.DocumentCulture, false) + "'", "DocumentStylesheetID"); if (String.IsNullOrEmpty(value)) { // If default site stylesheet not exist edit is set to -1 - disabled if (CMSContext.CurrentSiteStylesheet != null) { ctrlSiteSelectStyleSheet.Value = "default"; } else { ctrlSiteSelectStyleSheet.Value = -1; } } else { // Set parent stylesheet to current document ctrlSiteSelectStyleSheet.Value = value; } } } else { ctrlSiteSelectStyleSheet.Value = node.GetValue("DocumentStylesheetID"); } } } // Disable new button if document inherit stylesheet if (!isRoot && chkCssStyle.Checked) { ctrlSiteSelectStyleSheet.Enabled = false; ctrlSiteSelectStyleSheet.ButtonNew.Enabled = false; } // Initialize Rating control RefreshCntRatingResult(); double rating = 0.0f; if (node.DocumentRatings > 0) { rating = node.DocumentRatingValue / node.DocumentRatings; } ratingControl.MaxRating = 10; ratingControl.CurrentRating = rating; ratingControl.Visible = true; ratingControl.Enabled = false; // Initialize Reset button for rating btnResetRating.Text = GetString("general.reset"); btnResetRating.OnClientClick = "if (!confirm(" + ScriptHelper.GetString(GetString("GeneralProperties.ResetRatingConfirmation")) + ")) return false;"; object[] param = new object[1]; param[0] = node.DocumentID; // Check ad-hoc forum counts hasAdHocForum = (ModuleCommands.ForumsGetDocumentForumsCount(node.DocumentID) > 0); // Ad-Hoc message boards check hasAdHocBoard = (ModuleCommands.MessageBoardGetDocumentBoardsCount(node.DocumentID) > 0); plcAdHocForums.Visible = hasAdHocForum; plcAdHocBoards.Visible = hasAdHocBoard; } } else { btnResetRating.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { if (StopProcessing) { // Do nothing return; } gridElem.IsLiveSite = IsLiveSite; gridElem.OnExternalDataBound += gridElem_OnExternalDataBound; gridElem.HideControlForZeroRows = false; currentUserInfo = CMSContext.CurrentUser; // Initialize strings string strDays = GetString("MyDesk.OutdatedDocuments.Days"); string strWeeks = GetString("MyDesk.OutdatedDocuments.Weeks"); string strMonths = GetString("MyDesk.OutdatedDocuments.Months"); string strYears = GetString("MyDesk.OutdatedDocuments.Years"); // Set proper XML for control type switch (ListingType) { case ListingTypeEnum.CheckedOut: gridElem.ZeroRowsText = GetString("mydesk.ui.nochecked"); gridElem.WhereCondition = "View_CMS_Tree_Joined.DocumentCheckedOutByUserID = @UserID"; break; case ListingTypeEnum.MyDocuments: gridElem.ZeroRowsText = GetString("general.nodatafound"); gridElem.WhereCondition = "View_CMS_Tree_Joined.NodeOwner = @UserID"; break; case ListingTypeEnum.RecentDocuments: gridElem.ZeroRowsText = GetString("general.nodatafound"); gridElem.WhereCondition = "((View_CMS_Tree_Joined.DocumentCreatedByUserID = @UserID OR View_CMS_Tree_Joined.DocumentModifiedByUserID = @UserID OR View_CMS_Tree_Joined.DocumentCheckedOutByUserID = @UserID))"; break; case ListingTypeEnum.PendingDocuments: gridElem.ZeroRowsText = GetString("mydesk.ui.nowaitingdocs"); gridElem.WhereCondition = "CMS_WorkflowStep.StepName <> 'edit' AND CMS_WorkflowStep.StepName <> 'published' AND CMS_WorkflowStep.StepName <> 'archived' AND (View_CMS_Tree_Joined.DocumentWorkflowStepID IN ( SELECT StepID FROM CMS_Workflowsteproles LEFT JOIN View_CMS_UserRole_MembershipRole_ValidOnly_Joined ON View_CMS_UserRole_MembershipRole_ValidOnly_Joined.RoleID = CMS_WorkflowStepRoles.RoleID WHERE View_CMS_UserRole_MembershipRole_ValidOnly_Joined.UserID = @UserID ) OR @UserID = -1)"; break; case ListingTypeEnum.OutdatedDocuments: // Initialize controls if (!RequestHelper.IsPostBack()) { // Fill the dropdown list drpFilter.Items.Add(strDays); drpFilter.Items.Add(strWeeks); drpFilter.Items.Add(strMonths); drpFilter.Items.Add(strYears); // Load default value txtFilter.Text = "1"; drpFilter.SelectedValue = strYears; // Bind dropdown lists BindDropDowns(); } gridElem.WhereCondition = "((DocumentCreatedByUserID = @UserID OR DocumentModifiedByUserID = @UserID OR DocumentCheckedOutByUserID = @UserID) AND " + SOURCE_MODIFIEDWHEN + "<=@OlderThan AND " + SOURCE_NODESITEID + "=@SiteID)"; // Add where condition if (!string.IsNullOrEmpty(txtDocumentName.Text)) { gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, GetOutdatedWhereCondition(SOURCE_DOCUMENTNAME, drpDocumentName, txtDocumentName)); } if (!string.IsNullOrEmpty(txtDocumentType.Text)) { gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, GetOutdatedWhereCondition(SOURCE_CLASSDISPLAYNAME, drpDocumentType, txtDocumentType)); } gridElem.ZeroRowsText = GetString("mydesk.ui.nooutdated"); // Show custom filter plcOutdatedFilter.Visible = true; break; case ListingTypeEnum.WorkflowDocuments: break; case ListingTypeEnum.PageTemplateDocuments: gridElem.ZeroRowsText = GetString("Administration-PageTemplate_Header.Documents.nodata"); break; case ListingTypeEnum.CategoryDocuments: gridElem.ZeroRowsText = GetString("Category_Edit.Documents.nodata"); break; case ListingTypeEnum.ProductDocuments: break; case ListingTypeEnum.TagDocuments: gridElem.ZeroRowsText = GetString("taggroup_edit.documents.nodata"); break; case ListingTypeEnum.DocTypeDocuments: gridElem.ZeroRowsText = GetString("DocumentType_Edit_General.Documents.nodata"); break; case ListingTypeEnum.All: gridElem.ZeroRowsText = GetString("mydesk.ui.nodata"); break; } // Page Size if (!RequestHelper.IsPostBack() && !String.IsNullOrEmpty(ItemsPerPage)) { gridElem.Pager.DefaultPageSize = ValidationHelper.GetInteger(ItemsPerPage, -1); } // Order switch (ListingType) { case ListingTypeEnum.WorkflowDocuments: case ListingTypeEnum.OutdatedDocuments: case ListingTypeEnum.PageTemplateDocuments: case ListingTypeEnum.CategoryDocuments: case ListingTypeEnum.TagDocuments: case ListingTypeEnum.ProductDocuments: case ListingTypeEnum.DocTypeDocuments: gridElem.OrderBy = SOURCE_DOCUMENTNAME; break; default: gridElem.OrderBy = OrderBy; break; } if (ListingType == ListingTypeEnum.All) { gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, String.Format("(UserID1 = {0} OR UserID2 = {0} OR UserID3 = {0})", currentUserInfo.UserID)); } // Create query parameters QueryDataParameters parameters = new QueryDataParameters(); if (ListingType == ListingTypeEnum.OutdatedDocuments) { parameters.Add("@SiteID", CMSContext.CurrentSite.SiteID); DateTime olderThan = DateTime.Now; int dateTimeValue = ValidationHelper.GetInteger(txtFilter.Text, 0); if (drpFilter.SelectedValue == strDays) { olderThan = olderThan.AddDays(-dateTimeValue); } else if (drpFilter.SelectedValue == strWeeks) { olderThan = olderThan.AddDays(-dateTimeValue * 7); } else if (drpFilter.SelectedValue == strMonths) { olderThan = olderThan.AddMonths(-dateTimeValue); } else if (drpFilter.SelectedValue == strYears) { olderThan = olderThan.AddYears(-dateTimeValue); } parameters.Add("@OlderThan", olderThan); } // Initialize UserID query parameter int userID = currentUserInfo.UserID; if (ListingType == ListingTypeEnum.PendingDocuments) { if ((currentUserInfo.IsGlobalAdministrator) || (currentUserInfo.IsAuthorizedPerResource("CMS.Content", "manageworkflow"))) { userID = -1; } } parameters.Add("@UserID", userID); // Document Age if (DocumentAge != String.Empty) { string[] ages = DocumentAge.Split(';'); if (ages.Length == 2) { // Add from a to values to temp parameters int from = ValidationHelper.GetInteger(ages[1], 0); int to = ValidationHelper.GetInteger(ages[0], 0); if (from > 0) { gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, SOURCE_MODIFIEDWHEN + " >= @FROM"); parameters.Add("@FROM", DateTime.Now.AddDays((-1) * from)); } if (to > 0) { gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, SOURCE_MODIFIEDWHEN + " <= @TO"); parameters.Add("@TO", DateTime.Now.AddDays((-1) * to)); } } } // Site name if (!String.IsNullOrEmpty(SiteName) && (SiteName != UniGrid.ALL)) { SiteInfo site = SiteInfoProvider.GetSiteInfo(SiteName); if (site != null) { gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, SOURCE_NODESITEID + " = " + site.SiteID); UniGrid.GridColumns.Columns.RemoveAll(c => (c.Source == SOURCE_SITENAME || c.Source == SOURCE_NODESITEID)); } } // Path filter if (Path != String.Empty) { if (ListingType == ListingTypeEnum.All) { gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, SOURCE_DOCUMENTNAMEPATH + " LIKE N'" + CMSContext.ResolveCurrentPath(Path).Replace("'", "''") + "'"); } else { gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, SOURCE_NODEALIASPATH + " LIKE N'" + CMSContext.ResolveCurrentPath(Path).Replace("'", "''") + "'"); } } // Document type filer if (!String.IsNullOrEmpty(DocumentType)) { string[] types = DocumentType.Split(';'); gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, SqlHelperClass.GetWhereCondition <string>(SOURCE_CLASSNAME, types, true)); } // Document name filter if (DocumentName != String.Empty) { gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, SOURCE_DOCUMENTNAME + " LIKE N'%" + SqlHelperClass.GetSafeQueryString(DocumentName, false) + "%'"); } // Site running filter if ((SiteName == UniGrid.ALL) && DisplayOnlyRunningSites) { gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, "SiteName IN (SELECT SiteName FROM CMS_Site WHERE SiteStatus = 'RUNNING')"); } // Set parameters gridElem.QueryParameters = parameters; }
protected void Page_Init(object sender, EventArgs e) { // Initialize UniGrid collections gridElem.GridColumns = new UniGridColumns(); gridElem.GridOptions = new UniGridOptions(); gridElem.GridActions = new UniGridActions(); // Add edit action Action editAction = new Action(); editAction.Name = "Edit"; editAction.ExternalSourceName = EXTERNALSOURCE_EDIT; editAction.Icon = "edit.png"; editAction.Caption = "$contentmenu.edit$"; gridElem.GridActions.Actions.Add(editAction); // Add view action Action viewAction = new Action(); viewAction.Name = "Preview"; viewAction.ExternalSourceName = EXTERNALSOURCE_PREVIEW; viewAction.Icon = "view.png"; viewAction.Caption = "$documents.navigatetodocument$"; gridElem.GridActions.Actions.Add(viewAction); // Add document name column Column documentName = new Column(); documentName.Source = UniGrid.ALL; documentName.Sort = SOURCE_DOCUMENTNAME; documentName.ExternalSourceName = EXTERNALSOURCE_DOCUMENTNAME; documentName.Caption = "$general.documentname$"; documentName.Wrap = false; documentName.Tooltip = new ColumnTooltip(); documentName.Tooltip.Source = UniGrid.ALL; documentName.Tooltip.ExternalSourceName = EXTERNALSOURCE_DOCUMENTNAMETOOLTIP; documentName.Tooltip.Width = "0"; documentName.Tooltip.Encode = false; switch (ListingType) { case ListingTypeEnum.OutdatedDocuments: break; default: documentName.Filter = new ColumnFilter(); documentName.Filter.Type = "text"; documentName.Filter.Source = SOURCE_DOCUMENTNAME; break; } switch (ListingType) { case ListingTypeEnum.All: documentName.Width = "80%"; break; default: documentName.Width = "100%"; break; } // Add filter for specific listing types if ((ListingType == ListingTypeEnum.MyDocuments) || (ListingType == ListingTypeEnum.CheckedOut) || (ListingType == ListingTypeEnum.RecentDocuments) || (ListingType == ListingTypeEnum.PendingDocuments)) { gridElem.GridOptions.DisplayFilter = true; } gridElem.GridColumns.Columns.Add(documentName); // Add listing type (only if combined view) Column listingType = new Column(); listingType.Source = "type"; listingType.ExternalSourceName = "type"; listingType.Sort = "type"; listingType.Wrap = false; listingType.Caption = "$general.listingtype$"; if (ListingType == ListingTypeEnum.All) { gridElem.GridColumns.Columns.Add(listingType); } switch (ListingType) { case ListingTypeEnum.DocTypeDocuments: break; default: // Initialize document class name column Column classDisplayName = new Column(); classDisplayName.Source = SOURCE_CLASSDISPLAYNAME; classDisplayName.ExternalSourceName = EXTERNALSOURCE_CLASSDISPLAYNAME; classDisplayName.MaxLength = 50; classDisplayName.Caption = "$general.documenttype$"; classDisplayName.Wrap = false; classDisplayName.Tooltip = new ColumnTooltip(); classDisplayName.Tooltip.Source = SOURCE_CLASSDISPLAYNAME; classDisplayName.Tooltip.ExternalSourceName = EXTERNALSOURCE_CLASSDISPLAYNAMETOOLTIP; classDisplayName.Tooltip.Width = "0"; switch (ListingType) { case ListingTypeEnum.OutdatedDocuments: break; default: classDisplayName.Filter = new ColumnFilter(); classDisplayName.Filter.Type = "text"; classDisplayName.Filter.Source = SOURCE_CLASSDISPLAYNAME; break; } gridElem.GridColumns.Columns.Add(classDisplayName); break; } // Add timestamp column Column modifiedWhen = new Column(); modifiedWhen.Source = SOURCE_MODIFIEDWHEN; modifiedWhen.ExternalSourceName = EXTERNALSOURCE_MODIFIEDWHEN; modifiedWhen.Wrap = false; modifiedWhen.Tooltip = new ColumnTooltip(); modifiedWhen.Tooltip.ExternalSourceName = EXTERNALSOURCE_MODIFIEDWHENTOOLTIP; switch (ListingType) { case ListingTypeEnum.CheckedOut: modifiedWhen.Caption = "$general.checkouttime$"; break; default: modifiedWhen.Caption = "$general.modified$"; break; } gridElem.GridColumns.Columns.Add(modifiedWhen); // Add column with workflow information Column workflowStep = new Column(); workflowStep.Caption = "$general.workflowstep$"; workflowStep.Wrap = false; switch (ListingType) { case ListingTypeEnum.All: workflowStep.Source = SOURCE_WORKFLOWSTEPID; workflowStep.ExternalSourceName = EXTERNALSOURCE_STEPNAME; break; default: workflowStep.Source = SOURCE_WORKFLOWSTEPDISPLAYNAME; workflowStep.ExternalSourceName = EXTERNALSOURCE_STEPDISPLAYNAME; break; } gridElem.GridColumns.Columns.Add(workflowStep); // Add version information switch (ListingType) { case ListingTypeEnum.WorkflowDocuments: Column versionNumber = new Column(); versionNumber.Source = SOURCE_VERSION; versionNumber.ExternalSourceName = EXTERNALSOURCE_VERSION; versionNumber.Caption = "$general.version$"; versionNumber.Wrap = false; gridElem.GridColumns.Columns.Add(versionNumber); break; } // Add culture column Column culture = new Column(); culture.Source = UniGrid.ALL; culture.ExternalSourceName = EXTERNALSOURCE_CULTURE; culture.Caption = "$general.language$"; culture.Sort = SOURCE_CULTURENAME; culture.Wrap = false; gridElem.GridColumns.Columns.Add(culture); // Add site name column Column siteName = null; switch (ListingType) { default: siteName = new Column(); siteName.Source = SOURCE_SITENAME; siteName.ExternalSourceName = EXTERNALSOURCE_SITENAME; siteName.Caption = "$general.site$"; siteName.Wrap = false; gridElem.GridColumns.Columns.Add(siteName); break; case ListingTypeEnum.All: siteName = new Column(); siteName.Source = SOURCE_NODESITEID; siteName.ExternalSourceName = EXTERNALSOURCE_SITEID; siteName.Caption = "$general.site$"; siteName.Wrap = false; gridElem.GridColumns.Columns.Add(siteName); break; } // Prepare columns to select string baseColumns = SqlHelperClass.MergeColumns(new string[] { SOURCE_CLASSNAME, SOURCE_SITENAME, SOURCE_CLASSDISPLAYNAME, SOURCE_MODIFIEDWHEN, SOURCE_WORKFLOWSTEPDISPLAYNAME, SOURCE_NODEID, SOURCE_DOCUMENTCULTURE, SOURCE_DOCUMENTNAME, SOURCE_DOCUMENTNAMEPATH, SOURCE_NODEALIASPATH, SOURCE_NODELINKEDNODEID, SOURCE_CULTURENAME }); // Set UniGrid options switch (ListingType) { case ListingTypeEnum.PageTemplateDocuments: gridElem.Columns = SqlHelperClass.MergeColumns(new string[] { baseColumns, SOURCE_NODESITEID, "NodeACLID", "NodeOwner" }); gridElem.ObjectType = "cms.documentlist"; break; case ListingTypeEnum.WorkflowDocuments: gridElem.Columns = SqlHelperClass.MergeColumns(new string[] { baseColumns, SELECTION_COLUMN, SOURCE_VERSION }); gridElem.ObjectType = "cms.documentlist"; break; case ListingTypeEnum.All: gridElem.ObjectType = "cms.userdocumentslist"; break; default: gridElem.Columns = baseColumns; gridElem.ObjectType = "cms.documentlist"; break; } switch (ListingType) { case ListingTypeEnum.OutdatedDocuments: case ListingTypeEnum.WorkflowDocuments: break; case ListingTypeEnum.All: gridElem.GridOptions.DisplayFilter = true; break; } switch (ListingType) { case ListingTypeEnum.WorkflowDocuments: gridElem.GridOptions.ShowSelection = true; gridElem.GridOptions.SelectionColumn = SELECTION_COLUMN; break; } }
protected void Page_Load(object sender, EventArgs e) { // Register script for pendingCallbacks repair ScriptHelper.FixPendingCallbacks(Page); // Get site info currentSiteId = CMSContext.CurrentSiteID; currentSiteName = CMSContext.CurrentSiteName; // Initialize current user for the async actions currentUser = CMSContext.CurrentUser; serverId = QueryHelper.GetInteger("serverid", 0); HeaderActions.ActionPerformed += HeaderActions_ActionPerformed; if (RequestHelper.CausedPostback(btnSyncComplete)) { SyncComplete(); } else { if (!RequestHelper.IsCallback()) { int nodeId = QueryHelper.GetInteger("nodeid", 0); aliasPath = "/"; // Get the document node if (nodeId > 0) { TreeProvider tree = new TreeProvider(currentUser); TreeNode node = tree.SelectSingleNode(nodeId, TreeProvider.ALL_CULTURES); if (node != null) { aliasPath = node.NodeAliasPath; } } // Setup title titleElem.TitleText = GetString("Synchronization.Title"); titleElem.TitleImage = GetImageUrl("CMSModules/CMS_Staging/synchronization.png"); ucDisabledModule.SettingsKeys = "CMSStagingLogChanges;CMSStagingLogStagingChanges;"; ucDisabledModule.InfoTexts.Add(GetString("ContentStaging.TaskSeparator") + "<br/>"); ucDisabledModule.InfoTexts.Add(GetString("StagingChanges.NotLogged")); ucDisabledModule.ParentPanel = pnlNotLogged; // Check logging if (!ucDisabledModule.Check()) { plcContent.Visible = false; pnlFooter.Visible = false; return; } // Create header actions HeaderActions.AddAction(new HeaderAction() { Text = GetString("Tasks.SyncCurrent"), ImageUrl = GetImageUrl("CMSModules/CMS_Staging/synccurrent_16.png"), EventName = SYNCHRONIZE_CURRENT }); HeaderActions.AddAction(new HeaderAction() { Text = GetString("Tasks.SyncSubtree"), ImageUrl = GetImageUrl("CMSModules/CMS_Staging/syncsubtree.png"), EventName = SYNCHRONIZE_SUBTREE }); if (!RequestHelper.CausedPostback(HeaderActions, btnSyncSelected, btnSyncAll)) { // Check 'Manage servers' permission if (!currentUser.IsAuthorizedPerResource("cms.staging", "ManageDocumentsTasks")) { RedirectToAccessDenied("cms.staging", "ManageDocumentsTasks"); } // Register the dialog script ScriptHelper.RegisterDialogScript(this); ltlScript.Text += ScriptHelper.GetScript("function ConfirmDeleteTask(taskId) { return confirm(" + ScriptHelper.GetString(GetString("Tasks.ConfirmDelete")) + "); }"); ltlScript.Text += ScriptHelper.GetScript("function CompleteSync(){" + Page.ClientScript.GetPostBackEventReference(btnSyncComplete, null) + "}"); // Initialize grid tasksUniGrid.OnExternalDataBound += tasksUniGrid_OnExternalDataBound; tasksUniGrid.OnAction += tasksUniGrid_OnAction; tasksUniGrid.OnDataReload += tasksUniGrid_OnDataReload; tasksUniGrid.ShowActionsMenu = true; tasksUniGrid.Columns = "TaskID, TaskSiteID, TaskDocumentID, TaskNodeAliasPath, TaskTitle, TaskTime, TaskType, TaskObjectType, TaskObjectID, TaskRunning, (SELECT COUNT(*) FROM Staging_Synchronization WHERE SynchronizationTaskID = TaskID AND SynchronizationErrorMessage IS NOT NULL AND (SynchronizationServerID = @ServerID OR (@ServerID = 0 AND (@TaskSiteID = 0 OR SynchronizationServerID IN (SELECT ServerID FROM Staging_Server WHERE ServerSiteID = @TaskSiteID AND ServerEnabled=1))))) AS FailedCount"; TaskInfo ti = new TaskInfo(); tasksUniGrid.AllColumns = SqlHelperClass.MergeColumns(ti.ColumnNames); // Initialize images viewImage = GetImageUrl("Design/Controls/UniGrid/Actions/View.png"); deleteImage = GetImageUrl("Design/Controls/UniGrid/Actions/Delete.png"); syncImage = GetImageUrl("Design/Controls/UniGrid/Actions/Synchronize.png"); // Initialize tooltips syncTooltip = GetString("general.synchronize"); deleteTooltip = GetString("general.delete"); viewTooltip = GetString("general.view"); plcContent.Visible = true; // Initialize buttons btnCancel.Attributes.Add("onclick", ctlAsync.GetCancelScript(true) + "return false;"); btnCancel.Text = GetString("General.Cancel"); btnDeleteAll.Text = GetString("Tasks.DeleteAll"); btnDeleteSelected.Text = GetString("Tasks.DeleteSelected"); btnSyncAll.Text = GetString("Tasks.SyncAll"); btnSyncSelected.Text = GetString("Tasks.SyncSelected"); btnSyncSelected.OnClientClick = "return !" + tasksUniGrid.GetCheckSelectionScript(); btnDeleteAll.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("Tasks.ConfirmDeleteAll")) + ");"; btnDeleteSelected.OnClientClick = "return confirm(" + ScriptHelper.GetString(GetString("general.confirmdelete")) + ");"; pnlLog.Visible = false; } } } ctlAsync.OnFinished += ctlAsync_OnFinished; ctlAsync.OnError += ctlAsync_OnError; ctlAsync.OnRequestLog += ctlAsync_OnRequestLog; ctlAsync.OnCancel += ctlAsync_OnCancel; }
/// <summary> /// Generates complete filter where condition. /// </summary> private string GenerateWhereCondition() { string whereCond = ""; if (ShowGlobalEventsOnly) { SiteName = "0"; } if (!String.IsNullOrEmpty(Source)) { whereCond = SqlHelperClass.AddWhereCondition(whereCond, "Source = N'" + SqlHelperClass.GetSafeQueryString(Source, false) + "'"); } if (!String.IsNullOrEmpty(EventType)) { whereCond = SqlHelperClass.AddWhereCondition(whereCond, "EventType = N'" + SqlHelperClass.GetSafeQueryString(EventType, false) + "'"); } if (!String.IsNullOrEmpty(EventCode)) { whereCond = SqlHelperClass.AddWhereCondition(whereCond, "EventCode = N'" + SqlHelperClass.GetSafeQueryString(EventCode, false) + "'"); } // Append site condition if siteid given SiteInfo siteObj = null; int siteId = -1; if (SiteName != TreeProvider.ALL_SITES) { siteObj = SiteInfoProvider.GetSiteInfo(SiteName); } // -1: All sites with global events // 0: Global events only // or SiteName if (siteObj == null) { if (ShowGlobalEventsOnly) { siteId = 0; } } else { siteId = siteObj.SiteID; } // create where condition for SiteID if (!String.IsNullOrEmpty(whereCond) && (siteId >= 0)) { whereCond += " AND "; } if (siteId > 0) { whereCond += " (SiteID=" + siteId + ")"; } else if (siteId == 0) { whereCond += "(SiteID IS NULL)"; } return(whereCond); }
protected void Page_Load(object sender, EventArgs e) { // Security test if (!CMSContext.CurrentUser.UserSiteManagerAdmin) { RedirectToAccessDenied(GetString("attach.actiondenied")); } // Add link to external stylesheet CSSHelper.RegisterCSSLink(this, "~/App_Themes/Default/CMSDesk.css"); // Get current resolver resolver = CMSContext.CurrentResolver.CreateContextChild(); DataSet ds = null; DataSet cds = null; // Check init settings bool allWidgets = QueryHelper.GetBoolean("allWidgets", false); bool allWebParts = QueryHelper.GetBoolean("allWebparts", false); // Get webpart (widget) from querystring - only if no allwidget or allwebparts set bool isWebpartInQuery = false; bool isWidgetInQuery = false; String webpartQueryParam = String.Empty; //If not show all widgets or webparts - check if any widget or webpart is present if ((!allWidgets) && (!allWebParts)) { webpartQueryParam = QueryHelper.GetString("webpart", ""); if (!string.IsNullOrEmpty(webpartQueryParam)) { isWebpartInQuery = true; } else { webpartQueryParam = QueryHelper.GetString("widget", ""); if (!string.IsNullOrEmpty(webpartQueryParam)) { isWidgetInQuery = true; } } } // Set development option if is required if (QueryHelper.GetString("details", "0") == "1") { development = true; } // Generate all webparts if (allWebParts) { // Get all webpart categories cds = WebPartCategoryInfoProvider.GetAllCategories(); } // Generate all widgets else if (allWidgets) { // Get all widget categories cds = WidgetCategoryInfoProvider.GetWidgetCategories(String.Empty, String.Empty, 0, String.Empty); } // Generate single webpart else if (isWebpartInQuery) { // Split weparts string[] webparts = webpartQueryParam.Split(';'); if (webparts.Length > 0) { string webpartWhere = SqlHelperClass.GetWhereCondition("WebpartName", webparts); ds = WebPartInfoProvider.GetWebParts(webpartWhere, null); // If any webparts found if (!DataHelper.DataSourceIsEmpty(ds)) { StringBuilder categoryWhere = new StringBuilder(""); foreach (DataRow dr in ds.Tables[0].Rows) { categoryWhere.Append(ValidationHelper.GetString(dr["WebpartCategoryID"], "NULL") + ","); } string ctWhere = "CategoryID IN (" + categoryWhere.ToString().TrimEnd(',') + ")"; cds = WebPartCategoryInfoProvider.GetCategories(ctWhere, null); } } } // Generate single widget else if (isWidgetInQuery) { string[] widgets = webpartQueryParam.Split(';'); if (widgets.Length > 0) { string widgetsWhere = SqlHelperClass.GetWhereCondition("WidgetName", widgets); ds = WidgetInfoProvider.GetWidgets(widgetsWhere, null, 0, String.Empty); } if (!DataHelper.DataSourceIsEmpty(ds)) { StringBuilder categoryWhere = new StringBuilder(""); foreach (DataRow dr in ds.Tables[0].Rows) { categoryWhere.Append(ValidationHelper.GetString(dr["WidgetCategoryID"], "NULL") + ","); } string ctWhere = "WidgetCategoryID IN (" + categoryWhere.ToString().TrimEnd(',') + ")"; cds = WidgetCategoryInfoProvider.GetWidgetCategories(ctWhere, null, 0, String.Empty); } } if (allWidgets || isWidgetInQuery) { documentationTitle = "Kentico CMS Widgets"; Page.Header.Title = "Widgets documentation"; } if (!allWebParts && !allWidgets && !isWebpartInQuery && !isWidgetInQuery) { pnlContent.Visible = false; pnlInfo.Visible = true; } // Check whether at least one category is present if (!DataHelper.DataSourceIsEmpty(cds)) { string namePrefix = ((isWidgetInQuery) || (allWidgets)) ? "Widget" : String.Empty; // Loop through all web part categories foreach (DataRow cdr in cds.Tables[0].Rows) { // Get all webpart in the categories if (allWebParts) { ds = WebPartInfoProvider.GetAllWebParts(Convert.ToInt32(cdr["CategoryId"])); } // Get all widgets in the category else if (allWidgets) { int categoryID = Convert.ToInt32(cdr["WidgetCategoryId"]); ds = WidgetInfoProvider.GetWidgets("WidgetCategoryID = " + categoryID.ToString(), null, 0, null); } // Check whether current category contains at least one webpart if (!DataHelper.DataSourceIsEmpty(ds)) { // Generate category name code menu += "<br /><strong>" + HTMLHelper.HTMLEncode(cdr[namePrefix + "CategoryDisplayName"].ToString()) + "</strong><br /><br />"; // Loop through all web web parts in categories foreach (DataRow dr in ds.Tables[0].Rows) { // Init isImagePresent = false; undocumentedProperties = 0; documentation = 0; // Webpart (Widget) information string itemDisplayName = String.Empty; string itemDescription = String.Empty; string itemDocumentation = String.Empty; string itemType = String.Empty; int itemID = 0; WebPartInfo wpi = null; WidgetInfo wi = null; // Set webpart info if ((isWebpartInQuery) || (allWebParts)) { wpi = new WebPartInfo(dr); if (wpi != null) { itemDisplayName = wpi.WebPartDisplayName; itemDescription = wpi.WebPartDescription; itemDocumentation = wpi.WebPartDocumentation; itemID = wpi.WebPartID; itemType = PortalObjectType.WEBPART; if (wpi.WebPartCategoryID != ValidationHelper.GetInteger(cdr["CategoryId"], 0)) { wpi = null; } } } // Set widget info else if ((isWidgetInQuery) || (allWidgets)) { wi = new WidgetInfo(dr); if (wi != null) { itemDisplayName = wi.WidgetDisplayName; itemDescription = wi.WidgetDescription; itemDocumentation = wi.WidgetDocumentation; itemType = PortalObjectType.WIDGET; itemID = wi.WidgetID; if (wi.WidgetCategoryID != ValidationHelper.GetInteger(cdr["WidgetCategoryId"], 0)) { wi = null; } } } // Check whether web part (widget) exists if ((wpi != null) || (wi != null)) { // Link GUID Guid mguid = Guid.NewGuid(); // Whether description is present in webpart bool isDescription = false; // Image url string wimgurl = GetItemImage(itemID, itemType); // Set description text string descriptionText = itemDescription; // Parent webpart info WebPartInfo pwpi = null; // If webpart look for parent's description and documentation if (wpi != null) { // Get parent description if webpart is inherited if (wpi.WebPartParentID > 0) { pwpi = WebPartInfoProvider.GetWebPartInfo(wpi.WebPartParentID); if (pwpi != null) { if ((descriptionText == null || descriptionText.Trim() == "")) { // Set description from parent descriptionText = pwpi.WebPartDescription; } // Set documentation text from parent if WebPart is inherited if ((wpi.WebPartDocumentation == null) || (wpi.WebPartDocumentation.Trim() == "")) { itemDocumentation = pwpi.WebPartDocumentation; if (!String.IsNullOrEmpty(itemDocumentation)) { documentation = 2; } } } } } // Set description as present if (descriptionText.Trim().Length > 0) { isDescription = true; } // Generate HTML for menu and content menu += " <a href=\"#_" + mguid.ToString() + "\">" + HTMLHelper.HTMLEncode(itemDisplayName) + "</a> "; // Generate webpart header content += "<table style=\"width:100%;\"><tr><td><h1><a name=\"_" + mguid.ToString() + "\">" + HTMLHelper.HTMLEncode(cdr[namePrefix + "CategoryDisplayName"].ToString()) + " > " + HTMLHelper.HTMLEncode(itemDisplayName) + "</a></h1></td><td style=\"text-align:right;\"> <a href=\"#top\" class=\"noprint\">top</a></td></tr></table>"; // Generate WebPart content content += @"<table style=""width: 100%; height: 200px; border: solid 1px #DDDDDD;""> <tr> <td style=""width: 50%; text-align:center; border-right: solid 1px #DDDDDD; vertical-align: middle;margin-left: auto; margin-right:auto; text-align:center;""> <img src=""" + wimgurl + @""" alt=""imageTeaser""> </td> <td style=""width: 50%; vertical-align: center;text-align:center;"">" + HTMLHelper.HTMLEncode(descriptionText) + @" </td> </tr> </table>"; // Properties content content += "<div class=\"DocumentationWebPartsProperties\">"; // Generate content if (wpi != null) { GenerateDocContent(CreateFormInfo(wpi)); } else if (wi != null) { GenerateDocContent(CreateFormInfo(wi)); } // Close content area content += "</div>"; // Generate documentation text content content += "<br /><div style=\"border: solid 1px #dddddd;width: 100%;\">" + DataHelper.GetNotEmpty(HTMLHelper.ResolveUrls(itemDocumentation, null), "<strong>Additional documentation text is not provided.</strong>") + "</div>"; // Set page break tag for print content += "<br /><p style=\"page-break-after: always;width:100%\"> </p><hr class=\"noprint\" />"; // If development is required - highlight missing description, images and doc. text if (development) { // Check image if (!isImagePresent) { menu += "<span style=\"color:Brown;\">image </span>"; } // Check properties if (undocumentedProperties > 0) { menu += "<span style=\"color:Red;\">properties(" + undocumentedProperties + ") </span>"; } // Check properties if (!isDescription) { menu += "<span style=\"color:#37627F;\">description </span>"; } // Check documentation text if (String.IsNullOrEmpty(itemDocumentation)) { documentation = 1; } switch (documentation) { // Display information about missing documentation case 1: menu += "<span style=\"color:Green;\">documentation </span>"; break; // Display information about inherited documentation case 2: menu += "<span style=\"color:Green;\">documentation (inherited) </span>"; break; } } menu += "<br />"; } } } } } ltlContent.Text = menu + "<br /><p style=\"page-break-after: always;width:100%\"> </p><hr class=\"noprint\" />" + content; }
/// <summary> /// Creates child controls. /// </summary> protected override void CreateChildControls() { if (StopProcessing) { return; } drpTemplate.Items.Clear(); // Do not retrieve page templates string whereCond = null; if (!this.ShowTemplates) { whereCond = "ObjectType = 'pagetemplatecategory'"; } // Filter out adhoc category and adhoc templates if (!this.mShowAdHocCategory) { whereCond = SqlHelperClass.AddWhereCondition(whereCond, "(ObjectType != 'pagetemplatecategory' OR CodeName != 'AdHoc') AND (ObjectType != 'pagetemplate' OR ParentID NOT IN (SELECT CategoryID FROM CMS_PageTemplateCategory WHERE CategoryName = 'AdHoc'))"); } ds = ConnectionHelper.ExecuteQuery("cms.pagetemplatecategory.selectallview", null, whereCond, "DisplayName", 0, "ObjectID, DisplayName, ParentID, ObjectType"); if (!DataHelper.DataSourceIsEmpty(ds)) { int counter = 0; // Make special collection for "tree mapping" Dictionary <int, SortedList <string, object[]> > categories = new Dictionary <int, SortedList <string, object[]> >(); // Fill collection from dataset foreach (DataRow dr in ds.Tables[0].Rows) { int parentId = ValidationHelper.GetInteger(dr["ParentID"], 0); int id = ValidationHelper.GetInteger(dr["ObjectID"], 0); string name = ResHelper.LocalizeString(ValidationHelper.GetString(dr["DisplayName"], String.Empty)); string type = ValidationHelper.GetString(dr["ObjectType"], String.Empty); // Skip page template, take only PageTemplateCategory if (type == "pagetemplate") { continue; } SortedList <string, object[]> list; categories.TryGetValue(parentId, out list); // Sub categories list not created yet if (list == null) { list = new SortedList <string, object[]>(); categories.Add(parentId, list); } list.Add(name + "_" + counter, new object[2] { id, name }); counter++; } // Start filling the dropdown from the root(parentId = 0) int level = 0; // Root is not shown, start indentation later if (!this.ShowRoot) { level = -1; } AddSubCategories(categories, 0, level); } }
/// <summary> /// On PreRender. /// </summary> protected override void OnPreRender(EventArgs e) { if (StopProcessing) { return; } if (!ShowWidgetOnlyWebparts) { // Do not display widget only web parts flatElem.WhereCondition = SqlHelperClass.AddWhereCondition(flatElem.WhereCondition, "WebPartType IS NULL OR WebPartType != " + Convert.ToInt32(WebPartTypeEnum.WidgetOnly)); } // Restrict to items in selected category (if not root) if (SelectedCategory != null) { flatElem.WhereCondition = SqlHelperClass.AddWhereCondition(flatElem.WhereCondition, "WebPartCategoryID = " + SelectedCategory.CategoryID + " OR WebPartCategoryID IN (SELECT CategoryID FROM CMS_WebPartCategory WHERE CategoryPath LIKE N'" + SqlHelperClass.GetSafeQueryString(SelectedCategory.CategoryPath, false).TrimEnd('/') + "/%')"); } // Recently used if (TreeSelectedItem.ToLowerCSafe() == "recentlyused") { flatElem.WhereCondition = SqlHelperClass.AddWhereCondition(flatElem.WhereCondition, SqlHelperClass.GetWhereCondition("WebPartName", CMSContext.CurrentUser.UserSettings.UserUsedWebParts.Split(';'))); } // Description area and recently used litCategory.Text = ShowInDescriptionArea(SelectedItem); base.OnPreRender(e); }
/// <summary> /// Loads contact groups of merged contacts into checkboxlist. /// </summary> private void LoadContactGroups() { if (!RequestHelper.IsPostBack()) { StringBuilder idList = new StringBuilder("("); foreach (DataRow dr in mergedAccounts.Tables[0].Rows) { idList.Append(dr["AccountID"] + ","); } // Remove last comma idList.Remove(idList.Length - 1, 1); idList.Append(")"); // Remove site contact groups string addWhere = null; if (parentAccount.AccountSiteID == 0) { addWhere = " AND ContactGroupMemberContactGroupID IN (SELECT ContactGroupID FROM OM_ContactGroup WHERE ContactGroupSiteID IS NULL)"; } string where = "ContactGroupMemberType = 1 AND ContactGroupMemberRelatedID IN " + idList.ToString() + " AND ContactGroupMemberContactGroupID NOT IN (SELECT ContactGroupMemberContactGroupID FROM OM_ContactGroupMember WHERE ContactGroupMemberRelatedID = " + parentAccount.AccountID + " AND ContactGroupMemberType = 1)" + addWhere; // Limit selection of contact groups according to current user's permissions if (!CMSContext.CurrentUser.UserSiteManagerAdmin) { bool readModifySite = ContactGroupHelper.AuthorizedReadContactGroup(parentAccount.AccountSiteID, false) && ContactGroupHelper.AuthorizedModifyContactGroup(parentAccount.AccountSiteID, false); bool readGlobal = ContactGroupHelper.AuthorizedReadContactGroup(UniSelector.US_GLOBAL_RECORD, false) && ContactGroupHelper.AuthorizedModifyContactGroup(UniSelector.US_GLOBAL_RECORD, false); if (!readModifySite && !readGlobal) { tabContactGroups.Visible = false; tabContactGroups.HeaderText = null; } else if (readModifySite && !readGlobal) { where = SqlHelperClass.AddWhereCondition(where, " ContactGroupMemberContactGroupID IN (SELECT ContactGroupID FROM OM_ContactGroup WHERE ContactGroupSiteID = " + CMSContext.CurrentSiteID + ")"); } else if (!readModifySite && readGlobal) { where = SqlHelperClass.AddWhereCondition(where, " ContactGroupMemberContactGroupID IN (SELECT ContactGroupID FROM OM_ContactGroup WHERE ContactGroupSiteID IS NULL)"); } else { where = SqlHelperClass.AddWhereCondition(where, " ContactGroupMemberContactGroupID IN (SELECT ContactGroupID FROM OM_ContactGroup WHERE ContactGroupSiteID IS NULL OR ContactGroupSiteID = " + CMSContext.CurrentSiteID + ")"); } } // Get contact group relations DataSet result = ContactGroupMemberInfoProvider.GetRelationships(where, null, -1, "DISTINCT ContactGroupMemberContactGroupID"); if (!DataHelper.DataSourceIsEmpty(result)) { ListItem contactGroup; ContactGroupInfo cg; foreach (DataRow dr in result.Tables[0].Rows) { contactGroup = new ListItem(); contactGroup.Value = ValidationHelper.GetString(dr["ContactGroupMemberContactGroupID"], "0"); contactGroup.Selected = true; // Fill in checkbox list cg = ContactGroupInfoProvider.GetContactGroupInfo(ValidationHelper.GetInteger(dr["ContactGroupMemberContactGroupID"], 0)); if (cg != null) { contactGroup.Text = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(cg.ContactGroupDisplayName)); chkContactGroups.Items.Add(contactGroup); } } } else { tabContactGroups.Visible = false; tabContactGroups.HeaderText = null; } } }
private void SetFilter() { string where = string.Empty; int paging = 0; string order = null; if (FilterByQuery) { int status = QueryHelper.GetInteger("statusid", 0); int manufacturer = QueryHelper.GetInteger("manufacturerid", 0); bool stock = QueryHelper.GetBoolean("available", false); paging = QueryHelper.GetInteger("pagesize", 12); order = QueryHelper.GetString("order", string.Empty); string search = QueryHelper.GetString("search", string.Empty); if (status > 0) { where = SqlHelperClass.AddWhereCondition(where, "SKUPublicStatusID = " + status); } if (manufacturer > 0) { where = SqlHelperClass.AddWhereCondition(where, "SKUManufacturerID = " + manufacturer); } if (stock) { where = SqlHelperClass.AddWhereCondition(where, "SKUAvailableItems > 0"); } if (!string.IsNullOrEmpty(search)) { where = SqlHelperClass.AddWhereCondition(where, String.Format("SKUName LIKE N'%{0}%'", SqlHelperClass.GetSafeQueryString(search, false))); } switch (order.ToLower()) { case "nameasc": order = "SKUName"; break; case "namedesc": order = "SKUName DESC"; break; case "priceasc": order = "SKUPrice"; break; case "pricedesc": order = "SKUPrice DESC"; break; default: order = string.Empty; break; } } else { // Build where condition according to dropdowns setings if (Convert.ToInt32(statusSelector.Value) > 0) { where = SqlHelperClass.AddWhereCondition(where, "SKUPublicStatusID = " + statusSelector.Value); } if (Convert.ToInt32(manufacturerSelector.Value) > 0) { where = SqlHelperClass.AddWhereCondition(where, "SKUManufacturerID = " + manufacturerSelector.Value); } if (chkStock.Checked) { where = SqlHelperClass.AddWhereCondition(where, "SKUAvailableItems > 0"); } if (!string.IsNullOrEmpty(txtSearch.Text)) { where = SqlHelperClass.AddWhereCondition(where, String.Format("SKUName LIKE N'%{0}%'", SqlHelperClass.GetSafeQueryString(txtSearch.Text, false))); } // Process drpSort dropdown if (drpPaging.SelectedValue != string.Empty) { paging = ValidationHelper.GetInteger(drpPaging.SelectedValue, 12); } // Process drpSort dropdown if (drpSort.Visible && (drpSort.SelectedValue != string.Empty)) { switch (drpSort.SelectedValue.ToLower()) { case "nameasc": order = "SKUName"; break; case "namedesc": order = "SKUName DESC"; break; case "priceasc": order = "SKUPrice"; break; case "pricedesc": order = "SKUPrice DESC"; break; } } } if (where != string.Empty) { // Set where condition WhereCondition = where; } if (order != string.Empty) { // Set orderBy condition OrderBy = order; } if (paging >= 0) { // Set paging PageSize = paging; } // Filter changed event RaiseOnFilterChanged(); }
/// <summary> /// Publishes document(s). /// </summary> private void PublishAll(object parameter) { if (parameter == null) { return; } TreeProvider tree = new TreeProvider(currentUser); tree.AllowAsyncActions = false; try { // Begin log AddLog(ResHelper.GetString("content.publishingdocuments", currentCulture)); string[] parameters = ((string)parameter).Split(';'); string siteName = parameters[1]; // Get identifiers int[] workNodes = nodeIds.ToArray(); // Prepare the where condition string where = SqlHelperClass.GetWhereCondition("NodeID", workNodes); string columns = SqlHelperClass.MergeColumns(TreeProvider.SELECTNODES_REQUIRED_COLUMNS, "NodeAliasPath, ClassName, DocumentCulture"); // Get cultures string cultureCode = chkAllCultures.Checked ? TreeProvider.ALL_CULTURES : parameters[0]; // Get the documents DataSet documents = tree.SelectNodes(siteName, "/%", cultureCode, false, null, where, "NodeAliasPath DESC", TreeProvider.ALL_LEVELS, false, 0, columns); // Create instance of workflow manager class WorkflowManager wm = WorkflowManager.GetInstance(tree); if (!DataHelper.DataSourceIsEmpty(documents)) { foreach (DataRow nodeRow in documents.Tables[0].Rows) { // Get the current document TreeNode node = GetDocument(tree, siteName, nodeRow); // Publish document if (PerformPublish(wm, tree, siteName, nodeRow)) { return; } // Process underlying documents if (chkUnderlying.Checked && (node.NodeChildNodesCount > 0)) { if (PublishSubDocuments(node, tree, wm, cultureCode, siteName)) { return; } } } } else { AddError(ResHelper.GetString("content.nothingtopublish", currentCulture)); } } catch (ThreadAbortException ex) { string state = ValidationHelper.GetString(ex.ExceptionState, string.Empty); if (state != CMSThread.ABORT_REASON_STOP) { // Log error LogExceptionToEventLog(ResHelper.GetString("content.publishfailed", currentCulture), ex); } } catch (Exception ex) { // Log error LogExceptionToEventLog(ResHelper.GetString("content.publishfailed", currentCulture), ex); } }
protected void Page_Load(object sender, EventArgs e) { process = true; // If control is not visible don't process anything if (!this.Visible || this.StopProcessing) { process = false; EnableViewState = false; return; } string forumIDs = null; // Group where condition part string groupWhere = String.Empty; if (SiteName == string.Empty) { SiteName = CMSContext.CurrentSiteName; } if (SiteName != TreeProvider.ALL_SITES) { groupWhere = "GroupSiteID IN (SELECT SiteID FROM CMS_Site WHERE SiteName = N'" + SqlHelperClass.GetSafeQueryString(SiteName, false) + "')"; } if (this.CommunityGroupId > 0) { groupWhere = SqlHelperClass.AddWhereCondition(groupWhere, "GroupGroupID = " + this.CommunityGroupId); } // Add where condition from property if (this.WhereCondition != String.Empty) { groupWhere = SqlHelperClass.AddWhereCondition(groupWhere, this.WhereCondition); } bool hasGroupRights = false; if (this.CommunityGroupId > 0) { if (CMSContext.CurrentUser.IsGroupAdministrator(CommunityGroupId) || CMSContext.CurrentUser.IsAuthorizedPerResource("cms.groups", "Manage")) { hasGroupRights = true; } } // Get forums moderated by current user else if (!CMSContext.CurrentUser.IsGlobalAdministrator) { // Get forumId where the user is moderator and forum satisfy group where condition string whereCond = "UserID =" + CMSContext.CurrentUser.UserID; if (groupWhere != String.Empty) { whereCond += " AND ForumID IN ( SELECT ForumID FROM Forums_Forum WHERE " + "ForumGroupID IN (SELECT GroupID FROM Forums_ForumGroup WHERE " + groupWhere + "))"; } // Get forums where user is moderator DataSet ds = ForumModeratorInfoProvider.GetGroupForumsModerators(whereCond, null); if (!DataHelper.DataSourceIsEmpty(ds)) { forumIDs = ""; foreach (DataRow dr in ds.Tables[0].Rows) { forumIDs += ValidationHelper.GetString(dr["ForumID"], "") + ","; } // Remove ending , forumIDs = forumIDs.TrimEnd(','); } } string zeroRowText = String.Empty; if (ZeroRowText == String.Empty) { zeroRowText = GetString("general.nodatafound"); } else { zeroRowText = HTMLHelper.HTMLEncode(ZeroRowText); } // Hide approvals if ((!CMSContext.CurrentUser.IsGlobalAdministrator) && (String.IsNullOrEmpty(forumIDs)) && (hasGroupRights == false)) { if (!HideControlForNoData) { gridApprove.StopProcessing = true; process = false; lblInfo.Text = zeroRowText; lblInfo.Visible = true; return; } else { this.Visible = false; } } gridApprove.ZeroRowsText = zeroRowText; gridApprove.OnAction += new OnActionEventHandler(gridApprove_OnAction); gridApprove.GridView.AllowSorting = false; gridApprove.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridApprove_OnExternalDataBound); gridApprove.IsLiveSite = this.IsLiveSite; gridApprove.HideControlForZeroRows = false; if ((!RequestHelper.IsPostBack()) && (!string.IsNullOrEmpty(ItemsPerPage))) { gridApprove.Pager.DefaultPageSize = ValidationHelper.GetInteger(ItemsPerPage, -1); } if (CMSContext.CurrentUser.IsGlobalAdministrator || hasGroupRights) { if (groupWhere != String.Empty) { gridApprove.WhereCondition = "(PostApproved IS NULL OR PostApproved = 0) AND (PostForumID IN (SELECT ForumID FROM [Forums_Forum] WHERE ForumGroupID IN (SELECT GroupID FROM [Forums_ForumGroup] WHERE " + groupWhere + ")))"; } // Show only posts waiting for approval else { gridApprove.WhereCondition = "(PostApproved IS NULL OR PostApproved = 0)"; } } else if (forumIDs != null) { gridApprove.WhereCondition = "((PostApproved IS NULL) OR (PostApproved = 0)) AND (PostForumID IN (SELECT ForumID FROM [Forums_Forum] WHERE (ForumID IN (" + forumIDs + "))"; if (groupWhere != String.Empty) { gridApprove.WhereCondition += " AND (ForumGroupID IN (SELECT GroupID FROM [Forums_ForumGroup] WHERE " + groupWhere + "))))"; } else { gridApprove.WhereCondition += "))"; } } //Filter group names if (GroupNames != String.Empty) { string where = String.Empty; string parsedNames = String.Empty; string[] names = GroupNames.Split(';'); if (names.Length > 0) { foreach (string name in names) { parsedNames += "'" + SqlHelperClass.GetSafeQueryString(name, false) + "',"; } parsedNames = parsedNames.TrimEnd(','); where = "(PostForumID IN (SELECT ForumID FROM [Forums_Forum] WHERE (ForumGroupID IN (SELECT GroupID FROM [Forums_ForumGroup] WHERE GroupName IN (" + parsedNames + ")))))"; gridApprove.WhereCondition = SqlHelperClass.AddWhereCondition(gridApprove.WhereCondition, where); } } }
protected void Page_Load(object sender, EventArgs e) { if (DocumentManager != null) { CMS.DocumentEngine.TreeNode node = DocumentManager.Node; if (node != null) { DocumentSettings = true; // Try get info whether exist linked document in path DataSet ds = DocumentManager.Tree.SelectNodes(CMSContext.CurrentSiteName, "/%", node.DocumentCulture, false, null, "NodeLinkedNodeID IS NOT NULL AND (N'" + SqlHelperClass.GetSafeQueryString(node.NodeAliasPath) + "' LIKE NodeAliasPath + '%')", null, -1, false, 1, "Count(*) AS NumOfDocs"); // If node is not link or none of parent documents is not linked document use document name path if (!node.IsLink && ValidationHelper.GetInteger(DataHelper.GetDataRowValue(ds.Tables[0].Rows[0], "NumOfDocs"), 0) == 0) { TreePath = TreePathUtils.GetParentPath("/" + node.DocumentNamePath); } else { // Otherwise use alias path TreePath = TreePathUtils.GetParentPath("/" + node.NodeAliasPath); } } } if (DocumentSettings) { radInheritAll.Text = GetString("InheritLevels.UseTemplateSettigns"); } else { radInheritAll.Text = GetString("InheritLevels.InheritAll"); } radNonInherit.Text = GetString("InheritLevels.NonInherit"); radSelect.Text = GetString("InheritLevels.Select"); radInheritMaster.Text = GetString("InheritLevels.InheritMaster"); }
/// <summary> /// Reloads the data in the selector. /// </summary> public void ReloadData() { string where = null; bool authorizedSiteAccounts = false; bool authorizedGlobalAccounts = AccountHelper.AuthorizedReadAccount(UniSelector.US_GLOBAL_RECORD, false); currentUser = CMSContext.CurrentUser; if (SiteID > 0) { authorizedSiteAccounts = AccountHelper.AuthorizedReadAccount(SiteID, false); } else { authorizedSiteAccounts = AccountHelper.AuthorizedReadAccount(CMSContext.CurrentSiteID, false); } // Filter site objects if (this.SiteID > 0) { if (authorizedSiteAccounts) { where = "(AccountSiteID = " + this.SiteID + " AND AccountMergedWithAccountID IS NULL)"; } else { where = "(1=0)"; } } // Filter only global objects else if ((this.SiteID == UniSelector.US_GLOBAL_RECORD) || (this.SiteID == 0)) { if (authorizedGlobalAccounts) { where = "(AccountSiteID IS NULL AND AccountGlobalAccountID IS NULL)"; } else { where = "(1=0)"; } } // Display current site and global contacts else if (this.SiteID == UniSelector.US_GLOBAL_OR_SITE_RECORD) { if (authorizedSiteAccounts && authorizedGlobalAccounts) { where = "(AccountSiteID IS NULL AND AccountGlobalAccountID IS NULL) OR (AccountSiteID = " + CMSContext.CurrentSiteID + " AND AccountMergedWithAccountID IS NULL)"; uniSelector.AddGlobalObjectSuffix = true; } else if (authorizedGlobalAccounts) { where = "(AccountSiteID IS NULL AND AccountMergedWithAccountID IS NULL)"; } else if (authorizedSiteAccounts) { where = "(AccountSiteID = " + CMSContext.CurrentSiteID + " AND AccountMergedWithAccountID IS NULL)"; } else { where = "(1=0)"; } } // Display all objects else if ((this.SiteID == UniSelector.US_ALL_RECORDS) && currentUser.UserSiteManagerAdmin) { where = "((AccountSiteID IS NULL AND AccountGlobalAccountID IS NULL) OR (AccountSiteID > 0 AND AccountMergedWithAccountID IS NULL))"; uniSelector.AddGlobalObjectSuffix = true; } // Not enough permissions else { where = "(1=0)"; } uniSelector.WhereCondition = SqlHelperClass.AddWhereCondition(this.WhereCondition, where); uniSelector.Reload(true); }
protected void Page_Load(object sender, EventArgs e) { if (PostbackOnChange) { ucUniSelector.DropDownSingleSelect.AutoPostBack = true; ScriptManager scr = ScriptManager.GetCurrent(Page); scr.RegisterPostBackControl(ucUniSelector.DropDownSingleSelect); } if (!URLHelper.IsPostback()) { // If some test belongs to node give by NodeID - preselect it in ABTest selector if (NodeID != 0) { TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); TreeNode node = tree.SelectSingleNode(NodeID, CMSContext.PreferredCultureCode, tree.CombineWithDefaultCulture); if (node != null) { DataSet ds = ABTestInfoProvider.GetABTests("ABTestSiteID = " + CMSContext.CurrentSiteID + " AND ABTestOriginalPage = '" + SqlHelperClass.GetSafeQueryString(node.NodeAliasPath, false) + "'", "ABTestName", -1, null, null); if (!DataHelper.DataSourceIsEmpty(ds)) { // Preselect running test bool runningTestFound = false; foreach (DataRow row in ds.Tables[0].Rows) { ABTestInfo abTestObj = new ABTestInfo(row); if (ABTestInfoProvider.ABTestIsRunning(abTestObj)) { runningTestFound = true; ucUniSelector.Value = abTestObj.ABTestID; } } // If no running test found for the page, preselect the first test (alphabetically) if (!runningTestFound) { int abTestID = ValidationHelper.GetInteger(ds.Tables[0].Rows[0]["ABTestID"], 0); if (abTestID != 0) { ucUniSelector.Value = abTestID; } } } } } } ReloadData(false); }
/// <summary> /// Adds group for actions. /// </summary> /// <param name="where">Pattern to be used to filter actions</param> private void AddActionGroup(string where) { string condition = "ActionEnabled = 1"; // Allowed objects condition = SqlHelperClass.AddWhereCondition(condition, "ActionAllowedObjects IS NULL OR ActionAllowedObjects LIKE N'%" + SqlHelperClass.GetSafeQueryString(Workflow.WorkflowAllowedObjects) + "%'"); // Workflow type condition = SqlHelperClass.AddWhereCondition(condition, Workflow.IsAutomation ? "ActionWorkflowType = " + (int)Workflow.WorkflowType : "ActionWorkflowType = " + (int)Workflow.WorkflowType + " OR ActionWorkflowType IS NULL"); InfoDataSet <WorkflowActionInfo> actions = WorkflowActionInfoProvider.GetWorkflowActions(condition, "ActionDisplayName", "ActionID, ActionThumbnailGUID, ActionDisplayName, ActionDescription, ActionIconGUID"); List <Item> nodesMenuItems = Factory.GetSettingsObjectBy(actions); nodesMenuItems = FilterList(nodesMenuItems, where); nodesMenuItems = nodesMenuItems.OrderBy(i => i.Text).ToList(); if (nodesMenuItems.Count > 0) { KeyValuePair <string, object> nodesValue = new KeyValuePair <string, object>("NodesMenuItems", nodesMenuItems); AppendGroup(NodesControlPath, nodesValue, ""); } }
protected override void OnPreRender(EventArgs e) { ucGraphType.ProcessChartSelectors(false); // Prepare report parameters DataTable dtp = new DataTable(); dtp.Columns.Add("FromDate", typeof(DateTime)); dtp.Columns.Add("ToDate", typeof(DateTime)); dtp.Columns.Add("CodeName", typeof(string)); dtp.Columns.Add("MVTestName", typeof(string)); dtp.Columns.Add("ConversionName", typeof(string)); object[] parameters = new object[5]; parameters[0] = ucGraphType.From; parameters[1] = ucGraphType.To; parameters[2] = "mvtests"; String reportName = ucGraphType.GetReportName("mvtests.yearreport;mvtests.monthreport;mvtests.weekreport;mvtests.dayreport;mvtests.hourreport"); String conversionRateReportName = ucGraphType.GetReportName("mvtestsconversionrate.yearreport;mvtestsconversionrate.monthreport;mvtestsconversionrate.weekreport;mvtestsconversionrate.dayreport;mvtestsconversionrate.hourreport"); String valuesReportName = ucGraphType.GetReportName("mvtestsconversionvalue.yearreport;mvtestsconversionvalue.monthreport;mvtestsconversionvalue.weekreport;mvtestsconversionvalue.dayreport;mvtestsconversionvalue.hourreport"); string MVTestName = ValidationHelper.GetString(ucMVTests.Value, String.Empty); if (MVTestName == ucMVTests.AllRecordValue) { MVTestName = String.Empty; } else if (!String.IsNullOrEmpty(MVTestName)) { listElem.Grid.WhereCondition = SqlHelperClass.AddWhereCondition(listElem.Grid.WhereCondition, "MVTestName='" + SqlHelperClass.GetSafeQueryString(MVTestName, false) + "'"); } switch (ucGraphType.SelectedInterval) { case HitsIntervalEnum.Hour: listElem.Grid.Query = "om.mvtest.selectwithhitsHours"; break; case HitsIntervalEnum.Day: listElem.Grid.Query = "om.mvtest.selectwithhitsDays"; break; case HitsIntervalEnum.Week: listElem.Grid.Query = "om.mvtest.selectwithhitsWeeks"; break; case HitsIntervalEnum.Month: listElem.Grid.Query = "om.mvtest.selectwithhitsMonths"; break; case HitsIntervalEnum.Year: listElem.Grid.Query = "om.mvtest.selectwithhitsYears"; break; } listElem.Grid.QueryParameters = new QueryDataParameters(); listElem.Grid.QueryParameters.Add("@From", ucGraphType.From); listElem.Grid.QueryParameters.Add("@To", ucGraphType.To.AddSeconds(1)); listElem.Grid.Columns = "MVTestDisplayName,MVTestID,MVTestCulture,MVTestPage,MVTestOpenFrom,MVTestOpenTo,MVTestEnabled,MVTestConversions,MVTestSiteID,HitsValue"; parameters[3] = MVTestName; parameters[4] = String.Empty; dtp.Rows.Add(parameters); dtp.AcceptChanges(); ucDisplayReport.ReportName = reportName; ucTestValuesReport.ReportName = valuesReportName; ucConversionRateReport.ReportName = conversionRateReportName; // Conversion count if (!ucDisplayReport.IsReportLoaded()) { lblErrorConversions.Visible = true; lblErrorConversions.Text = String.Format(GetString("Analytics_Report.ReportDoesnotExist"), reportName); } else { ucDisplayReport.LoadFormParameters = false; ucDisplayReport.DisplayFilter = false; ucDisplayReport.ReportParameters = dtp.Rows[0]; ucDisplayReport.GraphImageWidth = 100; ucDisplayReport.IgnoreWasInit = true; ucDisplayReport.ReloadData(true); ucDisplayReport.UseExternalReload = true; ucDisplayReport.UseProgressIndicator = true; } // Conversion value if (!ucTestValuesReport.IsReportLoaded()) { lblErrorValues.Visible = true; lblErrorValues.Text = String.Format(GetString("Analytics_Report.ReportDoesnotExist"), valuesReportName); } else { ucTestValuesReport.LoadFormParameters = false; ucTestValuesReport.DisplayFilter = false; ucTestValuesReport.ReportParameters = dtp.Rows[0]; ucTestValuesReport.GraphImageWidth = 50; ucTestValuesReport.AreaMaxWidth = ucDisplayReport.AreaMaxWidth; ucTestValuesReport.IgnoreWasInit = true; ucTestValuesReport.ReloadData(true); ucTestValuesReport.UseExternalReload = true; ucTestValuesReport.UseProgressIndicator = true; } // Conversion rate if (!ucConversionRateReport.IsReportLoaded()) { lblErrorRate.Visible = true; lblErrorRate.Text = String.Format(GetString("Analytics_Report.ReportDoesnotExist"), conversionRateReportName); } else { ucConversionRateReport.LoadFormParameters = false; ucConversionRateReport.DisplayFilter = false; ucConversionRateReport.ReportParameters = dtp.Rows[0]; ucConversionRateReport.GraphImageWidth = 50; ucConversionRateReport.AreaMaxWidth = ucDisplayReport.AreaMaxWidth; ucTestValuesReport.UseExternalReload = true; ucTestValuesReport.UseProgressIndicator = true; ucConversionRateReport.IgnoreWasInit = true; ucConversionRateReport.ReloadData(true); } base.OnPreRender(e); }
/// <summary> /// Moves the node to the specified target. /// </summary> /// <param name="node">Node to move</param> /// <param name="targetNode">Target node</param> /// <param name="tree">Tree provider</param> /// <param name="preservePermissions">Indicates if node permissions should be preserved</param> /// <returns>Whether to set new order</returns> protected bool MoveNode(TreeNode node, TreeNode targetNode, TreeProvider tree, bool preservePermissions) { int targetId = targetNode.NodeID; string encodedAliasPath = " (" + HTMLHelper.HTMLEncode(node.NodeAliasPath) + ")"; // If node parent ID is already the target ID, do not move it if (targetId == node.NodeParentID) { if (IsDialogAction) { // Impossible to move document to same location AddError(GetString("contentrequest.cannotmovetosameloc") + encodedAliasPath); } return(true); } // Check move permission if (!IsUserAuthorizedToMove(node, targetId, node.NodeClassName)) { AddError(GetString("ContentRequest.NotAllowedToMove") + encodedAliasPath); return(false); } // Get the document to copy int nodeId = node.NodeID; if (nodeId == targetId) { AddError(GetString("ContentRequest.CannotMoveToItself") + encodedAliasPath); return(false); } // Check cyclic movement (movement of the node to some of its child nodes) if ((targetNode.NodeSiteID == node.NodeSiteID) && targetNode.NodeAliasPath.StartsWith(node.NodeAliasPath + "/", StringComparison.CurrentCultureIgnoreCase)) { AddError(GetString("ContentRequest.CannotMoveToChild")); return(false); } if (targetNode.NodeSiteID != node.NodeSiteID) { SiteInfo targetSite = SiteInfoProvider.GetSiteInfo(targetNode.NodeSiteID); string domainToCheck = targetSite.DomainName; // Check the licence limitations if ((node.NodeClassName.ToLower() == "cms.blog") && !LicenseHelper.LicenseVersionCheck(domainToCheck, FeatureEnum.Blogs, VersionActionEnum.Insert)) { AddError(GetString("cmsdesk.bloglicenselimits")); return(false); } } // Check allowed child classes int targetClassId = ValidationHelper.GetInteger(targetNode.GetValue("NodeClassID"), 0); int nodeClassId = ValidationHelper.GetInteger(node.GetValue("NodeClassID"), 0); if (!DataClassInfoProvider.IsChildClassAllowed(targetClassId, nodeClassId) || (ClassSiteInfoProvider.GetClassSiteInfo(nodeClassId, targetNode.NodeSiteID) == null)) { AddError(String.Format(GetString("ContentRequest.ErrorDocumentTypeNotAllowed"), node.NodeAliasPath, node.NodeClassName)); return(false); } // Get child documents if ((node.NodeChildNodesCount) > 0 && IsDialogAction) { string columns = SqlHelperClass.MergeColumns(TreeProvider.SELECTNODES_REQUIRED_COLUMNS, "NodeAliasPath"); DataSet childNodes = TreeProvider.SelectNodes(currentSite.SiteName, node.NodeAliasPath.TrimEnd('/') + "/%", TreeProvider.ALL_CULTURES, true, null, null, null, TreeProvider.ALL_LEVELS, false, 0, columns); if (!DataHelper.DataSourceIsEmpty(childNodes)) { foreach (DataRow childNode in childNodes.Tables[0].Rows) { AddLog(HTMLHelper.HTMLEncode(childNode["NodeAliasPath"] + " (" + childNode["DocumentCulture"] + ")")); } } } // Move the document AddLog(HTMLHelper.HTMLEncode(node.NodeAliasPath + " (" + node.DocumentCulture + ")")); DocumentHelper.MoveDocument(node, targetId, tree, preservePermissions); SetExpandedNode(node.NodeParentID); return(true); }
protected void Page_Load(object sender, EventArgs e) { currentUser = CMSContext.CurrentUser; if (currentUser == null) { return; } // No cms.blog doc. type if (DataClassInfoProvider.GetDataClass("cms.blog") == null) { RedirectToInformation(GetString("blog.noblogdoctype")); } // Check if user is authorized to manage isAuthorized = currentUser.IsAuthorizedPerResource("CMS.Blog", "Manage") || (currentUser.IsAuthorizedPerClassName("cms.blog", "Manage", CMSContext.CurrentSiteName) && currentUser.IsAuthorizedPerClassName("cms.blogpost", "Manage", CMSContext.CurrentSiteName)); gridBlogs.OnExternalDataBound += gridBlogs_OnExternalDataBound; gridBlogs.OnDataReload += gridBlogs_OnDataReload; gridBlogs.ShowActionsMenu = true; gridBlogs.Columns = "BlogID, ClassName, BlogName, NodeID, DocumentCulture, NodeOwner, BlogModerators"; // Get all possible columns to retrieve IDataClass nodeClass = DataClassFactory.NewDataClass("CMS.Tree"); DocumentInfo di = new DocumentInfo(); BlogInfo bi = new BlogInfo(); gridBlogs.AllColumns = SqlHelperClass.MergeColumns(SqlHelperClass.MergeColumns(SqlHelperClass.MergeColumns(bi.ColumnNames.ToArray()), SqlHelperClass.MergeColumns(di.ColumnNames.ToArray())), SqlHelperClass.MergeColumns(nodeClass.ColumnNames.ToArray())); // Get ClassID of the 'cms.blogpost' class DataClassInfo dci = DataClassInfoProvider.GetDataClass("cms.blogpost"); string classId = ""; string script = ""; if (dci != null) { classId = dci.ClassID.ToString(); } // Get scritp to redirect to new blog post page script += "function NewPost(parentId, culture) { \n"; script += " if (parentId != 0) { \n"; script += " parent.parent.parent.location.href = \"" + ResolveUrl("~/CMSDesk/default.aspx") + "?section=content&action=new&nodeid=\" + parentId + \"&classid=" + classId + "&culture=\" + culture;"; script += "}} \n"; // Generate javascript code ltlScript.Text = ScriptHelper.GetScript(script); }
/// <summary> /// Reloads control. /// </summary> public void ReloadData() { string where = WhereCondition; bool globalInCMSDesk = (SiteID == UniSelector.US_GLOBAL_RECORD) && SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".cmscmglobalconfiguration"); bool settingEnabledForSite = SettingsKeyProvider.GetBoolValue(SiteInfoProvider.GetSiteName(SiteID) + ".cmscmglobalconfiguration"); bool userAuthorized = ConfigurationHelper.AuthorizedReadConfiguration(UniSelector.US_GLOBAL_RECORD, false); bool allowGlobal = userAuthorized && (IsSiteManager || globalInCMSDesk || settingEnabledForSite); bool allowSite = ConfigurationHelper.AuthorizedReadConfiguration(SiteID > 0 ? SiteID : CMSContext.CurrentSiteID, false); uniselector.AllowAll = AllowAllItem; if (DisplayAll || DisplaySiteOrGlobal) { // Display all site and global statuses if (DisplayAll && allowSite && allowGlobal) { // No WHERE condition required } // Display current site and global statuses else if (DisplaySiteOrGlobal && allowSite && allowGlobal && (SiteID > 0)) { where = SqlHelperClass.AddWhereCondition(where, "AccountStatusSiteID IS NULL OR AccountStatusSiteID = " + (SiteID == 0 ? CMSContext.CurrentSiteID : SiteID)); } // Current site else if (allowSite && (SiteID > 0)) { where = SqlHelperClass.AddWhereCondition(where, "AccountStatusSiteID = " + SiteID); } // Display global statuses else if (allowGlobal) { where = SqlHelperClass.AddWhereCondition(where, "AccountStatusSiteID IS NULL "); } // Don't display anything if (String.IsNullOrEmpty(where) && !DisplayAll) { where = "(1=0)"; } } // Display either global or current site statuses else { // Current site if ((SiteID > 0) && allowSite) { where = SqlHelperClass.AddWhereCondition(where, "AccountStatusSiteID = " + SiteID); } // Display global statuses else if (((SiteID == UniSelector.US_GLOBAL_RECORD) || (SiteID == UniSelector.US_NONE_RECORD)) && allowGlobal) { where = SqlHelperClass.AddWhereCondition(where, "AccountStatusSiteID IS NULL "); } // Don't display anything if (String.IsNullOrEmpty(where)) { where = "(1=0)"; } } uniselector.WhereCondition = where; uniselector.Reload(true); }