Beispiel #1
0
        protected virtual void LoadSettings()
        {
            FileSystemProvider p = FileSystemManager.Providers[WebConfigSettings.FileSystemProvider];

            if (p != null)
            {
                fileSystem = p.GetFileSystem();
            }
            current = SiteUtils.GetCurrentSiteUser();
            if (current != null)
            {
                author = KLAuthor.GetKLAuthorByUserID(current.UserId);
                GeneralVariables.NameAuthor = current.Name;
                GeneralVariables.Level      = author.LevelAuthor;
                if (author != null)
                {
                    txtfb.Text              = author.LinkFacebook;
                    txtinstagram.Text       = author.LinkInstagram;
                    txtpinterest.Text       = author.LinkPinterest;
                    txttwinter.Text         = author.LinkTwitter;
                    txtFullName.Text        = author.Name;
                    txtEmail.Text           = current.Email;
                    editDescription.Content = current.Signature;
                    ImageAvatar.ImageUrl    = AuthorHepper.GetAvatarAuthor(siteSettings.SiteId, author.UserID);
                }
            }
            else
            {
                WebUtils.SetupRedirect(this, SiteRoot);
            }
        }
Beispiel #2
0
        public static string GetImageFilePath(int siteId, int AuthorId, string imageFile, string thumbnail)
        {
            if (imageFile.Length == 0 && thumbnail.Length == 0)
            {
                return(string.Empty);
            }

            if (thumbnail.Contains("/"))
            {
                return(thumbnail);
            }

            string mediaFolderPath = System.Web.VirtualPathUtility.ToAbsolute(AuthorHepper.MediaFolderPath(siteId, AuthorId));

            if (!string.IsNullOrEmpty(thumbnail))
            {
                return(mediaFolderPath + "thumbs/" + thumbnail);
            }

            if (imageFile.Contains("/"))
            {
                return(imageFile);
            }

            return(mediaFolderPath + imageFile);
        }
Beispiel #3
0
 private void LoadSettings()
 {
     currentUser  = SiteUtils.GetCurrentSiteUser();
     newsID       = WebUtils.ParseInt32FromQueryString("newsID", newsID);
     siteSettings = CacheHelper.GetCurrentSiteSettings();
     timeOffset   = SiteUtils.GetUserTimeOffset();
     timeZone     = SiteUtils.GetUserTimeZone();
     if (currentUser == null)
     {
         imgAvatar.ImageUrl = "/Data/Sites/1/Author/Authordefault.png";
         currentUser        = SiteUser.GetByEmail(siteSettings, "*****@*****.**");
     }
     else
     {
         author             = KLAuthor.GetKLAuthorByUserID(currentUser.UserId);
         imgAvatar.ImageUrl = AuthorHepper.MediaFolderPath(1, author.UserID) + author.Avatar;
         txtEmail.Text      = currentUser.Email;
         txtFullName.Text   = currentUser.Name;
     }
     news = new KLNews(newsID, 0);
 }
