public function get_forum_threads_id($username, $password, $course_code, $forum_id) { if ($this->verifyUserPass($username, $password) == "valid") { $threads_info = get_threads($forum_id, $course_code); $threads_id = '#'; foreach ($threads_info as $thread) { if (isset($thread['thread_id'])) { $threads_id .= $thread['thread_id'] . "#"; } } return $threads_id; } else { return get_lang('InvalidId'); } }
/** * Creates a list with all the forums in it * * @return string */ function get_forums() { global $charset; include '../forum/forumfunction.inc.php'; include '../forum/forumconfig.inc.php'; global $table_forums, $table_threads, $table_posts, $table_item_property, $table_users; $table_forums = Database::get_course_table(TABLE_FORUM); $table_threads = Database::get_course_table(TABLE_FORUM_THREAD); $table_posts = Database::get_course_table(TABLE_FORUM_POST); $table_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); $table_users = Database::get_main_table(TABLE_MAIN_USER); $a_forums = get_forums(); /* $return .= '<div class="lp_resource_header"' . " onclick=\"if(document.getElementById('forums').style.display == 'block') {document.getElementById('forums').style.display = 'none';} else {document.getElementById('forums').style.display = 'block';}\"" . '><img alt="" src="../img/lp_forum.gif" style="margin-right:5px;" title="" />' . get_lang('Forums') . '</div>'; $return .= '<div class="lp_resource_elements" style="border:1px solid #999999;" id="forums">'; */ $forum_lang_var = api_convert_encoding(get_lang('Forum'), $charset, api_get_system_encoding()); $close_lang_var = api_convert_encoding(get_lang('Close'), $charset, api_get_system_encoding()); $return = '<a href="#" onclick="javascript:popup(\'popUpDiv2\');" class="big_button four_buttons rounded grey_border forum_button">' . $forum_lang_var . '</a>'; $return .= '<div id="popUpDiv2" class="popUpDiv author_popup gradient rounded_10 grey_border" style="display:none;">' . '<span class="title">' . $forum_lang_var . '</span>' . '<a href="#" onclick="javascript:popup(\'popUpDiv2\');" class="close">' . $close_lang_var . '</a>'; // TODO use get_lang() $return .= '<div id="resDoc" class="content" >'; $return .= '<script type="text/javascript"> function toggle_forum(forum_id){ if(document.getElementById("forum_"+forum_id+"_content").style.display == "none"){ document.getElementById("forum_"+forum_id+"_content").style.display = "block"; document.getElementById("forum_"+forum_id+"_opener").src = "' . api_get_path(WEB_IMG_PATH) . 'remove.gif"; } else { document.getElementById("forum_"+forum_id+"_content").style.display = "none"; document.getElementById("forum_"+forum_id+"_opener").src = "' . api_get_path(WEB_IMG_PATH) . 'add.gif"; } } </script> '; foreach ($a_forums as $forum) { $return .= '<div class="lp_resource_element">'; if (!empty($forum['forum_id'])) { $return .= Display::return_icon('pixel.gif', '', array('class' => 'actionplaceholdericon actionforum ', 'style' => 'margin-right:5px;', 'title' => '')); $return .= '<a style="cursor:hand" onclick="toggle_forum(' . $forum['forum_id'] . ')" style="vertical-align:middle"><img src="' . api_get_path(WEB_IMG_PATH) . 'add.gif" id="forum_' . $forum['forum_id'] . '_opener" align="absbottom" /></a> <a href="' . api_get_self() . '?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&action=add_item&type=' . TOOL_FORUM . '&forum_id=' . $forum['forum_id'] . '&lp_id=' . $this->lp_id . '" style="vertical-align:middle">' . api_convert_encoding($forum['forum_title'], $charset, api_get_system_encoding()) . '</a><ul style="display:none" id="forum_' . $forum['forum_id'] . '_content">'; } $a_threads = get_threads($forum['forum_id']); if (is_array($a_threads)) { foreach ($a_threads as $thread) { $return .= '<li><a href="' . api_get_self() . '?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&action=add_item&type=' . TOOL_THREAD . '&thread_id=' . $thread['thread_id'] . '&lp_id=' . $this->lp_id . '">' . api_convert_encoding($thread['thread_title'], $charset, api_get_system_encoding()) . '</a></li>'; } } $return .= '</ul></div>'; } $return .= '<br/>'; $return .= '<div class="lp_resource_element">'; $return .= Display::return_icon('pixel.gif', '', array('class' => 'actionplaceholdericon actionnewlist', 'style' => 'margin-right:5px;', 'title' => '')); $return .= '<a href="' . api_get_path(REL_CODE_PATH) . 'forum/index.php?' . api_get_cidreq() . '&action=add&content=forum&lp_id=' . $this->lp_id . '" title="' . api_convert_encoding(get_lang('CreateANewForum')) . '">' . api_convert_encoding(get_lang('CreateANewForum'), $charset, api_get_system_encoding()) . '</a>'; $return .= '</div>'; $return .= '</div>'; $return .= '</div>'; // ending div#popUpDiv2 return $return; }
echo '<br /><span class="forum_description">' . prepare4display($current_forum['forum_comment']) . '</span>'; } echo '</th></tr></thead>'; } // The column headers (TODO: Make this sortable). echo '<tr class="forum_threadheader">'; echo '<td></td>'; echo '<td>' . get_lang('Title') . '</td>'; echo '<td>' . get_lang('Replies') . '</td>'; echo '<td>' . get_lang('Views') . '</td>'; echo '<td>' . get_lang('Author') . '</td>'; echo '<td>' . get_lang('LastPost') . '</td>'; echo '<td>' . get_lang('Actions') . '</td>'; echo '</tr>'; // Getting al the threads $threads = get_threads($my_forum); // Note: This has to be cleaned first $whatsnew_post_info = isset($_SESSION['whatsnew_post_info']) ? $_SESSION['whatsnew_post_info'] : null; $course_id = api_get_course_int_id(); $counter = 0; if (is_array($threads)) { foreach ($threads as $row) { // Thread who have no replies yet and the only post is invisible should not be displayed to students. if (api_is_allowed_to_edit(false, true) or !($row['thread_replies'] == '0' and $row['visibility'] == '0')) { if ($counter % 2 == 0) { $class = 'row_odd'; } else { $class = 'row_even'; } echo "<tr class=\"{$class}\">"; echo '<td>';
/** * Creates a list with all the forums in it * @return string */ public function get_forums() { require_once api_get_path(SYS_CODE_PATH) . 'forum/forumfunction.inc.php'; require_once api_get_path(SYS_CODE_PATH) . 'forum/forumconfig.inc.php'; $a_forums = get_forums(); $return = '<ul class="lp_resource">'; //First add link $return .= '<li class="lp_resource_element">'; $return .= Display::return_icon('forum_new_small.gif'); $return .= '<a href="' . api_get_path(REL_CODE_PATH) . 'forum/index.php?' . api_get_cidreq() . '&action=add&content=forum&origin=learnpath&lp_id=' . $this->lp_id . '" title="' . get_lang('CreateANewForum') . '"> ' . get_lang('CreateANewForum') . '</a>'; $return .= '</li>'; $return .= '<script> function toggle_forum(forum_id){ if(document.getElementById("forum_"+forum_id+"_content").style.display == "none"){ document.getElementById("forum_"+forum_id+"_content").style.display = "block"; document.getElementById("forum_"+forum_id+"_opener").src = "' . api_get_path(WEB_IMG_PATH) . 'remove.gif"; } else { document.getElementById("forum_"+forum_id+"_content").style.display = "none"; document.getElementById("forum_"+forum_id+"_opener").src = "' . api_get_path(WEB_IMG_PATH) . 'add.gif"; } } </script>'; foreach ($a_forums as $forum) { $return .= '<li class="lp_resource_element" data_id="' . $forum['forum_id'] . '" data_type="' . TOOL_FORUM . '" title="' . $forum['forum_title'] . '" >'; if (!empty($forum['forum_id'])) { $return .= '<a class="moved" href="#">'; $return .= Display::return_icon('move_everywhere.png', get_lang('Move'), array(), ICON_SIZE_TINY); $return .= ' </a>'; $return .= Display::return_icon('lp_forum.gif'); $return .= '<a style="cursor:hand" onclick="javascript: toggle_forum(' . $forum['forum_id'] . ')" style="vertical-align:middle"> <img src="' . api_get_path(WEB_IMG_PATH) . 'add.gif" id="forum_' . $forum['forum_id'] . '_opener" align="absbottom" /> </a> <a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=add_item&type=' . TOOL_FORUM . '&forum_id=' . $forum['forum_id'] . '&lp_id=' . $this->lp_id . '" style="vertical-align:middle">' . Security::remove_XSS($forum['forum_title']) . '</a>'; } $return .= '</li>'; $return .= '<div style="display:none" id="forum_' . $forum['forum_id'] . '_content">'; $a_threads = get_threads($forum['forum_id']); if (is_array($a_threads)) { foreach ($a_threads as $thread) { $return .= '<li class="lp_resource_element" data_id="' . $thread['thread_id'] . '" data_type="' . TOOL_THREAD . '" title="' . $thread['thread_title'] . '" >'; $return .= ' <a class="moved" href="#">'; $return .= Display::return_icon('move_everywhere.png', get_lang('Move'), array(), ICON_SIZE_TINY); $return .= ' </a>'; $return .= Display::return_icon('forumthread.png', get_lang('Thread'), array(), ICON_SIZE_TINY); $return .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=add_item&type=' . TOOL_THREAD . '&thread_id=' . $thread['thread_id'] . '&lp_id=' . $this->lp_id . '">' . Security::remove_XSS($thread['thread_title']) . '</a>'; $return .= '</li>'; } } $return .= '</div>'; } $return .= '</ul>'; return $return; }
/** * This function gets all the post written by an user * @param int $user_id * @param string $course_code * * @return string */ function get_all_post_from_user($user_id, $course_code) { $j = 0; $forums = get_forums('', $course_code); krsort($forums); $forum_results = ''; foreach ($forums as $forum) { if ($forum['visibility'] == 0) { continue; } if ($j <= 4) { $threads = get_threads($forum['forum_id'], $course_code); if (is_array($threads)) { $i = 0; $hand_forums = ''; $post_counter = 0; foreach ($threads as $thread) { if ($thread['visibility'] == 0) { continue; } if ($i <= 4) { $post_list = get_thread_user_post_limit($course_code, $thread['thread_id'], $user_id, 1); $post_counter = count($post_list); if (is_array($post_list) && count($post_list) > 0) { $hand_forums .= '<div id="social-thread">'; $hand_forums .= Display::return_icon('thread.png', get_lang('Thread'), '', ICON_SIZE_MEDIUM); $hand_forums .= ' ' . Security::remove_XSS($thread['thread_title'], STUDENT); $hand_forums .= '</div>'; foreach ($post_list as $posts) { $hand_forums .= '<div id="social-post">'; $hand_forums .= '<strong>' . Security::remove_XSS($posts['post_title'], STUDENT) . '</strong>'; $hand_forums .= '<br / >'; $hand_forums .= Security::remove_XSS($posts['post_text'], STUDENT); $hand_forums .= '</div>'; $hand_forums .= '<br / >'; } } } $i++; } $forum_results .= '<div id="social-forum">'; $forum_results .= '<div class="clear"></div><br />'; $forum_results .= '<div id="social-forum-title">' . Display::return_icon('forum.gif', get_lang('Forum')) . ' ' . Security::remove_XSS($forum['forum_title'], STUDENT) . '<div style="float:right;margin-top:-35px"> <a href="../forum/viewforum.php?cidReq=' . $course_code . '&gidReq=&forum=' . $forum['forum_id'] . ' " >' . get_lang('SeeForum') . '</a> </div></div>'; $forum_results .= '<br / >'; if ($post_counter > 0) { $forum_results .= $hand_forums; } $forum_results .= '</div>'; } $j++; } } return $forum_results; }
reset($thread_sujet); while (list($st, $v) = each($thread_sujet)) { preg_match("/\\&L\\=([^\"]*?)\"/", $thread_sujet[$st][0], $matches); $page .= "<TR><TD COLSPAN='3'>[<i><a href='{$PHP_SELF}?A=READ&L=" . $matches[1] . "&aplat=1'>Affichage à plat</a></i>]</TD></TR>\n"; while (list($clef, $sujet) = each($thread_sujet[$st])) { $page .= "<TR>\n<TD ALIGN='LEFT'>" . stripslashes($sujet) . "</TD>\n<TD ALIGN='LEFT'>" . stripslashes($thread_de[$st][$clef]) . "</TD>\n<TD ALIGN='LEFT'>" . $thread_date[$st][$clef] . "</TD>\n</TR>\n\n"; } $page .= "<TR><TD COLSPAN='3'><HR></TD></TR>\n\n"; } $page .= "</TABLE>"; } else { if ($A == "READ") { // affichage d'un message ou d'un fil // on récupère les fils preg_match("~/(\\d\\d\\d\\d)/(\\d\\d?)/~", $L, $matches); get_threads($matches[1], $matches[2]); if ($aplat == 1) { // affichage à plat d'un fil de discussion list($sujet_init, $page_init) = get_post($L); $sujet_thread = my_trim($sujet_init); $page = "<p>Affichage du fil de discussion : <b>{$sujet_thread}</b></p>\n<hr>\n"; $sujet_thread = addslashes($sujet_thread); while (list($clef, $sujet) = each($thread_sujet[$sujet_thread])) { if (preg_match("~" . preg_quote($L) . "~", $sujet)) { $page .= $page_init . "<hr>\n"; } else { preg_match("/\\&L\\=([^\"]*?)\"/", $sujet, $matches); list($sujet, $message) = get_post($matches[1]); $page .= $message . "<hr>\n"; } }
<script src="js/ajax.js?<?php echo filemtime('js/ajax.js'); ?> " type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="css/m.css?<?php echo filemtime('css/m.css'); ?> "> <meta name="viewport" content="width=240, height=320, user-scalable=yes, initial-scale=1.0, maximum-scale=5.0, minimum-scale=1.0"> </head> <body><a target="_top" href="/" title="Full version">Full Version</a> <?php #require('menu_inc.php'); print_pages($max_page, $page, '_self', $cur_page); print "<p/>"; $result = get_threads(); $content = array(); $msgs = m_print_threads($result, $content); m_print_msgs($content, $msgs, $pix); print_pages($max_page, $page, '_self', $cur_page); ?> <!--</form>--></body></html><? require_once('tail_inc.php'); ?><script language="javascript"> var last_id=""; function show_message(mess_id){ if (last_id != "") { document.getElementById("div_mes_" + last_id).style.display = "none"; }