Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

deleted forum_print_recent_instance_activity and forum_get_recent_pos…

…ts (only used in course/recent.php)

added  forum_get_recent_mod_activity and forum_print_recent_mod_activity for course/recent.php
  • Loading branch information...
commit a57a7794ea87723595479bc82c12f17dea4d7d60 1 parent 4581271
authored

Showing 1 changed file with 106 additions and 62 deletions. Show diff stats Hide diff stats

  1. 168  mod/forum/lib.php
168  mod/forum/lib.php
@@ -460,40 +460,6 @@ function forum_print_recent_activity($course, $isteacher, $timestart) {
460 460
 }
461 461
 
462 462
 
463  
-function forum_print_recent_instance_activity($forum, $timestart, $user="") {
464  
-
465  
-    global $CFG, $THEME;
466  
-
467  
-    if (!$posts = forum_get_recent_posts($timestart, $forum->id, $user)) {
468  
-        return false;
469  
-    }
470  
-
471  
-    foreach ($posts as $post) {
472  
-        echo '<table border="0" cellpadding="3" cellspacing="0" class="forumpost">';
473  
-        echo "<tr><td bgcolor=\"$THEME->cellcontent2\" class=\"forumpostpicture\" width=\"35\" valign=\"top\">";
474  
-        print_user_picture($post->userid, $forum->course, $post->picture);
475  
-        echo "</td>";
476  
-
477  
-        if ($post->parent) {
478  
-            echo "<td nowrap bgcolor=\"$THEME->cellheading\" class=\"forumpostheader\" width=\"100%\">";
479  
-        } else {
480  
-            echo "<td nowrap bgcolor=\"$THEME->cellheading2\" class=\"forumpostheadertopic\" width=\"100%\">";
481  
-        }
482  
-        echo "<p>";
483  
-        echo "<font size=3>";
484  
-        echo "<a href=\"$CFG->wwwroot/mod/forum/discuss.php?d=$post->discussion#$post->id\">";
485  
-        echo $post->subject;
486  
-        echo "</a></font><br>";
487  
-        echo "<font size=2>";
488  
-        $fullname = fullname($post);
489  
-        $by->name = "<a href=\"$CFG->wwwroot/user/view.php?id=$post->userid&course=$post->course\">$fullname</a>";
490  
-        $by->date = userdate($post->modified);
491  
-        print_string("bynameondate", "forum", $by);
492  
-        echo "</font></p></td></tr></table>";
493  
-    }
494  
-}
495  
-
496  
-
497 463
 function forum_grades($forumid) {
498 464
 /// Must return an array of grades, indexed by user, and a max grade.
499 465
 
@@ -959,34 +925,6 @@ function forum_subscribed_users($course, $forum) {
959 925
                           ORDER BY u.email ASC");
960 926
 }
961 927
 
962  
-function forum_get_recent_posts($sincetime, $forum="0", $user="") {
963  
-// Returns all forum posts since a given time.  If forum is specified then 
964  
-// this restricts the results
965  
-
966  
-    global $CFG;
967  
-
968  
-    if ($forum) {
969  
-        $forumselect = " AND d.forum = '$forum'";
970  
-    } else {
971  
-        $forumselect = "";
972  
-    }
973  
-    if ($user) {
974  
-        $userselect = " AND u.id = '$user'";
975  
-    } else {
976  
-        $userselect = "";
977  
-    }
978  
-
979  
-    return get_records_sql("SELECT p.*, d.name, u.firstname, u.lastname, u.picture, d.course
980  
-                              FROM {$CFG->prefix}forum_posts p, 
981  
-                                   {$CFG->prefix}forum_discussions d,
982  
-                                   {$CFG->prefix}user u
983  
-                             WHERE p.modified > '$sincetime' $forumselect
984  
-                               AND p.userid = u.id $userselect
985  
-                               AND p.discussion = d.id
986  
-                             ORDER BY p.modified ASC");
987  
-}
988  
-
989  
-
990 928
 /// OTHER FUNCTIONS ///////////////////////////////////////////////////////////
991 929
 
992 930
 
@@ -2333,4 +2271,110 @@ function forum_print_posts_nested($parent, $course, $ratings, $reply) {
2333 2271
     return $ratingsmenuused;
2334 2272
 }
2335 2273
 
  2274
+function forum_get_recent_mod_activity(&$activities, &$index, $sincetime, $courseid, $forum="0", $user="", $groupid="") {
  2275
+// Returns all forum posts since a given time.  If forum is specified then
  2276
+// this restricts the results
  2277
+
  2278
+    global $CFG;
  2279
+
  2280
+    if ($forum) {
  2281
+        $forumselect = " AND cm.id = '$forum'";
  2282
+    } else {
  2283
+        $forumselect = "";
  2284
+    }
  2285
+
  2286
+    if ($user) {
  2287
+        $userselect = " AND u.id = '$user'";
  2288
+    } else {
  2289
+        $userselect = "";
  2290
+    }
  2291
+
  2292
+    if ($groupid) {
  2293
+        $groupselect = " AND d.groupid = '$groupid'";
  2294
+    } else {
  2295
+        $groupselect = "";
  2296
+    }
  2297
+
  2298
+    $posts = get_records_sql("SELECT p.*, d.name, u.firstname, u.lastname,
  2299
+                                     u.picture, d.groupid, cm.instance, f.name, cm.section
  2300
+                               FROM {$CFG->prefix}forum_posts p,
  2301
+                                    {$CFG->prefix}forum_discussions d,
  2302
+                                    {$CFG->prefix}user u,
  2303
+                                    {$CFG->prefix}course_modules cm,
  2304
+                                    {$CFG->prefix}forum f
  2305
+                              WHERE p.modified > '$sincetime' $forumselect
  2306
+                                AND p.userid = u.id $userselect
  2307
+                                AND d.course = '$courseid'
  2308
+                                AND p.discussion = d.id $groupselect
  2309
+                                AND cm.instance = f.id
  2310
+                                AND cm.course = d.course
  2311
+                                AND cm.course = f.course
  2312
+                                AND f.id = d.forum
  2313
+                              ORDER BY d.id");
  2314
+
  2315
+  if (empty($posts))
  2316
+    return;
  2317
+
  2318
+  foreach ($posts as $post) {
  2319
+    $tmpactivity->type = "forum";
  2320
+    $tmpactivity->defaultindex = $index;
  2321
+    $tmpactivity->instance = $post->instance;
  2322
+    $tmpactivity->name = $post->name;
  2323
+    $tmpactivity->section = $post->section;
  2324
+
  2325
+    $tmpactivity->content->id = $post->id;
  2326
+    $tmpactivity->content->discussion = $post->discussion;
  2327
+    $tmpactivity->content->subject = $post->subject;
  2328
+    $tmpactivity->content->parent = $post->parent;
  2329
+
  2330
+    $tmpactivity->user->userid = $post->userid;
  2331
+    $tmpactivity->user->fullname = fullname($post);
  2332
+    $tmpactivity->user->picture = $post->picture;
  2333
+
  2334
+    $tmpactivity->timestamp = $post->modified;
  2335
+    $activities[] = $tmpactivity;
  2336
+
  2337
+    $index++;
  2338
+  }
  2339
+
  2340
+  return;
  2341
+}
  2342
+
  2343
+function forum_print_recent_mod_activity($activity, $course, $detail=false) {
  2344
+
  2345
+    global $CFG;
  2346
+
  2347
+    echo '<table border="0" cellpadding="3" cellspacing="0">';
  2348
+
  2349
+    if ($activity->content->parent) {
  2350
+        $openformat = "<font size=\"2\"><i>";
  2351
+        $closeformat = "</i></font>";
  2352
+    } else {
  2353
+        $openformat = "<b>";
  2354
+        $closeformat = "</b>";
  2355
+    }
  2356
+
  2357
+    echo "<tr><td bgcolor=\"$THEME->cellcontent2\" class=\"forumpostpicture\" width=\"35\" valign=\"top\">";
  2358
+    print_user_picture($activity->user->userid, $course, $activity->user->picture);
  2359
+    echo "</td><td>$openformat";
  2360
+
  2361
+    if ($detail) {
  2362
+        echo "<img src=\"$CFG->modpixpath/$activity->type/icon.gif\" ".
  2363
+             "height=16 width=16 alt=\"$activity->name\">  ";
  2364
+    }
  2365
+    echo "<a href=\"$CFG->wwwroot/mod/forum/discuss.php?d=" . $activity->content->discussion
  2366
+         . "#" . $activity->content->id . "\">";
  2367
+
  2368
+    echo $activity->content->subject;
  2369
+    echo "</a>$closeformat";
  2370
+
  2371
+    echo "<br><font size=\"2\">";
  2372
+    echo "<a href=\"$CFG->wwwroot/user/view.php?id=" . $activity->user->userid . "&course=" . "$course\">"
  2373
+         . $activity->user->fullname . "</a>";
  2374
+    echo " - " . userdate($activity->timestamp) . "</font></td></tr>";
  2375
+    echo "</table>";
  2376
+
  2377
+    return;
  2378
+}
  2379
+
2336 2380
 ?>

0 notes on commit a57a779

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