protected void ButtonChangeAlbumName_Click(object sender, EventArgs e) { Album album = new Album(); var pin = RadFileExplorerAlbum.CurrentFolder.Substring(RadFileExplorerAlbum.CurrentFolder.LastIndexOf('/') + 1); album.ChangeAlbumName(RadTextBoxAlbumName.Text, pin); RadFileExplorerAlbum.TreeView.Nodes.Clear(); }
private string GoToAlbum(string pin) { Album album = new Album(); if (album.AlbumExists(pin)) { Response.Redirect("Album2.aspx?pin=" + TextBoxPin.Text); } return "Album not found"; }
protected void ButtonCreateAlbum_Click(object sender, EventArgs e) { if (User.Identity.IsAuthenticated) { Album album = new Album(); string pin = album.CreateNewAlbum(TextBoxAlbumName.Text, User.Identity.GetUserId()); ButtonGoToAlbum.PostBackUrl = "Album2.aspx?pin=" + pin; LabelPin.Visible = true; LabelPin.Text = "Your new pin is: " + pin; ButtonGoToAlbum.Visible = true; } else { //LabelLoginError.Text = "Please login or create an account to create albums."; } }
protected bool UserHasAlbums() { var claimsIdentity = HttpContext.Current.User.Identity as ClaimsIdentity; if (claimsIdentity != null) { var userIdClaim = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier); if (userIdClaim != null) { var userIdValue = userIdClaim.Value; Album album = new Album(); if (album.GetPinNameListByUser(userIdValue).Length > 0) { return true; } } } return false; }
public Album.AlbumObject[] GetPinNameList(string userId) { Album album = new Album(); return album.GetPinNameListByUser(userId); }
public string GetAlbumName(string pin) { Album album = new Album(); return album.GetAlbumName(pin); }
public string CreateAlbum(string albumName, string userName) { Album album = new Album(); string pin = album.CreateNewAlbum(albumName,userName); return pin; }
public bool AlbumExists(string pin) { Album album = new Album(); return album.AlbumExists(pin); }
// Show directories as album name instead of pin. public override DirectoryItem ResolveRootDirectoryAsTree(string path) { Album album = new Album(); try { DirectoryItem orgDir = base.ResolveRootDirectoryAsTree(path); string pin = ""; int firstSlash = GetNthIndex(path, '/', 3); int secondSlash = GetNthIndex(path, '/', 4); if (secondSlash > firstSlash) { pin = path.Substring(firstSlash, (secondSlash - firstSlash)) + " : "; } else { pin = orgDir.Name + " : "; } orgDir.Name = pin + album.GetAlbumName(orgDir.Name); return orgDir; } catch (UnauthorizedAccessException) { //Eat access exceptions. //return new DirectoryItem(); return null; } }
private void ViewAnotherUsersAlbum(string albumPin) { Album album = new Album(); string albumUserId = album.GetAlbumUserId(albumPin); string albumUserFolder = rootDir + albumUserId + "/"; RadFileExplorerAlbum.Configuration.MaxUploadFileSize = GetUploadLimit(albumUserId); RadFileExplorerAlbum.Configuration.SearchPatterns = new string[] { "*.jpg", "*.jpeg", "*.gif", "*.png" }; RadFileExplorerAlbum.Configuration.ViewPaths = new string[] { albumUserFolder + albumPin }; RadFileExplorerAlbum.Configuration.UploadPaths = new string[] { albumUserFolder + albumPin }; RadFileExplorerAlbum.Configuration.DeletePaths = new string[] { albumUserFolder + albumPin }; RadFileExplorerAlbum.InitialPath = Page.ResolveUrl(albumUserFolder + albumPin); }
protected void RadFileExplorerAlbum_ExplorerPopulated(object sender, Telerik.Web.UI.RadFileExplorerPopulatedEventArgs e) { if (e.ControlName == "tree") { albumPin = Request.QueryString["pin"]; if (!String.IsNullOrEmpty(albumPin)) { Album album = new Album(); albumName = album.GetAlbumName(albumPin); RadTreeNode node = RadFileExplorerAlbum.TreeView.FindNodeByText(albumName); if (node != null) { node.Selected = true; node.Focus(); node.Expanded = true; RadFileExplorerAlbum.InitialPath = node.FullPath; } } } }
protected void Page_Load(object sender, EventArgs e) { Album album = new Album(); userFolder = rootDir; albumPin = Request.QueryString["pin"]; if (!IsPostBack) { LabelAlbumPin.Text = albumPin; if (User.Identity.IsAuthenticated) { string userId = User.Identity.GetUserId(); userFolder += userId + "/"; if (!String.IsNullOrEmpty(albumPin)) { string albumUserId = album.GetAlbumUserId(albumPin); if (albumUserId == userId) { //This album pin belongs to the current users //RadFileExplorerAlbum.InitialPath = Page.ResolveUrl(userFolder); RadFileExplorerAlbum.Configuration.MaxUploadFileSize = GetUploadLimit(userId); RadFileExplorerAlbum.Configuration.ViewPaths = getFolderArray(Request.MapPath(userFolder)); RadFileExplorerAlbum.Configuration.UploadPaths = new string[] { userFolder }; RadFileExplorerAlbum.Configuration.DeletePaths = new string[] { userFolder }; } else // The user is logged in but its not their album. ViewAnotherUsersAlbum(albumPin); LabelAlbumPin.Text = albumPin; RadTextBoxAlbumName.Text = album.GetAlbumName(albumPin); } else { // Load users root folder. RadFileExplorerAlbum.Configuration.MaxUploadFileSize = GetUploadLimit(userId); RadFileExplorerAlbum.Configuration.ViewPaths = getFolderArray(Request.MapPath(userFolder)); RadFileExplorerAlbum.Configuration.UploadPaths = new string[] { userFolder }; RadFileExplorerAlbum.Configuration.DeletePaths = new string[] { userFolder }; } } else { if (!String.IsNullOrEmpty(albumPin)) { // The user is not logged in therefor its another users pin. ViewAnotherUsersAlbum(albumPin); LabelAlbumPin.Text = albumPin; RadTextBoxAlbumName.Text = album.GetAlbumName(albumPin); } else { // The user is not logged in and no pin is given. Redirect. Response.Redirect("~/Default.aspx"); } } } }