Example #1
0
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            #region 保存相册分类
            if (this.CheckCookie())
            {
                //

                //AlbumCategoryInfo aci = new AlbumCategoryInfo();
                //aci.Title = title;
                //aci.Description = description;
                //aci.Displayorder = displayorder;

                //int albumcateid = Utils.StrToInt(this.albumCateId.Value, 0);
                ////增加新分类
                //if (albumcateid == 0)
                //{
                //    DatabaseProvider.GetInstance().AddAlbumCategory(aci);
                //}
                //else//更新原分类
                //{
                //    aci.Albumcateid = albumcateid;
                //    DatabaseProvider.GetInstance().UpdateAlbumCategory(aci);
                //}
                int  row   = 0;
                bool error = false;
                foreach (object o in DataGrid1.GetKeyIDArray())
                {
                    int    id           = int.Parse(o.ToString());
                    string title        = DataGrid1.GetControlValue(row, "title").Trim();
                    string description  = DataGrid1.GetControlValue(row, "description").Trim();
                    string displayorder = DataGrid1.GetControlValue(row, "displayorder");
                    if (title == "" || displayorder == "")
                    {
                        error = true;
                        continue;
                    }
                    AlbumCategoryInfo aci = new AlbumCategoryInfo();
                    aci.Title        = title;
                    aci.Description  = description;
                    aci.Displayorder = int.Parse(displayorder);
                    aci.Albumcateid  = id;
                    DbProvider.GetInstance().UpdateAlbumCategory(aci);
                    row++;
                    if (error)
                    {
                        //
                    }
                }

                //更新缓存
                Discuz.Cache.DNTCache.GetCacheService().RemoveObject("/Space/AlbumCategory");
                Discuz.Cache.DNTCache.GetCacheService().RemoveObject("/Photo/AlbumCategoryMenu");
                BindData();
                Response.Redirect("album_categorymanage.aspx");
            }
            #endregion
        }
        public void AddAlbumCategory(AlbumCategoryInfo aci)
        {
            DbParameter[] parms =
            {
                DbHelper.MakeInParam("@title",        (DbType)SqlDbType.NChar,  50, aci.Title),
                DbHelper.MakeInParam("@description",  (DbType)SqlDbType.NChar, 300, aci.Description),
                DbHelper.MakeInParam("@displayorder", (DbType)SqlDbType.Int,     4, aci.Displayorder)
            };

            string commandText = string.Format(@"INSERT INTO [{0}albumcategories]([title], [description], [albumcount], [displayorder]) VALUES(@title, @description, 0, @displayorder)", BaseConfigs.GetTablePrefix);

            DbHelper.ExecuteNonQuery(CommandType.Text, commandText, parms);
        }
        public void UpdateAlbumCategory(AlbumCategoryInfo aci)
        {
            DbParameter[] parms =
            {
                DbHelper.MakeInParam("@albumcateid",  (DbType)SqlDbType.Int,     4, aci.Albumcateid),
                DbHelper.MakeInParam("@title",        (DbType)SqlDbType.NChar,  50, aci.Title),
                DbHelper.MakeInParam("@description",  (DbType)SqlDbType.NChar, 300, aci.Description),
                DbHelper.MakeInParam("@displayorder", (DbType)SqlDbType.Int,     4, aci.Displayorder)
            };

            string commandText = string.Format(@"UPDATE [{0}albumcategories] SET [title]=@title, [description]=@description, [displayorder]=@displayorder WHERE [albumcateid]=@albumcateid", BaseConfigs.GetTablePrefix);

            DbHelper.ExecuteNonQuery(CommandType.Text, commandText, parms);
        }
Example #4
0
        protected void Save_Click(object sender, EventArgs e)
        {
            string title        = this.albumcateTitle.Text;
            string description  = this.description.Text;
            int    displayorder = Utils.StrToInt(this.displayorder.Text, 0);

            //bool error = false;
            if (title == "" || this.displayorder.Text == "")
            {
                //error = true;
                return;
            }
            AlbumCategoryInfo aci = new AlbumCategoryInfo();

            aci.Title        = title;
            aci.Description  = description;
            aci.Displayorder = displayorder;
            DbProvider.GetInstance().AddAlbumCategory(aci);
        }
