Passed
Push — 1.11.x ( bce6cd...c146d9 )
by Angel Fernando Quiroz
12:25
created

main/forum/iframe_thread.php (1 issue)

1
<?php
2
/* For licensing terms, see /license.txt */
3
4
/**
5
 * These files are a complete rework of the forum. The database structure is
6
 * based on phpBB but all the code is rewritten. A lot of new functionalities
7
 * are added:
8
 * - forum categories and forums can be sorted up or down, locked or made invisible
9
 * - consistent and integrated forum administration
10
 * - forum options:     are students allowed to edit their post?
11
 *                      moderation of posts (approval)
12
 *                      reply only forums (students cannot create new threads)
13
 *                      multiple forums per group
14
 * - sticky messages
15
 * - new view option: nested view
16
 * - quoting a message.
17
 *
18
 * @author Patrick Cool <[email protected]>, Ghent University
19
 * @copyright Ghent University
20
 */
21
require_once __DIR__.'/../inc/global.inc.php';
22
23
// A notice for unauthorized people.
24
api_protect_course_script(true);
25
26
$nameTools = get_lang('ToolForum');
27
Display::display_reduced_header();
28
29
require_once 'forumfunction.inc.php';
30
31
/* Retrieving forum and forum categorie information */
32
33
// We are getting all the information about the current forum and forum category.
34
// Note pcool: I tried to use only one sql statement (and function) for this,
35
// but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table.
36
$current_thread = get_thread_information(
37
    $_GET['forum'],
38
    $_GET['thread']
39
); // Note: this has to be validated that it is an existing thread.
40
$current_forum = get_forum_information($current_thread['forum_id']);
0 ignored issues
show
Deprecated Code introduced by
The function get_forum_information() has been deprecated: this functionality is now moved to get_forums($forum_id) ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

40
$current_forum = /** @scrutinizer ignore-deprecated */ get_forum_information($current_thread['forum_id']);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
41
// Note: this has to be validated that it is an existing forum.
42
$current_forum_category = get_forumcategory_information(
43
    $current_forum['forum_category']
44
);
45
46
/* Is the user allowed here? */
47
48
// if the user is not a course administrator and the forum is hidden
49
// then the user is not allowed here.
50
if (!api_is_allowed_to_edit(false, true) &&
51
    ($current_forum['visibility'] == 0 || $current_thread['visibility'] == 0)
52
) {
53
    api_not_allowed(false);
54
}
55
56
$course_id = api_get_course_int_id();
57
58
$table_posts = Database::get_course_table(TABLE_FORUM_POST);
59
$table_users = Database::get_main_table(TABLE_MAIN_USER);
60
61
/* Display Forum Category and the Forum information */
62
63
// We are getting all the information about the current forum and forum category.
64
// Note pcool: I tried to use only one sql statement (and function) for this,
65
// but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table.
66
$sql = "SELECT * FROM $table_posts posts 
67
        INNER JOIN $table_users users
68
        ON (posts.poster_id = users.user_id)
69
        WHERE
70
            posts.c_id = $course_id AND
71
            posts.thread_id='".$current_thread['thread_id']."'            
72
        ORDER BY posts.post_id ASC";
73
$result = Database::query($sql);
74
75
echo "<table width=\"100%\" height=\"100%\" cellspacing=\"5\" border=\"0\">";
76
while ($row = Database::fetch_array($result)) {
77
    echo "<tr>";
78
    echo "<td rowspan=\"2\" class=\"forum_message_left\">";
79
    $username = api_htmlentities(sprintf(get_lang('LoginX'), $row['username']), ENT_QUOTES);
80
    if ($row['user_id'] == '0') {
81
        $name = $row['poster_name'];
82
    } else {
83
        $name = api_get_person_name($row['firstname'], $row['lastname']);
84
    }
85
    echo Display::tag('span', $name, ['title' => $username]).'<br />';
86
    echo api_convert_and_format_date($row['post_date']).'<br /><br />';
87
88
    echo "</td>";
89
    echo "<td class=\"forum_message_post_title\">".Security::remove_XSS($row['post_title'])."</td>";
90
    echo "</tr>";
91
92
    echo "<tr>";
93
    echo "<td class=\"forum_message_post_text\">".Security::remove_XSS($row['post_text'], STUDENT)."</td>";
94
    echo "</tr>";
95
}
96
echo "</table>";
97
98
?>
99
</body>
100
</html>
101