summaryrefslogtreecommitdiff
path: root/forum/utils/view.php
blob: 01e8b6abd55a7b89876d5f82f4b19fa95a665c18 (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
<?php
echo "<div class=\"navigation\">";
if($fid) echo "<a href=\"?\">forums</a>";
if($tid) echo ":: <a href=\"?fid=" . $fid . "\">threads</a>";
if($pid) echo ":: <a href=\"?fid=" . $fid . "&amp;tid=" . $tid . "\">posts</a>";
echo "</div>\n";


	 if($fid && $tid) {
		 //		 echo "<h1>Posts</h1>";
		 include_once("posts.php");
		 $posts = new Posts($FORUMS_DIR . "/" . $fid . "/" . $tid . ".xml");
		 $posts->show();
	 } else if($fid) {
		 echo "<h1>Threads</h1>";
		 echo "<a href=\"?mode=editor&amp;task=new&amp;fid=".$fid.
			 "&amp;tid=".time()."&amp;pid=-1\">New thread</a>";

		 include_once("threads.php");
		 $threads = new Threads($FORUMS_DIR . "/" . $fid);
		 $threads->show();
	 } else {
		 echo "<h1>Forums</h1>";
		 include_once("forums.php");
		 $forums = new Forums($FORUMS_DIR . "/forums.xml");

		 if($action == "addforum") {
			 $newfid = 0;
			 while($forums->getForum($newfid)) $newfid++;

			 $forums->add(new Forum($newfid, $title));
			 $forums->write();
		 }

		 $forums->show();

		 if($current_user->uid == 0) {
?>
<form method="post" action="?mode=forum&amp;action=addforum">
Add new forum: <input name="title" value=""><button type="submit">Add</button>
</form>
<?php
		 } 

	 }
?>