-
Notifications
You must be signed in to change notification settings - Fork 0
/
single-uamp_article.php
78 lines (67 loc) · 2.6 KB
/
single-uamp_article.php
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/*
*Template Name: UAMP Article Template
*/
get_header();
?>
<div id="primary">
<div id="content" role="main">
<?php
$loop = new WP_Query(array("post_type" => "uamp_article"));
if(is_user_logged_in())
$userID = get_current_user_id();
while($loop->have_posts() ): $loop->the_post();
?>
<?php
$article = UAMP_Article::find($post->ID);
if( is_user_logged_in() || ( $article->visibility == "Public" && $article->isApproved() ) ):
?>
<article id="post-<?php the_ID() ?>" <?php post_class(); ?>>
<header class="entry-header">
<!-- Display featured image in right-aligned floating div -->
<div style="float: right; margin: 10px">
<?php the_post_thumbnail( array( 100, 100 ) ); ?>
</div>
<!-- Display Title and Author Name -->
<strong>Title: </strong><?php the_title(); ?><br />
<?php if(is_user_logged_in()): ?>
<?php
echo $article->visibility."<br/>";
if($article->isApproved())
echo "<strong>Approved</strong><br/>";
else
echo "<strong>Not Approved</strong><br/>";
$approval = $article->getApproval($userID);
if(!$approval && isset($_POST["uamp_approval_save"])) {
$desc = $_POST["uamp_approval_desc"];
$article->approve($userID, $desc);
$approval = $article->getApproval($userID);
}
if($approval && isset($_GET["disapprove"])) {
$article->disapprove($userID);
$approval = $article->getApproval($userID);
}
if($approval) {
echo "You have approved this article.<br/>";
echo "<blockqoute>".$approval->description."</blockqoute><br/>";
echo "<a href=\"?disapprove\">Disapprove</a><br/>";
}
else {
?>
<form action="" method="post" />
<strong>Motivation for approval</strong><br/>
<textarea name="uamp_approval_desc"></textarea></br>
<input type="submit" name="uamp_approval_save" value="Approve"/>
</form>
<?php
}
?>
<?php endif; ?>
</header>
<!-- Display movie review contents -->
<div class="entry-content"><?php the_content(); ?></div>
</article>
<?php
endif;
endwhile;
?>