public void SetApplicationNotification(ApplicationNotification notif, bool enable) { if ((notif & ApplicationNotification.AdminNotificationMask) != 0) { CheckIsAdmin(); } UserApplication up = db.SelectObjectWhere <UserApplication> ("UserId={0} AND ApplicationId={1}", user.Id, application.Id); if (enable) { if (up == null) { up = new UserApplication() { UserId = user.Id, ApplicationId = application.Id, Notifications = notif }; db.InsertObject <UserApplication> (up); } else { up.Notifications |= notif; db.UpdateObject(up); } } else if (up != null) { up.Notifications &= ~notif; db.UpdateObject(up); } }
public void SetUserApplicationPermission(int userId, ApplicationPermission perms, bool enable) { UserApplication up = db.SelectObjectWhere <UserApplication> ("UserId={0} AND ApplicationId={1}", userId, application.Id); if (up == null) { if (enable) { up = new UserApplication() { UserId = userId, ApplicationId = application.Id, Permissions = perms }; db.InsertObject(up); } } else { if (enable) { up.Permissions |= ApplicationPermission.Administer; } else { up.Permissions &= ~ApplicationPermission.Administer; } db.UpdateObject(up); } }
public void ResetUserPermission(ApplicationPermission perm) { CheckIsAdmin(); UserApplication up = db.SelectObjectWhere <UserApplication> ("UserId={0} AND ApplicationId={1}", user.Id, application.Id); if (up != null) { up.Permissions &= ~perm; db.UpdateObject(up); } }
public List <NotificationInfo> GetApplicationNotifications() { ApplicationNotification notifs = (ApplicationNotification)0; ProjectNotification projectNotifs = (ProjectNotification)0; UserApplication uap = db.SelectObjectWhere <UserApplication> ("UserId={0} AND ApplicationId={1}", User.Id, application.Id); if (uap != null) { notifs = uap.Notifications; projectNotifs = uap.ProjectNotifications; } List <NotificationInfo> list = new List <NotificationInfo> (); bool hasProjects = OwnedProjects.Count > 0; if (hasProjects) { list.Add(new NotificationInfo("Global Notifications")); } list.Add(new NotificationInfo("New Add-in", ApplicationNotification.FirstProjectRelease, notifs)); list.Add(new NotificationInfo("New Add-in Release", ApplicationNotification.ProjectNewRelease, notifs)); if (IsAdmin) { list.Add(new NotificationInfo("Build Success", ApplicationNotification.ProjectBuildSuccess, notifs)); list.Add(new NotificationInfo("Build Error", ApplicationNotification.ProjectBuildError, notifs)); list.Add(new NotificationInfo("Project Created", ApplicationNotification.NewProject, notifs)); list.Add(new NotificationInfo("Project Deleted", ApplicationNotification.DeleteProject, notifs)); list.Add(new NotificationInfo("Description Changed", ApplicationNotification.ProjectDescriptionChage, notifs)); list.Add(new NotificationInfo("Release Publish Request", ApplicationNotification.ProjectPublishReleaseRequest, notifs)); } if (IsSiteAdmin) { list.Add(new NotificationInfo("New User", SiteNotification.NewUser, User.SiteNotifications)); list.Add(new NotificationInfo("Build Bot Error", SiteNotification.BuildBotError, User.SiteNotifications)); } if (hasProjects) { list.Add(new NotificationInfo("Owned Project Notifications")); list.Add(new NotificationInfo("Release Published", ProjectNotification.NewRelease, projectNotifs)); list.Add(new NotificationInfo("Build Success", ProjectNotification.BuildSuccess, projectNotifs)); list.Add(new NotificationInfo("Build Error", ProjectNotification.BuildError, projectNotifs)); } return(list); }
public static UserModel GetForUser(string login, string password, int appId) { UserModel m = new UserModel(); m.db = DataConnection.GetConnection(); if (appId != -1) { m.application = m.db.SelectObjectById <Application> (appId); } else if (Settings.Default.SupportsMultiApps) { string app = GetCurrentAppName(); if (app != null) { m.application = m.db.SelectObjectWhere <Application> ("Subdomain={0}", app); } } else { m.application = m.db.SelectObjects <Application> ().FirstOrDefault(); } ServiceModel sm = ServiceModel.GetCurrent(); if (!string.IsNullOrEmpty(login)) { m.user = sm.GetUser(login); if (password != null && !m.user.CheckPassword(password)) { m.user = null; } } sm.Dispose(); if (m.application != null && m.user != null) { UserApplication uap = m.db.SelectObjectWhere <UserApplication> ("UserId={0} AND ApplicationId={1}", m.user.Id, m.application.Id); m.isAdmin = (uap != null && (uap.Permissions & ApplicationPermission.Administer) != 0); } else { m.isAdmin = false; } return(m); }
public void SetUserPermission(ApplicationPermission perm) { CheckIsAdmin(); UserApplication up = db.SelectObjectWhere <UserApplication> ("UserId={0} AND ApplicationId={1}", user.Id, application.Id); if (up == null) { up = new UserApplication() { UserId = user.Id, ApplicationId = application.Id, Permissions = perm }; db.InsertObject <UserApplication> (up); } else { up.Permissions |= perm; db.UpdateObject(up); } }
public void SetUserPermission(ApplicationPermission perm) { CheckIsAdmin (); UserApplication up = db.SelectObjectWhere<UserApplication> ("UserId={0} AND ApplicationId={1}", user.Id, application.Id); if (up == null) { up = new UserApplication () { UserId = user.Id, ApplicationId = application.Id, Permissions = perm }; db.InsertObject<UserApplication> (up); } else { up.Permissions |= perm; db.UpdateObject (up); } }
public void SetUserApplicationPermission(int userId, ApplicationPermission perms, bool enable) { UserApplication up = db.SelectObjectWhere<UserApplication> ("UserId={0} AND ApplicationId={1}", userId, application.Id); if (up == null) { if (enable) { up = new UserApplication () { UserId = userId, ApplicationId = application.Id, Permissions = perms }; db.InsertObject (up); } } else { if (enable) up.Permissions |= ApplicationPermission.Administer; else up.Permissions &= ~ApplicationPermission.Administer; db.UpdateObject (up); } }
public void SetApplicationNotification(ApplicationNotification notif, bool enable) { if ((notif & ApplicationNotification.AdminNotificationMask) != 0) CheckIsAdmin (); UserApplication up = db.SelectObjectWhere<UserApplication> ("UserId={0} AND ApplicationId={1}", user.Id, application.Id); if (enable) { if (up == null) { up = new UserApplication () { UserId = user.Id, ApplicationId = application.Id, Notifications = notif }; db.InsertObject<UserApplication> (up); } else { up.Notifications |= notif; db.UpdateObject (up); } } else if (up != null) { up.Notifications &= ~notif; db.UpdateObject (up); } }