diff --git a/main/forum/viewforum.php b/main/forum/viewforum.php index 1c2455b853..d470ec71f8 100755 --- a/main/forum/viewforum.php +++ b/main/forum/viewforum.php @@ -346,6 +346,8 @@ $whatsnew_post_info = isset($_SESSION['whatsnew_post_info']) ? $_SESSION['whatsn $course_id = api_get_course_int_id(); +$isTutor = GroupManager::is_tutor_of_group(api_get_user_id(), api_get_group_id(), $course_id); + $counter = 0; if (is_array($threads)) { foreach ($threads as $row) { @@ -393,33 +395,6 @@ if (is_array($threads)) { $post_date = api_convert_and_format_date($last_post_info['post_date']); $last_post = $post_date.' '.get_lang('By').' '.display_user_link($last_post_info['poster_id'], $poster_info['complete_name'], '', $poster_info['username']); } - /* - if ($row['last_poster_user_id'] == '0') { - $name = $row['poster_name']; - $last_poster_username = ""; - } else { - $name = api_get_person_name($row['last_poster_firstname'], $row['last_poster_lastname']); - $tab_last_poster_info = api_get_user_info($row['last_poster_user_id']); - $last_poster_username = sprintf(get_lang('LoginX'), $tab_last_poster_info['username']); - } - // If the last post is invisible and it is not the teacher who is looking then we have to find the last visible post of the thread. - if (($row['visible'] == '1' OR api_is_allowed_to_edit(false, true)) && $origin != 'learnpath') { - $last_post = $post_date.' '.get_lang('By').' '.display_user_link($row['last_poster_user_id'], $name, '', $last_poster_username); - } elseif ($origin != 'learnpath') { - $last_post_sql = "SELECT post.*, user.firstname, user.lastname, user.username FROM $table_posts post, $table_users user WHERE post.poster_id=user.user_id AND visible='1' AND thread_id='".$row['thread_id']."' AND post.c_id=".api_get_course_int_id()." ORDER BY post_id DESC"; - $last_post_result = Database::query($last_post_sql); - $last_post_row = Database::fetch_array($last_post_result); - $name = api_get_person_name($last_post_row['firstname'], $last_post_row['lastname']); - $last_post_info_username = sprintf(get_lang('LoginX'), $last_post_row['username']); - $last_post = api_convert_and_format_date($last_post_row['post_date']).' '.get_lang('By').' '.display_user_link($last_post_row['poster_id'], $name, '', $last_post_info_username); - } else { - $last_post_sql = "SELECT post.*, user.firstname, user.lastname, user.username FROM $table_posts post, $table_users user WHERE post.poster_id=user.user_id AND visible='1' AND thread_id='".$row['thread_id']."' AND post.c_id=".api_get_course_int_id()." ORDER BY post_id DESC"; - $last_post_result = Database::query($last_post_sql); - $last_post_row = Database::fetch_array($last_post_result); - $last_post_info_username = sprintf(get_lang('LoginX'), $last_post_row['username']); - $name = api_get_person_name($last_post_row['firstname'], $last_post_row['lastname']); - $last_post = api_convert_and_format_date($last_post_row['post_date']).' '.get_lang('By').' '.Display::tag('span', $name, array("title"=>api_htmlentities($last_post_info_username, ENT_QUOTES))); - }*/ echo ''.$last_post.''; echo ''; @@ -441,7 +416,10 @@ if (is_array($threads)) { $row_post_id = Database::fetch_array($result_post_id); if ($origin != 'learnpath') { - if (api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $_SESSION['id_session'])) { + $editShowed = false; + if (api_is_allowed_to_edit(false, true) && + !(api_is_course_coach() && $current_forum['session_id'] != $_SESSION['id_session']) + ) { echo ''. Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).''; @@ -454,8 +432,15 @@ if (is_array($threads)) { display_visible_invisible_icon('thread', $row['thread_id'], $row['visibility'], array('forum' => $my_forum, 'origin' => $origin, 'gidReq' => $groupId)); display_lock_unlock_icon('thread', $row['thread_id'], $row['locked'], array('forum' => $my_forum, 'origin' => $origin, 'gidReq' => api_get_group_id())); + echo ''. Display::return_icon('move.png', get_lang('MoveThread'), array(), ICON_SIZE_SMALL).''; + $editShowed = true; + } + + if ($isTutor && $editShowed == false) { + echo ''. + Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).''; } } $iconnotify = 'send_mail.gif'; diff --git a/main/forum/viewthread.php b/main/forum/viewthread.php index 109964863d..429cbaa0ee 100755 --- a/main/forum/viewthread.php +++ b/main/forum/viewthread.php @@ -24,6 +24,9 @@ require_once 'forumfunction.inc.php'; $nameTools = get_lang('Forum'); $forumUrl = api_get_path(WEB_CODE_PATH).'forum/'; +$userId = api_get_user_id(); +$groupId = api_get_group_id(); +$courseId = api_get_course_int_id(); // Are we in a lp ? $origin = ''; @@ -159,6 +162,18 @@ if ($my_message != 'PostDeletedSpecial') { } } } + } else { + if (!empty($group_id)) { + $reply = api_is_allowed_to_edit() || + ( + GroupManager::is_tutor_of_group($userId, $groupId, $courseId) || + GroupManager::is_subscribed($userId, $groupId, $courseId) + ); + if ($reply) { + echo ''. + Display::return_icon('reply_thread.png', get_lang('ReplyToThread'), '', ICON_SIZE_MEDIUM).''; + } + } } // The different views of the thread. diff --git a/main/forum/viewthread_flat.inc.php b/main/forum/viewthread_flat.inc.php index 16ec6d71e0..5beba9c245 100755 --- a/main/forum/viewthread_flat.inc.php +++ b/main/forum/viewthread_flat.inc.php @@ -5,6 +5,7 @@ * @copyright Julio Montoya UI Improvements + lots of bugfixes * @package chamilo.forum */ + //delete attachment file if ((isset($_GET['action']) && $_GET['action']=='delete_attach') && isset($_GET['id_attach'])) { delete_attachment(0,$_GET['id_attach']); @@ -94,7 +95,9 @@ if (isset($current_thread['thread_id'])) { } } - if (($current_forum_category && $current_forum_category['locked']==0) AND $current_forum['locked']==0 AND $current_thread['locked']==0 OR api_is_allowed_to_edit(false,true)) { + if (($current_forum_category && $current_forum_category['locked']==0) AND + $current_forum['locked']==0 AND $current_thread['locked']==0 OR api_is_allowed_to_edit(false,true) + ) { if ($_user['user_id'] OR ($current_forum['allow_anonymous']==1 AND !$_user['user_id'])) { if (!api_is_anonymous() && api_is_allowed_to_session_edit(false,true)) { echo ''.Display :: return_icon('message_reply_forum.png', get_lang('ReplyToMessage')).""; @@ -111,6 +114,19 @@ if (isset($current_thread['thread_id'])) { if ($current_thread['locked']==1) { echo get_lang('ThreadLocked').'
'; } + + if (!empty($group_id)) { + $reply = api_is_allowed_to_edit() || + ( + GroupManager::is_tutor_of_group($userId, $groupId, $courseId) || + GroupManager::is_subscribed($userId, $groupId, $courseId) + ); + + if ($reply) { + echo ''.Display :: return_icon('message_reply_forum.png', get_lang('ReplyToMessage')).""; + echo ''.Display :: return_icon('quote.gif', get_lang('QuoteMessage')).""; + } + } } echo ""; // prepare the notification icon @@ -152,7 +168,8 @@ if (isset($current_thread['thread_id'])) { echo ' '.$user_filename.' '; if (($current_forum['allow_edit']==1 AND $row['user_id']==$_user['user_id']) or (api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session']))) { - echo '  '.Display::return_icon('delete.png',get_lang('Delete'), array(), ICON_SIZE_SMALL).'
'; + echo '  '. + Display::return_icon('delete.png',get_lang('Delete'), array(), ICON_SIZE_SMALL).'
'; } echo ''.$attachment['comment'].''; echo '';