root/elgg/trunk/mod/forum/forum_view_thread.php

Revision 194, 6.1 kB (checked in by cedenoj, 10 months ago)

refs #2827 added a little bit of css to clean up the forum topics listing

Line 
1 <?php
2
3 //    ELGG weblog view page
4
5 // Run includes
6 require_once("../../includes.php");
7
8 run("profile:init");
9 run("friends:init");
10 run("weblogs:init");
11
12 global $profile_id;
13 global $individual;
14 global $CFG, $page_owner, $metatags, $PAGE;
15 global $redirect_url;
16
17 $metatags .= "<style type=\"text/css\">";
18 $metatags .= str_replace('{{url}}', $CFG->wwwroot, file_get_contents($CFG->dirroot . "mod/forum/css"));
19 $metatags .= "</style>";
20
21 define("context", "forum");
22
23 $individual = 1;
24
25 $post = $_GET["post"];
26 if (!empty($post)) {
27     
28     $where = run("users:access_level_sql_where",$_SESSION['userid']);
29     
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.");
38     }
39     
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);
45
46     $_SESSION['redirect_url'] = $CFG->wwwroot . 'mod/forum/forum.php?weblog=' . $weblog;
47     
48         if ((context == "forum")   && run("users:type:get", $profile_id) == "community")
49         {
50             // Add to the submenu
51                         
52             $num = count($PAGE->menu_sub) + 1;
53
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>';
56             
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("Post Reply") . "</a>";
60         }
61         
62         
63     templates_page_setup();
64     
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>";
72     
73     
74                                 $body .= "
75
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...") . "\">" . user_icon_html($post->owner,67) . "<br>" . user_info("name",$post->owner) . "</a><br>" . $time . "</div></td>
78                                 <td>" . run("weblogs:text:process", $post->body) . "";
79                                 
80     if (run("permissions:check",array("weblog:edit",$post->owner)))
81     {
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>";
89             
90
91     }
92                                 
93             $body .="                   
94                                 </td>
95                                 </tr>
96 ";
97
98
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;
104                             
105
106                         
107                             if (!empty($comments)){
108                         
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);
111                                     
112                                     if (logged_on && ($comment->owner == $_SESSION['userid'] || run("permissions:check",array("weblog:edit",$post->owner))))
113                                     {
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>
119                                                 ";
120                                     }
121         
122                                     
123                                     
124                                     $body .= "</td></tr>";
125                                 }
126                                                     
127                             }
128                                                     
129                             
130                             $body .= "</table><br>";
131                             $body .= '<form action="'. $CFG->wwwroot . $weblog . user_info('username',$post->weblog) . "/weblog/" . $post->ident . '.html#new_weblog_comment" >';
132                             $body .= '<input type="submit" value="'.__gettext("Reply Post").'"/></form>';
133                         }
134                         
135                         
136                         
137
138                     
139
140                     
141
142     
143     // Draw page
144         $title = run("profile:display:name") . " :: " . __gettext("Forum");
145
146         $body = templates_draw(array(
147                         'context' => 'contentholder',
148                         'title' => $title,
149                         'body' => $body
150                     )
151                     );
152
153         echo templates_page_draw( array(
154                         $title, $body
155                     )
156                     );
157
158 ?>
159
Note: See TracBrowser for help on using the browser.