Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-27286 recent files repo - fix for oracle and cleanup

  • Loading branch information...
commit ad08c5632ef49c47021ad269a5dfaf2bdea9619e 1 parent 6911fa1
@stronk7 stronk7 authored
Showing with 16 additions and 6 deletions.
  1. +16 −6 repository/recent/lib.php
View
22 repository/recent/lib.php
@@ -56,13 +56,23 @@ public function print_login() {
private function get_recent_files($limitfrom = 0, $limit = DEFAULT_RECENT_FILES_NUM) {
// XXX: get current itemid
global $USER, $DB, $itemid;
- $sql = 'SELECT * FROM {files} files1
- JOIN (SELECT contenthash, filename, MAX(id) AS id
- FROM {files}
- WHERE userid = ? AND filename != ? AND ((filearea = ? AND itemid = ?) OR filearea != ?)
- GROUP BY contenthash, filename) files2 ON files1.id = files2.id
+ $sql = 'SELECT files1.*
+ FROM {files} files1
+ JOIN (
+ SELECT contenthash, filename, MAX(id) AS id
+ FROM {files}
+ WHERE userid = :userid
+ AND filename != :filename
+ AND ((filearea = :filearea1 AND itemid = :itemid) OR filearea != :filearea2)
+ GROUP BY contenthash, filename
+ ) files2 ON files1.id = files2.id
ORDER BY files1.timemodified DESC';
- $params = array('userid'=>$USER->id, 'filename'=>'.', 'filearea'=>'draft', 'itemid'=>$itemid, 'draft');
+ $params = array(
+ 'userid' => $USER->id,
+ 'filename' => '.',
+ 'filearea1' => 'draft',
+ 'itemid' => $itemid,
+ 'filearea2' => 'draft');
$rs = $DB->get_recordset_sql($sql, $params, $limitfrom, $limit);
$result = array();
foreach ($rs as $file_record) {
Please sign in to comment.
Something went wrong with that request. Please try again.