Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merged branch 'MDL-26960' of git://git.luns.net.uk/moodle with changes

  • Loading branch information...
commit 0723dcab40294ee636ee6940ab394f4e70225813 2 parents aa8ec18 + a8134ff
@samhemelryk samhemelryk authored
Showing with 19 additions and 6 deletions.
  1. +16 −1 lib/messagelib.php
  2. +3 −5 message/edit.php
View
17 lib/messagelib.php
@@ -354,10 +354,25 @@ function message_set_default_message_preference($component, $messagename, $filep
/**
* Returns the active providers for the current user, based on capability
+ *
+ * This function has been deprecated please use {@see message_get_providers_for_user()} instead.
*
+ * @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 user specified, 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);
@@ -367,7 +382,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
}
}
View
8 message/edit.php
@@ -91,13 +91,14 @@
$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();
foreach ($providers as $provider) {
$componentproviderbase = $provider->component.'_'.$provider->name;
foreach (array('loggedin', 'loggedoff') as $state) {
@@ -142,7 +143,6 @@
$preferences->userdefaultemail = $user->email;//may be displayed by the email processor
/// Get providers preferences
-$providers = message_get_my_providers();
foreach ($providers as $provider) {
foreach (array('loggedin', 'loggedoff') as $state) {
$linepref = get_user_preferences('message_provider_'.$provider->component.'_'.$provider->name.'_'.$state, '', $user->id);
@@ -182,8 +182,6 @@
// Grab the renderer
$renderer = $PAGE->get_renderer('core', 'message');
-// Fetch message providers
-$providers = message_get_my_providers();
// Fetch default (site) preferences
$defaultpreferences = get_message_output_default_preferences();
Please sign in to comment.
Something went wrong with that request. Please try again.