Skip to content

Commit

Permalink
WIP: add fullname if note is added or updated on a board after adding…
Browse files Browse the repository at this point in the history
… or updating in an other browser by an other user
  • Loading branch information
andreasschenkel committed Dec 14, 2023
1 parent 5bb6f2c commit cc0c1ba
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion amd/build/board.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion amd/build/board.min.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion amd/src/board.js
Original file line number Diff line number Diff line change
Expand Up @@ -1171,12 +1171,14 @@ export default function(settings) {

var data = JSON.parse(item.content);
if (item.action == 'add_note') {
// This is called on a board if someone else has added a note in a different browser.
let sortorder = sortby == 3 ? data.sortorder : data.timecreated;
addNote(data.columnid, data.id, data.heading, data.content, data.attachment,
{id: item.userid}, sortorder, data.rating);
{id: item.userid , fullname: item.userid + " " + item.fullname}, sortorder, data.rating);
updateNoteAria(data.id);
sortNotes($('.board_column[data-ident=' + data.columnid + '] .board_column_content'));
} else if (item.action == 'update_note') {
// This is called on a board if someone else has updated a note in a different browser.
let note = getNote(data.id),
formModal = editModal,
historyData = data;
Expand Down
18 changes: 15 additions & 3 deletions classes/board.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class board {
/** @var int Value for the singleusermode setting in public mode*/
const SINGLEUSER_PUBLIC = 2;

static $alluserids = [];
static $alluserids = [];

/**
* Retrieves the course module for the board
Expand Down Expand Up @@ -440,8 +440,20 @@ public static function board_history(int $boardid, int $ownerid, int $since): ar
$params['ownerid'] = $ownerid;
}
}

return $DB->get_records_select('board_history', $condition, $params);
$history_items = $DB->get_records_select('board_history', $condition, $params);
// Add fullname to each item in history if author should be displayed.
$config = get_config('mod_board');
$allowshowauthorofnoteonboard = isset($config->allowshowauthorofnoteonboard) ? $config->allowshowauthorofnoteonboard : false;
if ($allowshowauthorofnoteonboard && self::board_show_authorofnote($board->id)) {
foreach ($history_items as $history_item) {
if (!self::$alluserids[$history_item->userid]) {
$user = core_user::get_user($history_item->userid);
self::$alluserids[$history_item->userid] = fullname($user);
}
$history_item->fullname =self::$alluserids[$history_item->userid];
}
}
return $history_items;
}

/**
Expand Down
1 change: 1 addition & 0 deletions external.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public static function board_history_returns(): external_multiple_structure {
'boardid' => new external_value(PARAM_INT, 'boardid'),
'action' => new external_value(PARAM_TEXT, 'action'),
'userid' => new external_value(PARAM_INT, 'userid'),
'fullname' => new external_value(PARAM_TEXT, 'user fullname', VALUE_DEFAULT, ''),
'content' => new external_value(PARAM_RAW, 'content')
)
)
Expand Down

0 comments on commit cc0c1ba

Please sign in to comment.