@ -27,11 +27,11 @@
use \ChamiloSession as Session;
// Name of the language file that needs to be included.
$language_file = 'forum';
$language_file = array( 'forum', 'link') ;
// Including the global initialization file.
require_once '../inc/global.inc.php';
$current_course_tool = TOOL_FORUM;
$current_course_tool = TOOL_FORUM;
$htmlHeadXtra[] = '< script >
$(document).ready(function() {
@ -144,12 +144,10 @@ event_access_tool(TOOL_FORUM);
*/
// Step 1: We store all the forum categories in an array $forum_categories.
$forum_categories_list = get_forum_categories();
$forumCategories = get_forum_categories();
// Step 2: We find all the forums (only the visible ones if it is a student).
$forum_list = array();
$forum_list = get_forums();
$user_id = api_get_user_id();
/* RETRIEVING ALL GROUPS AND THOSE OF THE USER */
@ -157,6 +155,7 @@ $user_id = api_get_user_id();
// The groups of the user.
$groups_of_user = array();
$groups_of_user = GroupManager::get_group_ids($_course['real_id'], $user_id);
// All groups in the course (and sorting them as the id of the group = the key of the array).
if (!api_is_anonymous()) {
$all_groups = GroupManager::get_group_list();
@ -181,62 +180,81 @@ echo '<div class="actions">';
//if is called from learning path
if (!empty($_GET['lp_id']) || !empty($_POST['lp_id'])){
echo "< a href = \"../newscorm/lp_controller.php?".api_get_cidreq()."&gradebook=&action=add_item&type=step&lp_id=".$lp_id."#resource_tab-5\" > ".Display::return_icon('back.png', get_lang("BackTo").' '.get_lang("LearningPaths"),'',ICON_SIZE_MEDIUM)."< / a > ";
echo "< a href = \"../newscorm/lp_controller.php?".api_get_cidreq()."&gradebook=&action=add_item&type=step&lp_id=".$lp_id."#resource_tab-5\" > ".
Display::return_icon('back.png', get_lang("BackTo").' '.get_lang("LearningPaths"),'',ICON_SIZE_MEDIUM)."< / a > ";
}
if (!empty($forum_list)) {
echo search_link();
}
if (api_is_allowed_to_edit(false, true)) {
echo '< a href = "'.api_get_self().'?'.api_get_cidreq().'&gradebook='.$gradebook.'&action=add&content=forumcategory&lp_id='.$lp_id.'" > '.Display::return_icon('new_folder.png', get_lang('AddForumCategory'),'',ICON_SIZE_MEDIUM).'< / a > ';
if (is_array($forum_categories_list) and !empty($forum_categories_list)) {
echo '< a href = "'.api_get_self().'?'.api_get_cidreq().'&gradebook='.$gradebook.'&action=add&content=forum&lp_id='.$lp_id.'" > '.Display::return_icon('new_forum.png', get_lang('AddForum'),'',ICON_SIZE_MEDIUM).'< / a > ';
echo '< a href = "'.api_get_self().'?'.api_get_cidreq().'&gradebook='.$gradebook.'&action=add&content=forumcategory&lp_id='.$lp_id.'" > '.
Display::return_icon('new_folder.png', get_lang('AddForumCategory'),'',ICON_SIZE_MEDIUM).'< / a > ';
if (is_array($forumCategories) and !empty($forumCategories)) {
echo '< a href = "'.api_get_self().'?'.api_get_cidreq().'&gradebook='.$gradebook.'&action=add&content=forum&lp_id='.$lp_id.'" > '.
Display::return_icon('new_forum.png', get_lang('AddForum'),'',ICON_SIZE_MEDIUM).'< / a > ';
}
}
echo '< / div > ';
/* Display Forum Categories and the Forums in it */
// Fixes error if there forums with no category.
$forumsInNoCategory = get_forums_in_category(0);
if (!empty($forumsInNoCategory)) {
$forumCategories = array_merge($forumCategories, array(
array(
'cat_id' => 0,
'session_id' => 0,
'visibility' => 1,
'cat_comment' => null
)
)
);
}
/* Display Forum Categories and the Forums in it */
// Step 3: We display the forum_categories first.
if (is_array($forum_categories_list)) {
foreach ($forum_categories_list as $forum_category) {
if (is_array($forumCategories)) {
foreach ($forumCategories as $forumCategory) {
// The forums in this category.
$forums_in_category = get_forums_in_category($forum_category['cat_id']);
echo '< table class = "forum_table" > ';
// Validacion when belongs to a session.
$session_img = api_get_session_image($forum_category['session_id'], $_user['status']);
$forumsInCategory = get_forums_in_category($forumCategory['cat_id']);
// Validation when belongs to a session.
$session_img = api_get_session_image($forumCategory['session_id'], $_user['status']);
if ((!isset($_SESSION['id_session']) || $_SESSION['id_session'] == 0) & & !empty($forum_c ategory['session_name'])) {
$session_displayed = ' ('.Security::remove_XSS($forum_c ategory['session_name']).')';
if ((!isset($_SESSION['id_session']) || $_SESSION['id_session'] == 0) & & !empty($forumCategory['session_name'])) {
$session_displayed = ' ('.Security::remove_XSS($forumCategory['session_name']).')';
} else {
$session_displayed = '';
}
if (empty($forumCategory['cat_title'])) {
$forumCategory['cat_title'] = get_lang('NoCategory');
}
echo '< table class = "forum_table" > ';
echo '< thead > ';
echo '< tr > < th class = "forum_head" colspan = "5" > ';
echo '< a href = "viewforumcategory.php?'.api_get_cidreq().'&forumcategory='.strval(intval($forum_category['cat_id'])).'" ' . class_visible_invisible ( strval ( intval ( $ forum_category [ ' visibility ' ] ) ) ) . ' > '.prepare4display($forum_category['cat_title']).$session_displayed.'< / a > '. $session_img .'< br / > ';
if ($forum_category['cat_comment'] != '' & & trim($forum_category['cat_comment']) != ' ') {
echo '< span class = "forum_description" > '.prepare4display($forum_category['cat_comment']).'< / span > ';
echo '< a href = "viewforumcategory.php?'.api_get_cidreq().'&forumcategory='.intval($forumCategory['cat_id']).'" ' . class_visible_invisible ( $ forumCategory [ ' visibility ' ] ) . ' > '.
prepare4display($forumCategory['cat_title']).$session_displayed.
'< / a > '. $session_img .'< br / > ';
if ($forumCategory['cat_comment'] != '' & & trim($forumCategory['cat_comment']) != ' ') {
echo '< span class = "forum_description" > '.prepare4display($forumCategory['cat_comment']).'< / span > ';
}
echo '< / th > ';
echo '< th style = "vertical-align: top;" align = "center" > ';
if (api_is_allowed_to_edit(false, true) & & !($forum_category['session_id'] == 0 & & intval($session_id) != 0)) {
echo '< a href = "'.api_get_self().'?'.api_get_cidreq().'&gradebook='.$gradebook.'&action=edit&content=forumcategory&id='.intval($forum_category['cat_id']).'" > '.Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'< / a > ';
echo '< a href = "'.api_get_self().'?'.api_get_cidreq().'&gradebook='.$gradebook.'&action=delete&content=forumcategory&id='.intval($forum_category['cat_id'])." \ " onclick = \"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('DeleteForumCategory'), ENT_QUOTES ) ) . " ' ) ) return false ; \ " > ".Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'< / a > ';
display_visible_invisible_icon('forumcategory', strval(intval($forum_category['cat_id'])), strval(intval($forum_category['visibility'])));
display_lock_unlock_icon('forumcategory', strval(intval($forum_category['cat_id'])), strval(intval($forum_category['locked'])));
display_up_down_icon('forumcategory', strval(intval($forum_category['cat_id'])), $forum_categories_list);
if (!empty($forumCategory['cat_id'])) {
if (api_is_allowed_to_edit(false, true) & & !($forumCategory['session_id'] == 0 & & intval($session_id) != 0)) {
echo '< a href = "'.api_get_self().'?'.api_get_cidreq().'&gradebook='.$gradebook.'&action=edit&content=forumcategory&id='.intval($forumCategory['cat_id']).'" > '.Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'< / a > ';
echo '< a href = "'.api_get_self().'?'.api_get_cidreq().'&gradebook='.$gradebook.'&action=delete&content=forumcategory&id='.intval($forumCategory['cat_id'])." \ " onclick = \"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('DeleteForumCategory'), ENT_QUOTES ) ) . " ' ) ) return false ; \ " > ".Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'< / a > ';
display_visible_invisible_icon('forumcategory', strval(intval($forumCategory['cat_id'])), strval(intval($forumCategory['visibility'])));
display_lock_unlock_icon('forumcategory', strval(intval($forumCategory['cat_id'])), strval(intval($forumCategory['locked'])));
display_up_down_icon('forumcategory', strval(intval($forumCategory['cat_id'])), $forumCategories);
}
}
echo '< / th > ';
echo '< / tr > ';
echo '< / thead > ';
if (!empty($forums_in_c ategory)) {
if (!empty($forumsInC ategory)) {
// Step 4: The interim headers (for the forum).
echo '< tr class = "forum_header" > ';
@ -265,24 +283,15 @@ if (is_array($forum_categories_list)) {
}
// Note: This can be speeded up if we transform the $forum_list to an array that uses the forum_category as the key.
if ($forum['forum_category'] == $forum_category['cat_id']) {
// The forum has to be showed if
// 1.v it is a not a group forum (teacher and student)
// 2.v it is a group forum and it is public (teacher and student)
// 3. it is a group forum and it is private (always for teachers only if the user is member of the forum
// if the forum is private and it is a group forum and the user is not a member of the group forum then it cannot be displayed
//if (!($forum['forum_group_public_private']=='private' AND !is_null($forum['forum_of_group']) AND !in_array($forum['forum_of_group'], $groups_of_user)))
//{
if ($forum['forum_category'] == $forumCategory['cat_id']) {
$show_forum = false;
// SHOULD WE SHOW THIS PARTICULAR FORUM
// you are teacher => show forum
if (api_is_allowed_to_edit(false, true)) {
//echo 'teacher';
$show_forum = true;
} else {
// you are not a teacher
// it is not a group forum => show forum (invisible forums are already left out see get_forums function)
if ($forum['forum_of_group'] == '0') {
$show_forum = true;
@ -355,7 +364,7 @@ if (is_array($forum_categories_list)) {
echo '< td > < a href = "viewforum.php?'.api_get_cidreq().'&gidReq='.intval($groupid).'&forum='.intval($forum['forum_id']).'" ' . class_visible_invisible ( strval ( intval ( $ forum [ ' visibility ' ] ) ) ) . ' > ';
//Forum title
// Forum title
echo prepare4display($forum['forum_title']).$session_displayed.'< / a > '.$forum_title_group_addition.'< br / > ';
echo '< span class = "forum_description" > '.prepare4display($forum['forum_comment']).'< / span > ';
@ -387,11 +396,13 @@ if (is_array($forum_categories_list)) {
echo '< / td > ';
echo '< td class = "td_actions" > ';
if (api_is_allowed_to_edit(false, true) & & !($forum['session_id'] == 0 & & intval($session_id) != 0)) {
echo '< a href = "'.api_get_self().'?'.api_get_cidreq().'&gradebook='.$gradebook.'&action=edit&content=forum&id='.$forum['forum_id'].'" > '.Display::return_icon('edit.png',get_lang('Edit'), array(), ICON_SIZE_SMALL).'< / a > ';
echo '< a href = "'.api_get_self().'?'.api_get_cidreq().'&gradebook='.$gradebook.'&action=delete&content=forum&id='.$forum['forum_id']." \ " onclick = \"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('DeleteForum'), ENT_QUOTES ) ) . " ' ) ) return false ; \ " > ".Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'< / a > ';
echo '< a href = "'.api_get_self().'?'.api_get_cidreq().'&gradebook='.$gradebook.'&action=edit&content=forum&id='.$forum['forum_id'].'" > '.
Display::return_icon('edit.png',get_lang('Edit'), array(), ICON_SIZE_SMALL).'< / a > ';
echo '< a href = "'.api_get_self().'?'.api_get_cidreq().'&gradebook='.$gradebook.'&action=delete&content=forum&id='.$forum['forum_id']." \ " onclick = \"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('DeleteForum'), ENT_QUOTES ) ) . " ' ) ) return false ; \ " > ".
Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'< / a > ';
display_visible_invisible_icon('forum', $forum['forum_id'], $forum['visibility']);
display_lock_unlock_icon('forum', $forum['forum_id'], $forum['locked']);
display_up_down_icon('forum', $forum['forum_id'], $forums_in_c ategory);
display_up_down_icon('forum', $forum['forum_id'], $forumsInC ategory);
}
$iconnotify = 'send_mail.gif';
$session_forum_notification = isset($_SESSION['forum_notification']['forum']) ? $_SESSION['forum_notification']['forum'] : false;
@ -402,7 +413,8 @@ if (is_array($forum_categories_list)) {
}
if (!api_is_anonymous() & & api_is_allowed_to_session_edit(false, true) ) {
echo '< a href = "'.api_get_self().'?'.api_get_cidreq().'&gradebook='.$gradebook.'&action=notify&content=forum&id='.$forum['forum_id'].'" > '.Display::return_icon($iconnotify, get_lang('NotifyMe')).'< / a > ';
echo '< a href = "'.api_get_self().'?'.api_get_cidreq().'&gradebook='.$gradebook.'&action=notify&content=forum&id='.$forum['forum_id'].'" > '.
Display::return_icon($iconnotify, get_lang('NotifyMe')).'< / a > ';
}
echo '< / td > < / tr > ';
}