Ejemplo n.º 1
0
        public static void SendPReqiresApprovalMessage(Post p, IGraffitiUser user)
        {
            var users = new List <IGraffitiUser>();

            foreach (IGraffitiUser u in GraffitiUsers.GetUsers("*"))
            {
                if (GraffitiUsers.IsAdmin(u) || RolePermissionManager.GetPermissions(p.CategoryId, u).Publish)
                {
                    users.Add(u);
                }
            }

            Macros m = new Macros();
            EmailTemplateToolboxContext pttc = new EmailTemplateToolboxContext();

            pttc.Put("sitesettings", SiteSettings.Get());
            pttc.Put("post", p);
            pttc.Put("user", user);
            pttc.Put("macros", m);
            pttc.Put("home", m.FullUrl(new Urls().Home));
            pttc.Put("adminUrl",
                     m.FullUrl(VirtualPathUtility.ToAbsolute("~/graffiti-admin/posts/write/")) + "?id=" + p.Id + "&v=" +
                     p.Version);

            string adminApprovalUrl = m.FullUrl(VirtualPathUtility.ToAbsolute("~/api/approve.ashx")) +
                                      "?key={0}&u={1}&id={2}&v={3}";

            EmailTemplate template = new EmailTemplate();

            template.Context      = pttc;
            template.Subject      = "You have content to approve: " + p.Title;
            template.TemplateName = "QueuedPost.view";

            foreach (IGraffitiUser admin in users)
            {
                template.Context.Put("adminApprovalUrl",
                                     string.Format(adminApprovalUrl, admin.UniqueId, admin.Name, p.Id, p.Version));

                try
                {
                    template.To = admin.Email;
                    Emailer.Send(template);

                    //Emailer.Send("QueuedPost.view", admin.Email, "You have content to approve: " + p.Title, pttc);
                }
                catch (Exception ex)
                {
                    Log.Error("Email Error", ex.Message);
                }
            }

            Log.Info("Post approval email", "{0} user(s) were sent an email to approve the post \"{1}\" (id: {2}).", users.Count,
                     p.Title, p.Id);
        }
Ejemplo n.º 2
0
        public static void SendRequestedChangesMessage(Post p, IGraffitiUser user)
        {
            List <IGraffitiUser> users = new List <IGraffitiUser>();

            foreach (IGraffitiUser u in GraffitiUsers.GetUsers("*"))
            {
                if (GraffitiUsers.IsAdmin(u) || RolePermissionManager.GetPermissions(p.CategoryId, u).Publish)
                {
                    users.Add(u);
                }
            }

            Macros m = new Macros();

            EmailTemplateToolboxContext pttc = new EmailTemplateToolboxContext();

            pttc.Put("sitesettings", SiteSettings.Get());
            pttc.Put("post", p);
            pttc.Put("user", user);
            pttc.Put("macros", m);
            pttc.Put("home", m.FullUrl(new Urls().Home));
            pttc.Put("adminUrl",
                     m.FullUrl(VirtualPathUtility.ToAbsolute("~/graffiti-admin/posts/write/")) + "?id=" + p.Id + "&v=" +
                     p.Version);

            EmailTemplate template = new EmailTemplate();

            template.Context      = pttc;
            template.To           = p.User.Email;
            template.Subject      = "Changes Requested: " + p.Title;
            template.TemplateName = "RequestChanges.view";

            try
            {
                Emailer.Send(template);
                //Emailer.Send("RequestChanges.view", p.User.Email, "Changes Requested: " + p.Title, pttc);
                Log.Info("Post Changes Email", p.User.Email + " was sent an email requesting changes");
            }
            catch (Exception ex)
            {
                Log.Error("Email Requested Changes Error", ex.Message);
            }
        }
Ejemplo n.º 3
0
        public static void DeleteRole(string roleName)
        {
            // Remove users from role
            List <IGraffitiUser> roleUsers = GraffitiUsers.GetUsers(roleName);

            if (roleUsers != null && roleUsers.Count > 0)
            {
                foreach (IGraffitiUser user in roleUsers)
                {
                    GraffitiUsers.RemoveUserFromRole(user.Name, roleName);
                }
            }

            RolePermissionsCollection         rp  = RolePermissionManager.GetRolePermissions();
            RoleCategoryPermissionsCollection rpc = RolePermissionManager.GetRoleCategoryPermissions();

            foreach (RolePermissions rperm in rp)
            {
                if (String.Compare(rperm.RoleName, roleName, StringComparison.InvariantCultureIgnoreCase) == 0)
                {
                    RolePermissions.Destroy(RolePermissions.Columns.RoleName, rperm.RoleName);
                    break;
                }
            }

            foreach (RoleCategoryPermissions rcatperm in rpc)
            {
                if (String.Compare(rcatperm.RoleName, roleName, StringComparison.InvariantCultureIgnoreCase) == 0)
                {
                    RoleCategoryPermissions.Destroy(RolePermissions.Columns.RoleName, rcatperm.RoleName);
                    break;
                }
            }

            RolePermissionManager.MarkDirty();

            // Remove role from other membership databases
            controller.DeleteRole(roleName);
        }