function wiki_print_recent_activity($course, $isteacher, $timestart) { /// Given a course and a time, this module should find recent activity /// that has occurred in wiki activities and print it out. /// Return true if there was output, or false is there was none. global $CFG; $sql = "SELECT l.*, cm.instance FROM {$CFG->prefix}log l \n INNER JOIN {$CFG->prefix}course_modules cm ON l.cmid = cm.id \n WHERE l.time > '{$timestart}' AND l.course = {$course->id} \n AND l.module = 'wiki' AND action LIKE 'edit%'\n ORDER BY l.time ASC"; if (!($logs = get_records_sql($sql))) { return false; } $modinfo = get_fast_modinfo($course); $wikis = array(); foreach ($logs as $log) { $cm = $modinfo->instances['wiki'][$log->instance]; if (!$cm->uservisible) { continue; } /// Process log->url and rebuild it here to properly clean the pagename - MDL-15896 $extractedpage = preg_replace('/^.*&page=/', '', $log->url); $log->url = preg_replace('/page=.*$/', 'page=' . urlencode($extractedpage), $log->url); $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); } if (!$wikis) { return false; } print_headline(get_string('updatedwikipages', 'wiki') . ':', 3); foreach ($wikis as $wiki) { print_recent_activity_note($wiki->time, $wiki, $wiki->pagename, $CFG->wwwroot . '/mod/wiki/' . $wiki->url); } return false; }
function wiki_print_recent_activity($course, $isteacher, $timestart) { /// Given a course and a time, this module should find recent activity /// that has occurred in wiki activities and print it out. /// 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 = new Object(); $tempmod->course = $log->course; $tempmod->id = $log->cmid; //Obtain the visible property from the instance $modvisible = instance_is_visible($log->module, $tempmod); /// Process log->url and rebuild it here to properly clean the pagename - MDL-15896 $extractedpage = preg_replace('/^.*&page=/', '', $log->url); $log->url = preg_replace('/page=.*$/', 'page=' . urlencode($extractedpage), $log->url); //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); } } if ($wikis) { $content = true; print_headline(get_string('updatedwikipages', 'wiki') . ':', 3); foreach ($wikis as $wiki) { print_recent_activity_note($wiki->time, $wiki, $wiki->pagename, $CFG->wwwroot . '/mod/wiki/' . $wiki->url); } } return true; // True if anything was printed, otherwise false }
function wiki_print_recent_activity($course, $isteacher, $timestart) { /// Given a course and a time, this module should find recent activity /// that has occurred in wiki activities and print it out. /// Return true if there was output, or false is there was none. global $CFG; $sql = "SELECT l.*, cm.instance FROM {$CFG->prefix}log l \n INNER JOIN {$CFG->prefix}course_modules cm ON l.cmid = cm.id \n WHERE l.time > '{$timestart}' AND l.course = {$course->id} \n AND l.module = 'wiki' AND action LIKE 'edit%'\n ORDER BY l.time ASC"; if (!($logs = get_records_sql($sql))) { return false; } foreach ($logs as $log) { //Create a temp valid module structure (course,id) $tempmod = new Object(); $tempmod->course = $log->course; $tempmod->id = $log->instance; //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); } } if (isset($wikis)) { $content = true; print_headline(get_string('updatedwikipages', 'wiki') . ':', 3); foreach ($wikis as $wiki) { print_recent_activity_note($wiki->time, $wiki, $wiki->pagename, $CFG->wwwroot . '/mod/wiki/' . $wiki->url); } } return true; // True if anything was printed, otherwise false }
/** * Given a course and a time, this module should find recent activity * that has occurred in wiki activities and print it out. * Return true if there was output, or false is there was none. * * @global stdClass * @global object * @param object $course * @param bool $isteacher * @param int $timestart * @return bool */ function wiki_print_recent_activity($course, $isteacher, $timestart) { global $CFG, $DB, $OUTPUT; $sql = "SELECT l.*, cm.instance\n FROM {log} l JOIN {course_modules} cm ON l.cmid = cm.id \n WHERE l.time > ? AND l.course = ? \n AND l.module = 'wiki' AND action LIKE 'edit%'\n ORDER BY l.time ASC"; if (!($logs = $DB->get_records_sql($sql, array($timestart, $course->id)))) { return false; } $modinfo = get_fast_modinfo($course); $wikis = array(); foreach ($logs as $log) { $cm = $modinfo->instances['wiki'][$log->instance]; if (!$cm->uservisible) { continue; } /// Process log->url and rebuild it here to properly clean the pagename - MDL-15896 $extractedpage = preg_replace('/^.*&page=/', '', $log->url); $log->url = preg_replace('/page=.*$/', 'page=' . urlencode($extractedpage), $log->url); $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); } if (!$wikis) { return false; } echo $OUTPUT->heading(get_string("updatedwikipages", 'wiki') . ':', 3); foreach ($wikis as $wiki) { print_recent_activity_note($wiki->time, $wiki, $wiki->pagename, $CFG->wwwroot . '/mod/wiki/' . $wiki->url); } return false; }