group coach can edit threads

group user  and group coach can reply

See BT#10935
1.9.x
jmontoya 10 years ago
parent 4adff8e291
commit 1c36851240
  1. 41
      main/forum/viewforum.php
  2. 15
      main/forum/viewthread.php
  3. 21
      main/forum/viewthread_flat.inc.php

@ -346,6 +346,8 @@ $whatsnew_post_info = isset($_SESSION['whatsnew_post_info']) ? $_SESSION['whatsn
$course_id = api_get_course_int_id(); $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; $counter = 0;
if (is_array($threads)) { if (is_array($threads)) {
foreach ($threads as $row) { foreach ($threads as $row) {
@ -393,33 +395,6 @@ if (is_array($threads)) {
$post_date = api_convert_and_format_date($last_post_info['post_date']); $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']); $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 '<td>'.$last_post.'</td>'; echo '<td>'.$last_post.'</td>';
echo '<td class="td_actions">'; echo '<td class="td_actions">';
@ -441,7 +416,10 @@ if (is_array($threads)) {
$row_post_id = Database::fetch_array($result_post_id); $row_post_id = Database::fetch_array($result_post_id);
if ($origin != 'learnpath') { 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 '<a href="'.$forumUrl.'editpost.php?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).'&amp;thread='.Security::remove_XSS($row['thread_id']).'&amp;post='.$row_post_id['post_id'].'&id_attach='.$id_attach.'">'. echo '<a href="'.$forumUrl.'editpost.php?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).'&amp;thread='.Security::remove_XSS($row['thread_id']).'&amp;post='.$row_post_id['post_id'].'&id_attach='.$id_attach.'">'.
Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>'; Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';
@ -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_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())); display_lock_unlock_icon('thread', $row['thread_id'], $row['locked'], array('forum' => $my_forum, 'origin' => $origin, 'gidReq' => api_get_group_id()));
echo '<a href="viewforum.php?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).'&amp;action=move&thread='.$row['thread_id'].$origin_string.'">'. echo '<a href="viewforum.php?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).'&amp;action=move&thread='.$row['thread_id'].$origin_string.'">'.
Display::return_icon('move.png', get_lang('MoveThread'), array(), ICON_SIZE_SMALL).'</a>'; Display::return_icon('move.png', get_lang('MoveThread'), array(), ICON_SIZE_SMALL).'</a>';
$editShowed = true;
}
if ($isTutor && $editShowed == false) {
echo '<a href="'.$forumUrl.'editpost.php?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).'&amp;thread='.Security::remove_XSS($row['thread_id']).'&amp;post='.$row_post_id['post_id'].'&id_attach='.$id_attach.'">'.
Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';
} }
} }
$iconnotify = 'send_mail.gif'; $iconnotify = 'send_mail.gif';

@ -24,6 +24,9 @@ require_once 'forumfunction.inc.php';
$nameTools = get_lang('Forum'); $nameTools = get_lang('Forum');
$forumUrl = api_get_path(WEB_CODE_PATH).'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 ? // Are we in a lp ?
$origin = ''; $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 '<a href="'.$forumUrl.'reply.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']).'&amp;action=replythread">'.
Display::return_icon('reply_thread.png', get_lang('ReplyToThread'), '', ICON_SIZE_MEDIUM).'</a>';
}
}
} }
// The different views of the thread. // The different views of the thread.

@ -5,6 +5,7 @@
* @copyright Julio Montoya <gugli100@gmail.com> UI Improvements + lots of bugfixes * @copyright Julio Montoya <gugli100@gmail.com> UI Improvements + lots of bugfixes
* @package chamilo.forum * @package chamilo.forum
*/ */
//delete attachment file //delete attachment file
if ((isset($_GET['action']) && $_GET['action']=='delete_attach') && isset($_GET['id_attach'])) { if ((isset($_GET['action']) && $_GET['action']=='delete_attach') && isset($_GET['id_attach'])) {
delete_attachment(0,$_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 ($_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)) { if (!api_is_anonymous() && api_is_allowed_to_session_edit(false,true)) {
echo '<a href="reply.php?'.api_get_cidreq().'&amp;forum='.$clean_forum_id.'&amp;thread='.$clean_thread_id.'&amp;post='.$row['post_id'].'&amp;action=replymessage&amp;origin='.$origin.'">'.Display :: return_icon('message_reply_forum.png', get_lang('ReplyToMessage'))."</a>"; echo '<a href="reply.php?'.api_get_cidreq().'&amp;forum='.$clean_forum_id.'&amp;thread='.$clean_thread_id.'&amp;post='.$row['post_id'].'&amp;action=replymessage&amp;origin='.$origin.'">'.Display :: return_icon('message_reply_forum.png', get_lang('ReplyToMessage'))."</a>";
@ -111,6 +114,19 @@ if (isset($current_thread['thread_id'])) {
if ($current_thread['locked']==1) { if ($current_thread['locked']==1) {
echo get_lang('ThreadLocked').'<br />'; echo get_lang('ThreadLocked').'<br />';
} }
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 '<a href="reply.php?'.api_get_cidreq().'&amp;forum='.$clean_forum_id.'&amp;thread='.$clean_thread_id.'&amp;post='.$row['post_id'].'&amp;action=replymessage&amp;origin='.$origin.'">'.Display :: return_icon('message_reply_forum.png', get_lang('ReplyToMessage'))."</a>";
echo '<a href="reply.php?'.api_get_cidreq().'&amp;forum='.$clean_forum_id.'&amp;thread='.$clean_thread_id.'&amp;post='.$row['post_id'].'&amp;action=quote&amp;origin='.$origin.'">'.Display :: return_icon('quote.gif', get_lang('QuoteMessage'))."</a>";
}
}
} }
echo "</td>"; echo "</td>";
// prepare the notification icon // prepare the notification icon
@ -152,7 +168,8 @@ if (isset($current_thread['thread_id'])) {
echo '<a href="download.php?file='.$realname.'"> '.$user_filename.' </a>'; echo '<a href="download.php?file='.$realname.'"> '.$user_filename.' </a>';
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']))) { 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 '&nbsp;&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;origin='.Security::remove_XSS($_GET['origin']).'&amp;action=delete_attach&amp;id_attach='.$attachment['id'].'&amp;forum='.$clean_forum_id.'&amp;thread='.$clean_thread_id.'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)).'\')) return false;">'.Display::return_icon('delete.png',get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a><br />'; echo '&nbsp;&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;origin='.Security::remove_XSS($_GET['origin']).'&amp;action=delete_attach&amp;id_attach='.$attachment['id'].'&amp;forum='.$clean_forum_id.'&amp;thread='.$clean_thread_id.'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)).'\')) return false;">'.
Display::return_icon('delete.png',get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a><br />';
} }
echo '<span class="forum_attach_comment" >'.$attachment['comment'].'</span>'; echo '<span class="forum_attach_comment" >'.$attachment['comment'].'</span>';
echo '</td></tr>'; echo '</td></tr>';

Loading…
Cancel
Save