From bf900e824f2c661df6380fd0360c13377da58bae Mon Sep 17 00:00:00 2001 From: xue <> Date: Wed, 31 May 2006 01:00:38 +0000 Subject: Fixed a few issues with the blog system. --- demos/blog/protected/Common/BlogDataModule.php | 4 ++-- demos/blog/protected/Layouts/MainLayout.tpl | 2 +- demos/blog/protected/Pages/Admin/PostMan.page | 2 +- demos/blog/protected/Pages/Admin/PostMan.php | 2 +- demos/blog/protected/Pages/Posts/NewPost.php | 1 + demos/blog/protected/Pages/Posts/ViewPost.php | 4 ++-- 6 files changed, 8 insertions(+), 7 deletions(-) (limited to 'demos') diff --git a/demos/blog/protected/Common/BlogDataModule.php b/demos/blog/protected/Common/BlogDataModule.php index 9c074260..b8f2b7d9 100644 --- a/demos/blog/protected/Common/BlogDataModule.php +++ b/demos/blog/protected/Common/BlogDataModule.php @@ -282,8 +282,8 @@ class BlogDataModule extends TModule $title=sqlite_escape_string($post->Title); $content=sqlite_escape_string($post->Content); $sql="INSERT INTO tblPosts - (author_id,create_time,title,content,status) - VALUES ({$post->AuthorID},{$post->CreateTime},'$title','$content',{$post->Status})"; + (author_id,create_time,modify_time,title,content,status) + VALUES ({$post->AuthorID},{$post->CreateTime},{$post->ModifyTime},'$title','$content',{$post->Status})"; $this->query($sql); $post->ID=sqlite_last_insert_rowid($this->_db); foreach($catIDs as $catID) diff --git a/demos/blog/protected/Layouts/MainLayout.tpl b/demos/blog/protected/Layouts/MainLayout.tpl index f3a77adc..8e2b1792 100644 --- a/demos/blog/protected/Layouts/MainLayout.tpl +++ b/demos/blog/protected/Layouts/MainLayout.tpl @@ -14,7 +14,7 @@ diff --git a/demos/blog/protected/Pages/Admin/PostMan.page b/demos/blog/protected/Pages/Admin/PostMan.page index 8c78574c..68ac44f8 100644 --- a/demos/blog/protected/Pages/Admin/PostMan.page +++ b/demos/blog/protected/Pages/Admin/PostMan.page @@ -60,7 +60,7 @@ PostGrid->CurrentPageIndex*$this->PostGrid->PageSize; $limit=$this->PostGrid->PageSize; - $this->PostGrid->DataSource=$this->DataAccess->queryPosts('','','ORDER BY a.status DESC, create_time DESC',"LIMIT $offset,$limit"); + $this->PostGrid->DataSource=$this->DataAccess->queryPosts('','','ORDER BY a.status DESC, modify_time DESC',"LIMIT $offset,$limit"); $this->PostGrid->VirtualItemCount=$this->DataAccess->queryPostCount('',''); $this->PostGrid->dataBind(); } diff --git a/demos/blog/protected/Pages/Posts/NewPost.php b/demos/blog/protected/Pages/Posts/NewPost.php index 7d02557d..bba09975 100644 --- a/demos/blog/protected/Pages/Posts/NewPost.php +++ b/demos/blog/protected/Pages/Posts/NewPost.php @@ -43,6 +43,7 @@ class NewPost extends BlogPage else $postRecord->Status=PostRecord::STATUS_PUBLISHED; $postRecord->CreateTime=time(); + $postRecord->ModifyTime=$postRecord->CreateTime; $postRecord->AuthorID=$this->User->ID; $cats=array(); foreach($this->Categories->SelectedValues as $value) diff --git a/demos/blog/protected/Pages/Posts/ViewPost.php b/demos/blog/protected/Pages/Posts/ViewPost.php index 8d0a7124..e45fd505 100644 --- a/demos/blog/protected/Pages/Posts/ViewPost.php +++ b/demos/blog/protected/Pages/Posts/ViewPost.php @@ -29,7 +29,7 @@ class ViewPost extends BlogPage if($this->_post===null) throw new BlogException(500,'post_id_invalid',$id); // if post is not published, only the author and admin can view it - if($this->_post->Status!==PostRecord::STATUS_PUBLISHED && !$this->User->IsAdmin && $this->User->ID!==$this->_post->AuthorID) + if($this->_post->Status!==PostRecord::STATUS_PUBLISHED && $this->_post->Status!==PostRecord::STATUS_STICKY && !$this->User->IsAdmin && $this->User->ID!==$this->_post->AuthorID) throw new BlogException(500,'post_view_disallowed',$id); $this->Title=htmlentities($this->_post->Title,ENT_QUOTES,'UTF-8'); } @@ -48,7 +48,7 @@ class ViewPost extends BlogPage public function onLoad($param) { parent::onLoad($param); - $this->Status->Visible=$this->_post->Status!==PostRecord::STATUS_PUBLISHED; + $this->Status->Visible=$this->_post->Status!==PostRecord::STATUS_PUBLISHED && $this->_post->Status!==PostRecord::STATUS_STICKY; $this->CategoryList->DataSource=$this->DataAccess->queryCategoriesByPostID($this->_post->ID); $this->CategoryList->dataBind(); $this->CommentList->DataSource=$this->DataAccess->queryCommentsByPostID($this->_post->ID); -- cgit v1.2.3