Messages - Add option to remove message from reporting - refs BT#19400

pull/4103/head
Christian 4 years ago
parent 1bdd7c086c
commit 24c480efc9
  1. 13
      main/inc/lib/message.lib.php
  2. 10
      main/mySpace/myStudents.php

@ -366,7 +366,7 @@ class MessageManager
*
* @return string
*/
public static function getMessagesAboutUserToString($userInfo)
public static function getMessagesAboutUserToString($userInfo, $origin = null)
{
$messages = self::getMessagesAboutUser($userInfo);
$html = '';
@ -388,8 +388,17 @@ class MessageManager
);
$senderId = $message->getUserSenderId();
$senderInfo = api_get_user_info($senderId);
$deleteLink = '';
if ('my_space' == $origin && api_get_user_id() == $senderId) {
$deleteLink = '<a title="'.addslashes(
get_lang('DeleteMessage')
).'" href="'.api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?student='.$userInfo['id'].'&action=delete_msg&msg_id='.$message->getId().'" onclick="javascript:if(!confirm('."'".addslashes(
api_htmlentities(get_lang('ConfirmDeleteMessage'))
)."'".')) return false;" >&nbsp;&nbsp;&nbsp;&nbsp;'.
Display::returnFontAwesomeIcon('trash', 1).'</a>';
}
$html .= Display::panelCollapse(
$localTime.' '.$senderInfo['complete_name'].' '.$message->getTitle(),
$localTime.' '.$senderInfo['complete_name'].' '.$message->getTitle().$deleteLink,
$message->getContent().'<br />'.$date.'<br />'.get_lang(
'Author'
).': '.$senderInfo['complete_name_with_message_link'],

@ -213,6 +213,10 @@ $user_id = isset($_GET['user_id']) && !empty($_GET['user_id']) ? (int) $_GET['us
$action = isset($_GET['action']) ? $_GET['action'] : '';
switch ($action) {
case 'delete_msg':
$messageId = (int) $_GET['msg_id'];
MessageManager::delete_message_by_user_sender(api_get_user_id(), $messageId);
break;
case 'export_to_pdf':
$sessionToExport = $sId = isset($_GET['session_to_export']) ? (int) $_GET['session_to_export'] : 0;
$sessionInfo = api_get_session_info($sessionToExport);
@ -1822,12 +1826,12 @@ if (empty($details)) {
'quiz.session_id'
);
$sql = "SELECT quiz.title, id
$sql = "SELECT quiz.title, id
FROM $t_quiz AS quiz
WHERE
quiz.c_id = ".$courseInfo['real_id']." AND
active IN (0, 1)
$sessionCondition
$sessionCondition
ORDER BY quiz.title ASC ";
$result_exercices = Database::query($sql);
@ -2170,7 +2174,7 @@ if ($allowAll) {
if ($allowMessages === true) {
// Messages
echo Display::page_subheader2(get_lang('Messages'));
echo MessageManager::getMessagesAboutUserToString($user_info);
echo MessageManager::getMessagesAboutUserToString($user_info, 'my_space');
echo Display::url(
get_lang('NewMessage'),
'javascript: void(0);',

Loading…
Cancel
Save