Example #5
0
 protected void DataGrid1_EditCommand(object source, DataGridCommandEventArgs e)
 {
     #region 加载编辑分类
     if (this.CheckCookie())
     {
         //编辑一个分类
         BindData();
         int albumcateid = Utils.StrToInt(DataGrid1.DataKeys[e.Item.ItemIndex], 0);
         if (albumcateid > 0)
         {
             AlbumCategoryInfo aci = DTOProvider.GetAlbumCategory(albumcateid);
             this.albumcateTitle.Text = aci.Title;
             this.description.Text    = aci.Description;
             this.displayorder.Text   = aci.Displayorder.ToString();
         }
         prompt.Text = "编辑相册分类";
     }
     #endregion
 }
        public Discuz.Common.Generic.List <AlbumCategoryInfo> GetAlbumCategory()
        {
            string commandText = string.Format("SELECT * FROM [{0}albumcategories] ORDER BY [displayorder]", BaseConfigs.GetTablePrefix);

            IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, commandText);

            Discuz.Common.Generic.List <AlbumCategoryInfo> acic = new Discuz.Common.Generic.List <AlbumCategoryInfo>();
            while (reader.Read())
            {
                AlbumCategoryInfo aci = new AlbumCategoryInfo();
                aci.Albumcateid  = TypeConverter.ObjectToInt(reader["albumcateid"], 0);
                aci.Albumcount   = TypeConverter.ObjectToInt(reader["albumcount"], 0);
                aci.Description  = reader["description"].ToString();
                aci.Displayorder = TypeConverter.ObjectToInt(reader["displayorder"], 0);
                aci.Title        = reader["title"].ToString();
                acic.Add(aci);
            }
            reader.Close();
            return(acic);
        }
Example #7
0
        protected override void ShowPage()
        {
            if (config.Enablealbum != 1)
            {
                AddErrLine("相册功能已被关闭");
                return;
            }

            forumpath = BaseConfigs.GetForumPath;
            if (albumid < 1)
            {
                AddErrLine("指定的相册不存在");
                return;
            }

            album = DTOProvider.GetAlbumInfo(albumid);
            if (album == null)
            {
                AddErrLine("指定的相册不存在");
                return;
            }

            if (config.Rssstatus == 1)
            {
                if (GeneralConfigs.GetConfig().Aspxrewrite == 1)
                {
                    photorssurl = string.Format("photorss-{0}{1}", album.Userid, GeneralConfigs.GetConfig().Extname);
                }
                else
                {
                    photorssurl = string.Format("rss.aspx?uid={0}&type=photo", album.Userid);
                }

                AddLinkRss(string.Format("tools/{0}", photorssurl), "最新图片");
            }

            pagetitle = album.Title;

            //权限验证部分,私有相册,不是相册所有者
            if (album.Type == 1 && album.Userid != userid)
            {
                if (ForumUtils.GetCookie("album" + albumid + "password") != Utils.MD5(album.Password))
                {
                    //首先验证Cookie中如果相册密码不正确,则要求输入密码,并以输入值验证
                    string password = DNTRequest.GetFormString("albumpassword");
                    if (album.Password == password)
                    {
                        ForumUtils.WriteCookie("album" + albumid + "password", Utils.MD5(password));
                        needpassword = false;
                    }
                }
                else
                {
                    needpassword = false;
                }
            }
            else
            {
                needpassword = false;
            }

            if (Utils.InArray(usergroupid.ToString(), config.Photomangegroups))
            {
                needpassword = false;
            }

            albumcategory = DTOProvider.GetAlbumCategory(album.Albumcateid);
            photoscount   = DTOProvider.GetSpacePhotosCount(albumid);

            pageCount = photoscount % pageSize == 0 ? photoscount / pageSize : photoscount / pageSize + 1;

            if (pageCount == 0)
            {
                pageCount = 1;
            }

            if (currentpage < 1)
            {
                currentpage = 1;
            }

            if (currentpage > pageCount)
            {
                currentpage = pageCount;
            }

            pagenumbers = Utils.GetPageNumbers(currentpage, pageCount, string.Format("showalbum.aspx?albumid={0}", albumid), 8);
            photolist   = DTOProvider.GetSpacePhotosInfo(DbProvider.GetInstance().SpacePhotosList(pageSize, currentpage, album.Userid, album.Albumid));

            foreach (PhotoInfo photo in photolist)
            {
                //当是远程照片时
                if (photo.Filename.IndexOf("http") < 0)
                {
                    photo.Filename = forumpath + Globals.GetThumbnailImage(photo.Filename);
                }
                else
                {
                    photo.Filename = Globals.GetThumbnailImage(photo.Filename);
                }
            }

            if (photolist.Count == 0)
            {
                AddMsgLine("暂无图片");
            }

            ForumUtils.WriteCookie("referer", string.Format("showalbum.aspx?albumid={0}&page={1}", albumid, currentpage));
        }
