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) { try { return(AlbumController.UpdateAlbumInfo(albumEntity)); } catch (Exception ex) { AppErrorController.LogError(ex); throw; } }
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) { try { 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); } catch (Exception ex) { AppErrorController.LogError(ex); throw; } }
/// <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> public static AlbumWebEntity UpdateAlbumInfo(AlbumWebEntity albumEntity) { if (albumEntity.Owner == Resources.GalleryServerPro.UC_Album_Header_Edit_Album_No_Owner_Text) { albumEntity.Owner = String.Empty; } IAlbum album = Factory.LoadAlbumInstance(albumEntity.Id, false); // Update remaining properties if user has edit album permission. if (GalleryPage.IsUserAuthorized(SecurityActions.EditAlbum, album.Id)) { if (album.Title != albumEntity.Title) { album.Title = Util.CleanHtmlTags(albumEntity.Title); if ((!album.IsRootAlbum) && (Config.GetCore().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); } } album.Summary = Util.CleanHtmlTags(albumEntity.Summary); 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 (GalleryPage.IsUserAuthorized(SecurityActions.AdministerSite, album.Id)) { 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); } // Util.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); }