Simple status box for the sidebar.
[elgg_plugins.git] / forum / forum_view_thread.php
blob390602a541574d19f7ca33992a7e59bcb9aa92ab
1 <?php
3 // ELGG weblog view page
5 // Run includes
6 require_once("../../includes.php");
8 run("profile:init");
9 run("friends:init");
10 run("weblogs:init");
12 global $profile_id;
13 global $individual;
14 global $CFG, $page_owner, $metatags, $PAGE;
15 global $redirect_url;
17 $metatags .= "<style type=\"text/css\">";
18 $metatags .= str_replace('{{url}}', $CFG->wwwroot, file_get_contents($CFG->dirroot . "mod/forum/css"));
19 $metatags .= "</style>";
21 define("context", "forum");
23 $individual = 1;
25 $post = $_GET["post"];
26 if (!empty($post)) {
28 $where = run("users:access_level_sql_where",$_SESSION['userid']);
30 if (!$post = get_record_select('weblog_posts','('.$where.') AND ident = '.$post)) {
31 $post = new StdClass;
32 $post->weblog = -1;
33 $post->owner = -1;
34 $post->title = __gettext("Access denied or post not found");
35 $post->posted = time();
36 $post->ident = -1;
37 $post->body = __gettext("Either this blog post doesn't exist or you don't currently have access privileges to view it.");
40 global $page_owner;
41 global $profile_id;
42 $profile_id = $post->weblog;
43 $page_owner = $post->weblog;
44 $weblog = user_info('username', $post->weblog);
46 $_SESSION['redirect_url'] = $CFG->wwwroot . 'mod/forum/forum.php?weblog=' . $weblog;
48 if ((context == "forum") && run("users:type:get", $profile_id) == "community")
50 // Add to the submenu
52 $num = count($PAGE->menu_sub) + 1;
54 $PAGE->menu_sub[$num]['name'] = "forum:blogview";
55 $PAGE->menu_sub[$num]['html'] = '<a href="'.$CFG->wwwroot . 'mod/forum/forum.php?weblog=' . $weblog . '">' . __gettext("Return to Forum") . '</a>';
57 $num = count($PAGE->menu_sub) + 1;
58 $PAGE->menu_sub[$num]['name'] = "forum:blogview";
59 $PAGE->menu_sub[$num]['html'] = "<a href=\"" . $CFG->wwwroot . $weblog . "/weblog/" . $post->ident . ".html#new_weblog_comment\" title=\"" . __gettext("Add a comment...") . "\">" . __gettext("Add new comment") . "</a>";
63 templates_page_setup();
65 $time = gmstrftime("%b %d, %y",$post->posted);
66 $body = "
67 <table id=\"forum_table\" cellspacing=\"0\" summary=\"Forum Table\">
68 <tr>
69 <th scope=\"col\" class=\"nobg\">" . __gettext("From") . "</th>
70 <th class=\"cent\">" . $post->title . "</th>
71 </tr>";
74 $body .= "
76 <tr scope=\"row\">
77 <td class=\"cent\" valign=\"top\"><div class=\"user\"><a href=\"" . $CFG->wwwroot . user_info("username",$post->owner) . "/" . "\" title=\"" . __gettext("View profile...") . "\"><img src=\"" . $CFG->wwwroot . "_icon/user/" . $post->icon . "\"><br>" . user_info("name",$post->owner) . "</a><br>" . $time . "</div></td>
78 <td>" . run("weblogs:text:process", $post->body) . "";
80 if (run("permissions:check",array("weblog:edit",$post->owner)))
82 $Edit = __gettext("Edit");
83 $returnConfirm = __gettext("Are you sure you want to permanently delete this forum post?");
84 $Delete = __gettext("Delete");
85 $body .="<div class=\"edit_delete\">
86 <a href=\"{$CFG->wwwroot}{$weblog}/weblog/edit/{$post->ident}\" title=\"$Edit\"><img src=\"images/edit.gif\" border=0></a>
87 <a href=\"{$CFG->wwwroot}/mod/blog/action_redirection.php?action=delete_weblog_post&amp;delete_post_id={$post->ident}&amp;extension=weblog\" onclick=\"return confirm('$returnConfirm')\" title=\"$Delete\"><img src=\"images/delete.gif\" border=0></a>
88 <div>";
93 $body .="
94 </td>
95 </tr>
99 $select='select * from ' . $CFG->prefix . 'weblog_comments Where post_id='. $post->ident . ' ORDER by posted ASC';
100 //echo $select;
101 $comments = get_records_sql($select);
102 $numberofcomments = get_record_sql("select count(*) as numberofcomments from ".$CFG->prefix."weblog_comments WHERE post_id =" . $post->ident);
103 $numberofcomments = $numberofcomments->numberofcomments;
107 if (!empty($comments)){
109 foreach($comments as $comment) {
110 $body .= "<tr><td class=\"cent\" valign=\"top\"><div class=\"user\"><a href=\"" . $CFG->wwwroot . user_info("username",$comment->owner) . "/" . "\" title=\"" . __gettext("View profile...") . "\"><img src=\"" . $CFG->wwwroot . "_icon/user/" . user_info("icon",$comment->owner) . "/h/67/w/67\"><br>" . $comment->postedname . "</a><br>" . gmstrftime('%b %d, %y',$comment->posted) . "</div></td><td>" . run("weblogs:text:process", $comment->body);
112 if (logged_on && ($comment->owner == $_SESSION['userid'] || run("permissions:check",array("weblog:edit",$post->owner))))
114 $returnConfirm = __gettext("Are you sure you want to permanently delete this forum comment?");
115 $Delete = __gettext("Delete");
116 $body .="<p align=right>
117 <a href=\"{$CFG->wwwroot}mod/blog/action_redirection.php?action=weblog_comment_delete&amp;weblog_comment_delete={$comment->ident}&amp;extension=weblog\" onclick=\"return confirm('$returnConfirm')\" title=\"$Delete\"><img src=\"images/delete.gif\" border=0></a>
118 </p>
124 $body .= "</td></tr>";
130 $body .= "</table><br><a href=\"" . $CFG->wwwroot . user_info('username',$post->weblog) . "/weblog/" . $post->ident . ".html#new_weblog_comment\" title=\"" . __gettext("Add new comment...") . "\">" . __gettext("Add new comment...") . "</a><br><br>";
141 // Draw page
142 $title = run("profile:display:name") . " :: " . __gettext("Forum") . " :: " . stripslashes($post->title);
144 $body = templates_draw(array(
145 'context' => 'contentholder',
146 'title' => $title,
147 'body' => $body
151 echo templates_page_draw( array(
152 $title, $body