Example #8
0
        protected override void ShowPage()
        {
            pagetitle = "相册列表";

            if (config.Enablealbum != 1)
            {
                AddErrLine("相册功能已被关闭");
                return;
            }

            if (albumsuserid == -1 && userid != -1)
            {
                albumsuserid = userid;
            }

            if (currentcate != 0)
            {
                currentalbumcategory = DTOProvider.GetAlbumCategory(currentcate);
                pagetitle            = currentalbumcategory.Title;
            }
            if (albumsuserid != 0)
            {
                ShortUserInfo shortUserInfo = Users.GetShortUserInfo(albumsuserid);
                albumusername = shortUserInfo == null ? "" : shortUserInfo.Username;
                pagetitle     = albumusername + "的" + pagetitle;
            }

            albumscount = DTOProvider.GetSpaceAlbumListCount(albumsuserid, currentcate);
            pagecount   = albumscount % pageSize == 0 ? albumscount / pageSize : albumscount / pageSize + 1;
            if (pagecount == 0)
            {
                pagecount = 1;
            }

            if (currentpage < 1)
            {
                currentpage = 1;
            }

            if (currentpage > pagecount)
            {
                currentpage = pagecount;
            }

            string parm = string.Empty;

            if (currentcate != 0)
            {
                parm = "cate=" + currentcate;
                if (albumsuserid != 0)
                {
                    parm += "&uid=" + albumsuserid;
                }
            }
            else if (albumsuserid != 0)
            {
                parm += "uid=" + albumsuserid;
            }

            if (parm != string.Empty)
            {
                parm += "&page=";
            }
            else
            {
                parm += "page=";
            }

            if (currentpage > 1)
            {
                prevpage = "<a href='showalbumlist.aspx?" + parm + (currentpage - 1) + "'>上一页</a>";
            }

            if (currentpage < pagecount)
            {
                nextpage = "<a href='showalbumlist.aspx?" + parm + (currentpage + 1) + "'>下一页</a>";
            }

            pagenumbers = Utils.GetPageNumbers(currentpage, pagecount, "showalbumlist.aspx", 8);
            albumlist   = DTOProvider.GetSpaceAlbumList(albumsuserid, currentcate, pageSize, currentpage);

            if (albumlist.Count == 0)
            {
                AddMsgLine("暂无相册");
            }
        }
