diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php index b5e68c8673672..3f3031d7e65dc 100644 --- a/mod/assignment/lib.php +++ b/mod/assignment/lib.php @@ -189,20 +189,23 @@ function assignment_print_recent_activity(&$logs, $isteacher=false) { $content = false; $assignments = NULL; - foreach ($logs as $log) { - if ($log->module == "assignment" and $log->action == "upload") { - //Create a temp valid module structure (course,id) - $tempmod->course = $log->course; - $tempmod->id = $log->info; - //Obtain the visible property from the instance - $modvisible = instance_is_visible($log->module,$tempmod); - - //Only if the mod is visible - if ($modvisible) { - $assignments[$log->info] = assignment_log_info($log); - $assignments[$log->info]->time = $log->time; - $assignments[$log->info]->url = $log->url; + foreach ($logs as $key => $log) { + if ($log->module == "assignment") { + if ($log->action == "upload") { + //Create a temp valid module structure (course,id) + $tempmod->course = $log->course; + $tempmod->id = $log->info; + //Obtain the visible property from the instance + $modvisible = instance_is_visible($log->module,$tempmod); + + //Only if the mod is visible + if ($modvisible) { + $assignments[$log->info] = assignment_log_info($log); + $assignments[$log->info]->time = $log->time; + $assignments[$log->info]->url = $log->url; + } } + unset($logs[$key]); // No longer need this record } } diff --git a/mod/forum/lib.php b/mod/forum/lib.php index f04de9bd03b81..72ada4c436105 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -304,46 +304,49 @@ function forum_print_recent_activity(&$logs, $isteacher=false) { $strftimerecent = get_string("strftimerecent"); - foreach ($logs as $log) { + foreach ($logs as $key => $log) { if ($log->module == "forum") { - //Get post info, I'll need it later - $post = forum_get_post_from_log($log); - - //Create a temp valid module structure (course,id) - $tempmod->course = $log->course; - $tempmod->id = $post->forum; - //Obtain the visible property from the instance - $modvisible = instance_is_visible($log->module,$tempmod); - - //Only if the mod is visible - if ($modvisible) { - if ($post) { - $teacheronly = ""; - if ($forum = get_record("forum", "id", $post->forum) ) { - if ($forum->type == "teacher") { - if ($isteacher) { - $teacheronly = "class=\"teacheronly\""; - } else { - continue; + if ($log->action == "add post" or $log->action == "add discussion") { + //Get post info, I'll need it later + $post = forum_get_post_from_log($log); + + //Create a temp valid module structure (course,id) + $tempmod->course = $log->course; + $tempmod->id = $post->forum; + //Obtain the visible property from the instance + $modvisible = instance_is_visible($log->module,$tempmod); + + //Only if the mod is visible + if ($modvisible) { + if ($post) { + $teacheronly = ""; + if ($forum = get_record("forum", "id", $post->forum) ) { + if ($forum->type == "teacher") { + if ($isteacher) { + $teacheronly = "class=\"teacheronly\""; + } else { + continue; + } } } + if (! $heading) { + print_headline(get_string("newforumposts", "forum").":"); + $heading = true; + $content = true; + } + $date = userdate($post->modified, $strftimerecent); + echo "

$date - $post->firstname $post->lastname
"; + echo "\"wwwroot/mod/forum/$log->url\">"; + if ($log->action == "add discussion") { + echo "$post->subject"; + } else { + echo "$post->subject"; + } + echo "\"

"; } - if (! $heading) { - print_headline(get_string("newforumposts", "forum").":"); - $heading = true; - $content = true; - } - $date = userdate($post->modified, $strftimerecent); - echo "

$date - $post->firstname $post->lastname
"; - echo "\"wwwroot/mod/forum/$log->url\">"; - if ($log->action == "add") { - echo "$post->subject"; - } else { - echo "$post->subject"; - } - echo "\"

"; } } + unset($logs[$key]); // No longer need this record } } return $content; diff --git a/mod/journal/lib.php b/mod/journal/lib.php index 0be5d42d71076..f932e27a682b8 100644 --- a/mod/journal/lib.php +++ b/mod/journal/lib.php @@ -125,7 +125,7 @@ function journal_print_recent_activity(&$logs, $isteacher=false) { $content = false; $journals = NULL; - foreach ($logs as $log) { + foreach ($logs as $key => $log) { if ($log->module == "journal") { if ($log->action == "add entry" or $log->action == "update entry") { ///Get journal info. I'll need it later @@ -146,6 +146,7 @@ function journal_print_recent_activity(&$logs, $isteacher=false) { } } } + unset($logs[$key]); // No longer need this record } } diff --git a/mod/survey/lib.php b/mod/survey/lib.php index 83b865288cd67..406d51d2e284f 100644 --- a/mod/survey/lib.php +++ b/mod/survey/lib.php @@ -106,20 +106,23 @@ function survey_print_recent_activity(&$logs, $isteacher=false) { $content = false; $surveys = NULL; - foreach ($logs as $log) { - if ($log->module == "survey" and $log->action == "submit") { - //Create a temp valid module structure (course,id) - $tempmod->course = $log->course; - $tempmod->id = $log->info; - //Obtain the visible property from the instance - $modvisible = instance_is_visible($log->module,$tempmod); - - //Only if the mod is visible - if ($modvisible) { - $surveys[$log->id] = survey_log_info($log); - $surveys[$log->id]->time = $log->time; - $surveys[$log->id]->url = $log->url; + foreach ($logs as $key => $log) { + if ($log->module == "survey") { + if ($log->action == "submit") { + //Create a temp valid module structure (course,id) + $tempmod->course = $log->course; + $tempmod->id = $log->info; + //Obtain the visible property from the instance + $modvisible = instance_is_visible($log->module,$tempmod); + + //Only if the mod is visible + if ($modvisible) { + $surveys[$log->id] = survey_log_info($log); + $surveys[$log->id]->time = $log->time; + $surveys[$log->id]->url = $log->url; + } } + unset($logs[$key]); // No longer need this record } }