예제 #1
0
 public IEnumerable GetCreators()
 {
     foreach (IGraffitiUser u in GraffitiUsers.GetUsers(MarketplacePlugin.MarketplaceCreatorsRoleName))
     {
         yield return(u);
     }
 }
예제 #2
0
        private void UpdateCreatorsFieldOptions(CustomField field)
        {
            List <ListItemFormElement> listItems = new List <ListItemFormElement>();

            foreach (IGraffitiUser u in GraffitiUsers.GetUsers(MarketplaceCreatorsRoleName))
            {
                listItems.Add(new ListItemFormElement(u.ProperName, u.Name));
            }
            field.ListOptions = listItems;
        }
예제 #3
0
파일: ajax.cs 프로젝트: harder/GraffitiCMS
        public void ProcessRequest(HttpContext context)
        {
            if (context.Request.RequestType != "POST")
            {
                return;
            }

            if (context.Items["UserId"] == null)
            {
                return;
            }


            context.Response.ContentType = "text/plain";


            switch (context.Request.QueryString["command"])
            {
            case "newComment":


                Comment comment = new Comment();

                comment.Name    = context.Request.Form["author"];
                comment.WebSite = context.Request.Form["url"];
                comment.Email   = context.Request.Form["email"];

                comment.Body = context.Request.Form["comment"];

                if (!context.Request.IsAuthenticated && String.IsNullOrEmpty(comment.Name))
                {
                    context.Response.Write("Please enter your name");
                    return;
                }

                if (String.IsNullOrEmpty(comment.Body))
                {
                    context.Response.Write("Please enter a comment");
                    return;
                }

                comment.IPAddress = context.Request.UserHostAddress;
                comment.PostId    = Int32.Parse(context.Request.Form["comment_post_ID"]);

                comment.Published = DateTime.Now.AddHours(SiteSettings.Get().TimeZoneOffSet);

                comment.Save();
                context.Response.Write("Your comment has been received and will be published shortly. Thanks!");

                break;

            case "newContactMessage":

                string subject = context.Request.Form["subject"];
                string email   = context.Request.Form["email"];
                string name    = context.Request.Form["name"];
                string message = context.Request.Form["message"];

                if (string.IsNullOrEmpty(subject) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(name) || string.IsNullOrEmpty(message))
                {
                    context.Response.Write("All of the fields are required, your message has not been sent");
                    context.Response.End();
                    return;
                }

                if (!Regex.IsMatch(email, @"\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b", RegexOptions.IgnoreCase))
                {
                    context.Response.Write("The email address you entered is not valid");
                    context.Response.End();
                    return;
                }

                EmailTemplateToolboxContext templateContext = new EmailTemplateToolboxContext();
                templateContext.Put("subject", context.Server.HtmlEncode(subject));
                templateContext.Put("email", context.Server.HtmlEncode(email));
                templateContext.Put("name", context.Server.HtmlEncode(name));
                templateContext.Put("message", Util.ConvertTextToHTML(message));
                templateContext.Put("ip", context.Request.UserHostAddress);

                EmailTemplate et = new EmailTemplate();
                et.Subject      = "Contact Request: " + subject;
                et.Context      = templateContext;
                et.From         = email;
                et.TemplateName = "contact.view";

                Log.Info("Contact Received", "Subject: {0}\nFrom:{1} ({2})\nIP:{3}\n\n{4}", subject, name, email, context.Request.UserHostAddress, message);

                foreach (IGraffitiUser user in GraffitiUsers.GetUsers(GraffitiUsers.AdminRole))
                {
                    et.To = user.Email;
                    Emailer.Send(et);
                }

                context.Response.Write("Your message was received. Thanks!");

                break;
            }
        }
