MDL-64093 core: added new 'messagingdefaultpressenter' setting

This commit is contained in:
Mark Nelson 2019-02-05 13:03:07 +08:00
parent 694513e2fe
commit 46014b8343
6 changed files with 22 additions and 4 deletions

View File

@ -21,6 +21,12 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
0)
);
$optionalsubsystems->add(new admin_setting_configcheckbox('messagingdefaultpressenter',
new lang_string('messagingdefaultpressenter', 'admin'),
new lang_string('configmessagingdefaultpressenter', 'admin'),
1)
);
$options = array(
DAYSECS => new lang_string('secondstotime86400'),
WEEKSECS => new lang_string('secondstotime604800'),

View File

@ -279,6 +279,7 @@ $string['configmaxeditingtime'] = 'This specifies the amount of time people have
$string['configmaxevents'] = 'Events to Lookahead';
$string['configmessaging'] = 'If enabled, users can send messages to other users on the site.';
$string['configmessagingallowemailoverride'] = 'Allow users to have email message notifications sent to an email address other than the email address in their profile';
$string['configmessagingdefaultpressenter'] = 'Whether \'Use enter to send\' is enabled by default in users\' messaging settings.';
$string['configmessagingdeletereadnotificationsdelay'] = 'Read notifications can be deleted to save space. How long after a notification is read can it be deleted?';
$string['configmessagingdeleteallnotificationsdelay'] = 'Read and unread notifications can be deleted to save space. How long after a notification is created can it be deleted?';
$string['configmessagingallusers'] = 'If enabled, users can view the list of all users on the site when selecting someone to message, and their message preferences include the option to accept messages from anyone on the site. If disabled, users can only view the list of users in their courses, and they have just two options in message preferences - to accept messages from their contacts only, or their contacts and anyone in their courses.';
@ -772,6 +773,7 @@ $string['mediapluginyoutube'] = 'Enable YouTube links filter';
$string['messaging'] = 'Enable messaging system';
$string['messagingallowemailoverride'] = 'Notification email override';
$string['messagingallusers'] = 'Allow site-wide messaging';
$string['messagingdefaultpressenter'] = 'Use enter to send enabled by default';
$string['messagingdeletereadnotificationsdelay'] = 'Delete read notifications';
$string['messagingdeleteallnotificationsdelay'] = 'Delete all notifications';
$string['minpassworddigits'] = 'Digits';

View File

@ -2719,5 +2719,13 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2019011801.03);
}
if ($oldversion < 2019020100.01) {
// Default 'off' for existing sites as this is the behaviour they had earlier.
set_config('messagingdefaultpressenter', false);
// Main savepoint reached.
upgrade_main_savepoint(true, 2019020100.01);
}
return true;
}

View File

@ -4160,7 +4160,7 @@ class core_message_external extends external_api {
* @since 3.2
*/
public static function get_user_message_preferences($userid = 0) {
global $PAGE;
global $CFG, $PAGE;
$params = self::validate_parameters(
self::get_user_message_preferences_parameters(),
@ -4189,11 +4189,13 @@ class core_message_external extends external_api {
$renderer = $PAGE->get_renderer('core_message');
$entertosend = get_user_preferences('message_entertosend', $CFG->messagingdefaultpressenter, $user);
$result = array(
'warnings' => array(),
'preferences' => $notificationlistoutput->export_for_template($renderer),
'blocknoncontacts' => \core_message\api::get_user_privacy_messaging_preference($user->id),
'entertosend' => get_user_preferences('message_entertosend', false, $user)
'entertosend' => $entertosend
);
return $result;
}

View File

@ -855,7 +855,7 @@ function core_message_standard_after_main_region_html() {
}
// Enter to send.
$entertosend = get_user_preferences('message_entertosend', false, $USER);
$entertosend = get_user_preferences('message_entertosend', $CFG->messagingdefaultpressenter, $USER);
return $renderer->render_from_template('core_message/message_drawer', [
'contactrequestcount' => $requestcount,

View File

@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2019020800.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2019020800.01; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.