/// <summary> /// On PreRender. /// </summary> protected override void OnPreRender(EventArgs e) { if (StopProcessing) { return; } if (!ShowWidgetOnlyWebparts) { // Do not display widget only web parts flatElem.WhereCondition = SqlHelper.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 = SqlHelper.AddWhereCondition(flatElem.WhereCondition, "WebPartCategoryID = " + SelectedCategory.CategoryID + " OR WebPartCategoryID IN (SELECT CategoryID FROM CMS_WebPartCategory WHERE CategoryPath LIKE N'" + SqlHelper.EscapeLikeText(SqlHelper.EscapeQuotes(SelectedCategory.CategoryPath)).TrimEnd('/') + "/%')"); } // Recently used if (TreeSelectedItem.ToLowerCSafe() == "recentlyused") { flatElem.WhereCondition = SqlHelper.AddWhereCondition(flatElem.WhereCondition, new WhereCondition().WhereIn("WebPartName", MembershipContext.AuthenticatedUser.UserSettings.UserUsedWebParts.Split(';')).ToString(true)); } // Description area and recently used litCategory.Text = ShowInDescriptionArea(SelectedItem); base.OnPreRender(e); }
/// <summary> /// On PreRender. /// </summary> protected override void OnPreRender(EventArgs e) { if (StopProcessing) { return; } // Security var currentUser = MembershipContext.AuthenticatedUser; if (SelectGroupWidgets) { // Shows group widgets without other security checks string where = "WidgetForGroup = 1"; // But user must be group admin, otherwise show nothing if (!currentUser.IsGroupAdministrator(GroupID) && ((PortalContext.ViewMode != ViewModeEnum.Design) || ((PortalContext.ViewMode == ViewModeEnum.Design) && (!currentUser.IsAuthorizedPerResource("CMS.Design", "Design"))))) { flatElem.ErrorText = GetString("widget.notgroupadmin"); } flatElem.WhereCondition = SqlHelper.AddWhereCondition(flatElem.WhereCondition, where); } else { // Create security where condition string securityWhere = String.Empty; if (SelectEditorWidgets) { securityWhere += "WidgetForEditor = 1 "; } else if (SelectUserWidgets) { securityWhere += "WidgetForUser = 1 "; } else if (SelectDashboardWidgets) { securityWhere += "WidgetForDashboard = 1 "; } else if (SelectInlineWidgets) { securityWhere += " WidgetForInline = 1 "; } else { securityWhere += " 1 = 2 "; } securityWhere += CreateAuthWhereCondition(); flatElem.WhereCondition = SqlHelper.AddWhereCondition(flatElem.WhereCondition, securityWhere); } // Restrict to items in selected category (if not root) if ((SelectedCategory != null) && (SelectedCategory.WidgetCategoryParentID > 0)) { flatElem.WhereCondition = SqlHelper.AddWhereCondition(flatElem.WhereCondition, "WidgetCategoryID = " + SelectedCategory.WidgetCategoryID + " OR WidgetCategoryID IN (SELECT WidgetCategoryID FROM CMS_WidgetCategory WHERE WidgetCategoryPath LIKE '" + SelectedCategory.WidgetCategoryPath + "/%')"); } // Recently used items if (TreeSelectedItem.ToLowerCSafe() == "recentlyused") { flatElem.WhereCondition = SqlHelper.AddWhereCondition(flatElem.WhereCondition, new WhereCondition().WhereIn("WidgetName", currentUser.UserSettings.UserUsedWidgets.Split(';')).ToString(true)); } // Description area and recently used litCategory.Text = ShowInDescriptionArea(SelectedItem); base.OnPreRender(e); }