Merged branch 'MDL-26960-for-20_STABLE' of git://git.luns.net.uk/moodle with changes
This commit is contained in:
+15
-1
@@ -230,9 +230,23 @@ function message_update_providers($component='moodle') {
|
||||
|
||||
/**
|
||||
* Returns the active providers for the current user, based on capability
|
||||
*
|
||||
* @deprecated since 2.1
|
||||
* @todo Remove in 2.2
|
||||
* @return array of message providers
|
||||
*/
|
||||
function message_get_my_providers() {
|
||||
global $USER;
|
||||
return message_get_providers_for_user($USER->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the active providers for the requested user, based on capability
|
||||
*
|
||||
* @param int $userid id of user
|
||||
* @return array of message providers
|
||||
*/
|
||||
function message_get_providers_for_user($userid) {
|
||||
global $DB;
|
||||
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
@@ -242,7 +256,7 @@ function message_get_my_providers() {
|
||||
// Remove all the providers we aren't allowed to see now
|
||||
foreach ($providers as $providerid => $provider) {
|
||||
if (!empty($provider->capability)) {
|
||||
if (!has_capability($provider->capability, $systemcontext)) {
|
||||
if (!has_capability($provider->capability, $systemcontext, $userid)) {
|
||||
unset($providers[$providerid]); // Not allowed to see this
|
||||
}
|
||||
}
|
||||
|
||||
+3
-5
@@ -90,13 +90,14 @@ if ($user->id == $USER->id) {
|
||||
$PAGE->navigation->extend_for_user($user);
|
||||
}
|
||||
|
||||
// Fetch message providers
|
||||
$providers = message_get_providers_for_user($user->id);
|
||||
|
||||
/// Save new preferences if data was submitted
|
||||
|
||||
if (($form = data_submitted()) && confirm_sesskey()) {
|
||||
$preferences = array();
|
||||
|
||||
/// Set all the preferences for all the message providers
|
||||
$providers = message_get_my_providers();
|
||||
$possiblestates = array('loggedin', 'loggedoff');
|
||||
foreach ( $providers as $providerid => $provider){
|
||||
foreach ($possiblestates as $state){
|
||||
@@ -156,8 +157,6 @@ if (($form = data_submitted()) && confirm_sesskey()) {
|
||||
$preferences = new stdClass();
|
||||
$preferences->userdefaultemail = $user->email;//may be displayed by the email processor
|
||||
|
||||
/// Get providers preferences
|
||||
$providers = message_get_my_providers();
|
||||
foreach ( $providers as $providerid => $provider){
|
||||
foreach (array('loggedin', 'loggedoff') as $state){
|
||||
$linepref = get_user_preferences('message_provider_'.$provider->component.'_'.$provider->name.'_'.$state, '', $user->id);
|
||||
@@ -211,7 +210,6 @@ echo '<form class="mform" method="post" action="'.$PAGE->url.'">';
|
||||
/// Settings table...
|
||||
echo '<fieldset id="providers" class="clearfix">';
|
||||
echo '<legend class="ftoggler">'.get_string('providers_config', 'message').'</legend>';
|
||||
$providers = message_get_my_providers();
|
||||
$processors = $DB->get_records('message_processors', null, 'name DESC');
|
||||
$number_procs = count($processors);
|
||||
echo '<table cellpadding="2"><tr><td> </td>'."\n";
|
||||
|
||||
Reference in New Issue
Block a user