Example #9
0
        protected override void ShowPage()
        {
            if (config.Enablealbum != 1)
            {
                AddErrLine("相册功能已被关闭");
                return;
            }

            //一周热图总排行
            weekhotphotolist = AggregationFacade.AlbumAggregation.GetWeekHotPhotoList(photoconfig.Weekhot);
            string go = DNTRequest.GetString("go");

            switch (go)
            {
            case "prev":
                mode = 1;
                break;

            case "next":
                mode = 2;
                break;

            default:
                mode = 0;
                break;
            }

            if (photoid < 1)
            {
                AddErrLine("指定的图片不存在");
                return;
            }

            photo = DTOProvider.GetPhotoInfo(photoid, 0, 0);
            if (photo == null)
            {
                AddErrLine("指定的图片不存在");
                return;
            }

            album = DTOProvider.GetAlbumInfo(photo.Albumid);
            if (album == null)
            {
                AddErrLine("指定的相册不存在");
                return;
            }

            if (mode != 0)
            {
                photo = DTOProvider.GetPhotoInfo(photoid, photo.Albumid, mode);
                if (photo == null)
                {
                    AddErrLine("指定的图片不存在");
                    return;
                }
            }

            if (config.Rssstatus == 1)
            {
                if (GeneralConfigs.GetConfig().Aspxrewrite == 1)
                {
                    photorssurl = string.Format("photorss-{0}{1}", photo.Userid, GeneralConfigs.GetConfig().Extname);
                }
                else
                {
                    photorssurl = string.Format("rss.aspx?uid={0}&type=photo", photo.Userid);
                }

                AddLinkRss(string.Format("tools/{0}", photorssurl), "最新图片");
            }

            comments  = DTOProvider.GetPhotoCommentCollection(photo.Photoid);
            pagetitle = photo.Title;

            //权限验证部分,私有相册,不是相册所有者
            if (album.Type == 1 && album.Userid != userid)
            {
                if (ForumUtils.GetCookie("album" + photo.Albumid + "password") != Utils.MD5(album.Password))
                {
                    //首先验证Cookie中如果相册密码不正确,则要求输入密码,并以输入值验证
                    string password = DNTRequest.GetFormString("albumpassword");
                    if (album.Password == password)
                    {
                        ForumUtils.WriteCookie("album" + photo.Albumid + "password", Utils.MD5(password));
                        needpassword = false;
                    }
                }
                else
                {
                    needpassword = false;
                }
            }
            else
            {
                needpassword = false;
            }

            if (Utils.InArray(usergroupid.ToString(), config.Photomangegroups))
            {
                needpassword = false;
            }

            albumcategory = DTOProvider.GetAlbumCategory(album.Albumcateid);
            jsonfilename  = "cache/album/" + (album.Albumid / 1000 + 1).ToString() + "/" + album.Albumid.ToString() + "_json.txt";

            //非图片所有者时更新图片浏览量
            if (userid != photo.Userid)
            {
                DTOProvider.UpdatePhotoViews(photoid);
            }

            //判断权限
            {
                switch (photo.Commentstatus)
                {
                case PhotoStatus.Owner:
                    if (userid != photo.Userid)
                    {
                        commentable = false;
                    }
                    break;
                }
                if (userid < 1)
                {
                    commentable = false;
                }

                //重构时加入指定管理用户组
                if (userid == photo.Userid || Utils.InArray(usergroupid.ToString(), config.Photomangegroups))
                {
                    editable = true;
                }
            }

            // 如果评论数不同步则同步
            if (photo.Comments != comments.Count)
            {
                DbProvider.GetInstance().UpdatePhotoComments(photo.Photoid, comments.Count - photo.Comments);//更新评论数
            }
            if (ispost)
            {
                string message = DNTRequest.GetFormString("message").Trim();
                int    delcid  = DNTRequest.GetFormInt("delcommentid", 0);
                if (message != string.Empty)
                {
                    SavePhotoComment(message);
                    return;
                }
                else if (delcid > 0)
                {
                    if (editable)
                    {
                        DbProvider.GetInstance().DeletePhotoComment(delcid);
                        //更新评论数
                        DbProvider.GetInstance().UpdatePhotoComments(photo.Photoid, -1);
                        AddMsgLine("删除成功!");
                        SetUrl("showphoto.aspx?photoid=" + photo.Photoid);
                        SetMetaRefresh();
                        return;
                    }
                }
                AddErrLine("非法操作");
                SetMetaRefresh();
            }
        }