MDL-45171 log reports: fix sql for cross support
[moodle.git] / repository / dropbox / thumbnail.php
blob6a4887e7b80e981382fbf6b658855d75bd7e7d61
1 <?php
3 // This file is part of Moodle - http://moodle.org/
4 //
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 /**
19 * This script displays one thumbnail of the image in current user's dropbox.
20 * If {@link repository_dropbox::send_thumbnail()} can not display image
21 * the default 64x64 filetype icon is returned
23 * @package repository_dropbox
24 * @copyright 2012 Marina Glancy
25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28 require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
29 require_once(dirname(__FILE__).'/lib.php');
31 $repo_id = optional_param('repo_id', 0, PARAM_INT); // Repository ID
32 $contextid = optional_param('ctx_id', SYSCONTEXTID, PARAM_INT); // Context ID
33 $source = optional_param('source', '', PARAM_TEXT); // File path in current user's dropbox
35 if (isloggedin() && $repo_id && $source
36 && ($repo = repository::get_repository_by_id($repo_id, $contextid))
37 && method_exists($repo, 'send_thumbnail')) {
38 // try requesting thumbnail and outputting it. This function exits if thumbnail was retrieved
39 $repo->send_thumbnail($source);
42 // send default icon for the file type
43 $fileicon = file_extension_icon($source, 64);
44 send_file($CFG->dirroot.'/pix/'.$fileicon.'.png', basename($fileicon).'.png');