private void PerformCopy(N2.ContentItem newItem) { EnsureAuthorization(Permission.Write); EnsureAuthorization(Selection.MemorizedItem, Permission.Read); var persister = Engine.Persister; newItem = persister.Copy(newItem, Selection.SelectedItem); var security = Engine.SecurityManager; if (security.GetPermissions(User, newItem) != security.GetPermissions(User, Selection.SelectedItem)) { security.CopyPermissions(newItem.Parent, newItem); persister.Repository.SaveOrUpdate(newItem); } if (newItem.IsPublished() && !security.IsAuthorized(User, newItem, Permission.Publish)) { newItem.Published = null; persister.Repository.SaveOrUpdate(newItem); } Engine.AddActivity(new ManagementActivity { Operation = "Copy", PerformedBy = User.Identity.Name, Path = newItem.Path, ID = newItem.ID }); Refresh(newItem, ToolbarArea.Both); }
private void PerformCopy(N2.ContentItem newItem) { var authorizationToWrite = Permission.Write; //Limit non-admins from copy/paste items in uploads folder if ((Selection.MemorizedItem.GetType() == typeof(FileSystem.Items.Directory) || Selection.MemorizedItem.GetType() == typeof(FileSystem.Items.File)) && Selection.MemorizedItem.ID == 0) { var config = new ConfigurationManagerWrapper(); authorizationToWrite = config.Sections.Management.UploadFolders.RequiredPermissionToModify; } EnsureAuthorization(authorizationToWrite); EnsureAuthorization(Selection.MemorizedItem, Permission.Read); var persister = Engine.Persister; newItem = persister.Copy(newItem, Selection.SelectedItem); var security = Engine.SecurityManager; if (security.GetPermissions(User, newItem) != security.GetPermissions(User, Selection.SelectedItem)) { security.CopyPermissions(newItem.Parent, newItem); persister.Repository.SaveOrUpdate(newItem); } if (newItem.IsPublished() && !security.IsAuthorized(User, newItem, Permission.Publish)) { newItem.Published = null; persister.Repository.SaveOrUpdate(newItem); } Engine.AddActivity(new ManagementActivity { Operation = "Copy", PerformedBy = User.Identity.Name, Path = newItem.Path, ID = newItem.ID }); Refresh(newItem, ToolbarArea.Both); }
private void PerformCopy(N2.ContentItem newItem) { EnsureAuthorization(Permission.Write); EnsureAuthorization(Selection.MemorizedItem, Permission.Read); var persister = Engine.Persister; newItem = persister.Copy(newItem, Selection.SelectedItem); var security = Engine.SecurityManager; if (security.GetPermissions(User, newItem) != security.GetPermissions(User, Selection.SelectedItem)) { security.CopyPermissions(newItem.Parent, newItem); persister.Repository.Save(newItem); } if (newItem.IsPublished() && !security.IsAuthorized(User, newItem, Permission.Publish)) { newItem.Published = null; persister.Repository.Save(newItem); } Refresh(newItem, ToolbarArea.Both); }