public override object GetDataSource() { LightboxFinder finder = new LightboxFinder(); finder.IsPublic = true; finder.SortExpressions.Add(new AscendingSort(Lightbox.Columns.Name)); return(Lightbox.FindMany(finder)); }
private static bool IsDuplicateName(string newName, int userId) { LightboxFinder finder = new LightboxFinder { UserId = userId, Name = newName }; int count = Lightbox.GetCount(finder); return(count > 0); }
public static void EnsureUserHasDefaultLightbox(User user) { if (user.IsNew || user.IsNull) { return; } LightboxFinder finder = new LightboxFinder { UserId = user.UserId.GetValueOrDefault(), IsDefault = true }; int count = Lightbox.GetCount(finder); if (count == 0) { Lightbox lb = Lightbox.New(); lb.UserId = user.UserId.GetValueOrDefault(); lb.Name = "My Assets"; lb.IsDefault = true; lb.CreateDate = DateTime.Now; Lightbox.Update(lb); AuditLogManager.LogUserAction(user, AuditUserAction.AddLightbox, "System created default lightbox as there were no other ligthboxes"); } }
public override object GetDataSource() { Dictionary <Int32, String> ht = new Dictionary <int, string>(); foreach (Lightbox lb in ContextInfo.LightboxManager.UserLightboxes) { // Filter out linked lightboxes if required if (!lb.IsLinked || !HideLinkedLightboxes) { StringBuilder sb = new StringBuilder(lb.Name); JoinableList jList = new JoinableList(", "); if (lb.IsDefault) { jList.Add("default"); } if (lb.IsPublic) { jList.Add("public"); } if (lb.IsLinked) { jList.Add("linked"); } if (jList.Count > 0) { sb.AppendFormat(" ({0})", jList); } ht[lb.LightboxId.GetValueOrDefault()] = sb.ToString(); } } if (ShowPublicLightboxes) { // Initialise finder to get public lightboxes LightboxFinder finder = new LightboxFinder { IsPublic = true }; // Non-superadmins should only see public lightboxes which are assigned // to a brand to which they are also assigned (so a user cannot see lightboxes // assigned to brands to which they do not have access). if (SessionInfo.Current.User.UserRole != UserRole.SuperAdministrator && BrandManager.IsMultipleBrandMode) { finder.BrandIdList.Add(0); finder.BrandIdList.AddRange(SessionInfo.Current.User.Brands.Select(b => b.BrandId.GetValueOrDefault())); } // Get the lightboxes List <Lightbox> lightboxList = Lightbox.FindMany(finder); foreach (Lightbox lb in lightboxList) { int lightboxId = lb.LightboxId.GetValueOrDefault(); // Check that the lightbox isn't already in the list // (In case the current user has public lightboxes) if (!ht.ContainsKey(lightboxId)) { string lightboxName = string.Format("{0} (public)", lb.Name); ht.Add(lightboxId, lightboxName); } } } return(ht); }