Allowing group tutors to edit/delete forum posts see BT#3088

skala
Julio Montoya 13 years ago
parent 4a930e1386
commit 5b3ffd1213
  1. 8
      main/forum/editpost.php
  2. 7
      main/forum/viewthread.php
  3. 8
      main/forum/viewthread_flat.inc.php

@ -153,25 +153,31 @@ if (!api_is_allowed_to_edit(null, true) AND (($current_forum_category['visibilit
exit;
}
}
if (!api_is_allowed_to_edit(null, true) AND ($current_forum_category['locked'] <> 0 OR $current_forum['locked'] <> 0 OR $current_thread['locked'] <> 0)) {
$forum_allow = forum_not_allowed_here();
if ($forum_allow === false) {
exit;
}
}
if (!$_user['user_id'] AND $current_forum['allow_anonymous'] == 0) {
$forum_allow = forum_not_allowed_here();
if ($forum_allow === false) {
exit;
}
}
if (!api_is_allowed_to_edit(null, true) AND $current_forum['allow_edit'] == 0) {
$group_id = api_get_group_id();
if (!api_is_allowed_to_edit(null, true) AND $current_forum['allow_edit'] == 0 && !GroupManager::is_tutor_of_group(api_get_user_id(), $group_id)) {
$forum_allow = forum_not_allowed_here();
if ($forum_allow === false) {
exit;
}
}
// Action links
if ($origin != 'learnpath') {
echo '<div class="actions">';

@ -101,11 +101,14 @@ if (!api_is_allowed_to_edit(false, true) AND ($current_forum['visibility'] == 0
/* Actions */
$group_id = api_get_group_id();
$my_action = isset($_GET['action']) ? $_GET['action'] : '';
if ($my_action == 'delete' AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit(false, true)) {
if ($my_action == 'delete' AND isset($_GET['content']) AND isset($_GET['id']) AND (api_is_allowed_to_edit(false, true) OR GroupManager::is_tutor_of_group(api_get_user_id(), $group_id))) {
$message = delete_post($_GET['id']); // Note: This has to be cleaned first.
}
if (($my_action == 'invisible' OR $my_action == 'visible') AND isset($_GET['id']) AND api_is_allowed_to_edit(false, true)) {
if (($my_action == 'invisible' OR $my_action == 'visible') AND isset($_GET['id']) AND api_is_allowed_to_edit(false, true) OR GroupManager::is_tutor_of_group(api_get_user_id(), $group_id)) {
$message = approve_post($_GET['id'], $_GET['action']); // Note: This has to be cleaned first.
}
if ($my_action == 'move' AND isset($_GET['post'])) {

@ -46,6 +46,8 @@ if (isset($current_thread['thread_id'])){
} else {
echo $name. '<br />';
}
$group_id = api_get_group_id();
echo api_convert_and_format_date($row['post_date']).'<br /><br />';
// get attach id
@ -53,15 +55,17 @@ if (isset($current_thread['thread_id'])){
$id_attach = !empty($attachment_list)?$attachment_list['id']:'';
// The user who posted it can edit his thread only if the course admin allowed this in the properties of the forum
// The course admin him/herself can do this off course always
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 ( GroupManager::is_tutor_of_group(api_get_user_id(), $group_id) OR ($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 (api_is_allowed_to_session_edit(false,true)) {
echo "<a href=\"editpost.php?".api_get_cidreq()."&amp;gidReq=".Security::remove_XSS($_GET['gidReq'])."&amp;forum=".$clean_forum_id."&amp;thread=".$clean_thread_id."&amp;post=".$row['post_id']."&amp;origin=".$origin."&amp;edit=edition&amp;id_attach=".$id_attach."\">".Display::return_icon('edit.png',get_lang('Edit'), array(), 22)."</a>";
}
}
if ($origin != 'learnpath') {
if (api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session'])) {
if (GroupManager::is_tutor_of_group(api_get_user_id(), $group_id) OR api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session'])) {
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&amp;gidReq=".Security::remove_XSS($_GET['gidReq'])."&amp;forum=".$clean_forum_id."&amp;thread=".$clean_thread_id."&amp;action=delete&amp;content=post&amp;id=".$row['post_id']."&amp;origin=".$origin."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('DeletePost'), ENT_QUOTES))."')) return false;\">".Display::return_icon('delete.png', get_lang('Delete'),array(), 22)."</a>";
}
if (api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session'])) {
display_visible_invisible_icon('post', $row['post_id'], $row['visible'],array('forum'=>$clean_forum_id,'thread'=>$clean_thread_id, 'origin'=>$origin ));
echo "";
if ($increment>0) {

Loading…
Cancel
Save