/// <summary> /// Update the album with the specified properties in the albumEntity parameter. The title is validated before /// saving, and may be altered to conform to business rules, such as removing HTML tags. After the object is persisted /// to the data store, the albumEntity parameter is updated with the latest properties from the album object and returned. /// If the user is not authorized to edit the album, no action is taken. /// </summary> /// <param name="albumEntity">An AlbumWebEntity instance containing data to be persisted to the data store.</param> /// <returns>Returns an AlbumWebEntity instance containing the data as persisted to the data store. Some properties, /// such as the Title property, may be slightly altered to conform to validation rules.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="albumEntity" /> is null.</exception> public static AlbumWebEntity UpdateAlbumInfo(AlbumWebEntity albumEntity) { if (albumEntity == null) throw new ArgumentNullException("albumEntity"); if (albumEntity.Owner == Resources.GalleryServerPro.UC_Album_Header_Edit_Album_No_Owner_Text) { albumEntity.Owner = String.Empty; } IAlbum album = AlbumController.LoadAlbumInstance(albumEntity.Id, false, true); // Update remaining properties if user has edit album permission. if (Utils.IsUserAuthorized(SecurityActions.EditAlbum, album.Id, album.GalleryId, album.IsPrivate)) { if (album.Title != albumEntity.Title) { IGallerySettings gallerySetting = Factory.LoadGallerySetting(album.GalleryId); album.Title = Utils.CleanHtmlTags(albumEntity.Title, album.GalleryId); if ((!album.IsRootAlbum) && (gallerySetting.SynchAlbumTitleAndDirectoryName)) { // Root albums do not have a directory name that reflects the album's title, so only update this property for non-root albums. album.DirectoryName = HelperFunctions.ValidateDirectoryName(album.Parent.FullPhysicalPath, album.Title, gallerySetting.DefaultAlbumDirectoryNameLength); } } album.Summary = Utils.CleanHtmlTags(albumEntity.Summary, album.GalleryId); album.DateStart = albumEntity.DateStart.Date; album.DateEnd = albumEntity.DateEnd.Date; if (albumEntity.IsPrivate != album.IsPrivate) { if (!albumEntity.IsPrivate && album.Parent.IsPrivate) { throw new NotSupportedException("Cannot make album public: It is invalid to make an album public when it's parent album is private."); } album.IsPrivate = albumEntity.IsPrivate; SynchIsPrivatePropertyOnChildGalleryObjects(album); } // If the owner has changed, update it, but only if the user is administrator. if (albumEntity.Owner != album.OwnerUserName) { if (Utils.IsUserAuthorized(SecurityActions.AdministerSite | SecurityActions.AdministerGallery, RoleController.GetGalleryServerRolesForUser(), album.Id, album.GalleryId, album.IsPrivate)) { if (!String.IsNullOrEmpty(album.OwnerUserName)) { // Another user was previously assigned as owner. Delete role since this person will no longer be the owner. RoleController.DeleteGalleryServerProRole(album.OwnerRoleName); } if (UserController.GetUsersCurrentUserCanView(album.GalleryId).Contains(albumEntity.Owner) || String.IsNullOrEmpty(albumEntity.Owner)) { // GalleryObjectController.SaveGalleryObject will make sure there is a role created for this user. album.OwnerUserName = albumEntity.Owner; } } } GalleryObjectController.SaveGalleryObject(album); HelperFunctions.PurgeCache(); // Refresh the entity object with the data from the album object, in case something changed. For example, // some javascript or HTML may have been removed from the Title or Summary fields. albumEntity.Title = album.Title; albumEntity.Summary = album.Summary; albumEntity.DateStart = album.DateStart; albumEntity.DateEnd = album.DateEnd; albumEntity.IsPrivate = album.IsPrivate; albumEntity.Owner = album.OwnerUserName; } return albumEntity; }
public AlbumWebEntity UpdateAlbumInfo(AlbumWebEntity albumEntity) { if (albumEntity == null) return null; try { albumEntity.Owner = Utils.HtmlDecode(albumEntity.Owner); return AlbumController.UpdateAlbumInfo(albumEntity); } catch (Exception ex) { AppErrorController.LogError(ex); throw; } }
public AlbumWebEntity GetAlbumInfo(int albumId) { AlbumWebEntity albumEntity = new AlbumWebEntity(); if (GalleryPage.IsUserAuthorized(SecurityActions.ViewAlbumOrMediaObject, albumId)) { IAlbum album = Factory.LoadAlbumInstance(albumId, false); albumEntity.Title = album.Title; albumEntity.Summary = album.Summary; albumEntity.DateStart = album.DateStart; albumEntity.DateEnd = album.DateEnd; albumEntity.IsPrivate = album.IsPrivate; } return albumEntity; }
public AlbumWebEntity GetAlbumInfo(int albumId) { IAlbum album = null; try { AlbumWebEntity albumEntity = new AlbumWebEntity(); album = AlbumController.LoadAlbumInstance(albumId, false); if (Utils.IsUserAuthorized(SecurityActions.ViewAlbumOrMediaObject, albumId, album.GalleryId, album.IsPrivate)) { albumEntity.Title = album.Title; albumEntity.Summary = album.Summary; albumEntity.DateStart = album.DateStart; albumEntity.DateEnd = album.DateEnd; albumEntity.IsPrivate = album.IsPrivate; } return albumEntity; } catch (Exception ex) { if (album != null) { AppErrorController.LogError(ex, album.GalleryId); } else { AppErrorController.LogError(ex); } throw; } }
public AlbumWebEntity UpdateAlbumInfo(AlbumWebEntity albumEntity) { return AlbumController.UpdateAlbumInfo(albumEntity); }