示例#1
0
 public function onInit($param)
 {
     parent::onInit($param);
     $id = TPropertyValue::ensureInteger($this->Request['id']);
     $this->_category = $this->DataAccess->queryCategoryByID($id);
     if ($this->_category === null) {
         throw new BlogException(500, 'category_id_invalid', $id);
     }
 }
示例#2
0
 public function onInit($param)
 {
     parent::onInit($param);
     $this->_posts = $this->DataAccess->queryPosts($this->getPostFilter(), $this->getCategoryFilter(), 'ORDER BY a.status DESC, create_time DESC', 'LIMIT ' . $this->getPageOffset() . ',' . $this->getPageSize());
     if ($this->Request['cat'] !== null) {
         $catID = TPropertyValue::ensureInteger($this->Request['cat']);
         $this->_category = $this->DataAccess->queryCategoryByID($catID);
         $this->CategoryPanel->Visible = true;
     }
     $this->Title = $this->Application->Parameters['SiteTitle'];
 }
示例#3
0
 public function onInit($param)
 {
     parent::onInit($param);
     $id = TPropertyValue::ensureInteger($this->Request['id']);
     $this->_postRecord = $this->DataAccess->queryPostByID($id);
     if ($this->_postRecord === null) {
         throw new BlogException(500, 'post_id_invalid', $id);
     }
     // only the author and admin can edit the post
     if (!$this->User->IsAdmin && $this->User->ID !== $this->_postRecord->AuthorID) {
         throw new BlogException(500, 'post_edit_disallowed', $id);
     }
 }
示例#4
0
 public function onInit($param)
 {
     parent::onInit($param);
     if (($id = $this->Request['id']) !== null) {
         $id = TPropertyValue::ensureInteger($id);
     } else {
         $id = $this->User->ID;
     }
     if (($this->_userRecord = $this->DataAccess->queryUserByID($id)) === null) {
         throw new BlogException(500, 'profile_id_invalid', $id);
     }
     $this->_userRecord->Email = strtr(strtoupper($this->_userRecord->Email), array('@' => ' at ', '.' => ' dot '));
 }
示例#5
0
 public function onInit($param)
 {
     parent::onInit($param);
     $id = TPropertyValue::ensureInteger($this->Request['id']);
     $this->_post = $this->DataAccess->queryPostByID($id);
     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->_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');
 }
示例#6
0
 public function onInit($param)
 {
     parent::onInit($param);
     if (($id = $this->Request['id']) !== null) {
         $id = TPropertyValue::ensureInteger($id);
         if (!$this->User->IsAdmin && $this->User->ID !== $id) {
             throw new BlogException(500, 'profile_edit_disallowed', $id);
         }
     } else {
         $id = $this->User->ID;
     }
     if (($this->_userRecord = $this->DataAccess->queryUserByID($id)) === null) {
         throw new BlogException(500, 'profile_id_invalid', $id);
     }
 }
示例#7
0
 public function onInit($param)
 {
     parent::onInit($param);
     $this->_posts = $this->DataAccess->queryPostsSearch($this->getPostKeywords(), 'ORDER BY create_time DESC', 'LIMIT ' . $this->getPageOffset() . ',' . $this->getPageSize());
 }