@ -107,8 +107,7 @@ $whatsnew_post_info = isset($_SESSION['whatsnew_post_info']) ? $_SESSION['whatsn
// if the user is not a course administrator and the forum is hidden
// then the user is not allowed here.
if (
!api_is_allowed_to_edit(false, true) AND
if (!api_is_allowed_to_edit(false, true) & &
($current_forum_category & & $current_forum_category['visibility'] == 0)
) {
api_not_allowed();
@ -171,8 +170,7 @@ if ($action_forums != 'add') {
$html = '';
$html .= '< div class = "category-forum" > ';
if (
(!isset($sessionId) || $sessionId == 0) & &
if ((!isset($sessionId) || $sessionId == 0) & &
!empty($forum_category['session_name'])
) {
$session_displayed = ' ('.Security::remove_XSS($forum_category['session_name']).')';
@ -191,8 +189,9 @@ if ($action_forums != 'add') {
ICON_SIZE_MEDIUM
);
if (api_is_allowed_to_edit(false, true) & & !($forum_category['session_id'] == 0 & & $sessionId != 0)) {
if (api_is_allowed_to_edit(false, true) & &
!($forum_category['session_id'] == 0 & & $sessionId != 0)
) {
$iconsEdit = '< a href = "'.api_get_self().'?'.api_get_cidreq().'&forumcategory='
. Security::remove_XSS($_GET['forumcategory']).'& action=edit& content=forumcategory& id='
. ''.$forumId.'">'
@ -205,17 +204,20 @@ if ($action_forums != 'add') {
. "')) return false;\">".Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL)
. '< / a > ';
$iconsEdit .= return_visible_invisible_icon(
'forumcategory', $forum_category['cat_id'],
'forumcategory',
$forum_category['cat_id'],
$forum_category['visibility'],
array('forumcategory' => $_GET['forumcategory'])
);
$iconsEdit .= return_lock_unlock_icon(
'forumcategory', $forum_category['cat_id'],
'forumcategory',
$forum_category['cat_id'],
$forum_category['locked'],
array('forumcategory' => $_GET['forumcategory'])
);
$iconsEdit .= return_up_down_icon(
'forumcategory', $forum_category['cat_id'],
'forumcategory',
$forum_category['cat_id'],
$forum_categories_list
);
$html .= Display::tag(
@ -241,7 +243,6 @@ if ($action_forums != 'add') {
null
);
if ($descriptionCategory != '' & & trim($descriptionCategory) != ' ') {
$html .= '< div class = "forum-description" > '.$descriptionCategory.'< / div > ';
}
@ -254,261 +255,252 @@ if ($action_forums != 'add') {
// Step 4: We display all the forums in this category.
$forum_count = 0;
foreach ($forum_list as $forum) {
if(!empty($forum['forum_category'])){
if (!empty($forum['forum_category'])) {
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))) {
$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
//echo 'student';
// it is not a group forum => show forum (invisible forums are already left out see get_forums function)
if ($forum['forum_of_group'] == '0') {
//echo '-gewoon forum';
// 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))) {
$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 {
// it is a group forum
//echo '-groepsforum';
// it is a group forum but it is public => show
if ($forum['forum_group_public_private'] == 'public') {
// you are not a teacher
//echo 'student';
// it is not a group forum => show forum (invisible forums are already left out see get_forums function)
if ($forum['forum_of_group'] == '0') {
//echo '-gewoon forum';
$show_forum = true;
//echo '-publiek';
} else {
// it is a group forum and it is private
//echo '-prive';
// it is a group forum and it is private but the user is member of the group
if (in_array($forum['forum_of_group'], $groups_of_user)) {
//echo '-is lid';
// it is a group forum
//echo '-groepsforum';
// it is a group forum but it is public => show
if ($forum['forum_group_public_private'] == 'public') {
$show_forum = true;
//echo '-publiek';
} else {
//echo '-is GEEN lid';
$show_forum = false;
// it is a group forum and it is private
//echo '-prive';
// it is a group forum and it is private but the user is member of the group
if (in_array($forum['forum_of_group'], $groups_of_user)) {
//echo '-is lid';
$show_forum = true;
} else {
//echo '-is GEEN lid';
$show_forum = false;
}
}
}
}
}
//echo '< hr / > ';
$form_count = isset($form_count) ? $form_count : 0;
if ($show_forum === true) {
$form_count++;
$form_count = isset($form_count) ? $form_count : 0;
if ($show_forum === true) {
$form_count++;
$html = '< div class = "panel panel-default forum" > ';
$html .= '< div class = "panel-body" > ';
$my_whatsnew_post_info = isset($whatsnew_post_info[$forum['forum_id']]) ? $whatsnew_post_info[$forum['forum_id']] : null;
if ($forum['forum_of_group'] == '0') {
$forum_image = Display::return_icon(
'forum_group.png',
get_lang('GroupForum'),
null,
ICON_SIZE_LARGE
);
} else {
$forum_image = Display::return_icon(
'forum.png',
get_lang('Forum'),
null,
ICON_SIZE_LARGE
);
}
$html = '< div class = "panel panel-default forum" > ';
$html .= '< div class = "panel-body" > ';
if ($forum['forum_of_group'] != '0') {
$my_all_groups_forum_name = isset($all_groups[$forum['forum_of_group']]['name'])
? $all_groups[$forum['forum_of_group']]['name']
: null;
$my_all_groups_forum_id = isset($all_groups[$forum['forum_of_group']]['id'])
? $all_groups[$forum['forum_of_group']]['id']
: null;
$group_title = api_substr($my_all_groups_forum_name, 0, 30);
$forum_title_group_addition = ' (< a href = "../group/group_space.php?'.api_get_cidreq()
. '& gidReq='.$my_all_groups_forum_id.'" class="forum_group_link">'
. get_lang('GoTo').' '.$group_title.'< / a > )';
} else {
$forum_title_group_addition = '';
}
$my_whatsnew_post_info = isset($whatsnew_post_info[$forum['forum_id']]) ? $whatsnew_post_info[$forum['forum_id']] : null;
if (!empty($sessionId) & & !empty($forum['session_name'])) {
$session_displayed = ' ('.$forum['session_name'].')';
} else {
$session_displayed = '';
}
if ($forum['forum_of_group'] == '0') {
$forum_image = Display::return_icon(
'forum_group.png',
get_lang('GroupForum'),
null,
ICON_SIZE_LARGE
);
// the number of topics and posts
$my_number_threads = isset($forum['number_of_threads']) ? $forum['number_of_threads'] : 0;
$my_number_posts = isset($forum['number_of_posts']) ? $forum['number_of_posts'] : 0;
} else {
$forum_image = Display::return_icon(
'forum.png',
get_lang('Forum'),
$html .= '< div class = "row" > ';
$html .= '< div class = "col-md-6" > ';
$html .= '< div class = "col-md-3" > ';
$html .= '< div class = "number-post" > '.$forum_image.'< p > '.$my_number_threads.' '.get_lang('ForumThreads').'< / p > < / div > ';
$html .= '< / div > ';
$html .= '< div class = "col-md-9" > ';
$iconForum = Display::return_icon(
'forum_yellow.png',
get_lang($forum_category['cat_title']),
null,
ICON_SIZE_LARGE
ICON_SIZE_MEDIUM
);
}
if ($forum['forum_of_group'] != '0') {
$my_all_groups_forum_name = isset($all_groups[$forum['forum_of_group']]['name'])
? $all_groups[$forum['forum_of_group']]['name']
: null;
$my_all_groups_forum_id = isset($all_groups[$forum['forum_of_group']]['id'])
? $all_groups[$forum['forum_of_group']]['id']
: null;
$group_title = api_substr($my_all_groups_forum_name, 0, 30);
$forum_title_group_addition = ' (< a href = "../group/group_space.php?'.api_get_cidreq()
. '& gidReq='.$my_all_groups_forum_id.'" class="forum_group_link">'
. get_lang('GoTo').' '.$group_title.'< / a > )';
} else {
$forum_title_group_addition = '';
}
if (!empty($sessionId) & & !empty($forum['session_name'])) {
$session_displayed = ' ('.$forum['session_name'].')';
} else {
$session_displayed = '';
}
// the number of topics and posts
$my_number_threads = isset($forum['number_of_threads']) ? $forum['number_of_threads'] : 0;
$my_number_posts = isset($forum['number_of_posts']) ? $forum['number_of_posts'] : 0;
$html .= '< div class = "row" > ';
$html .= '< div class = "col-md-6" > ';
$html .= '< div class = "col-md-3" > ';
$html .= '< div class = "number-post" > '.$forum_image.'< p > '.$my_number_threads.' '.get_lang('ForumThreads').'< / p > < / div > ';
$html .= '< / div > ';
$html .= '< div class = "col-md-9" > ';
$iconForum = Display::return_icon(
'forum_yellow.png',
get_lang($forum_category['cat_title']),
null,
ICON_SIZE_MEDIUM
);
$linkForum = '';
$linkForum .= Display::tag(
'a',
$forum['forum_title'].$session_displayed,
array(
'href' => 'viewforum.php?'.api_get_cidreq()
. "& gidReq={$forum['forum_of_group']}& forum={$forum['forum_id']}& search="
. Security::remove_XSS(urlencode(isset($_GET['search']) ? $_GET['search'] : '')),
'class' => empty($forum['visibility']) ? 'text-muted' : null
)
);
$html .= Display::tag(
'h3',
$linkForum.' '.$forum_title_group_addition,
array(
'class' => 'title'
)
);
$html .= Display::tag(
'p',
strip_tags($forum['forum_comment']),
array(
'class' => 'description'
)
);
if ($forum['moderated'] == 1 & & api_is_allowed_to_edit(false, true)) {
$waitingCount = getCountPostsWithStatus(
CForumPost::STATUS_WAITING_MODERATION,
$forum
$linkForum = '';
$linkForum .= Display::tag(
'a',
$forum['forum_title'].$session_displayed,
array(
'href' => 'viewforum.php?'.api_get_cidreq()
. "& gidReq={$forum['forum_of_group']}& forum={$forum['forum_id']}& search="
. Security::remove_XSS(urlencode(isset($_GET['search']) ? $_GET['search'] : '')),
'class' => empty($forum['visibility']) ? 'text-muted' : null
)
);
if (!empty($waitingCount)) {
$html .= Display::label(
get_lang('PostsPendingModeration').': '.$waitingCount,
'warning'
$html .= Display::tag(
'h3',
$linkForum.' '.$forum_title_group_addition,
array(
'class' => 'title'
)
);
$html .= Display::tag(
'p',
strip_tags($forum['forum_comment']),
array(
'class' => 'description'
)
);
if ($forum['moderated'] == 1 & & api_is_allowed_to_edit(false, true)) {
$waitingCount = getCountPostsWithStatus(
CForumPost::STATUS_WAITING_MODERATION,
$forum
);
if (!empty($waitingCount)) {
$html .= Display::label(
get_lang('PostsPendingModeration').': '.$waitingCount,
'warning'
);
}
}
}
$html .= '< / div > ';
$html .= '< / div > ';
$html .= '< div class = "col-md-6" > ';
$html .= '< / div > ';
$html .= '< / div > ';
$html .= '< div class = "col-md-6" > ';
$iconEmpty = '';
$iconEmpty = '';
// The number of topics and posts.
if ($forum['forum_of_group'] !== '0') {
$newPost = '';
if (is_array($my_whatsnew_post_info) & & !empty($my_whatsnew_post_info)) {
$newPost = ' '.Display::return_icon('alert.png', get_lang('Forum'), null, ICON_SIZE_SMALL);
} else {
$newPost = $iconEmpty;
}
} else {
if (is_array($my_whatsnew_post_info) & & !empty($my_whatsnew_post_info)) {
$newPost = ' '.Display::return_icon('alert.png', get_lang('Forum'), null, ICON_SIZE_SMALL);
// The number of topics and posts.
if ($forum['forum_of_group'] !== '0') {
$newPost = '';
if (is_array($my_whatsnew_post_info) & & !empty($my_whatsnew_post_info)) {
$newPost = ' '.Display::return_icon('alert.png', get_lang('Forum'), null, ICON_SIZE_SMALL);
} else {
$newPost = $iconEmpty;
}
} else {
$newPost = $iconEmpty;
if (is_array($my_whatsnew_post_info) & & !empty($my_whatsnew_post_info)) {
$newPost = ' '.Display::return_icon('alert.png', get_lang('Forum'), null, ICON_SIZE_SMALL);
} else {
$newPost = $iconEmpty;
}
}
}
$html .= '< div class = "row" > ';
$html .= '< div class = "col-md-2" > ';
$html .= $newPost.'< / div > ';
$html .= '< div class = "row" > ';
$html .= '< div class = "col-md-2" > ';
$html .= $newPost.'< / div > ';
$poster_id = 0;
$name = '';
// the last post in the forum
if (isset($forum['last_poster_name']) & & $forum['last_poster_name'] != '') {
$name = $forum['last_poster_name'];
} else {
if (isset($forum['last_poster_lastname'])) {
$name = api_get_person_name($forum['last_poster_firstname'], $forum['last_poster_lastname']);
$poster_id = $forum['last_poster_id'];
$poster_id = 0;
$name = '';
// the last post in the forum
if (isset($forum['last_poster_name']) & & $forum['last_poster_name'] != '') {
$name = $forum['last_poster_name'];
} else {
if (isset($forum['last_poster_lastname'])) {
$name = api_get_person_name($forum['last_poster_firstname'], $forum['last_poster_lastname']);
$poster_id = $forum['last_poster_id'];
}
}
$html .= '< div class = "col-md-6" > ';
if (!empty($forum['last_post_id'])) {
$html .= Display::return_icon('post-item.png', null, null, ICON_SIZE_TINY).' ';
$html .= api_convert_and_format_date($forum['last_post_date'])
. ' '.get_lang('By').' '
. display_user_link($poster_id, $name);
}
$html .= '< / div > ';
$html .= '< div class = "col-md-4" > ';
if (api_is_allowed_to_edit(false, true) & &
!($forum['session_id'] == 0 & & $sessionId != 0)
) {
$html .= '< a href = "'.api_get_self().'?'.api_get_cidreq().'&forumcategory='
. Security::remove_XSS($_GET['forumcategory'])
. '& action=edit& content=forum& id='.$forum['forum_id'].'">'
. Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'< / a > ';
$html .= '< a href = "'.api_get_self().'?'.api_get_cidreq().'&forumcategory='
. Security::remove_XSS($_GET['forumcategory'])
. '& 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 > ';
$html .= return_visible_invisible_icon(
'forum',
$forum['forum_id'],
$forum['visibility'],
array('forumcategory' => $_GET['forumcategory'])
);
$html .= return_lock_unlock_icon(
'forum',
$forum['forum_id'],
$forum['locked'],
array('forumcategory' => $_GET['forumcategory'])
);
$html .= return_up_down_icon('forum', $forum['forum_id'], $forums_in_category);
}
}
$html .= '< div class = "col-md-6" > ';
if (!empty($forum['last_post_id'])) {
$html .= Display::return_icon('post-item.png', null, null, ICON_SIZE_TINY).' ';
$html .= api_convert_and_format_date($forum['last_post_date'])
. ' '.get_lang('By').' '
. display_user_link($poster_id, $name);
}
$html .= '< / div > ';
$html .= '< div class = "col-md-4" > ';
if (
api_is_allowed_to_edit(false, true) & &
!($forum['session_id'] == 0 & & $sessionId != 0)
) {
$html .= '< a href = "'.api_get_self().'?'.api_get_cidreq().'&forumcategory='
. Security::remove_XSS($_GET['forumcategory'])
. '& action=edit& content=forum& id='.$forum['forum_id'].'">'
. Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'< / a > ';
$html .= '< a href = "'.api_get_self().'?'.api_get_cidreq().'&forumcategory='
. Security::remove_XSS($_GET['forumcategory'])
. '& 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 > ';
$html .= return_visible_invisible_icon(
'forum',
$forum['forum_id'],
$forum['visibility'],
array('forumcategory' => $_GET['forumcategory'])
);
$html .= return_lock_unlock_icon(
'forum',
$forum['forum_id'],
$forum['locked'],
array('forumcategory' => $_GET['forumcategory'])
);
$html .= return_up_down_icon('forum', $forum['forum_id'], $forums_in_category);
}
$iconnotify = 'notification_mail_na.png';
if (is_array(isset($_SESSION['forum_notification']['forum']) ? $_SESSION['forum_notification']['forum'] : null)) {
if (in_array($forum['forum_id'], $_SESSION['forum_notification']['forum'])) {
$iconnotify = 'notification_mail.png';
$iconnotify = 'notification_mail_na.png';
if (is_array(isset($_SESSION['forum_notification']['forum']) ? $_SESSION['forum_notification']['forum'] : null)) {
if (in_array($forum['forum_id'], $_SESSION['forum_notification']['forum'])) {
$iconnotify = 'notification_mail.png';
}
}
}
if (!api_is_anonymous()) {
$html .= '< a href = "'.api_get_self().'?'.api_get_cidreq().'&forumcategory='
. Security::remove_XSS($_GET['forumcategory']).'& action=notify& content=forum& id='
. $forum['forum_id'].'">'.Display::return_icon($iconnotify, get_lang('NotifyMe')).'< / a > ';
if (!api_is_anonymous()) {
$html .= '< a href = "'.api_get_self().'?'.api_get_cidreq().'&forumcategory='
. Security::remove_XSS($_GET['forumcategory']).'& action=notify& content=forum& id='
. $forum['forum_id'].'">'.Display::return_icon($iconnotify, get_lang('NotifyMe')).'< / a > ';
}
$html .= '< / div > ';
$html .= '< / div > ';
$html .= '< / div > ';
$html .= '< / div > ';
$html .= '< / div > < / div > ';
}
$html .= '< / div > ';
$html .= '< / div > ';
$html .= '< / div > ';
$html .= '< / div > ';
$html .= '< / div > < / div > ';
echo $html;
}
echo $html;
}
}
}
if (count($forum_list) == 0) {
echo '< div class = "alert alert-warning" > '.get_lang('NoForumInThisCategory').'< / div > ';
}
echo '< / div > ';
}