Beispiel #4
0
        protected virtual void LoadSettings()
        {
            currentUser = SiteUtils.GetCurrentSiteUser();
            if (currentUser == null)
            {
                WebUtils.SetupRedirect(this, SiteRoot);
            }
            if (newsId > -1)
            {
                news = new News(siteSettings.SiteId, newsId);
                if (news != null && news.NewsID > 0)
                {
                    KLnews = new KLNews(news.NewsID, 0);
                    if (news.IsDeleted)
                    {
                        SiteUtils.RedirectToEditAccessDeniedPage();
                        return;
                    }
                    newsType        = news.NewsType;
                    imageFolderPath = NewsHelper.MediaFolderPath(siteSettings.SiteId, news.NewsID);
                }
            }

            shortcontent.ImageManager.ViewPaths   = new string[] { AuthorHepper.PublicFolderPath(siteSettings.SiteId, currentUser.UserId) };
            shortcontent.ImageManager.UploadPaths = new string[] { AuthorHepper.PublicFolderPath(siteSettings.SiteId, currentUser.UserId) };
            shortcontent.ImageManager.DeletePaths = new string[] { AuthorHepper.PublicFolderPath(siteSettings.SiteId, currentUser.UserId) };


            fullcontent.ImageManager.ViewPaths   = new string[] { AuthorHepper.PublicFolderPath(siteSettings.SiteId, currentUser.UserId) };
            fullcontent.ImageManager.UploadPaths = new string[] { AuthorHepper.PublicFolderPath(siteSettings.SiteId, currentUser.UserId) };
            fullcontent.ImageManager.DeletePaths = new string[] { AuthorHepper.PublicFolderPath(siteSettings.SiteId, currentUser.UserId) };

            FileSystemProvider p = FileSystemManager.Providers[WebConfigSettings.FileSystemProvider];

            if (p != null)
            {
                fileSystem = p.GetFileSystem();
            }
        }
        private int Save()
        {
            checkpass();
            if (comfim)
            {
                try
                {
                    var    full = txtFullName.Text.Trim().Split(' ');
                    string Fist = "";
                    string Last = "";
                    for (int i = 0; i < full.Length; i++)
                    {
                        if ((i + 1) < full.Length)
                        {
                            Last += full[i];
                        }
                        else
                        {
                            Fist += full[i];
                        }
                    }
                    SiteUser user = new SiteUser(siteSettings)
                    {
                        Name      = txtFullName.Text.Trim(),
                        FirstName = Fist,
                        LastName  = Last,
                        Email     = txtEmail.Text.Trim(),
                        LoginName = txtFullName.Text.Trim().Replace(' ', '-'),
                        Password  = txtPass2.Text,
                    };
                    user.Save();
                    user = new SiteUser(siteSettings, txtFullName.Text.Replace(' ', '-'));
                    KLAuthor author = null;

                    imageFolderPath = AuthorHepper.MediaFolderPath(siteSettings.SiteId, user.UserId);
                    if (user.Save())
                    {
                        author = new KLAuthor()
                        {
                            ArticleCount = 0,
                            UserID       = user.UserId,
                            IsDel        = false,
                            LevelAuthor  = "Basic",
                            Name         = txtFullName.Text,
                            IsActive     = false,
                        };
                        if (fileImage.UploadedFiles.Count > 0)
                        {
                            imageFolderPath = AuthorHepper.MediaFolderPath(siteSettings.SiteId, user.UserId);


                            AuthorHepper.VerifyAuthorFolders(fileSystem, imageFolderPath);

                            foreach (UploadedFile file in fileImage.UploadedFiles)
                            {
                                string ext = file.GetExtension();
                                if (SiteUtils.IsAllowedUploadBrowseFile(ext, WebConfigSettings.ImageFileExtensions))
                                {
                                    ContentMedia media = new ContentMedia();
                                    media.SiteGuid = siteSettings.SiteGuid;
                                    //image.Title = txtImageTitle.Text;
                                    media.DisplayOrder = 0;

                                    string newFileName  = file.FileName.ToCleanFileName(WebConfigSettings.ForceLowerCaseForUploadedFiles);
                                    string newImagePath = VirtualPathUtility.Combine(imageFolderPath, newFileName);

                                    if (media.MediaFile == newFileName)
                                    {
                                        // an existing image delete the old one
                                        fileSystem.DeleteFile(newImagePath);
                                    }
                                    else
                                    {
                                        // this is a new newsImage instance, make sure we don't use the same file name as any other instance
                                        int i = 1;
                                        while (fileSystem.FileExists(VirtualPathUtility.Combine(imageFolderPath, newFileName)))
                                        {
                                            newFileName = i.ToInvariantString() + newFileName;
                                            i          += 1;
                                        }
                                    }

                                    newImagePath = VirtualPathUtility.Combine(imageFolderPath, newFileName);

                                    file.SaveAs(Server.MapPath(newImagePath));

                                    media.MediaFile     = newFileName;
                                    media.ThumbnailFile = newFileName;

                                    author.Avatar = newFileName;
                                    media.Save();
                                    AuthorHepper.ProcessImage(media, fileSystem, imageFolderPath, file.FileName);
                                }
                            }
                        }
                    }
                    author.Save();

                    Role role = new Role(siteSettings.SiteId, "Author");
                    Role.AddUser(role.RoleId, author.UserID, role.RoleGuid, user.UserGuid);

                    if (!sendmail(user.Name, user.Email))
                    {
                        return(-1);
                    }

                    return(author.UserID);
                }
                catch (Exception ex)
                {
                    log.Error(ex.Message);
                }
            }
            return(-1);
        }
