Fix report button, fix report messages see BT#15173

pull/3063/head
Julio 7 years ago
parent d91848a97d
commit 5f57c759e1
  1. 9
      main/forum/editthread.php
  2. 24
      main/forum/forumfunction.inc.php
  3. 2
      main/forum/viewthread.php
  4. 20
      main/forum/viewthread_flat.inc.php
  5. 11
      main/forum/viewthread_nested.inc.php

@ -156,6 +156,8 @@ $actions = [
$threadData = getThreadInfo($threadId, $cId);
$gradeThisThread = empty($_POST) && ($threadData['threadQualifyMax'] > 0 || $threadData['threadWeight'] > 0);
$form = new FormValidator(
'thread',
'post',
@ -183,14 +185,13 @@ if ((api_is_course_admin() || api_is_session_general_coach() || api_is_course_tu
'checkbox',
'thread_qualify_gradebook',
'',
get_lang('QualifyThreadGradebook'),
['id' => 'thread_qualify_gradebook']
get_lang('QualifyThreadGradebook')
);
} else {
$form->addElement('hidden', 'thread_qualify_gradebook', false);
}
$form->addElement('html', '<div id="options_field" style="display:none">');
$form->addElement('html', '<div id="options_field" style="'.($gradeThisThread ? '' : 'display:none;').'">');
$form->addElement('text', 'numeric_calification', get_lang('QualificationNumeric'));
$form->applyFilter('numeric_calification', 'html_filter');
$form->addElement('text', 'calification_notebook_title', get_lang('TitleColumnGradebook'));
@ -222,7 +223,7 @@ $form->addElement('html', '</div>');
$skillList = Skill::addSkillsToForm($form, ITEM_TYPE_FORUM_THREAD, $threadId);
if (!empty($threadData)) {
$defaults['thread_qualify_gradebook'] = ($threadData['threadQualifyMax'] > 0 && empty($_POST)) ? 1 : 0;
$defaults['thread_qualify_gradebook'] = $gradeThisThread;
$defaults['thread_title'] = prepare4display($threadData['threadTitle']);
$defaults['thread_sticky'] = strval(intval($threadData['threadSticky']));
$defaults['thread_peer_qualify'] = intval($threadData['threadPeerQualify']);

@ -6599,7 +6599,7 @@ function getReportRecepients()
}
}
$users = array_unique(array_filter($users));var_dump($users);
$users = array_unique(array_filter($users));
}
return $users;
@ -6608,35 +6608,45 @@ function getReportRecepients()
/**
* @param int $postId
* @param array $forumInfo
* @param array $threadInfo
*
* @return bool
*/
function reportPost($postId, $threadInfo)
function reportPost($postId, $forumInfo, $threadInfo)
{
if (!reportAvailable()) {
return false;
}
if (empty($forumInfo) || empty($threadInfo)) {
return false;
}
$postId = (int) $postId;
$postData = get_post_information($postId);
$currentUser = api_get_user_info();
if (!empty($postData)) {
$users = getReportRecepients();
if (!empty($users)) {
$url = api_get_path(WEB_CODE_PATH).
'forum/viewthread.php?forum='.$threadInfo['forum_id'].'&thread='.$threadInfo['thread_id'].'&post_id='.$postId;
'forum/viewthread.php?forum='.$threadInfo['forum_id'].'&thread='.$threadInfo['thread_id'].'&'.api_get_cidreq().'&post_id='.$postId.'#post_id_'.$postId;
$postLink = Display::url(
get_lang('Link'),
$postData['post_title'],
$url
);
$subject = sprintf(get_lang('PostXReported'), $postData['post_title']);
$content = sprintf(get_lang('PostXReportedVisitLinkX'), $postData['post_title'], $postLink);
$subject = get_lang('ForumPostReported');
$content = sprintf(
get_lang('UserXReportedPostXInForumX'),
$currentUser['complete_name'],
$postLink,
$forumInfo['forum_title']
);
foreach ($users as $userId) {
MessageManager::send_message_simple($userId, $subject, $content);
}
exit;
}
}
}

@ -120,7 +120,7 @@ switch ($my_action) {
case 'report':
$postId = isset($_GET['post_id']) ? $_GET['post_id'] : 0;
$result = reportPost($postId, $current_thread);
$result = reportPost($postId, $current_forum, $current_thread);
Display::addFlash(Display::return_message(get_lang('Reported')));
header('Location: '.$currentUrl);
exit;

@ -286,16 +286,28 @@ if (isset($current_thread['thread_id'])) {
}
}
$reportButton = '';
if ($allowReport) {
$reportButton = getReportButton($row['post_id'], $current_thread);
}
if (!empty($iconEdit)) {
$html .= '<div class="tools-icons">'.$iconEdit.' '.$statusIcon.'</div>';
$html .= "<div class='tools-icons'>$reportButton $iconEdit $statusIcon </div>";
} else {
if (!empty(strip_tags($statusIcon))) {
$html .= '<div class="tools-icons">'.$statusIcon.'</div>';
$html .= "<div class='tools-icons'> $reportButton $statusIcon </div>";
}
}
$html .= $closedPost;
$html .= '</div>';
$html .= '<div class="col-md-10">';
$highLightClass = '';
if (isset($_GET['post_id']) && $_GET['post_id'] == $row['post_id']) {
$highLightClass = 'alert alert-danger';
}
$html .= '<div class="col-md-10 '.$highLightClass.'">';
$titlePost = Display::tag(
'h3',
@ -368,6 +380,8 @@ if (isset($current_thread['thread_id'])) {
$html .= '</div>';
$html .= '</div>';
// The post has been displayed => it can be removed from the what's new array
unset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]);
unset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']]);

@ -317,11 +317,16 @@ foreach ($posts as $post) {
);
}
$html .= '<div class="col-md-10">';
// The post title
$highLightClass = '';
if (isset($_GET['post_id']) && $_GET['post_id'] == $post['post_id']) {
$highLightClass = 'alert alert-danger';
}
$html .= '<div class="col-md-10 '.$highLightClass.'">';
// The post title
$titlePost = Display::tag('h3', $post['post_title'], ['class' => 'forum_post_title']);
$html .= Display::tag('div', $titlePost, ['class' => 'post-header']);
$html .= '<a name="post_id_'.$post['post_id'].'"></a>';
// the post body
$html .= Display::tag('div', $post['post_text'], ['class' => 'post-body']);
@ -354,7 +359,7 @@ foreach ($posts as $post) {
$html .= '</div>';
$html .= '<div class="col-md-6 text-right">';
$html .= "$reportButton $editButton $buttonReply $buttonQuote $waitingValidation";
$html .= "$editButton $buttonReply $buttonQuote $waitingValidation";
$html .= '</div>';
$html .= '</div>';

Loading…
Cancel
Save