Permalink
Browse files

Added the 'get_recent_activity' function (see bug 1897).

  • Loading branch information...
1 parent 8a92247 commit 1fb5d4b081761d005883b20a0468a3308f4b87fb mchurch committed Mar 5, 2005
Showing with 50 additions and 7 deletions.
  1. +5 −4 mod/wiki/ewikimoodlelib.php
  2. +42 −1 mod/wiki/lib.php
  3. +3 −2 mod/wiki/view.php
@@ -48,10 +48,11 @@ function ewiki_database_moodle($action, &$args, $sw1, $sw2) {
$select="(pagename=$id) AND wiki=".$wiki_entry->id." $version ";
$sort="version DESC";
- $result_arr=get_records_select(EWIKI_DB_TABLE_NAME, $select,$sort,"*",0,1);
- //Iterate to get the first (and unique!)
- foreach ($result_arr as $obj) {
- $result_obj = $obj;
+ if ($result_arr = get_records_select(EWIKI_DB_TABLE_NAME, $select,$sort,"*",0,1)) {
+ //Iterate to get the first (and unique!)
+ foreach ($result_arr as $obj) {
+ $result_obj = $obj;
+ }
}
if($result_obj) {
//Convert to array
View
@@ -143,8 +143,49 @@ function wiki_print_recent_activity($course, $isteacher, $timestart) {
/// Return true if there was output, or false is there was none.
global $CFG;
+ if (!$logs = get_records_select("log", "time > '$timestart' AND ".
+ "course = '$course->id' AND ".
+ "module = 'wiki' AND ".
+ "action LIKE 'edit%' ", "time ASC")){
+ return false;
+ }
+
+ foreach ($logs as $log) {
+ //Create a temp valid module structure (course,id)
+ $tempmod->course = $log->course;
+ $tempmod->id = $log->cmid;
+ //Obtain the visible property from the instance
+ $modvisible = instance_is_visible($log->module,$tempmod);
+
+ //Only if the mod is visible
+ if ($modvisible) {
+ $wikis[$log->info] = wiki_log_info($log);
+ $wikis[$log->info]->pagename = $log->info;
+ $wikis[$log->info]->time = $log->time;
+ $wikis[$log->info]->url = str_replace('&', '&', $log->url);
+ }
+ }
- return false; // True if anything was printed, otherwise false
+ if ($wikis) {
+ $strftimerecent = get_string("strftimerecent");
+ $content = true;
+ print_headline('Updated wiki page'.":");
+ foreach ($wikis as $wiki) {
+ $date = userdate($wiki->time, $strftimerecent);
+ echo $date.' - '.fullname($wiki)."<br />";
+ echo '"<a href="'.$CFG->wwwroot.'/mod/wiki/'.$wiki->url.'">';
+ echo $wiki->pagename;
+ echo '</a>"<br />';
+ }
+ }
+ return true; // True if anything was printed, otherwise false
+}
+
+function wiki_log_info($log) {
+ global $CFG;
+ return get_record_sql("SELECT u.firstname, u.lastname
+ FROM {$CFG->prefix}user u
+ WHERE u.id = '$log->userid'");
}
function wiki_cron () {
View
@@ -219,8 +219,9 @@
}
/// Moodle Log
- add_to_log($course->id, "wiki", $ewiki_action, addslashes("view.php?id=$cm->id&amp;groupid=$groupid&amp;userid=$userid&amp;page=$page"), $wiki->name." ".$ewiki_title);
-
+ add_to_log($course->id, "wiki", $ewiki_action,
+ addslashes("view.php?id=$cm->id&amp;groupid=$groupid&amp;userid=$userid&amp;page=$page"),
+ $wiki->name.": ".$ewiki_title, $cm->id, $userid);
/// Print the page header

0 comments on commit 1fb5d4b

Please sign in to comment.