Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error on draft or new messages #142

Open
wants to merge 1 commit into
base: MOODLE_401_STABLE
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions classes/local/course_enrolment_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@ public function search_users_with_groups(string $search = '', bool $searchanywhe
* @param int $perpage Number of users returned per page.
* @param bool $returnexactcount Return the exact total users using count_record or not.
* @param ?int $contextid Context ID we are in - we might use search on activity level and its group mode can be different from course group mode.
* @return array with two or three elements:
* int totalusers Number users matching the search. (This element only exist if $returnexactcount was set to true)
* array users List of user objects returned by the query.
* boolean moreusers True if there are still more users, otherwise is False.
* @return array An array of users
*/
public function search_users(string $search = '', bool $searchanywhere = false, int $page = 0, int $perpage = 25,
bool $returnexactcount = false, ?int $contextid = null) {
Expand Down
5 changes: 3 additions & 2 deletions formlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ protected function definition() {

$mform->addElement('editor', 'body', get_string('message', 'dialogue'), null, self::editor_options());
$mform->setType('body', PARAM_RAW);
$mform->addRule('body', null, 'required', null, 'client');

// Maxattachments = 0 = No attachments at all.
if (!get_config('dialogue', 'maxattachments') || !empty($PAGE->activityrecord->maxattachments)) {
Expand Down Expand Up @@ -254,14 +255,14 @@ protected function definition() {
'ajax' => 'mod_dialogue/form-user-selector',
'multiple' => true,
'cmid' => $cm->id,
'valuehtmlcallback' => function($value, $USER, $cm) {
'valuehtmlcallback' => function($value) {
global $OUTPUT;
$userfieldsapi = \core_user\fields::for_name();
$allusernames = $userfieldsapi->get_sql('', false, '', '', false)->selects;
$fields = 'id, ' . $allusernames;
$user = \core_user::get_user($value, $fields);
$useroptiondata = [
'fullname' => dialogue_add_user_fullname($user, $USER, $cm),
'fullname' => dialogue_add_user_fullname($user),
];
return $OUTPUT->render_from_template('mod_dialogue/form-user-selector-suggestion', $useroptiondata);
}
Expand Down
14 changes: 11 additions & 3 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -488,16 +488,24 @@ function dialogue_contains_draft_files($draftid) {
}

/**
* Get the name for a user - hiding their full name if the required capability
* is missing.
* Get the name for a user -
* hiding their full name if the required capability is missing.
*
* @param stdClass $userviewed the user whose details are being viewed
* @param stdClass $userviewedby the user who is viewing these details
* @param stdClass $cm the course module object
*
* @return string fullname
*/
function dialogue_add_user_fullname(stdClass $userviewed, stdClass $userviewedby, stdClass $cm) {
function dialogue_add_user_fullname(stdClass $userviewed,
stdClass $userviewedby = null, stdClass $cm = null) {
global $PAGE, $USER;
if (!$userviewedby) {
$userviewedby = $USER;
}
if (!$cm) {
$cm = $PAGE->cm;
}
$capability = 'moodle/site:viewfullnames';
$context = context_module::instance($cm->id);
$hasviewfullnames = has_capability($capability, $context, $userviewedby);
Expand Down
Loading