summaryrefslogtreecommitdiff
path: root/view_post.php
blob: 63bc73090411b161a9b8f13b9ccc71ed16655089 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
 * @version $Header$
 *
 * @package blogs
 * @subpackage functions
 */

// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See below for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details.

/**
 * required setup
 */
require_once '../kernel/includes/setup_inc.php';
use Bitweaver\Blogs\BitBlogPost;

$gBitSystem->verifyPackage( 'blogs' );

include_once BLOGS_PKG_INCLUDE_PATH.'lookup_post_inc.php';

if( !$gContent->isValid() ) {
	$gBitSystem->setHttpStatus( 404 );
	$gBitSystem->fatalError( "The blog post you requested could not be found." );
}

$gContent->verifyViewPermission();

$now = $gBitSystem->getUTCTime();
$view = false;

if ( $gContent->hasAdminPermission()  || ( $gContent->hasUserPermission( 'p_blog_posts_read_future' ) && $gContent->hasUserPermission( 'p_blog_posts_read_expired' ) ) ){
	$view = true;
}elseif ( $gContent->mInfo['publish_date'] == $gContent->mInfo['expire_date'] ) {
	$view = true;
}elseif ( $gContent->mInfo['publish_date'] > $now && $gContent->hasUserPermission( 'p_blog_posts_read_future' ) ){
	$view = true;
}elseif ( $gContent->mInfo['expire_date'] < $now && $gContent->hasUserPermission( 'p_blog_posts_read_expired' ) ){
	$view = true;
}elseif ( ( $gContent->mInfo['publish_date'] <= $now ) && ( $gContent->mInfo['expire_date'] > $now || $gContent->mInfo['expire_date'] <= $gContent->mInfo['publish_date'] ) ){
	$view = true;
}

if ($view == true){
	include_once BLOGS_PKG_INCLUDE_PATH.'display_bitblogpost_inc.php';
}else{
	$gBitSystem->setHttpStatus( 404 );
	$gBitSystem->fatalError( "The blog post you requested could not be found." );
}

if( $gContent->isValid() ) {
	$gContent->addHit();
}