예제 #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        LiHyperLink.SetNameToCompare(Context, "UserManagement");

        IGraffitiUser currentUser = GraffitiUsers.Current;


        if (Request.QueryString["user"] != null)
        {
            if (!IsPostBack)
            {
                user = GraffitiUsers.GetUser(Request.QueryString["user"]);


                if (user == null)
                {
                    throw new Exception("This user does not exist or cannot be edited.");
                }

                if (!GraffitiUsers.IsAdmin(currentUser) && user.Name != currentUser.Name)
                {
                    throw new SecurityException("You do not have permission to edit this user");
                }


                if (Request.QueryString["new"] != null && !IsPostBack)
                {
                    Message.Text = "The user <strong>" + user.Name + "</strong> was created.";
                    Message.Type = StatusType.Success;
                }
                PageText.Text            = "Update " + user.ProperName + "'s profile.";
                AdminUserLinks.Visible   = true;
                PasswordLink.NavigateUrl = string.Format("~/graffiti-admin/user-management/users/changepassword.aspx?user={0}", Request.QueryString["user"]);
                if (GraffitiUsers.CanRenameUsers && GraffitiUsers.IsAdmin(GraffitiUsers.Current))
                {
                    AdminUserLinksDelim.Visible = true;
                    RenameLink.Visible          = true;
                    RenameLink.NavigateUrl      = string.Format("javascript:Telligent_Modal.Open('RenameUser.aspx?user={0}', 400, 200, null);", Request.QueryString["user"]);
                }
                txtExistingUserName.Text = Server.HtmlDecode(user.Name);
                txtProperName.Text       = Server.HtmlDecode(user.ProperName);
                txtExistingEmail.Text    = user.Email;
                txtAvatar.Text           = user.Avatar;
                Editor.Text     = user.Bio;
                txtWebsite.Text = string.IsNullOrEmpty(user.WebSite)
                                                                                         ? new Macros().FullUrl(new Urls().Home)
                                                                                         : Server.HtmlEncode(user.WebSite);

                bool isAdmin = GraffitiUsers.IsUserInRole(GraffitiUsers.Current.Name, GraffitiUsers.AdminRole);

                role_section.Visible = isAdmin;
                AllRoles.Visible     = isAdmin;

                if (!isAdmin)
                {
                    Cancel_Edit.NavigateUrl = "~/graffiti-admin/";
                }

                if (isAdmin)
                {
                    RolePermissionsCollection rp = RolePermissionManager.GetRolePermissions();

                    RolePermissionsCollection newrp = new RolePermissionsCollection();
                    newrp.AddRange(rp);

                    RolePermissions temp = newrp.Find(delegate(RolePermissions r)
                    {
                        return(r.RoleName == GraffitiUsers.EveryoneRole);
                    });

                    if (temp != null)
                    {
                        newrp.Remove(temp);
                    }

                    newrp.Sort(delegate(RolePermissions rp1, RolePermissions rp2)
                    {
                        return(Comparer <string> .Default.Compare(rp1.RoleName, rp2.RoleName));
                    });

                    Roles.DataSource = newrp;
                    Roles.DataBind();

                    foreach (string role in user.Roles)
                    {
                        if (role == GraffitiUsers.AdminRole)
                        {
                            chkAdmin.Checked = true;

                            if (GraffitiUsers.Current.Name == user.Name)
                            {
                                chkAdmin.Enabled = false;
                            }
                        }
                    }
                }
            }

            new_user_container.Visible = false;
            User_List.Visible          = false;
            user_edit_form.Visible     = true;
        }
        else
        {
            if (!GraffitiUsers.IsUserInRole(currentUser.Name, GraffitiUsers.AdminRole))
            {
                Response.Redirect("?user="******"*");

            User_List.DataSource = users;
            User_List.DataBind();

            // filter out everyone if they are not a content publisher for licensing
            List <IGraffitiUser> filteredUsers = new List <IGraffitiUser>();
            filteredUsers.AddRange(users);

            bool isEveryonePublisher = RolePermissionManager.IsEveryoneAContentPublisher();

            if (!isEveryonePublisher)
            {
                foreach (IGraffitiUser user in users)
                {
                    if (user.Roles != null && user.Roles[0] == GraffitiUsers.EveryoneRole)
                    {
                        filteredUsers.Remove(user);
                    }
                }
            }
        }
    }