Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-25674 forum must send full user record when setting up different …

…session user in cron
  • Loading branch information...
commit c35ae136919153f7b12df181e4a281ab7e200b9f 1 parent 5d6ab05
Petr Škoda authored December 16, 2010 stronk7 committed December 20, 2010

Showing 1 changed file with 26 additions and 21 deletions. Show diff stats Hide diff stats

  1. 47  mod/forum/lib.php
47  mod/forum/lib.php
@@ -461,8 +461,9 @@ function forum_cron() {
461 461
             // caching subscribed users of each forum
462 462
             if (!isset($subscribedusers[$forumid])) {
463 463
                 $modcontext = get_context_instance(CONTEXT_MODULE, $coursemodules[$forumid]->id);
464  
-                if ($subusers = forum_subscribed_users($courses[$courseid], $forums[$forumid], 0, $modcontext)) {
  464
+                if ($subusers = forum_subscribed_users($courses[$courseid], $forums[$forumid], 0, $modcontext, "u.*")) {
465 465
                     foreach ($subusers as $postuser) {
  466
+                        unset($postuser->description); // not necessary
466 467
                         // this user is subscribed to this forum
467 468
                         $subscribedusers[$forumid][$postuser->id] = $postuser->id;
468 469
                         // this user is a user we have to process later
@@ -530,6 +531,7 @@ function forum_cron() {
530 531
                 if (array_key_exists($post->userid, $users)) { // we might know him/her already
531 532
                     $userfrom = $users[$post->userid];
532 533
                 } else if ($userfrom = $DB->get_record('user', array('id' => $post->userid))) {
  534
+                    unset($userfrom->description); // not necessary
533 535
                     $users[$userfrom->id] = $userfrom; // fetch only once, we can add it to user list, it will be skipped anyway
534 536
                 } else {
535 537
                     mtrace('Could not find user '.$post->userid);
@@ -2796,9 +2798,10 @@ function forum_get_potential_subscribers($forumcontext, $groupid, $fields, $sort
2796 2798
  * @param forum $forum the forum
2797 2799
  * @param integer $groupid group id, or 0 for all.
2798 2800
  * @param object $context the forum context, to save re-fetching it where possible.
  2801
+ * @param string $fields requested user fields (with "u." table prefix)
2799 2802
  * @return array list of users.
2800 2803
  */
2801  
-function forum_subscribed_users($course, $forum, $groupid=0, $context = NULL) {
  2804
+function forum_subscribed_users($course, $forum, $groupid=0, $context = null, $fields = null) {
2802 2805
     global $CFG, $DB;
2803 2806
     $params = array($forum->id);
2804 2807
 
@@ -2811,25 +2814,27 @@ function forum_subscribed_users($course, $forum, $groupid=0, $context = NULL) {
2811 2814
         $groupselect = '';
2812 2815
     }
2813 2816
 
2814  
-    $fields ="u.id,
2815  
-              u.username,
2816  
-              u.firstname,
2817  
-              u.lastname,
2818  
-              u.maildisplay,
2819  
-              u.mailformat,
2820  
-              u.maildigest,
2821  
-              u.imagealt,
2822  
-              u.email,
2823  
-              u.city,
2824  
-              u.country,
2825  
-              u.lastaccess,
2826  
-              u.lastlogin,
2827  
-              u.picture,
2828  
-              u.timezone,
2829  
-              u.theme,
2830  
-              u.lang,
2831  
-              u.trackforums,
2832  
-              u.mnethostid";
  2817
+    if (empty($fields)) {
  2818
+        $fields ="u.id,
  2819
+                  u.username,
  2820
+                  u.firstname,
  2821
+                  u.lastname,
  2822
+                  u.maildisplay,
  2823
+                  u.mailformat,
  2824
+                  u.maildigest,
  2825
+                  u.imagealt,
  2826
+                  u.email,
  2827
+                  u.city,
  2828
+                  u.country,
  2829
+                  u.lastaccess,
  2830
+                  u.lastlogin,
  2831
+                  u.picture,
  2832
+                  u.timezone,
  2833
+                  u.theme,
  2834
+                  u.lang,
  2835
+                  u.trackforums,
  2836
+                  u.mnethostid";
  2837
+    }
2833 2838
 
2834 2839
     if (forum_is_forcesubscribed($forum)) {
2835 2840
         if (empty($context)) {

0 notes on commit c35ae13

Please sign in to comment.
Something went wrong with that request. Please try again.