Ejemplo n.º 1
0
        public static IList<User> SendMail(String text, String headLine, IList<User> emailList, User sendingUser, bool userIsSender)
        {
            IList<User> sendUsers = new List<User>();

            SmtpClient client = new SmtpClient();
            MailMessage mail = new MailMessage {
                Subject = headLine,
                Body = text,
                IsBodyHtml = false
            };

            if (userIsSender && emailPattern.IsMatch(sendingUser.Email.Trim()))
                mail.From = new MailAddress(sendingUser.Email.Trim());
            else {
                mail.From = new MailAddress(ConfigurationManager.AppSettings["WebmasterMail"]);
            }

            foreach (var user in emailList) {
                if (!String.IsNullOrEmpty(user.Email.Trim()) && emailPattern.IsMatch(user.Email.Trim())) {
                    mail.Bcc.Add(new MailAddress(user.Email.Trim()));
                    sendUsers.Add(user);
                }
            }

            client.Send(mail);

            return sendUsers;
        }
Ejemplo n.º 2
0
        public static bool IsAuthorized(User user, string role1 = null, string role2 = null, string role3 = null)
        {
            List<String> currentRoles = new List<string>();
            foreach (Role r in user.Roles) currentRoles.Add(r.RoleName);

            if (user.UserId == 17787) return true; // Is Reuss?
            if (currentRoles.Contains("Webmaster")) return true;
            if (role1 != null && currentRoles.Contains(role1)) return true;
            if (role2 != null && currentRoles.Contains(role2)) return true;
            if (role3 != null && currentRoles.Contains(role3)) return true;

            return false;
        }
Ejemplo n.º 3
0
 public VMUser(User user, UserGroup group)
 {
     this.user = user;
     this.group = group;
 }
Ejemplo n.º 4
0
 public VMUser(User user)
 {
     this.user = user;
 }
Ejemplo n.º 5
0
 public VMUser()
 {
     user = new User();
 }
Ejemplo n.º 6
0
        public List<HKMenuItem> FrontpageMenu(HalloContext context, HttpRequestBase request, User user)
        {
            List<HKMenuItem> menu = new List<HKMenuItem>();

            List<HKMenuItem> categoryLinks = new List<HKMenuItem>();
            List<ArticleCategory> cList = context.Categories.Where(x => x.Articles.Count > 0).OrderBy(c => c.LocalName).ToList();

            foreach (ArticleCategory ac in cList)
                categoryLinks.Add(new HKMenuItem { Text = ac.LocalName, Url = "/Home/Index/" + ac.Id });

            menu.Add(new HKMenuItem() {
                Text = "Artikler",
                SubMenu = categoryLinks,
                Active = request.FilePath.Contains("Home/Index/") && request.FilePath.Length > 11
            });
            menu.Add(new HKMenuItem() {
                Text = "Aktivitetsklub",
                Url = "/AcPlan/TeamOverview?all=false"
            });
            if (user.Authorized) {
                menu.Add(new HKMenuItem { Text = "Streaming", Url = "/Meeting/Streaming" });

                List<HKMenuItem> adminLinks = new List<HKMenuItem>();
                if (HalloController.IsAuthorized(user, "Editor")) {
                    adminLinks.Add(new HKMenuItem {
                        Text = "Rettigheder",
                        Url = "/Role/Admin"
                    });
                }
                if (HalloController.IsAuthorized(user, "Editor", "Journalist")) {
                    adminLinks.Add(new HKMenuItem {
                        Text = "Artikler",
                        Url = "/Article/List"
                    });
                    adminLinks.Add(new HKMenuItem {
                        Text = "Filer",
                        Url = "/File/List"
                    });
                    adminLinks.Add(new HKMenuItem {
                        Text = "Familier",
                        Url = "/FamilyPresentation/List"
                    });
                }
                if (HalloController.IsAuthorized(user, "PmoAdmin")) {
                    adminLinks.Add(new HKMenuItem {
                        Text = "Upload PMO-info",
                        Url = "/User/PmoUpload"
                    });
                }
                if (HalloController.IsAuthorized(user, "SmsAdmin")) {
                    adminLinks.Add(new HKMenuItem {
                        Text = "Send Mail/SMS",
                        Url = "/Mail"
                    });
                    adminLinks.Add(new HKMenuItem {
                        Text = "Se afsendte SMS",
                        Url = "/Mail/SmsLog"
                    });
                    adminLinks.Add(new HKMenuItem {
                        Text = "SMS-grupper",
                        Url = "/UserGroup"
                    });
                }
                if (HalloController.IsAuthorized(user, "AcAdmin")) {
                    adminLinks.Add(new HKMenuItem {
                        Text = "AK hold",
                        Url = "/UserGroup/ACIndex"
                    });
                    adminLinks.Add(new HKMenuItem {
                        Text = "AK datoer",
                        Url = "/AcDate"
                    });
                }

                if (adminLinks.Count > 0) {
                    menu.Add(new HKMenuItem {
                        Text = "Administration",
                        SubMenu = adminLinks
                    });
                }

            }
            //menu.Add(new HKMenuItem() { Text = "Kalender", Url = "/Calender/Index" });

            List<HKMenuItem> externalLinks = new List<HKMenuItem>();
            List<FrontpageLink> fpList = context.FrontpageLinks.ToList();

            foreach (FrontpageLink fpl in fpList)
                externalLinks.Add(new HKMenuItem {
                    Text = fpl.Label, Url =
                    fpl.NavigationUrl
                });

            bool linksActive = true;
            foreach (HKMenuItem item in menu) if (item.Active) linksActive = false;

            menu.Add(new HKMenuItem() {
                Text = "Links",
                SubMenu = externalLinks,
                Active = linksActive
            });

            return menu;
        }