Minor - format code.

remotes/angel/1.11.x
jmontoyaa 8 years ago
parent f4a9e20260
commit a12d673467
  1. 138
      main/forum/forumfunction.inc.php
  2. 48
      main/forum/index.php
  3. 446
      main/forum/viewforumcategory.php

@ -1005,18 +1005,24 @@ function check_if_last_post_of_thread($thread_id)
}
/**
* @param $content what is it that we want to make (in)visible: forum category, forum, thread, post
* @param $id the id of the content we want to make invisible
* @param $current_visibility_status what is the current status of the visibility (0 = invisible, 1 = visible)
* @param string $content what is it that we want to make (in)visible: forum category, forum, thread, post
* @param int $id the id of the content we want to make invisible
* @param int $current_visibility_status what is the current status of the visibility (0 = invisible, 1 = visible)
* @param array $additional_url_parameters
*
* @return string HTML
*/
function return_visible_invisible_icon($content, $id, $current_visibility_status, $additional_url_parameters = '')
{
function return_visible_invisible_icon(
$content,
$id,
$current_visibility_status,
$additional_url_parameters = ''
) {
$html = '';
$id = Security::remove_XSS($id);
if ($current_visibility_status == '1') {
$id = (int) $id;
$current_visibility_status = (int) $current_visibility_status;
if ($current_visibility_status == 1) {
$html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&';
if (is_array($additional_url_parameters)) {
foreach ($additional_url_parameters as $key => $value) {
@ -1026,7 +1032,7 @@ function return_visible_invisible_icon($content, $id, $current_visibility_status
$html .= 'action=invisible&content='.$content.'&id='.$id.'">'.
Display::return_icon('visible.png', get_lang('MakeInvisible'), array(), ICON_SIZE_SMALL).'</a>';
}
if ($current_visibility_status == '0') {
if ($current_visibility_status == 0) {
$html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&';
if (is_array($additional_url_parameters)) {
foreach ($additional_url_parameters as $key => $value) {
@ -1036,6 +1042,7 @@ function return_visible_invisible_icon($content, $id, $current_visibility_status
$html .= 'action=visible&content='.$content.'&id='.$id.'">'.
Display::return_icon('invisible.png', get_lang('MakeVisible'), array(), ICON_SIZE_SMALL).'</a>';
}
return $html;
}
@ -1085,8 +1092,8 @@ function return_lock_unlock_icon($content, $id, $current_lock_status, $additiona
/**
* This function takes care of the display of the up and down icon
*
* @param $content what is it that we want to make (in)visible: forum category, forum, thread, post
* @param $id is the id of the item we want to display the icons for
* @param string $content what is it that we want to make (in)visible: forum category, forum, thread, post
* @param int $id is the id of the item we want to display the icons for
* @param $list is an array of all the items. All items in this list should have
* an up and down icon except for the first (no up icon) and the last (no down icon)
* The key of this $list array is the id of the item.
@ -1095,7 +1102,7 @@ function return_lock_unlock_icon($content, $id, $current_lock_status, $additiona
**/
function return_up_down_icon($content, $id, $list)
{
$id = strval(intval($id));
$id = (int) $id;
$total_items = count($list);
$position = 0;
$internal_counter = 0;
@ -1123,6 +1130,7 @@ function return_up_down_icon($content, $id, $list)
} else {
$return_value .= Display::return_icon('down_na.png', '-', array(), ICON_SIZE_SMALL);
}
return $return_value;
}
@ -1346,7 +1354,12 @@ function get_forum_categories($id = '', $courseId = 0, $sessionId = 0)
$session_id = $sessionId ?: api_get_session_id();
$course_id = $courseId ?: api_get_course_int_id();
$condition_session = api_get_session_condition($session_id, true, true, 'forum_categories.session_id');
$condition_session = api_get_session_condition(
$session_id,
true,
true,
'forum_categories.session_id'
);
$condition_session .= " AND forum_categories.c_id = $course_id AND item_properties.c_id = $course_id";
if (empty($id)) {
@ -2105,7 +2118,12 @@ function get_thread_information($forumId, $thread_id, $sessionId = null)
$table_threads = Database::get_course_table(TABLE_FORUM_THREAD);
$thread_id = intval($thread_id);
$sessionId = $sessionId !== null ? intval($sessionId) : api_get_session_id();
$sessionCondition = api_get_session_condition($sessionId, true, false, 'threads.session_id');
$sessionCondition = api_get_session_condition(
$sessionId,
true,
false,
'threads.session_id'
);
$forumCondition = '';
if (!empty($forumId)) {
$forumId = (int) $forumId;
@ -2158,25 +2176,27 @@ function get_thread_users_details($thread_id)
$user_to_avoid = "'".$session_info['id_coach']."', '".$session_info['session_admin_id']."'";
//not showing coaches
$sql = "SELECT DISTINCT user.id, user.lastname, user.firstname, thread_id
FROM $t_posts p, $t_users user, $t_session_rel_user session_rel_user_rel_course
WHERE p.poster_id = user.id AND
user.id = session_rel_user_rel_course.user_id AND
session_rel_user_rel_course.status<>'2' AND
session_rel_user_rel_course.user_id NOT IN ($user_to_avoid) AND
p.thread_id = ".intval($thread_id)." AND
session_id = ".api_get_session_id()." AND
p.c_id = $course_id AND
session_rel_user_rel_course.c_id = ".$course_id." $orderby ";
FROM $t_posts p, $t_users user, $t_session_rel_user session_rel_user_rel_course
WHERE
p.poster_id = user.id AND
user.id = session_rel_user_rel_course.user_id AND
session_rel_user_rel_course.status<>'2' AND
session_rel_user_rel_course.user_id NOT IN ($user_to_avoid) AND
p.thread_id = ".intval($thread_id)." AND
session_id = ".api_get_session_id()." AND
p.c_id = $course_id AND
session_rel_user_rel_course.c_id = ".$course_id." $orderby ";
} else {
$sql = "SELECT DISTINCT user.id, user.lastname, user.firstname, thread_id
FROM $t_posts p, $t_users user, $t_course_user course_user
WHERE p.poster_id = user.id
AND user.id = course_user.user_id
AND course_user.relation_type<>".COURSE_RELATION_TYPE_RRHH."
AND p.thread_id = ".intval($thread_id)."
AND course_user.status NOT IN('1') AND
p.c_id = $course_id AND
course_user.c_id = ".$course_id." $orderby";
FROM $t_posts p, $t_users user, $t_course_user course_user
WHERE
p.poster_id = user.id
AND user.id = course_user.user_id
AND course_user.relation_type<>".COURSE_RELATION_TYPE_RRHH."
AND p.thread_id = ".intval($thread_id)."
AND course_user.status NOT IN('1') AND
p.c_id = $course_id AND
course_user.c_id = ".$course_id." $orderby";
}
$result = Database::query($sql);
@ -3005,7 +3025,11 @@ function show_add_post_form($current_forum, $forum_setting, $action, $id = '', $
// The course admin can make a thread sticky (=appears with special icon and always on top).
$form->addRule('post_title', get_lang('ThisFieldIsRequired'), 'required');
if ($current_forum['allow_anonymous'] == 1 && !isset($_user['user_id'])) {
$form->addRule('poster_name', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule(
'poster_name',
get_lang('ThisFieldIsRequired'),
'required'
);
}
// Validation or display
@ -3126,7 +3150,6 @@ function saveThreadScore(
$sql = "INSERT INTO $table_threads_qualify (c_id, user_id, thread_id,qualify,qualify_user_id,qualify_time,session_id)
VALUES (".$course_id.", '".$user_id."','".$thread_id."',".(float) $thread_qualify.", '".$currentUserId."','".$qualify_time."','".$session_id."')";
Database::query($sql);
$insertId = Database::insert_id();
if ($insertId) {
$sql = "UPDATE $table_threads_qualify SET id = iid
@ -3766,7 +3789,6 @@ function display_user_link($user_id, $name, $origin = '', $in_title = '')
function display_user_image($user_id, $name, $origin = '')
{
$userInfo = api_get_user_info($user_id);
$link = '<a href="'.(!empty($origin) ? '#' : $userInfo['profile_url']).'" '.(!empty($origin) ? 'target="_self"' : '').'>';
if ($user_id != 0) {
@ -4516,10 +4538,16 @@ function display_forum_search_results($search_term)
)";
}
$sessionCondition = api_get_session_condition($session_id, true, false, 'item_property.session_id');
$sessionCondition = api_get_session_condition(
$session_id,
true,
false,
'item_property.session_id'
);
$sql = "SELECT posts.*
FROM $table_posts posts INNER JOIN $table_threads threads
FROM $table_posts posts
INNER JOIN $table_threads threads
ON (posts.thread_id = threads.thread_id AND posts.c_id = threads.c_id)
INNER JOIN $table_item_property item_property
ON (item_property.ref = threads.thread_id AND item_property.c_id = threads.c_id)
@ -4777,8 +4805,14 @@ function edit_forum_attachment_file($file_comment, $post_id, $id_attach)
$safe_id_attach = (int) $id_attach;
// Storing the attachments if any.
if ($result) {
$sql = "UPDATE $table_forum_attachment SET filename = '$safe_file_name', comment = '$safe_file_comment', path = '$safe_new_file_name', post_id = '$safe_post_id', size ='".$attachment['size']."'
WHERE c_id = $course_id AND id = '$safe_id_attach'";
$sql = "UPDATE $table_forum_attachment
SET
filename = '$safe_file_name',
comment = '$safe_file_comment',
path = '$safe_new_file_name',
post_id = '$safe_post_id',
size ='".$attachment['size']."'
WHERE c_id = $course_id AND id = '$safe_id_attach'";
Database::query($sql);
api_item_property_update(
$_course,
@ -4918,7 +4952,6 @@ function get_forums_of_group($groupInfo)
// Student
// Select all the forum information of all forums (that are visible to students).
$sql = "SELECT * FROM $table_forums forum
INNER JOIN $table_item_property item_properties
ON (forum.forum_id = item_properties.ref AND item_properties.c_id = forum.c_id)
@ -4964,7 +4997,8 @@ function get_forums_of_group($groupInfo)
if (api_is_allowed_to_edit()) {
// Select all the forum information of all forums (that are not deleted).
$sql = "SELECT *
FROM $table_forums forum INNER JOIN $table_item_property item_properties
FROM $table_forums forum
INNER JOIN $table_item_property item_properties
ON (forum.forum_id = item_properties.ref AND item_properties.c_id = forum.c_id)
WHERE
forum.forum_of_group = $groupId AND
@ -4976,7 +5010,8 @@ function get_forums_of_group($groupInfo)
// Select the number of threads of the forums (only the threads that are not deleted).
$sql2 = "SELECT count(thread_id) AS number_of_threads, threads.forum_id
FROM $table_threads threads INNER JOIN $table_item_property item_properties
FROM $table_threads threads
INNER JOIN $table_item_property item_properties
ON (threads.thread_id=item_properties.ref AND item_properties.c_id = threads.c_id)
WHERE
threads.c_id = $course_id AND
@ -5051,7 +5086,6 @@ function get_forums_of_group($groupInfo)
function set_notification($content, $id, $add_only = false)
{
$_user = api_get_user_info();
// Database table definition
$table_notification = Database::get_course_table(TABLE_FORUM_NOTIFICATION);
@ -5184,7 +5218,6 @@ function send_notifications($forum_id = 0, $thread_id = 0, $post_id = 0)
if (is_array($users_to_be_notified)) {
foreach ($users_to_be_notified as $value) {
$user_info = api_get_user_info($value['user_id']);
$email_body = get_lang('Dear').' '.api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS).", <br />\n\r";
$email_body .= get_lang('NewForumPost').": ".$current_forum['forum_title'].' - '.$current_thread['thread_title']." <br />\n";
@ -5437,13 +5470,17 @@ function get_all_post_from_user($user_id, $course_code)
$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_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">';
@ -5477,7 +5514,8 @@ function get_all_post_from_user($user_id, $course_code)
$forum_results .= $hand_forums;
}
$forum_results .= '</div>';
}$j++;
}
$j++;
}
}
@ -5505,8 +5543,8 @@ function get_thread_user_post_limit($course_code, $thread_id, $user_id, $limit =
ON posts.poster_id=users.user_id
WHERE
posts.c_id = $course_id AND
posts.thread_id='".Database::escape_string($thread_id)."'
AND posts.poster_id='".Database::escape_string($user_id)."'
posts.thread_id='".Database::escape_string($thread_id)."' AND
posts.poster_id='".Database::escape_string($user_id)."'
ORDER BY posts.post_id DESC LIMIT $limit ";
$result = Database::query($sql);
$post_list = array();
@ -5535,7 +5573,6 @@ function getForumCreatedByUser($user_id, $courseId, $sessionId)
);
$courseInfo = api_get_course_info_by_id($courseId);
$forumList = array();
if (!empty($items)) {
foreach ($items as $forum) {
@ -5815,7 +5852,8 @@ function getAttachedFiles($forumId, $threadId, $postId = 0, $attachId = 0, $cour
*
* @return array
*/
function clearAttachedFiles($postId = null, $courseId = null) {
function clearAttachedFiles($postId = null, $courseId = null)
{
// Init variables
$courseId = intval($courseId);
$postId = intval($postId);
@ -5862,7 +5900,6 @@ function clearAttachedFiles($postId = null, $courseId = null) {
*/
function getAttachmentIdsByPostId($postId, $courseId = null)
{
$array = array();
$courseId = intval($courseId);
$postId = intval($postId);
@ -5894,7 +5931,6 @@ function getAttachmentIdsByPostId($postId, $courseId = null)
function getForumCategoryByTitle($title, $courseId, $sessionId = 0)
{
$sessionId = intval($sessionId);
$forumCategoryTable = Database::get_course_table(TABLE_FORUM_CATEGORY);
$itemProperty = Database::get_course_table(TABLE_ITEM_PROPERTY);

@ -28,7 +28,6 @@ use Chamilo\CourseBundle\Entity\CForumPost;
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_FORUM;
$htmlHeadXtra[] = '<script>
$(document).ready(function() {
$(\'.hide-me\').slideUp();
});
@ -36,7 +35,6 @@ $(document).ready(function() {
function hidecontent(content){
$(content).slideToggle(\'normal\');
}
</script>';
// The section (tabs).
@ -72,7 +70,6 @@ if (!empty($gradebook) && $gradebook == 'view') {
$search_forum = isset($_GET['search']) ? Security::remove_XSS($_GET['search']) : '';
/* ACTIONS */
$actions = isset($_GET['action']) ? $_GET['action'] : '';
if ($actions === 'add') {
@ -120,9 +117,8 @@ if (api_is_allowed_to_edit(false, true)) {
// Notification
if ($actions == 'notify' && isset($_GET['content']) && isset($_GET['id'])) {
if (
api_get_session_id() != 0
&& api_is_allowed_to_session_edit(false, true) == false
if (api_get_session_id() != 0 &&
api_is_allowed_to_session_edit(false, true) == false
) {
api_not_allowed();
}
@ -131,14 +127,11 @@ if ($actions == 'notify' && isset($_GET['content']) && isset($_GET['id'])) {
}
get_whats_new();
$whatsnew_post_info = Session::read('whatsnew_post_info');
$tpl = new Template($nameTools, false, false, false, false, true, false);
/* TRACKING */
Event::event_access_tool(TOOL_FORUM);
/*
RETRIEVING ALL THE FORUM CATEGORIES AND FORUMS
note: we do this here just after het handling of the actions to be
@ -200,7 +193,8 @@ if (api_is_allowed_to_edit(false, true)) {
null,
ICON_SIZE_MEDIUM
),
api_get_self().'?'.api_get_cidreq().'&action=add&content=forumcategory&lp_id='.$lp_id);
api_get_self().'?'.api_get_cidreq().'&action=add&content=forumcategory&lp_id='.$lp_id
);
if (is_array($forumCategories) && !empty($forumCategories)) {
$actionLeft .= Display::url(
@ -237,7 +231,6 @@ if (!empty($forumsInNoCategory)) {
// Step 3: We display the forum_categories first.
$listForumCategory = array();
$forumCategoryInfo = array();
if (is_array($forumCategories)) {
foreach ($forumCategories as $forumCategory) {
$forumCategoryInfo['id'] = $forumCategory['cat_id'];
@ -247,12 +240,12 @@ if (is_array($forumCategories)) {
$forumCategoryInfo['title'] = $forumCategory['cat_title'];
}
$forumCategoryInfo['icon_session'] = api_get_session_image(
$forumCategory['session_id'], $_user['status']
$forumCategory['session_id'],
$_user['status']
);
// Validation when belongs to a session
$forumCategoryInfo['description'] = $forumCategory['cat_comment'];
if (empty($sessionId) && !empty($forumCategory['session_name'])) {
$forumCategory['session_display'] = ' ('.Security::remove_XSS($forumCategory['session_name']).')';
} else {
@ -264,10 +257,8 @@ if (is_array($forumCategories)) {
$forumCategoryInfo['url'] = 'viewforumcategory.php?'.api_get_cidreq().'&forumcategory='.intval($idCategory);
if (!empty($idCategory)) {
if (
api_is_allowed_to_edit(false, true)
&& !($forumCategory['session_id'] == 0
&& intval($sessionId) != 0)
if (api_is_allowed_to_edit(false, true) &&
!($forumCategory['session_id'] == 0 && intval($sessionId) != 0)
) {
$tools .= '<a href="'.api_get_self().'?'.api_get_cidreq()
.'&action=edit&content=forumcategory&id='.intval($idCategory)
@ -289,17 +280,17 @@ if (is_array($forumCategories)) {
.'</a>';
$tools .= return_visible_invisible_icon(
'forumcategory',
strval(intval($idCategory)),
strval(intval($forumCategory['visibility']))
$idCategory,
$forumCategory['visibility']
);
$tools .= return_lock_unlock_icon(
'forumcategory',
strval(intval($idCategory)),
strval(intval($forumCategory['locked']))
$idCategory,
$forumCategory['locked']
);
$tools .= return_up_down_icon(
'forumcategory',
strval(intval($idCategory)),
$idCategory,
$forumCategories
);
}
@ -411,7 +402,8 @@ if (is_array($forumCategories)) {
if ($forum['moderated'] == 1 && api_is_allowed_to_edit(false, true)) {
$waitingCount = getCountPostsWithStatus(
CForumPost::STATUS_WAITING_MODERATION, $forum
CForumPost::STATUS_WAITING_MODERATION,
$forum
);
if (!empty($waitingCount)) {
$forumInfo['moderation'] = $waitingCount;
@ -423,9 +415,13 @@ if (is_array($forumCategories)) {
// The number of topics and posts.
if ($forum['forum_of_group'] !== '0') {
if (is_array($mywhatsnew_post_info) && !empty($mywhatsnew_post_info)) {
$forumInfo['alert'] = ' '.Display::return_icon(
'alert.png', get_lang('Forum'), null, ICON_SIZE_SMALL
);
$forumInfo['alert'] = ' '.
Display::return_icon(
'alert.png',
get_lang('Forum'),
null,
ICON_SIZE_SMALL
);
}
} else {
if (is_array($mywhatsnew_post_info) && !empty($mywhatsnew_post_info)) {

@ -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) != '&nbsp;') {
$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>';
}

Loading…
Cancel
Save