/// <summary> /// Handles reset button click. Resets zones of specified type to default settings. /// </summary> protected void btnReset_Click(object sender, EventArgs e) { // Disable the reset action when document editing is not allowed (i.e. non-editable workflow step) if (!WidgetActionsEnabled) { resetAllowed = false; } // Security check if (!DisplayResetButton || !resetAllowed) { return; } PageInfo pi = CurrentPageInfo; if (pi == null) { return; } if ((zoneType == WidgetZoneTypeEnum.Editor) || (zoneType == WidgetZoneTypeEnum.Group)) { // Clear document webparts/group webparts TreeNode node = DocumentHelper.GetDocument(pi.DocumentID, TreeProvider); if (node != null) { bool updateDocument = true; if (zoneType == WidgetZoneTypeEnum.Editor) { if (ViewMode.IsEdit(true) || ViewMode.IsEditLive()) { // Do not save the document to the database, keep it in only in the memory updateDocument = false; // Get the default template widgets PortalContext.SaveEditorWidgets(pi.DocumentID, pi.UsedPageTemplateInfo.TemplateInstance.GetZonesXML(WidgetZoneTypeEnum.Editor)); } else { node.SetValue("DocumentWebParts", String.Empty); } ClearEditorWidgetsContent(node, pi.UsedPageTemplateInfo.TemplateInstance, updateDocument); // Delete all variants if (pi.UsedPageTemplateInfo != null) { foreach (WebPartZoneInstance zoneInstance in zoneInstances) { if (zoneInstance.WebPartsContainVariants) { VariantHelper.DeleteWidgetVariants(zoneInstance.ZoneID, pi.UsedPageTemplateInfo.PageTemplateId, node.DocumentID); } } } } else if (zoneType == WidgetZoneTypeEnum.Group) { node.SetValue("DocumentGroupWebParts", String.Empty); } if (updateDocument) { // Save the document DocumentHelper.UpdateDocument(node, TreeProvider); } } } else if (zoneType == WidgetZoneTypeEnum.User) { // Delete user personalization info PersonalizationInfo up = PersonalizationInfoProvider.GetUserPersonalization(MembershipContext.AuthenticatedUser.UserID, pi.DocumentID); PersonalizationInfoProvider.DeletePersonalizationInfo(up); // Clear cached values TreeNode node = DocumentHelper.GetDocument(pi.DocumentID, TreeProvider); if (node != null) { node.ClearCache(); } } else if (zoneType == WidgetZoneTypeEnum.Dashboard) { // Delete user personalization info PersonalizationInfo up = PersonalizationInfoProvider.GetDashBoardPersonalization(MembershipContext.AuthenticatedUser.UserID, PortalContext.DashboardName, PortalContext.DashboardSiteName); PersonalizationInfoProvider.DeletePersonalizationInfo(up); // Clear cached page template if (pi.UsedPageTemplateInfo != null) { CacheHelper.TouchKey("cms.pagetemplate|byid|" + pi.UsedPageTemplateInfo.PageTemplateId); } } // Make redirect to see changes after load string url = RequestContext.CurrentURL; if (ViewMode.IsEdit(true) || ViewMode.IsEditLive()) { // Ensure that the widgets will be loaded from the session layer (not from database) url = URLHelper.UpdateParameterInUrl(url, "cmscontentchanged", "true"); } URLHelper.Redirect(url); }