protected void Page_Load(object sender, EventArgs e) { // Initialize modal page RegisterEscScript(); ScriptHelper.RegisterWOpenerScript(Page); if (QueryHelper.ValidateHash("hash")) { externalControlID = QueryHelper.GetString("externalControlID", string.Empty); string title = GetString("Relationship.AddRelatedDocs"); Page.Title = title; CurrentMaster.Title.TitleText = title; CurrentMaster.Title.TitleImage = GetImageUrl("/Objects/CMS_RelationshipName/new.png"); btnSave.Click += new EventHandler(btnSave_Click); btnClose.Attributes.Add("onclick", "window.close(); return false;"); AddNoCacheTag(); addRelatedDocument.ShowButtons = false; nodeId = QueryHelper.GetInteger("nodeid", 0); if (nodeId > 0) { // Get the node node = TreeProvider.SelectSingleNode(nodeId, CMSContext.PreferredCultureCode, TreeProvider.CombineWithDefaultCulture); // Set edited document EditedDocument = node; if (node != null) { // Check read permissions if (CMSContext.CurrentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Read) == AuthorizationResultEnum.Denied) { RedirectToAccessDenied(String.Format(GetString("cmsdesk.notauthorizedtoreaddocument"), node.NodeAliasPath)); } else { lblInfo.Visible = false; } // Set tree node addRelatedDocument.TreeNode = node; } else { btnSave.Enabled = false; } } } else { // Hide all controls btnSave.Visible = false; btnClose.Visible = false; addRelatedDocument.Visible = false; string url = ResolveUrl("~/CMSMessages/Error.aspx?title=" + GetString("dialogs.badhashtitle") + "&text=" + GetString("dialogs.badhashtext") + "&cancel=1"); ltlScript.Text = ScriptHelper.GetScript("window.location = '" + url + "';"); } }
protected void Page_Load(object sender, EventArgs e) { UIContext.PropertyTab = PropertyTabEnum.RelatedDocs; nodeId = QueryHelper.GetInteger("nodeid", 0); // Check if any relationship exists DataSet dsRel = RelationshipNameInfoProvider.GetRelationshipNames("RelationshipNameID", "RelationshipAllowedObjects LIKE '%" + CMSObjectHelper.GROUP_DOCUMENTS + "%' AND RelationshipNameID IN (SELECT RelationshipNameID FROM CMS_RelationshipNameSite WHERE SiteID = " + CMSContext.CurrentSiteID + ")", null, 1); if (DataHelper.DataSourceIsEmpty(dsRel)) { pnlNewItem.Visible = false; relatedDocuments.Visible = false; lblInfo.Text = ResHelper.GetString("relationship.norelationship"); lblInfo.Visible = true; } else { if (nodeId > 0) { // Get the node tree = new TreeProvider(CMSContext.CurrentUser); node = tree.SelectSingleNode(nodeId, CMSContext.PreferredCultureCode, tree.CombineWithDefaultCulture); // Set edited document EditedDocument = node; if (node != null) { // Check read permissions if (CMSContext.CurrentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Read) == AuthorizationResultEnum.Denied) { RedirectToAccessDenied(String.Format(GetString("cmsdesk.notauthorizedtoreaddocument"), node.NodeAliasPath)); } // Check modify permissions else if (CMSContext.CurrentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied) { relatedDocuments.Enabled = false; lnkNewRelationship.Enabled = false; imgNewRelationship.Enabled = false; lblInfo.Visible = true; lblInfo.Text = String.Format(GetString("cmsdesk.notauthorizedtoeditdocument"), node.NodeAliasPath); } else { lblInfo.Visible = false; } // Set tree node relatedDocuments.TreeNode = node; // Initialize controls lnkNewRelationship.NavigateUrl = "~/CMSModules/Content/CMSDesk/Properties/Relateddocs_Add.aspx?nodeid=" + nodeId; imgNewRelationship.ImageUrl = GetImageUrl("CMSModules/CMS_Content/Properties/addrelationship.png"); imgNewRelationship.DisabledImageUrl = GetImageUrl("CMSModules/CMS_Content/Properties/addrelationshipdisabled.png"); } } } }
/// <summary> /// Creates department media library. /// </summary> /// <param name="departmentNode">Department node</param> private void CreateDepartmentMediaLibrary(TreeNode departmentNode) { // Set general values string departmentName = departmentNode.DocumentName; string codeName = "Department_" + departmentNode.NodeGUID; string suffix = ""; // Check if library with same name already exists MediaLibraryInfo mlInfo = MediaLibraryInfoProvider.GetMediaLibraryInfo(codeName, CMSContext.CurrentSiteName); if (mlInfo != null) { return; } // Create new object (record) if needed mlInfo = new MediaLibraryInfo(); suffix = " media library"; mlInfo.LibraryDisplayName = TextHelper.LimitLength(departmentName, 200 - suffix.Length, "") + suffix; mlInfo.LibraryFolder = departmentNode.NodeAlias; mlInfo.LibraryDescription = "Media library for " + departmentName + " department."; mlInfo.LibraryName = codeName; mlInfo.LibrarySiteID = CMSContext.CurrentSiteID; // Set security mlInfo.FileCreate = SecurityAccessEnum.AuthorizedRoles; mlInfo.FileDelete = SecurityAccessEnum.AuthorizedRoles; mlInfo.FileModify = SecurityAccessEnum.AuthorizedRoles; mlInfo.FolderCreate = SecurityAccessEnum.AuthorizedRoles; mlInfo.FolderDelete = SecurityAccessEnum.AuthorizedRoles; mlInfo.FolderModify = SecurityAccessEnum.AuthorizedRoles; mlInfo.Access = SecurityAccessEnum.AuthorizedRoles; try { MediaLibraryInfoProvider.SetMediaLibraryInfo(mlInfo); } catch { return; } // Create additional folders //MediaLibraryInfoProvider.CreateMediaLibraryFolder(CMSContext.CurrentSiteName, mlInfo.LibraryID, "Videos", false); //MediaLibraryInfoProvider.CreateMediaLibraryFolder(CMSContext.CurrentSiteName, mlInfo.LibraryID, "Other", false); //MediaLibraryInfoProvider.CreateMediaLibraryFolder(CMSContext.CurrentSiteName, mlInfo.LibraryID, "Photos & Images", false); }
public override void ReloadData(bool forceLoad) { TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); TreeNode nd = tree.SelectSingleNode(EventID, CMSContext.PreferredCultureCode, tree.CombineWithDefaultCulture, false); if (nd == null) { lblError.Text = GetString("editedobject.notexists"); lblError.Visible = true; plcSend.Visible = false; lblTitle.Visible = false; return; } //Enable controls txtSenderName.Enabled = true; txtSenderEmail.Enabled = true; txtSubject.Enabled = true; htmlEmail.Enabled = true; btnSend.Enabled = true; lblInfo.Visible = true; if (forceLoad) { string siteName = CMSContext.CurrentSiteName; txtSenderEmail.Text = SettingsKeyProvider.GetStringValue(siteName + ".CMSEventManagerInvitationFrom"); txtSenderName.Text = SettingsKeyProvider.GetStringValue(siteName + ".CMSEventManagerSenderName"); txtSubject.Text = SettingsKeyProvider.GetStringValue(siteName + ".CMSEventManagerInvitationSubject"); } // Disable form if no attendees present or user doesn't have modify permission if (CMSContext.CurrentUser.IsAuthorizedPerResource("cms.eventmanager", "Modify")) { DataSet ds = EventAttendeeInfoProvider.GetEventAttendees(EventID, null, null, "AttendeeID", 1); if (DataHelper.DataSourceIsEmpty(ds)) { DisableForm(); lblInfo.Text = GetString("Events_List.NoAttendees"); lblInfo.Visible = true; } } else { DisableForm(); lblInfo.Text = GetString("events_sendemail.modifypermission"); lblInfo.Visible = true; } }
/// <summary> /// Determines whether current user is authorized to copy document. /// </summary> /// <param name="sourceNode">Source node</param> /// <param name="targetNodeId">Target node class name</param> /// <param name="sourceNodeClassName">Source node class name</param> /// <returns>True if authorized</returns> protected bool IsUserAuthorizedToCopyOrLink(TreeNode sourceNode, int targetNodeId, string sourceNodeClassName) { bool isAuthorized = false; // Check 'read permission' to source document if (CurrentUser.IsAuthorizedPerDocument(sourceNode, NodePermissionsEnum.Read) == AuthorizationResultEnum.Allowed) { // Check 'create permission' if (CurrentUser.IsAuthorizedToCreateNewDocument(targetNodeId, sourceNodeClassName)) { isAuthorized = true; } } return(isAuthorized); }
/// <summary> /// Creates or rebuild department content search index. /// </summary> /// <param name="departmentNode">Department node</param> private void CreateDepartmentContentSearchIndex(TreeNode departmentNode) { string codeName = "default_department_" + departmentNode.NodeGUID; string departmentName = departmentNode.DocumentName; SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(codeName); if (sii == null) { // Create search index info sii = new SearchIndexInfo(); sii.IndexName = codeName; string suffix = " - Default"; sii.IndexDisplayName = TextHelper.LimitLength(departmentName, 200 - suffix.Length, "") + suffix; sii.IndexAnalyzerType = AnalyzerTypeEnum.StandardAnalyzer; sii.IndexType = PredefinedObjectType.DOCUMENT; sii.IndexIsCommunityGroup = false; // Create search index settings info SearchIndexSettingsInfo sisi = new SearchIndexSettingsInfo(); sisi.ID = Guid.NewGuid(); sisi.Path = departmentNode.NodeAliasPath + "/%"; sisi.Type = SearchIndexSettingsInfo.TYPE_ALLOWED; sisi.ClassNames = ""; // Create settings item SearchIndexSettings sis = new SearchIndexSettings(); // Update settings item sis.SetSearchIndexSettingsInfo(sisi); // Update xml value sii.IndexSettings = sis; SearchIndexInfoProvider.SetSearchIndexInfo(sii); // Assing to current website SearchIndexSiteInfoProvider.AddSearchIndexToSite(sii.IndexID, CMSContext.CurrentSiteID); } // Add curent culture to search index CultureInfo ci = CultureInfoProvider.GetCultureInfo(departmentNode.DocumentCulture); SearchIndexCultureInfoProvider.AddSearchIndexCulture(sii.IndexID, ci.CultureID); // Rebuild search index SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Rebuild, sii.IndexType, null, sii.IndexName); }
/// <summary> /// Logs registration activity. /// </summary> /// <param name="bpsi">Blog subscription info</param> /// <param name="nodeId">Docuemnt node ID</param> /// <param name="culture">Document culture</param> private void LogRegistrationActivity(BlogPostSubscriptionInfo bpsi, int nodeId, string culture) { if ((CMSContext.ViewMode != ViewModeEnum.LiveSite) || (bpsi == null) || !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser)) { return; } string siteName = CMSContext.CurrentSiteName; if (!ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) || !ActivitySettingsHelper.BlogPostSubscriptionEnabled(siteName)) { return; } if (bpsi.SubscriptionPostDocumentID > 0) { TreeProvider tree = new TreeProvider(); TreeNode blogPost = DocumentHelper.GetDocument(bpsi.SubscriptionPostDocumentID, tree); if ((blogPost != null) && ValidationHelper.GetBoolean(blogPost.GetValue("BlogLogActivity"), false)) { string blogName = null; TreeNode blogNode = BlogHelper.GetParentBlog(bpsi.SubscriptionPostDocumentID, false); if (blogNode != null) { blogName = blogNode.DocumentName; } // Update contact info according to subscribtion var data = new ActivityData() { ContactID = ModuleCommands.OnlineMarketingGetCurrentContactID(), SiteID = CMSContext.CurrentSiteID, Type = PredefinedActivityType.SUBSCRIPTION_BLOG_POST, ItemDetailID = (blogNode != null ? blogNode.NodeID : 0), TitleData = bpsi.SubscriptionEmail, URL = URLHelper.CurrentRelativePath, NodeID = nodeId, Value = TextHelper.LimitLength(blogName, 250), Culture = culture, Campaign = CMSContext.Campaign }; ActivityLogProvider.LogActivity(data); } } }
void txtNodeId_TextChanged(object sender, EventArgs e) { int nodeId = ValidationHelper.GetInteger(txtNodeId.Text, 0); if (nodeId > 0) { TreeNode node = this.TreeProvider.SelectSingleNode(nodeId); if (node != null) { SiteID = node.NodeSiteID; PathTextBox.Text = node.NodeAliasPath; // Raise change event RaiseOnChanged(); } } }
protected TreeNode ProcessFileUploader(TreeProvider tree) { TreeNode node = null; // Create new document string fileName = Path.GetFileNameWithoutExtension(FileUpload.FileName); int maxFileNameLength = FileNameFieldInfo.Size; if (fileName.Length > maxFileNameLength) { fileName = fileName.Substring(0, maxFileNameLength); } node = TreeNode.New("CMS.File", tree); node.DocumentCulture = CMSContext.PreferredCultureCode; node.DocumentName = fileName; // Load default values FormHelper.LoadDefaultValues(node); if (node.ContainsColumn("FileDescription")) { node.SetValue("FileDescription", txtFileDescription.Text); } //node.SetValue("FileName", fileName); node.SetValue("FileAttachment", Guid.Empty); // Set default template ID if (templateId > 0) { node.DocumentPageTemplateID = templateId; } else { node.DocumentPageTemplateID = DataClass.ClassDefaultPageTemplateID; } // Insert the document DocumentHelper.InsertDocument(node, nodeId, tree); // Add the file DocumentHelper.AddAttachment(node, "FileAttachment", FileUpload.PostedFile, tree, ResizeToWidth, ResizeToHeight, ResizeToMaxSideSize); return(node); }
protected TreeNode ProcessDirectUploader(TreeProvider tree) { TreeNode node = null; // Create new document string fileName = Path.GetFileNameWithoutExtension(ucDirectUploader.AttachmentName); int maxFileNameLength = FileNameFieldInfo.Size; if (fileName.Length > maxFileNameLength) { fileName = fileName.Substring(0, maxFileNameLength); } node = TreeNode.New("CMS.File", tree); node.DocumentCulture = CMSContext.PreferredCultureCode; node.DocumentName = fileName; // Load default values FormHelper.LoadDefaultValues(node); if (node.ContainsColumn("FileDescription")) { node.SetValue("FileDescription", txtFileDescription.Text); } //node.SetValue("FileName", fileName); node.SetValue("FileAttachment", Guid.Empty); // Set default template ID if (templateId > 0) { node.DocumentPageTemplateID = templateId; } else { node.DocumentPageTemplateID = DataClass.ClassDefaultPageTemplateID; } // Insert the document DocumentHelper.InsertDocument(node, nodeId, tree); // Set the attachment GUID later - important when document is under workflow and using check-in/check-out node.SetValue("FileAttachment", ucDirectUploader.Value); return(node); }
/// <summary> /// Logs rating activity /// </summary> /// <param name="value">Rating value</param> private void LogActivity(double value) { if ((CMSContext.ViewMode != ViewModeEnum.LiveSite) || !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser)) { return; } string siteName = CMSContext.CurrentSiteName; if (!ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) || !ActivitySettingsHelper.ContentRatingEnabled(siteName)) { return; } bool logActivity = false; TreeNode currentDoc = CMSContext.CurrentDocument; if (currentDoc != null) { if (CMSContext.CurrentDocument.DocumentLogVisitActivity == null) { logActivity = ValidationHelper.GetBoolean(currentDoc.GetInheritedValue("DocumentLogVisitActivity", SiteInfoProvider.CombineWithDefaultCulture(siteName)), false); } else { logActivity = currentDoc.DocumentLogVisitActivity == true; } if (logActivity) { var data = new ActivityData() { ContactID = ModuleCommands.OnlineMarketingGetCurrentContactID(), SiteID = CMSContext.CurrentSiteID, Type = PredefinedActivityType.RATING, TitleData = String.Format("{0} ({1})", value.ToString(), currentDoc.DocumentName), URL = URLHelper.CurrentRelativePath, NodeID = currentDoc.NodeID, Value = value.ToString(), Culture = currentDoc.DocumentCulture, Campaign = CMSContext.Campaign }; ActivityLogProvider.LogActivity(data); } } }
protected void Page_Load(object sender, EventArgs e) { uniGrid.OnDataReload += uniGrid_OnDataReload; uniGrid.OnExternalDataBound += uniGrid_OnExternalDataBound; uniGrid.ShowActionsMenu = true; uniGrid.Columns = "NodeID, DocumentName, DocumentNamePath, DocumentCulture, DocumentModifiedWhen, ClassDisplayName, NodeChildNodesCount"; uniGrid.OnBeforeDataReload += uniGrid_OnBeforeDataReload; IDataClass nodeClass = DataClassFactory.NewDataClass("CMS.Tree"); DocumentInfo di = new DocumentInfo(); uniGrid.AllColumns = SqlHelperClass.MergeColumns(SqlHelperClass.MergeColumns(di.ColumnNames.ToArray()), SqlHelperClass.MergeColumns(nodeClass.ColumnNames.ToArray()));; nodeId = QueryHelper.GetInteger("nodeid", 0); serverId = QueryHelper.GetInteger("serverid", 0); if (nodeId > 0) { TreeNode node = TreeProvider.SelectSingleNode(nodeId); if (node != null) { if (node.NodeParentID > 0) { lnkUpperDoc.Attributes["onclick"] = "parent.frames['tasksTree'].RefreshNode(" + node.NodeParentID + "," + node.NodeParentID + ");window.location.href='" + ResolveUrl("~/CMSModules/Staging/Tools/Tasks/DocumentsList.aspx?serverid=") + serverId + "&nodeid=" + node.NodeParentID + "'; return false;"; imgUpperDoc.ImageUrl = GetImageUrl("Design/Controls/Tree/folderup.png"); } else { lnkUpperDoc.Attributes["onclick"] = "return false"; imgUpperDoc.ImageUrl = GetImageUrl("Design/Controls/Tree/folderupdisabled.png"); } string closeLink = "<a href=\"#\"><span class=\"ListingClose\" style=\"cursor: pointer;\" " + "onclick=\"parent.frames['tasksHeader'].selectDocuments = false; window.location.href='" + ResolveUrl("~/CMSModules/Staging/Tools/Tasks/Tasks.aspx?serverid=") + serverId + "&nodeid=" + nodeId + "';" + "var completeObj = parent.frames['tasksHeader'].document.getElementById('pnlComplete');" + "if (completeObj != null){ completeObj.style.display = 'block'; }" + "return false;\">" + GetString("general.close") + "</span></a>"; string docNamePath = "<span class=\"ListingPath\">" + node.DocumentNamePath + "</span>"; lblListingInfo.Text = String.Format(GetString("synchronization.listinginfo"), docNamePath, closeLink); } } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> protected void Page_Load(object sender, EventArgs e) { rfvDocumentName.ErrorMessage = GetString("om.enterdocumentname"); nodeID = QueryHelper.GetInteger("nodeId", 0); ucABTestSelector.NodeID = nodeID; // Get alias path tree = new TreeProvider(CMSContext.CurrentUser); node = tree.SelectSingleNode(nodeID); if (!URLHelper.IsPostback()) { if (node != null) { ucPath.Value = node.NodeAliasPath; } } }
/// <summary> /// Publishes sub documents of given node. /// </summary> /// <param name="parentNode">Parent node</param> /// <param name="tree">Tree provider</param> /// <param name="wm">Workflow manager</param> /// <param name="cultureCode">Culture code</param> /// <param name="siteName">Site name</param> /// <returns>TRUE if operation fails and whole process should be canceled.</returns> private bool PublishSubDocuments(TreeNode parentNode, TreeProvider tree, WorkflowManager wm, string cultureCode, string siteName) { // Get sub documents DataSet subDocuments = GetSubDocuments(parentNode, tree, cultureCode, siteName); if (!DataHelper.DataSourceIsEmpty(subDocuments)) { foreach (DataRow nodeRow in subDocuments.Tables[0].Rows) { if (PerformPublish(wm, tree, siteName, nodeRow)) { return(true); } } } return(false); }
/// <summary> /// CreateURL of current task from current document. /// </summary> private string CreateTaskURL() { String url = String.Empty; if (this.ProjectTaskObj != null) { if (this.ProjectTaskObj.ProjectTaskProjectID != 0) { // Find project node url ProjectInfo pi = ProjectInfoProvider.GetProjectInfo(this.ProjectTaskObj.ProjectTaskProjectID); if (pi != null) { TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); TreeNode treeNode = tree.SelectSingleNode(pi.ProjectNodeID); if (treeNode != null) { SiteInfo si = SiteInfoProvider.GetSiteInfo(pi.ProjectSiteID); if (si != null) { // Create absulte URL of project's node url = URLHelper.GetAbsoluteUrl(CMSContext.GetUrl(treeNode.NodeAliasPath, String.Empty, si.SiteName)); // Add projectID as parameter url = URLHelper.UpdateParameterInUrl(url, "projectid", this.ProjectTaskObj.ProjectTaskProjectID.ToString()); // Add taskID as parameter url = URLHelper.UpdateParameterInUrl(url, "taskid", this.ProjectTaskObj.ProjectTaskID.ToString()); } } } } else { // If Ad hoc task create url to current node url = URLHelper.GetAbsoluteUrl(URLHelper.CurrentURL); // Remove query url = URLHelper.RemoveQuery(url); // Add task ID url = URLHelper.UpdateParameterInUrl(url, "taskid", this.ProjectTaskObj.ProjectTaskID.ToString()); } } return(url); }
/// <summary> /// Handles the UniGrid's OnAction event. /// </summary> /// <param name="actionName">Name of item (button) that throws event</param> /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param> protected void ugRecycleBin_OnAction(string actionName, object actionArgument) { TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); VersionManager verMan = new VersionManager(tree); int versionHistoryId = ValidationHelper.GetInteger(actionArgument, 0); TreeNode doc = null; if (actionName == "restore") { try { if (IsAuthorizedPerDocument(versionHistoryId, "Create", currentUser, out doc, verMan)) { verMan.RestoreDocument(versionHistoryId, doc); lblInfo.Visible = true; lblInfo.Text = GetString("Recyclebin.RestorationOK"); } else { lblError.Visible = true; lblError.Text = String.Format(ResHelper.GetString("Recyclebin.RestorationFailedPermissions", currentCulture), doc.DocumentNamePath); } } catch (Exception ex) { lblError.Visible = true; lblError.Text = GetString("recyclebin.errorrestoringdocument") + " " + ex.Message; } } else if (actionName == "destroy") { if (IsAuthorizedPerDocument(versionHistoryId, "Destroy", currentUser, out doc, verMan)) { verMan.DestroyDocumentHistory(doc.DocumentID); lblInfo.Visible = true; lblInfo.Text = GetString("recyclebin.destroyok"); } else { lblError.Visible = true; lblError.Text = String.Format(ResHelper.GetString("recyclebin.destructionfailedpermissions", currentCulture), doc.DocumentNamePath); } } ugRecycleBin.ResetSelection(); }
/// <summary> /// Handles the OnAfterSave event of the EditForm control. /// </summary> protected void EditForm_OnAfterSave(object sender, EventArgs e) { if (UIFormControl.EditedObject != null) { // Clear cache CacheHelper.TouchKey("om.personalizationvariant|bytemplateid|" + (UIFormControl.EditedObject as ContentPersonalizationVariantInfo).VariantPageTemplateID); // Log widget variant synchronization ContentPersonalizationVariantInfo variantInfo = (ContentPersonalizationVariantInfo)UIFormControl.EditedObject; if (variantInfo.VariantDocumentID > 0) { // Log synchronization TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); TreeNode node = tree.SelectSingleDocument(variantInfo.VariantDocumentID); DocumentSynchronizationHelper.LogDocumentChange(node, TaskTypeEnum.UpdateDocument, tree); } } }
protected void Page_Load(object sender, EventArgs e) { int nodeId = QueryHelper.GetInteger("nodeid", 0); // Get current node TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); TreeNode node = tree.SelectSingleNode(nodeId); // Set edited document EditedDocument = node; frameHeader.Attributes.Add("src", "header.aspx" + URLHelper.Url.Query); if (CultureHelper.IsUICultureRTL()) { ControlsHelper.ReverseFrames(colsFrameset); } }
/// <summary> /// Returns the text of the specified region. /// </summary> /// <param name="aliasPath">Aliaspath of the region MenuItem</param> /// <param name="regionID">Region ID to get the text from</param> public static string GetEditableRegionText(string aliasPath, string regionID) { try { TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); TreeNode node = tree.SelectSingleNode(CMSContext.CurrentSiteName, aliasPath, CMSContext.PreferredCultureCode); if (node != null) { PageInfo pi = new PageInfo(); pi.LoadContentXml(Convert.ToString(node.GetValue("DocumentContent"))); return(Convert.ToString(pi.EditableRegions[regionID.ToLower()])); } } catch { } return(null); }
/// <summary> /// Redirects user to blog post page. /// </summary> private void RedirectToBlogPost() { TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); TreeNode node = tree.SelectSingleNode(postGuid, culture, CMSContext.CurrentSiteName); string path = null; // Check that requested blog post exists if (node != null) { path = CMSContext.GetUrl(node.NodeAliasPath); URLHelper.Redirect(path); } else { path = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSDefaultAliasPath"); URLHelper.Redirect(CMSContext.GetUrl(path)); } }
/// <summary> /// Undoes checkout for given node. /// </summary> /// <param name="tree">Tree provider</param> /// <param name="node">Node to undo checkout</param> /// <returns>FALSE when document is checked out and checkbox for undoing checkout is not checked</returns> private bool UndoPossibleCheckOut(TreeProvider tree, TreeNode node) { if (node.IsCheckedOut) { if (chkUndoCheckOut.Checked) { node.SetValue("DocumentCheckedOutByUserID", null); node.SetValue("DocumentCheckedOutAutomatically", null); node.SetValue("DocumentCheckedOutWhen", null); DocumentHelper.UpdateDocument(node, tree); } else { AddError(string.Format(ResHelper.GetString("content.checkedoutdocument"), HTMLHelper.HTMLEncode(node.NodeAliasPath + " (" + node.GetValue("DocumentCulture") + ")"))); return(false); } } return(true); }
/// <summary> /// Gets node name from guid. /// </summary> /// <param name="objGuid">Guid object</param> /// <param name="siteName">Site name</param> private string GetNodeName(string objGuid, string siteName) { Guid nodeGuid = ValidationHelper.GetGuid(objGuid, Guid.Empty); if (nodeGuid != Guid.Empty) { if (String.IsNullOrEmpty(siteName)) { siteName = CMSContext.CurrentSiteName; } TreeNode node = this.TreeProvider.SelectSingleNode(nodeGuid, TreeProvider.ALL_CULTURES, siteName); if (node != null) { return(node.NodeAliasPath); } } return(""); }
/// <summary> /// Archives sub documents of given node. /// </summary> /// <param name="parentNode">Parent node</param> /// <param name="tree">Tree provider</param> /// <param name="wm">Workflow manager</param> /// <param name="cultureCode">Culture code</param> /// <param name="siteName">Site name</param> /// <returns>TRUE if operation fails and whole process should be canceled.</returns> private bool ArchiveSubDocuments(TreeNode parentNode, TreeProvider tree, WorkflowManager wm, string cultureCode, string siteName) { DataSet subDocuments = GetSubDocuments(parentNode, tree, cultureCode, siteName); if (!DataHelper.DataSourceIsEmpty(subDocuments)) { foreach (DataRow nodeRow in subDocuments.Tables[0].Rows) { // Get the current document string aliasPath = ValidationHelper.GetString(nodeRow["NodeAliasPath"], string.Empty); if (PerformArchive(wm, tree, GetDocument(tree, siteName, nodeRow), aliasPath)) { return(true); } } } return(false); }
protected void Page_Load(object sender, EventArgs e) { int eventId = QueryHelper.GetInteger("eventId", 0); // Check if requested event exists TreeProvider mTree = new TreeProvider(); TreeNode mEventNode = mTree.SelectSingleNode(eventId); if ((mEventNode == null) || (mEventNode.NodeClassName.ToLower() != "cms.bookingevent")) { CMSPage.EditedObject = null; } emailSender.EventID = eventId; if (!URLHelper.IsPostback()) { emailSender.ReloadData(true); } emailSender.OnCheckPermissions += new CMSAdminControl.CheckPermissionsEventHandler(emailSender_OnCheckPermissions); }
/// <summary> /// Creates forum search index. /// </summary> /// <param name="departmentNode">Department node</param> private void CreateDepartmentForumSearchIndex(TreeNode departmentNode) { string codeName = "forums_department_" + departmentNode.NodeGUID; string departmentName = departmentNode.DocumentName; SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(codeName); if (sii == null) { // Create search index info sii = new SearchIndexInfo(); sii.IndexName = codeName; string suffix = " - Forums"; sii.IndexDisplayName = TextHelper.LimitLength(departmentName, 200 - suffix.Length, "") + suffix; sii.IndexAnalyzerType = AnalyzerTypeEnum.StandardAnalyzer; sii.IndexType = PredefinedObjectType.FORUM; sii.IndexIsCommunityGroup = false; // Create search index settings info SearchIndexSettingsInfo sisi = new SearchIndexSettingsInfo(); sisi.ID = Guid.NewGuid(); sisi.Type = SearchIndexSettingsInfo.TYPE_ALLOWED; sisi.SiteName = CMSContext.CurrentSiteName; sisi.ForumNames = "*_department_" + departmentNode.NodeGUID; // Create settings item SearchIndexSettings sis = new SearchIndexSettings(); // Update settings item sis.SetSearchIndexSettingsInfo(sisi); // Update xml value sii.IndexSettings = sis; SearchIndexInfoProvider.SetSearchIndexInfo(sii); // Assing to current website and current culture SearchIndexSiteInfoProvider.AddSearchIndexToSite(sii.IndexID, CMSContext.CurrentSiteID); CultureInfo ci = CultureInfoProvider.GetCultureInfo(departmentNode.DocumentCulture); SearchIndexCultureInfoProvider.AddSearchIndexCulture(sii.IndexID, ci.CultureID); } }
/// <summary> /// Reloads comment list. /// </summary> public void ReloadComments() { this.SetContext(); this.pnlComment.Visible = this.AreCommentsOpened; if (this.PostNode != null) { CurrentUserInfo currentUser = CMSContext.CurrentUser; // Check permissions for blog if (this.BlogProperties.CheckPermissions) { if (currentUser.IsAuthorizedPerDocument(this.PostNode, NodePermissionsEnum.Read) != AuthorizationResultEnum.Allowed) { this.Visible = false; return; } } ctrlCommentEdit.PostDocumentId = this.PostNode.DocumentID; ctrlCommentEdit.PostNodeId = this.PostNode.NodeID; ctrlCommentEdit.PostCulture = this.PostNode.DocumentCulture; if (!this.BlogProperties.StopProcessing) { // Get parent blog bool selectOnlyPublished = (CMSContext.ViewMode == ViewModeEnum.LiveSite); TreeNode blogNode = BlogHelper.GetParentBlog(this.AliasPath, this.SiteName, selectOnlyPublished); // Determine whether user is authorized to manage comments isUserAuthorized = BlogHelper.IsUserAuthorizedToManageComments(blogNode); // Get all post comments rptComments.DataSource = BlogCommentInfoProvider.GetPostComments(this.PostNode.DocumentID, !isUserAuthorized, isUserAuthorized, DisplayTrackbacks); rptComments.DataBind(); } } this.ReleaseContext(); }
private void CheckedChanged() { if (radSelect.Checked) { pnlSelect.Enabled = true; pnlSelect.Visible = true; ctrlProduct.Visible = false; pnlNew.Visible = false; } else { pnlSelect.Enabled = false; pnlSelect.Visible = false; ctrlProduct.Visible = true; pnlNew.Visible = true; // Set mappings TreeNode node = this.Node; if (node != null) { DataClassInfo dci = DataClassInfoProvider.GetDataClass(this.Node.NodeClassName); if (dci != null) { // Get the mapped values ctrlProduct.ProductName = ValidationHelper.GetString(node.GetValue(Convert.ToString(dci.SKUMappings["SKUName"])), ""); ctrlProduct.ProductPrice = ValidationHelper.GetDouble(node.GetValue(Convert.ToString(dci.SKUMappings["SKUPrice"])), 0); ctrlProduct.ProductWeight = ValidationHelper.GetDouble(node.GetValue(Convert.ToString(dci.SKUMappings["SKUWeight"])), 0); ctrlProduct.ProductHeight = ValidationHelper.GetDouble(node.GetValue(Convert.ToString(dci.SKUMappings["SKUHeight"])), 0); ctrlProduct.ProductWidth = ValidationHelper.GetDouble(node.GetValue(Convert.ToString(dci.SKUMappings["SKUWidth"])), 0); ctrlProduct.ProductDepth = ValidationHelper.GetDouble(node.GetValue(Convert.ToString(dci.SKUMappings["SKUDepth"])), 0); ctrlProduct.ProductDescription = ValidationHelper.GetString(node.GetValue(Convert.ToString(dci.SKUMappings["SKUDescription"])), ""); Guid guid = ValidationHelper.GetGuid(node.GetValue(Convert.ToString(dci.SKUMappings["SKUImagePath"])), Guid.Empty); ctrlProduct.ProductImagePath = ((guid != Guid.Empty) ? TreePathUtils.GetAttachmentUrl(guid, this.Node.NodeAlias) : ""); } } // prefill form with values from the document ctrlProduct.SetValues(); } }
protected void Page_Load(object sender, EventArgs e) { // check 'Manage servers' permission if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.staging", "ManageDocumentsTasks")) { RedirectToAccessDenied("cms.staging", "ManageDocumentsTasks"); } ltlScript.Text = ScriptHelper.GetScript("treeUrl = '" + ResolveUrl("~/CMSModules/Staging/Tools/Tasks/tree.aspx") + "';"); treeContent.NodeTextTemplate = "<span id=\"##NODEID##\" class=\"ContentTreeItem\" onclick=\"SelectNode(##NODEID##); return false;\">##ICON##<span class=\"Name\">##NODENAME##</span></span>"; treeContent.SelectedNodeTextTemplate = "<span id=\"##NODEID##\" class=\"ContentTreeSelectedItem\" onclick=\"SelectNode(##NODEID##); return false;\">##ICON##<span class=\"Name\">##NODENAME##</span></span>"; treeContent.MaxTreeNodeText = "<span id=\"##NODEID##\" class=\"ContentTreeItem\" onclick=\"SelectNode(##PARENTNODEID##, true); return false;\"><span class=\"Name\" style=\"font-style: italic;\">" + GetString("ContentTree.SeeListing") + "</span></span>"; // If no node specified, select root node id int nodeId = QueryHelper.GetInteger("nodeid", 0); if (nodeId <= 0) { // Get the root node TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); TreeNode rootNode = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/", TreeProvider.ALL_CULTURES, false, null, false); if (rootNode != null) { nodeId = rootNode.NodeID; } } // If nodeId set, init the list of the nodes to expand int expandNodeId = QueryHelper.GetInteger("expandnodeid", 0); treeContent.ExpandNodeID = expandNodeId; // Current Node ID treeContent.NodeID = nodeId; // Setup the current node script if (nodeId > 0) { ltlScript.Text += ScriptHelper.GetScript(" currentNodeId = " + nodeId + ";"); } }
void txtGuid_TextChanged(object sender, EventArgs e) { int nodeId = ValidationHelper.GetInteger(txtGuid.Text, 0); if (FieldIsInteger()) { txtName.Text = GetNodeName(nodeId); return; } if (nodeId > 0) { TreeNode node = this.TreeProvider.SelectSingleNode(nodeId, TreeProvider.ALL_CULTURES, true); if (node != null) { string site = (node.NodeSiteID != CMSContext.CurrentSiteID ? ";" + node.NodeSiteName : ""); txtName.Text = node.NodeAliasPath; txtGuid.Text = node.NodeGUID.ToString() + site; } } }
/// <summary> /// Loads the URL path to the UI /// </summary> private void LoadURLPath(TreeNode node) { ctrlURL.URLPath = node.DocumentUrlPath; txtExtensions.Enabled = chkCustomExtensions.Checked; if (isRoot) { txtAlias.Enabled = false; valAlias.Enabled = false; ctrlURL.Enabled = false; chkCustomExtensions.Enabled = false; } if (node.IsLink) { ctrlURL.Enabled = false; } }
private void SetAliasPath(object valueObj, bool isNodeId) { if (valueObj != null) { if (!isNodeId) { string[] split = valueObj.ToString().Split(';'); string siteName = null; // Check if site name is presented in value if (split.Length > 1) { siteName = split[1]; } else { if ((Form != null) && (Form.EditedObject != null)) { TreeNode editedNode = Form.EditedObject as TreeNode; if (editedNode != null) { int linkedSiteId = editedNode.OriginalNodeSiteID; if ((linkedSiteId > 0) && (linkedSiteId != CMSContext.CurrentSiteID)) { siteName = SiteInfoProvider.GetSiteName(linkedSiteId); } } } } if (ValidationHelper.GetGuid(split[0], Guid.Empty) != Guid.Empty) { this.txtName.Text = GetNodeName(split[0], siteName); } } else { this.txtName.Text = GetNodeName(ValidationHelper.GetInteger(valueObj, 0)); } } }
/// <summary> /// Check user permissions for document. /// </summary> /// <param name="document">Document</param> /// <param name="permission">Permissions</param> /// <param name="user">User</param> /// <returns>TreeNode if authorized, null otherwise</returns> public bool IsAuthorizedPerDocument(TreeNode document, string permission, CurrentUserInfo user) { // Initialize variables string className = null; // Check global permission bool userHasGlobalPerm = user.IsAuthorizedPerResource("CMS.Content", permission); // Get node properties try { // Get the values form deleted node className = document.NodeClassName; } catch (ThreadAbortException) { throw; } catch (Exception ex) { CurrentError = "Error occurred: " + ex.Message; AddLog(CurrentError); } bool additionalPermission = false; if (permission.ToLower() == "create") { additionalPermission = user.IsAuthorizedPerClassName(className, "CreateSpecific"); } // Check permissions if (userHasGlobalPerm || user.IsAuthorizedPerClassName(className, permission) || additionalPermission) { return(true); } return(false); }
/// <summary> /// Creates department forum group. /// </summary> /// <param name="departmentNode">Department node</param> private void CreateDepartmentForumGroup(TreeNode departmentNode) { // Set general values string departmentName = departmentNode.DocumentName; string suffix = ""; #region "Create forum group" // Get forum group code name string groupCodeName = "Department_" + departmentNode.NodeGUID; // Check if forum group with given name already exists if (ForumGroupInfoProvider.GetForumGroupInfo(groupCodeName, CMSContext.CurrentSiteID) != null) { return; } // Create base URL for forums string baseUrl = CMSContext.GetUrl(departmentNode.NodeAliasPath + "/" + FORUM_DOCUMENT_ALIAS); ForumGroupInfo forumGroupObj = new ForumGroupInfo(); forumGroupObj.GroupDescription = "Forum group for " + departmentName + " department."; suffix = " forum group"; forumGroupObj.GroupDisplayName = TextHelper.LimitLength(departmentName, 200 - suffix.Length, "") + suffix; forumGroupObj.GroupName = groupCodeName; forumGroupObj.GroupOrder = 0; forumGroupObj.GroupEnableQuote = true; forumGroupObj.GroupSiteID = CMSContext.CurrentSiteID; forumGroupObj.GroupBaseUrl = baseUrl; // Additional settings forumGroupObj.GroupEnableCodeSnippet = true; forumGroupObj.GroupEnableFontBold = true; forumGroupObj.GroupEnableFontColor = true; forumGroupObj.GroupEnableFontItalics = true; forumGroupObj.GroupEnableFontStrike = true; forumGroupObj.GroupEnableFontUnderline = true; forumGroupObj.GroupEnableQuote = true; forumGroupObj.GroupEnableURL = true; forumGroupObj.GroupEnableImage = true; ForumGroupInfoProvider.SetForumGroupInfo(forumGroupObj); #endregion #region "Create forum" string codeName = "Default_department_" + departmentNode.NodeGUID; // Check if forum with given name already exists if (ForumInfoProvider.GetForumInfo(codeName, CMSContext.CurrentSite.SiteID) != null) { return; } ForumInfo forumObj = new ForumInfo(); forumObj.ForumSiteID = CMSContext.CurrentSiteID; forumObj.ForumIsLocked = false; forumObj.ForumOpen = true; forumObj.ForumDisplayEmails = false; forumObj.ForumDescription = "Forum for " + departmentName + " department."; forumObj.ForumRequireEmail = false; suffix = " forum"; forumObj.ForumDisplayName = TextHelper.LimitLength(departmentName, 200 - suffix.Length, "") + suffix; forumObj.ForumName = codeName; forumObj.ForumGroupID = forumGroupObj.GroupID; forumObj.ForumModerated = false; forumObj.ForumAccess = 40000; forumObj.ForumPosts = 0; forumObj.ForumThreads = 0; forumObj.ForumPostsAbsolute = 0; forumObj.ForumThreadsAbsolute = 0; forumObj.ForumOrder = 0; forumObj.ForumUseCAPTCHA = false; forumObj.SetValue("ForumHTMLEditor", null); // Set security forumObj.AllowAccess = SecurityAccessEnum.AuthorizedRoles; forumObj.AllowAttachFiles = SecurityAccessEnum.AuthorizedRoles; forumObj.AllowMarkAsAnswer = SecurityAccessEnum.AuthorizedRoles; forumObj.AllowPost = SecurityAccessEnum.AuthorizedRoles; forumObj.AllowReply = SecurityAccessEnum.AuthorizedRoles; forumObj.AllowSubscribe = SecurityAccessEnum.AuthorizedRoles; if (ForumInfoProvider.LicenseVersionCheck(URLHelper.GetCurrentDomain(), FeatureEnum.Forums, VersionActionEnum.Insert)) { ForumInfoProvider.SetForumInfo(forumObj); } #endregion }
/// <summary> /// Copy documents section. /// </summary> /// <param name="source">Source document</param> /// <param name="targetParentId">ID of target parent document</param> /// <param name="tree">Tree provider</param> private void CopyDocumentSection(TreeNode source, int targetParentId, TreeProvider tree) { DocumentHelper.CopyDocument(source, targetParentId, true, tree); }
protected override void OnPreRender(EventArgs e) { AddScript("function LocalCheckIn(){" + Page.ClientScript.GetPostBackEventReference(btnCheckIn, null) + ";}"); // Load content to controls bool isMenuAction = false; foreach (Control control in menuElem.Controls) { if (control == invokeControl && control != menuElem.FindControl("btnSave")) { isMenuAction = true; } } // Get actualized content for undo checkout operation if (invokeControl == menuElem.FindControl("btnUndoCheckout")) { node = DocumentHelper.GetDocument(menuElem.NodeID, CMSContext.PreferredCultureCode, TreeProvider); content = GetContent(); if ((EditingForms)Convert.ToInt32(drpEditControl.SelectedValue) == EditingForms.EditableImage) { imageContent.LoadContent(content, true); } // Reload tree ltlScript.Text += ScriptHelper.GetScript("parent.frames['tree'].location.replace('" + ResolveUrl("~/CMSModules/Content/CMSDesk/Properties/Advanced/EditableContent/tree.aspx") + "?nodeid=" + nodeId + "&selectednodename=" + txtName.Text.Trim() + "&selectednodetype=" + keyType + "');"); } // Load content to text fields if (!RequestHelper.IsPostBack() || invokeControl == drpEditControl || isMenuAction) { txtAreaContent.Text = content; htmlContent.ResolvedValue = content; txtContent.Text = content; } if (menuElem.AllowEdit && menuElem.AllowSave) { ScriptHelper.RegisterShortcuts(this); SetEnableMode(true); LoadImageData(ViewModeEnum.Edit); } else { SetEnableMode(false); LoadImageData(ViewModeEnum.EditDisabled); } if (!string.IsNullOrEmpty(keyName)) { // Prepare script for refresh menu in Tree string script = "parent.frames['tree'].location.replace('" + ResolveUrl("~/CMSModules/Content/CMSDesk/Properties/Advanced/EditableContent/tree.aspx") + "?nodeid=" + nodeId + "&selectednodename=" + keyName + "&selectednodetype=" + keyType + "');"; // Script for UpdateMenu int Tree ScriptHelper.RegisterStartupScript(this, typeof(string), "RefreshTree", ScriptHelper.GetScript(script)); } if (!IsAuthorizedToModify()) { SetEnableMode(false); } lblWorkflow.Text = menuElem.WorkflowInfo; lblWorkflow.Visible = !string.IsNullOrEmpty(lblWorkflow.Text); base.OnPreRender(e); }
protected void Page_Load(object sender, EventArgs e) { if (!RequestHelper.IsPostBack()) { // Fill dropdown list InitEditorOptions(); // Inform user about saving if (QueryHelper.GetBoolean("imagesaved", false)) { lblInfo.Text = GetString("general.changessaved"); lblInfo.Visible = true; drpEditControl.SelectedIndex = 1; } } // Initialize HTML editor InitHTMLEditor(); // Find postback invoker string invokerName = Page.Request.Params.Get("__EVENTTARGET"); invokeControl = !string.IsNullOrEmpty(invokerName) ? Page.FindControl(invokerName) : null; // Set whether new item is to be created createNew = QueryHelper.GetBoolean("createNew", false); if (invokerName != null) { if (createNew && (invokeControl == drpEditControl)) { createNew = true; } else { if (invokeControl == drpEditControl) { createNew = false; lblInfo.Text = string.Empty; lblInfo.Visible = false; } } } // Get query parameters keyName = QueryHelper.GetString("nodename", string.Empty); nodeId = QueryHelper.GetInteger("nodeid", 0); // Set editable content type enum switch (QueryHelper.GetString("nodetype", "webpart")) { case "webpart": keyType = EditableContentType.webpart; break; case "region": keyType = EditableContentType.region; break; } // Get node node = DocumentHelper.GetDocument(nodeId, CMSContext.PreferredCultureCode, TreeProvider); // Set edited document EditedDocument = node; // Initialize javascripts ltlScript.Text += ScriptHelper.GetScript("mainUrl = '" + ResolveUrl("~/CMSModules/Content/CMSDesk/Properties/Advanced/EditableContent/main.aspx") + "?nodeid=" + nodeId + "';"); lblError.Visible = false; // Show editing controls if ((createNew || keyName != string.Empty)) { pnlMenu.Visible = true; menuElem.AllowSave = IsAuthorizedToModify(); pnlEditableContent.Visible = true; } // Get content if ((node != null) && (keyName != string.Empty) || createNew) { if (!RequestHelper.IsPostBack() && !createNew) { txtName.Text = MultiKeyHashtable.GetFirstKey(keyName); } if (!createNew) { content = GetContent(); // Disable HTML editor if content is typeof image if (content != null) { if (content.StartsWith("<image>")) { ListItem li = drpEditControl.Items.FindByValue(Convert.ToInt32(EditingForms.HTMLEditor).ToString()); if (li != null) { drpEditControl.Items.Remove(li); } } } } } // Hide all content controls txtAreaContent.Visible = txtContent.Visible = htmlContent.Visible = imageContent.Visible = false; // Set up editing forms switch (((EditingForms)Convert.ToInt32(drpEditControl.SelectedValue))) { case EditingForms.TextArea: txtAreaContent.Visible = true; break; case EditingForms.HTMLEditor: htmlContent.Visible = true; break; case EditingForms.EditableImage: imageContent.Visible = true; imageContent.ImageTitle = HTMLHelper.HTMLEncode(MultiKeyHashtable.GetFirstKey(keyName)); break; case EditingForms.TextBox: txtContent.Visible = true; break; } lblContent.Visible = txtContent.Visible; }
/// <summary> /// Delete documents section. /// </summary> /// <param name="node">Node to be deleted</param> /// <param name="tree">Tree provider</param> private void DeleteDocumentSection(TreeNode node, TreeProvider tree) { // Delete all document cultures DocumentHelper.DeleteDocument(node, tree, true, false, false); }
/// <summary> /// Processes the given action. /// </summary> /// <param name="node">Node to process</param> /// <param name="targetNode">Target node</param> /// <param name="action">Action to process</param> /// <param name="childNodes">Process also child nodes</param> /// <param name="throwExceptions">If true, the exceptions are thrown</param> /// <param name="copyPermissions">Indicates if permissions should be copied</param> protected TreeNode ProcessAction(TreeNode node, TreeNode targetNode, string action, bool childNodes, bool throwExceptions, bool copyPermissions) { int nodeId = node.NodeID; int targetId = targetNode.NodeID; action = action.ToLower(); bool first = action.EndsWith("first"); // Perform the action switch (action) { case "linknodefirst": case "linknodeposition": { try { // Set the parent ID int newPosition = 1; if ((targetNode.NodeClassName.ToLower() != "cms.root") && !first) { // Init the node orders in parent TreeProvider.InitNodeOrders(targetNode.NodeParentID); targetNode = TreeProvider.SelectSingleNode(targetId); // Get the target order and real parent ID int newTargetId = targetNode.NodeParentID; newPosition = targetNode.NodeOrder + 1; targetNode = TreeProvider.SelectSingleNode(newTargetId); } // Link the node TreeNode newNode = LinkNode(node, targetNode, TreeProvider, copyPermissions, childNodes); if (newNode != null) { nodeId = newNode.NodeID; // Reposition the node if (newPosition == 1) { // First position int newOrder = TreeProvider.SetNodeOrder(nodeId, DocumentOrderEnum.First); newNode.SetValue("NodeOrder", newOrder); } else { targetNode = TreeProvider.SelectSingleNode(targetId); newPosition = targetNode.NodeOrder + 1; // After the target TreeProvider.SetNodeOrder(nodeId, newPosition, false); newNode.SetValue("NodeOrder", newPosition); } } return newNode; } catch (Exception ex) { EventLogProvider.LogException("Content", "LINKDOC", ex); AddError(GetString("ContentRequest.LinkFailed")); if (throwExceptions) { throw; } return null; } } case "linknode": { try { // Link the node TreeNode newNode = LinkNode(node, targetNode, TreeProvider, copyPermissions, childNodes); if (newNode != null) { // Set default position int newOrder = TreeProvider.SetNodeOrder(newNode.NodeID, DocumentOrderEnum.First); newNode.SetValue("NodeOrder", newOrder); } return newNode; } catch (Exception ex) { EventLogProvider.LogException("Content", "LINKDOC", ex); AddError(GetString("ContentRequest.LinkFailed")); if (throwExceptions) { throw; } return null; } } case "copynodefirst": case "copynodeposition": { try { // Set the parent ID int newPosition = 1; if ((targetNode.NodeClassName.ToLower() != "cms.root") && !first) { // Init the node orders in parent TreeProvider.InitNodeOrders(targetNode.NodeParentID); targetNode = TreeProvider.SelectSingleNode(targetId); // Get the target order and real parent ID int newTargetId = targetNode.NodeParentID; newPosition = targetNode.NodeOrder + 1; targetNode = TreeProvider.SelectSingleNode(newTargetId); } // Copy the node TreeNode newNode = CopyNode(node, targetNode, childNodes, TreeProvider, copyPermissions); if (newNode != null) { nodeId = newNode.NodeID; // Reposition the node if (newPosition == 1) { // First position int newOrder = TreeProvider.SetNodeOrder(nodeId, DocumentOrderEnum.First); newNode.SetValue("NodeOrder", newOrder); } else { targetNode = TreeProvider.SelectSingleNode(targetId); newPosition = targetNode.NodeOrder + 1; // After the target TreeProvider.SetNodeOrder(nodeId, newPosition, false); newNode.SetValue("NodeOrder", newPosition); } return newNode; } } catch (Exception ex) { EventLogProvider.LogException("Content", "COPYDOC", ex); AddError(GetString("ContentRequest.CopyFailed")); if (throwExceptions) { throw; } return null; } } break; case "copynode": { try { // Copy the node TreeNode newNode = CopyNode(node, targetNode, childNodes, TreeProvider, copyPermissions); if (newNode != null) { // Set default position int newOrder = TreeProvider.SetNodeOrder(newNode.NodeID, DocumentOrderEnum.First); newNode.SetValue("NodeOrder", newOrder); } return newNode; } catch (Exception ex) { EventLogProvider.LogException("Content", "COPYDOC", ex); AddError(GetString("ContentRequest.CopyFailed")); if (throwExceptions) { throw; } return null; } } case "movenodefirst": case "movenodeposition": { try { // Check the permissions for document if (CurrentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Allowed) { // Set the parent ID int newPosition = 1; if ((targetNode.NodeClassName.ToLower() != "cms.root") && !first) { // Init the node orders in parent TreeProvider.InitNodeOrders(targetNode.NodeParentID); targetNode = TreeProvider.SelectSingleNode(targetId); // Get the target order and real parent ID int newTargetId = targetNode.NodeParentID; newPosition = targetNode.NodeOrder + 1; targetNode = TreeProvider.SelectSingleNode(newTargetId); } // Move the node under the correct parent if (((node.NodeOrder != newPosition) || (node.NodeParentID != targetNode.NodeID)) && MoveNode(node, targetNode, TreeProvider, copyPermissions)) { if (targetNode.NodeID == nodeId) { return null; } // Reposition the node if (newPosition == 1) { // First position int newOrder = TreeProvider.SetNodeOrder(nodeId, DocumentOrderEnum.First); node.SetValue("NodeOrder", newOrder); } else { // After the target TreeProvider.SetNodeOrder(nodeId, newPosition, false); node.SetValue("NodeOrder", newPosition); } return node; } } else { string encodedAliasPath = " (" + HTMLHelper.HTMLEncode(node.NodeAliasPath) + ")"; AddError(GetString("ContentRequest.NotAllowedToMove") + encodedAliasPath); } } catch (Exception ex) { EventLogProvider.LogException("Content", "MOVEDOC", ex); AddError(GetString("ContentRequest.MoveFailed")); if (throwExceptions) { throw; } return null; } } break; case "movenode": { try { // Move the node if (MoveNode(node, targetNode, TreeProvider, copyPermissions)) { // Set default position int newOrder = TreeProvider.SetNodeOrder(nodeId, DocumentOrderEnum.First); node.SetValue("NodeOrder", newOrder); return node; } } catch (Exception ex) { EventLogProvider.LogException("Content", "MOVEDOC", ex); AddError(GetString("ContentRequest.MoveFailed")); if (throwExceptions) { throw; } return null; } } break; } return null; }
protected void Page_Load(object sender, EventArgs e) { // Check UI Analytics.Settings CurrentUserInfo ui = CMSContext.CurrentUser; if (!ui.IsAuthorizedPerUIElement("CMS.Content", "Analytics.Settings")) { RedirectToCMSDeskUIElementAccessDenied("CMS.Content", "Analytics.Settings"); } // Display disabled information if (!AnalyticsHelper.AnalyticsEnabled(CMSContext.CurrentSiteName)) { this.pnlWarning.Visible = true; this.lblWarning.Text = ResHelper.GetString("WebAnalytics.Disabled"); } ucConversionSelector.SelectionMode = SelectionModeEnum.SingleTextBox; ucConversionSelector.IsLiveSite = false; nodeID = QueryHelper.GetInteger("nodeid", 0); mSave = GetString("general.save"); UIContext.AnalyticsTab = AnalyticsTabEnum.Settings; tree = new TreeProvider(CMSContext.CurrentUser); node = tree.SelectSingleNode(nodeID, CMSContext.PreferredCultureCode, tree.CombineWithDefaultCulture); if (ui.IsAuthorizedPerDocument(node, NodePermissionsEnum.Read) == AuthorizationResultEnum.Denied) { RedirectToAccessDenied(String.Format(GetString("cmsdesk.notauthorizedtoreaddocument"), node.NodeAliasPath)); } // Check modify permissions else if (ui.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied) { lblInfo.Visible = true; lblInfo.Text = String.Format(GetString("cmsdesk.notauthorizedtoeditdocument"), node.NodeAliasPath); // Disable save button btnSave.Enabled = false; usSelectCampaign.Enabled = false; } if (node != null) { if (!URLHelper.IsPostback()) { ReloadData(); } } }
protected void lnkSave_Click(object sender, EventArgs e) { // Get the document TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); node = tree.SelectSingleNode(nodeId, CMSContext.PreferredCultureCode); if (node != null) { // Check modify permissions if (CMSContext.CurrentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied) { return; } bool correct = true; // OWNER group is displayed by UI profile if (!this.pnlUIOwner.IsHidden) { // Set owner int ownerId = ValidationHelper.GetInteger(usrOwner.Value, 0); if (ownerId > 0) { node.SetValue("NodeOwner", usrOwner.Value); } else { node.SetValue("NodeOwner", null); } } // Search node.DocumentSearchExcluded = chkExcludeFromSearch.Checked; // DESIGN group is displayed by UI profile if (!this.pnlUIDesign.IsHidden) { node.SetValue("DocumentStylesheetID", -1); if (!chkCssStyle.Checked) { // Set stylesheet int selectedCssId = ValidationHelper.GetInteger(ctrlSiteSelectStyleSheet.Value, 0); if (selectedCssId < 1) { node.SetValue("DocumentStylesheetID", null); } else { node.SetValue("DocumentStylesheetID", selectedCssId); } ctrlSiteSelectStyleSheet.CurrentDropDown.Enabled = true; } else { ctrlSiteSelectStyleSheet.CurrentDropDown.Enabled = false; } } // CACHE group is displayed by UI profile bool clearCache = false; if (!this.pnlUICache.IsHidden) { // Cache minutes int cacheMinutes = 0; if (radNo.Checked) { cacheMinutes = 0; txtCacheMinutes.Text = ""; } else if (radYes.Checked) { cacheMinutes = ValidationHelper.GetInteger(txtCacheMinutes.Text, -5); if (cacheMinutes <= 0) { correct = false; } } else if (radInherit.Checked) { cacheMinutes = -1; txtCacheMinutes.Text = ""; } // Set cache minutes if (cacheMinutes != node.NodeCacheMinutes) { node.NodeCacheMinutes = cacheMinutes; clearCache = true; } } if (correct) { node.DocumentLogVisitActivity = (chkPageVisitInherit.Checked ? (bool?)null : chkLogPageVisit.Checked); // Save the data node.Update(); // Update search index for node if ((node.PublishedVersionExists) && (SearchIndexInfoProvider.SearchEnabled)) { SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Update, PredefinedObjectType.DOCUMENT, SearchHelper.ID_FIELD, node.GetSearchID()); } // Log synchronization DocumentSynchronizationHelper.LogDocumentChange(node, TaskTypeEnum.UpdateDocument, tree); // Clear cache if cache settings changed if (clearCache) { node.ClearOutputCache(true, true); } lblInfo.Text = GetString("General.ChangesSaved"); lblInfo.Visible = true; ReloadData(); } else { // Show error message lblError.Text = GetString("GeneralProperties.BadCacheMinutes"); lblError.Visible = true; } } }
/// <summary> /// Checks whether the user is authorized to delete document. /// </summary> /// <param name="node">Document node</param> /// <param name="siteName">Site name</param> protected bool IsUserAuthorizedToDeleteDocument(TreeNode node, string siteName) { // Check delete permission for document return (currentUser.IsAuthorizedPerDocument(node, new NodePermissionsEnum[] { NodePermissionsEnum.Delete, NodePermissionsEnum.Read }, siteName) == AuthorizationResultEnum.Allowed); }
/// <summary> /// Ensures that loaded site is really the one selected in the drop-down list. /// </summary> private void EnsureLoadedSite() { if (SourceType != MediaSourceEnum.DocumentAttachments) { siteSelector.Reload(true); // Name of the site selected in the site DDL string siteName = ""; int siteId = siteSelector.SiteID; if (siteId > 0) { SiteInfo si = SiteInfoProvider.GetSiteInfo(siteId); if (si != null) { siteName = si.SiteName; } } if (siteName != SiteName) { SiteName = siteName; // Get site root by default TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); if (tree != null) { TreeNodeObj = tree.SelectSingleNode(SiteName, "/", null, false, "cms.root", null, null, 1, true, TreeProvider.SELECTNODES_REQUIRED_COLUMNS); NodeID = TreeNodeObj.NodeID; InitializeContentTree(); contentTree.NodeID = NodeID; contentTree.ExpandNodeID = NodeID; EnsureLoadedData(); } } } }
/// <summary> /// Check user permissions for document. /// </summary> /// <param name="document">Document</param> /// <param name="permission">Permissions</param> /// <param name="user">User</param> /// <returns>TreeNode if authorized, null otherwise</returns> public bool IsAuthorizedPerDocument(TreeNode document, string permission, CurrentUserInfo user) { // Initialize variables string className = null; // Check global permission bool userHasGlobalPerm = user.IsAuthorizedPerResource("CMS.Content", permission); // Get node properties try { // Get the values form deleted node className = document.NodeClassName; } catch (ThreadAbortException) { throw; } catch (Exception ex) { CurrentError = "Error occurred: " + ex.Message; AddLog(CurrentError); } bool additionalPermission = false; if (permission.ToLower() == "create") { additionalPermission = user.IsAuthorizedPerClassName(className, "CreateSpecific"); } // Check permissions if (userHasGlobalPerm || user.IsAuthorizedPerClassName(className, permission) || additionalPermission) { return true; } return false; }
/// <summary> /// Check user permissions for document version. /// </summary> /// <param name="versionId">Document version</param> /// <param name="permission">Permission</param> /// <param name="user">User</param> /// <param name="checkedNode">Checked node</param> /// <param name="versionManager">Version manager</param> /// <returns>True if authorized, false otherwise</returns> public bool IsAuthorizedPerDocument(int versionId, string permission, CurrentUserInfo user, out TreeNode checkedNode, VersionManager versionManager) { if (versionManager == null) { TreeProvider tree = new TreeProvider(user); tree.AllowAsyncActions = false; versionManager = new VersionManager(tree); } // Get the values form deleted node checkedNode = versionManager.GetVersion(versionId); return IsAuthorizedPerDocument(checkedNode, permission, user); }
/// <summary> /// Ensures the given node within the tree. /// </summary> /// <param name="node">Node to ensure</param> /// <param name="nodeId">Ensure by NodeID</param> protected void EnsureNode(TreeNode node, int nodeId) { if (node == null) { // If not already exists, do not add if (allNodes[nodeId] != null) { return; } else { // Get the node node = TreeProvider.SelectSingleNode(nodeId, TreeProvider.ALL_CULTURES, true); if (!SelectPublishedData) { node = DocumentHelper.GetDocument(node, TreeProvider); } } } else { nodeId = node.NodeID; } if (node != null) { // Get the correct parent node System.Web.UI.WebControls.TreeNode parentNode = (System.Web.UI.WebControls.TreeNode)allNodes[node.NodeParentID]; if (parentNode != null) { // Expand the parent parentNode.Expanded = true; // If still not present, add the node if (allNodes[nodeId] == null) { TreeSiteMapNode sourceNode = new TreeSiteMapNode(MapProvider, nodeId.ToString()); sourceNode.TreeNode = node; System.Web.UI.WebControls.TreeNode newNode = CreateNode(sourceNode, 0, true); parentNode.ChildNodes.Add(newNode); } } else { // Get the correct node and add it to list of processed nodes TreeSiteMapNode targetNode = MapProvider.GetNodeByAliasPath(node.NodeAliasPath); if (targetNode != null) { ArrayList procNodes = new ArrayList(); procNodes.Add(targetNode.NodeData["NodeID"]); if (targetNode.ParentNode != null) { // Repeat until existing parent node in allNodes is found do { int targetParentNodeId = (int)((TreeSiteMapNode)targetNode.ParentNode).NodeData["NodeID"]; procNodes.Add(targetParentNodeId); targetNode = (TreeSiteMapNode)targetNode.ParentNode; } while ((targetNode.ParentNode != null) && (allNodes[(int)(((TreeSiteMapNode)(targetNode.ParentNode)).NodeData["NodeID"])] == null)); } // Process nodes in reverse order procNodes.Reverse(); foreach (int nodeID in procNodes) { EnsureNode(null, nodeID); } } } } return; }
/// <summary> /// Publishes document. /// </summary> /// <param name="node">Node to publish</param> /// <param name="wm">Workflow manager</param> /// <returns>Whether node is already published</returns> private static bool Publish(TreeNode node, WorkflowManager wm) { WorkflowStepInfo currentStep = wm.GetStepInfo(node); bool toReturn = true; if (currentStep != null) { // For archive step start new version if (currentStep.StepName.ToLower() == "archived") { VersionManager vm = new VersionManager(node.TreeProvider); currentStep = vm.CheckOut(node, node.IsPublished, true); vm.CheckIn(node, null, null); } // Remove possible checkout if (node.GetIntegerValue("DocumentCheckedOutByUserID") > 0) { TreeProvider.ClearCheckoutInformation(node); node.Update(); } // Approve until the document is published while ((currentStep != null) && (currentStep.StepName.ToLower() != "published")) { currentStep = wm.MoveToNextStep(node, string.Empty); toReturn = false; } } return toReturn; }
/// <summary> /// Links 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="copyPermissions">Indicates if node permissions should be copied</param> /// <param name="childNodes">Indicates whether to link also child nodes</param> protected TreeNode LinkNode(TreeNode node, TreeNode targetNode, TreeProvider tree, bool copyPermissions, bool childNodes) { string encodedAliasPath = " (" + HTMLHelper.HTMLEncode(node.NodeAliasPath) + ")"; int targetId = targetNode.NodeID; // Check create permission if (!IsUserAuthorizedToCopyOrLink(node, targetId, node.NodeClassName)) { AddError(GetString("ContentRequest.NotAllowedToLink") + encodedAliasPath); return null; } // Check allowed child class 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 null; } // Determine whether any child nodes are present bool includeChildNodes = (node.NodeChildNodesCount > 0) && childNodes; // Document can't be copied under itself if child nodes are present if ((node.NodeID == targetNode.NodeID) && includeChildNodes) { AddError(GetString("ContentRequest.CannotLinkToItself") + encodedAliasPath); return null; } string domainToCheck = null; if (targetNode.NodeSiteID == node.NodeSiteID) { domainToCheck = URLHelper.GetCurrentDomain(); } else { SiteInfo targetSite = SiteInfoProvider.GetSiteInfo(targetNode.NodeSiteID); 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 null; } // Check cyclic linking (linking of the node to some of its child nodes) if ((targetNode.NodeSiteID == node.NodeSiteID) && (targetNode.NodeAliasPath.TrimEnd('/') + "/").StartsWith(node.NodeAliasPath + "/", StringComparison.CurrentCultureIgnoreCase) && includeChildNodes) { AddError(GetString("ContentRequest.CannotLinkToChild")); return null; } // Copy the document AddLog(HTMLHelper.HTMLEncode(node.NodeAliasPath)); DocumentHelper.InsertDocumentAsLink(node, targetId, tree, includeChildNodes, copyPermissions); SetExpandedNode(node.NodeParentID); return node; }
/// <summary> /// Checks if current use can moddify the perrmission. /// </summary> /// <param name="redirect">If true and can't moddify the user is redirected to denied page</param> /// <param name="currentNode">Node to examine</param> /// <param name="currentUser">Current user</param> private bool CanModifyPermission(bool redirect, TreeNode currentNode, CurrentUserInfo currentUser) { bool hasPermission = false; if (currentNode != null) { hasPermission = (currentUser.IsAuthorizedPerDocument(currentNode, NodePermissionsEnum.ModifyPermissions) == AuthorizationResultEnum.Allowed); // If hasn't permission and resirect enabled if (!hasPermission) { if (redirect) { RedirectToAccessDenied(String.Format(GetString("cmsdesk.notauthorizedtoeditdocument"), currentNode.NodeAliasPath)); } else { pnlAccessPart.Enabled = false; btnRadOk.Enabled = false; pnlInheritance.Enabled = false; lnkInheritance.Visible = false; // Display message lblPermission.Visible = true; lblPermission.Text = String.Format(GetString("cmsdesk.notauthorizedtoeditdocument"), Node.NodeAliasPath); } } } return hasPermission; }
/// <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; }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (this.StopProcessing || CMSContext.CurrentDocument == null || CMSContext.CurrentDocument.NodeClassName.ToLower() != "cms.bookingevent") { // Do nothing this.Visible = false; } else { // Get current event document EventNode = CMSContext.CurrentDocument; // Get event date, open from/to, capacity and possibility to register over capacity information eventDate = ValidationHelper.GetDateTime(EventNode.GetValue("EventDate"), DataHelper.DATETIME_NOT_SELECTED); openFrom = ValidationHelper.GetDateTime(EventNode.GetValue("EventOpenFrom"), DataHelper.DATETIME_NOT_SELECTED); openTo = ValidationHelper.GetDateTime(EventNode.GetValue("EventOpenTo"), DataHelper.DATETIME_NOT_SELECTED); capacity = ValidationHelper.GetInteger(EventNode.GetValue("EventCapacity"), 0); allowRegistrationOverCapacity = ValidationHelper.GetBoolean(EventNode.GetValue("EventAllowRegistrationOverCapacity"), false); // Display registration section DisplayRegistration(); // Display link to iCalendar file which adds this event to users Outlook if (this.AllowExportToOutlook) { TimeZoneInfo tzi = null; CMSContext.GetDateTimeForControl(this, DateTime.Now, out tzi); string timeZoneId = string.Empty; if (tzi != null) { timeZoneId = "&timezoneid=" + tzi.TimeZoneID; } lnkOutlook.NavigateUrl = "~/CMSModules/EventManager/CMSPages/AddToOutlook.aspx?eventid=" + EventNode.NodeID.ToString() + timeZoneId; lnkOutlook.Target = "_blank"; lnkOutlook.Text = GetString("eventmanager.exporttooutlook"); lnkOutlook.Visible = true; } } }
protected void gridDocs_OnAction(string actionName, object actionArgument) { switch (actionName.ToLower()) { case "delete": int deleteNodeId = ValidationHelper.GetInteger(actionArgument, 0); if (deleteNodeId > 0) { // Get the document if (tree == null) { tree = new TreeProvider(currentUser); } TreeNode deleteNode = tree.SelectSingleNode(deleteNodeId, TreeProvider.ALL_CULTURES); if ((deleteNode != null) && (node != null)) { try { // Get deleted node site name string siteName = CMSContext.CurrentSiteName; if (node.NodeSiteID != deleteNode.NodeSiteID) { SiteInfo si = SiteInfoProvider.GetSiteInfo(deleteNode.NodeSiteID); if (si != null) { siteName = si.SiteName; } } // Check user permissions if (IsUserAuthorizedToDeleteDocument(deleteNode, siteName)) { // Delete the document DocumentHelper.DeleteDocument(deleteNode, tree, false, false, false); if ((deleteNode.NodeSiteID == node.NodeSiteID) && (node.NodeAliasPath.StartsWith(deleteNode.NodeAliasPath, StringComparison.CurrentCulture))) { ltlScript.Text += ScriptHelper.GetScript("SelectItem(" + deleteNode.NodeParentID + ", " + deleteNode.NodeParentID + ");"); } else { gridDocs.ReloadData(); ltlScript.Text += ScriptHelper.GetScript("RefreshTree(" + nodeParentId + ", " + nodeId + ");"); } } else { lblError.Text = String.Format(GetString("cmsdesk.notauthorizedtodeletedocument"), HTMLHelper.HTMLEncode(deleteNode.NodeAliasPath)); lblError.Visible = true; } } catch (Exception ex) { lblError.Text = GetString("ContentRequest.DeleteFailed") + " : " + ex.Message; lblError.Visible = true; } // If node no longer present, refresh node = tree.SelectSingleNode(nodeId, TreeProvider.ALL_CULTURES); if (node == null) { if (lblError.Text != "") { ltlScript.Text += ScriptHelper.GetAlertScript(lblError.Text); lblError.Text = ""; lblError.Visible = false; } ltlScript.Text += ScriptHelper.GetScript("SelectItem(" + nodeId + ", " + nodeId + ");"); } } } break; } }
protected void Page_Load(object sender, EventArgs e) { // Register the scripts ScriptHelper.RegisterProgress(this.Page); ScriptHelper.RegisterTooltip(this.Page); ScriptHelper.RegisterDialogScript(this); // Set user control properties usrOwner = this.Page.LoadControl("~/CMSModules/Membership/FormControls/Users/selectuser.ascx") as FormEngineUserControl; usrOwner.ID = "ctrlUsrOwner"; usrOwner.IsLiveSite = false; usrOwner.SetValue("ShowSiteFilter", false); usrOwner.StopProcessing = this.pnlUIOwner.IsHidden; plcUsrOwner.Controls.Add(usrOwner); UIContext.PropertyTab = PropertyTabEnum.General; nodeId = QueryHelper.GetInteger("nodeid", 0); // Init strings pnlDesign.GroupingText = GetString("GeneralProperties.DesignGroup"); pnlCache.GroupingText = GetString("GeneralProperties.CacheGroup"); pnlOther.GroupingText = GetString("GeneralProperties.OtherGroup"); pnlAdvanced.GroupingText = GetString("GeneralProperties.AdvancedGroup"); pnlOwner.GroupingText = GetString("GeneralProperties.OwnerGroup"); // Advanced section mEditableContent = GetString("GeneralProperties.EditableContent"); mForums = GetString("PageProperties.AdHocForum"); mMessageBoards = GetString("PageProperties.MessageBoards"); lnkEditableContent.OnClientClick = "ShowEditableContent(); return false;"; lnkMessageBoards.OnClientClick = "ShowMessageBoards(); return false;"; lnkForums.OnClientClick = "ShowForums(); return false;"; imgEditableContent.ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditableContent/editablecontent.png"); imgMessageBoards.ImageUrl = GetImageUrl("CMSModules/CMS_MessageBoards/module.png"); imgForums.ImageUrl = GetImageUrl("CMSModules/CMS_Forums/module.png"); // Get strings for radio buttons radInherit.Text = GetString("GeneralProperties.radInherit"); radYes.Text = GetString("general.yes"); radNo.Text = GetString("general.no"); lblCacheMinutes.Text = GetString("GeneralProperties.cacheMinutes"); // Get strings for labels lblNameTitle.Text = GetString("GeneralProperties.Name"); lblNamePathTitle.Text = GetString("GeneralProperties.NamePath"); lblAliasPathTitle.Text = GetString("GeneralProperties.AliasPath"); lblTypeTitle.Text = GetString("GeneralProperties.Type"); lblNodeIDTitle.Text = GetString("GeneralProperties.NodeID"); lblLastModifiedByTitle.Text = GetString("GeneralProperties.LastModifiedBy"); lblLastModifiedTitle.Text = GetString("GeneralProperties.LastModified"); lblLiveURLTitle.Text = GetString("GeneralProperties.LiveURL"); lblPreviewURLTitle.Text = GetString("GeneralProperties.PreviewURL"); lblGUIDTitle.Text = GetString("GeneralProperties.GUID"); lblDocGUIDTitle.Text = GetString("GeneralProperties.DocumentGUID"); lblDocIDTitle.Text = GetString("GeneralProperties.DocumentID"); lblCultureTitle.Text = GetString("GeneralProperties.Culture"); lblCreatedByTitle.Text = GetString("GeneralProperties.CreatedBy"); lblCreatedTitle.Text = GetString("GeneralProperties.Created"); lblOwnerTitle.Text = GetString("GeneralProperties.Owner"); lblCssStyle.Text = GetString("PageProperties.CssStyle"); lblPublishedTitle.Text = GetString("PageProperties.Published"); chkExcludeFromSearch.Text = GetString("GeneralProperties.ExcludeFromSearch"); chkCssStyle.Text = GetString("Metadata.Inherit"); pnlOnlineMarketing.GroupingText = GetString("general.onlinemarketing"); // Set default item value string defaultStyleSheet = "-1"; CssStylesheetInfo cssInfo = CMSContext.CurrentSiteStylesheet; // If current site default stylesheet defined, choose it if (cssInfo != null) { defaultStyleSheet = "default"; } ctrlSiteSelectStyleSheet.CurrentSelector.SpecialFields = new string[1, 2] { { GetString("general.defaultchoice"), defaultStyleSheet } }; ctrlSiteSelectStyleSheet.ReturnColumnName = "StyleSheetID"; ctrlSiteSelectStyleSheet.SiteId = CMSContext.CurrentSiteID; if (CMSContext.CurrentSite != null) { usrOwner.SetValue("SiteID", CMSContext.CurrentSite.SiteID); } // Initialize Save button imgSave.ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/save.png"); mSave = GetString("general.save"); int documentId = 0; // Get the document TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); node = tree.SelectSingleNode(nodeId, CMSContext.PreferredCultureCode, false); // Redirect to page 'New culture version' in split mode. It must be before setting EditedDocument. if ((node == null) && displaySplitMode) { URLHelper.Redirect("~/CMSModules/Content/CMSDesk/New/NewCultureVersion.aspx" + URLHelper.Url.Query); } // Set edited document EditedDocument = node; if (node != null) { documentId = node.DocumentID; canEditOwner = (CMSContext.CurrentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.ModifyPermissions) == AuthorizationResultEnum.Allowed); ReloadData(); } // Generate executive script string script = "function ShowEditableContent() { modalDialog('" + ResolveUrl("Advanced/EditableContent/default.aspx") + "?nodeid=" + nodeId + "', 'EditableContent', 1015, 700); } \n"; if (hasAdHocBoard) { plcAdHocBoards.Visible = true; script += "function ShowMessageBoards() { modalDialog('" + ResolveUrl("~/CMSModules/MessageBoards/Content/Properties/default.aspx") + "?documentid=" + documentId + "', 'MessageBoards', 1020, 680); } \n"; } if (hasAdHocForum) { plcAdHocForums.Visible = true; script += "function ShowForums() { modalDialog('" + ResolveUrl("~/CMSModules/Forums/Content/Properties/default.aspx") + "?documentid=" + documentId + "', 'Forums', 1130, 680); } \n"; } ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ModalDialogsToAdvancedSection", ScriptHelper.GetScript(script)); // Register js synchronization script for split mode if (displaySplitMode) { RegisterSplitModeSync(true, false); } }
/// <summary> /// Copies the node to the specified target. /// </summary> /// <param name="node">Node to copy</param> /// <param name="targetNode">Target node</param> /// <param name="tree">Tree provider</param> /// <param name="childNodes">Copy also child nodes</param> /// <param name="copyPermissions">Indicates if node permissions should be copied</param> protected TreeNode CopyNode(TreeNode node, TreeNode targetNode, bool childNodes, TreeProvider tree, bool copyPermissions) { return CopyNode(node, targetNode, childNodes, tree, copyPermissions, null); }
protected void Page_Load(object sender, EventArgs e) { UIContext.PropertyTab = PropertyTabEnum.LinkedDocs; nodeId = QueryHelper.GetInteger("nodeid", 0); currentSiteName = CMSContext.CurrentSiteName.ToLower(); tree = new TreeProvider(currentUser); node = tree.SelectSingleNode(nodeId, TreeProvider.ALL_CULTURES, tree.CombineWithDefaultCulture, false); // Set edited document EditedDocument = node; gridDocs.OnExternalDataBound += gridDocuments_OnExternalDataBound; gridDocs.OnAction += gridDocs_OnAction; gridDocs.OnBeforeDataReload += new OnBeforeDataReload(gridDocs_OnBeforeDataReload); }
/// <summary> /// Copies the node to the specified target. /// </summary> /// <param name="node">Node to copy</param> /// <param name="targetNode">Target node</param> /// <param name="tree">Tree provider</param> /// <param name="childNodes">Copy also child nodes</param> /// <param name="copyPermissions">Indicates if node permissions should be copied</param> /// <param name="newDocumentName">New document name</param> protected TreeNode CopyNode(TreeNode node, TreeNode targetNode, bool childNodes, TreeProvider tree, bool copyPermissions, string newDocumentName) { string encodedAliasPath = " (" + HTMLHelper.HTMLEncode(node.NodeAliasPath) + ")"; int targetId = targetNode.NodeID; // Do not copy child nodes in case of no child nodes childNodes = childNodes && (node.NodeChildNodesCount > 0); // Get the document to copy int nodeId = node.NodeID; if ((nodeId == targetId) && childNodes) { AddError(GetString("ContentRequest.CannotCopyToItself") + encodedAliasPath); return null; } // Check move permission if (!IsUserAuthorizedToCopyOrLink(node, targetId, node.NodeClassName)) { AddError(GetString("ContentRequest.NotAllowedToCopy") + encodedAliasPath); return null; } // Check cyclic copying (copying of the node to some of its child nodes) if (childNodes && (targetNode.NodeSiteID == node.NodeSiteID) && targetNode.NodeAliasPath.StartsWith(node.NodeAliasPath + "/", StringComparison.CurrentCultureIgnoreCase)) { AddError(GetString("ContentRequest.CannotCopyToChild")); return null; } string domainToCheck = null; if (targetNode.NodeSiteID == node.NodeSiteID) { domainToCheck = URLHelper.GetCurrentDomain(); } else { SiteInfo targetSite = SiteInfoProvider.GetSiteInfo(targetNode.NodeSiteID); 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 null; } // Check allowed child class 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 null; } // Copy the document AddLog(HTMLHelper.HTMLEncode(node.NodeAliasPath + " (" + node.DocumentCulture + ")")); node = DocumentHelper.CopyDocument(node, targetId, childNodes, tree, 0, 0, copyPermissions, newDocumentName); SetExpandedNode(node.NodeParentID); return node; }
/// <summary> /// Determines whether current user is authorized to move document. /// </summary> /// <param name="sourceNode">Source node</param> /// <param name="targetNodeId">Target node class name</param> /// <param name="sourceNodeClassName">Source node class name</param> /// <returns>True if authorized</returns> protected bool IsUserAuthorizedToMove(TreeNode sourceNode, int targetNodeId, string sourceNodeClassName) { bool isAuthorized = false; // Check 'modify permission' to source document if (CurrentUser.IsAuthorizedPerDocument(sourceNode, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Allowed) { // Check 'create permission' if (CurrentUser.IsAuthorizedToCreateNewDocument(targetNodeId, sourceNodeClassName)) { isAuthorized = true; } } return isAuthorized; }