Beispiel #6
0
 protected string getImageURL()
 {
     return(AuthorHepper.GetAvatarAuthor(siteSettings.SiteId, current.UserId));
 }
 protected string getImageURL(int userid)
 {
     return(AuthorHepper.GetAvatarAuthor(siteSettings.SiteId, userid));
 }
Beispiel #8
0
        protected string getimgURL(int CommentId)
        {
            KLNewsComment com = new KLNewsComment(CommentId);

            return(AuthorHepper.GetAvatarAuthor(siteSettings.SiteId, com.UserID));
        }
Beispiel #9
0
        private int Save()
        {
            Page.Validate("Author");

            if (!Page.IsValid)
            {
                return(-1);
            }
            try
            {
                author.LinkFacebook  = txtfb.Text;
                author.LinkInstagram = txtinstagram.Text;
                author.LinkPinterest = txtpinterest.Text;
                author.LinkTwitter   = txttwinter.Text;
                author.Name          = txtFullName.Text;
                SiteUser temp = new SiteUser(siteSettings, author.UserID);
                temp.Signature = editDescription.Text;
                if (fileImage.UploadedFiles.Count > 0)
                {
                    imageFolderPath = AuthorHepper.MediaFolderPath(siteSettings.SiteId, author.UserID);


                    AuthorHepper.VerifyAuthorFolders(fileSystem, imageFolderPath);

                    foreach (UploadedFile file in fileImage.UploadedFiles)
                    {
                        string ext = file.GetExtension();
                        if (SiteUtils.IsAllowedUploadBrowseFile(ext, WebConfigSettings.ImageFileExtensions))
                        {
                            ContentMedia media = new ContentMedia();
                            media.SiteGuid = siteSettings.SiteGuid;
                            //image.Title = txtImageTitle.Text;
                            media.DisplayOrder = 0;

                            string newFileName  = file.FileName.ToCleanFileName(WebConfigSettings.ForceLowerCaseForUploadedFiles);
                            string newImagePath = VirtualPathUtility.Combine(imageFolderPath, newFileName);

                            if (media.MediaFile == newFileName)
                            {
                                // an existing image delete the old one
                                fileSystem.DeleteFile(newImagePath);
                            }
                            else
                            {
                                // this is a new newsImage instance, make sure we don't use the same file name as any other instance
                                int i = 1;
                                while (fileSystem.FileExists(VirtualPathUtility.Combine(imageFolderPath, newFileName)))
                                {
                                    newFileName = i.ToInvariantString() + newFileName;
                                    i          += 1;
                                }
                            }

                            newImagePath = VirtualPathUtility.Combine(imageFolderPath, newFileName);

                            file.SaveAs(Server.MapPath(newImagePath));

                            media.MediaFile     = newFileName;
                            media.ThumbnailFile = newFileName;

                            author.Avatar = newFileName;
                            media.Save();
                            AuthorHepper.ProcessImage(media, fileSystem, imageFolderPath, file.FileName);
                        }
                    }
                }


                if (temp.Save() && author.Save())
                {
                    ImageAvatar.ImageUrl = AuthorHepper.GetAvatarAuthor(siteSettings.SiteId, author.UserID);
                    LogActivity.Write("Update Author", author.Name);
                    message.SuccessMessage = ResourceHelper.GetResourceString("CustomResources", "UpdateAuthorSuccess");
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
            }
            return(author.AuthorID);
        }
Beispiel #10
0
        protected string getGuestImage(int authorid)
        {
            int userid = new KLAuthor(authorid).UserID;

            return(AuthorHepper.GetAvatarAuthor(siteSettings.SiteId, userid));
        }