chamilo /
chamilo-lms
| 1 | <?php |
||
| 2 | /* For licensing terms, see /license.txt */ |
||
| 3 | |||
| 4 | require_once 'dropbox_init.inc.php'; |
||
| 5 | |||
| 6 | $file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE); |
||
| 7 | $person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON); |
||
| 8 | $course_id = api_get_course_int_id(); |
||
| 9 | $user_id = api_get_user_id(); |
||
| 10 | $session_id = api_get_session_id(); |
||
| 11 | |||
| 12 | if (empty($course_id)) { |
||
| 13 | api_not_allowed(); |
||
| 14 | } |
||
| 15 | |||
| 16 | if (!api_is_allowed_to_session_edit(false, true)) { |
||
| 17 | api_not_allowed(); |
||
| 18 | } |
||
| 19 | |||
| 20 | echo Display::page_subheader(get_lang('RecoverDropboxFiles')); |
||
| 21 | if (isset($_GET['recover_id']) && !empty($_GET['recover_id'])) { |
||
| 22 | $recover_id = intval($_GET['recover_id']); |
||
| 23 | |||
| 24 | $sql = "INSERT INTO $person_tbl VALUES('$course_id', $recover_id, $user_id)"; |
||
| 25 | $result = Database::query($sql); |
||
| 26 | if ($result) { |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 27 | echo Display::return_message(get_lang('Recovered'), 'confirm'); |
||
| 28 | } |
||
| 29 | } |
||
| 30 | |||
| 31 | $sql = "SELECT * FROM $file_tbl |
||
| 32 | WHERE c_id = $course_id AND session_id = $session_id"; |
||
| 33 | $result = Database::query($sql); |
||
| 34 | |||
| 35 | if (Database::num_rows($result)) { |
||
| 36 | $files = Database::store_result($result); |
||
| 37 | $rows = []; |
||
| 38 | foreach ($files as $file) { |
||
| 39 | //Check if I have this file: |
||
| 40 | $sql = "SELECT * FROM $person_tbl |
||
| 41 | WHERE c_id = $course_id AND user_id = $user_id AND file_id = {$file['id']}"; |
||
| 42 | $result_person = Database::query($sql); |
||
| 43 | if (Database::num_rows($result_person) == 0) { |
||
| 44 | $rows[] = [ |
||
| 45 | $file['filename'], |
||
| 46 | api_convert_and_format_date($file['upload_date']), |
||
| 47 | Display::url( |
||
| 48 | get_lang('Recover'), |
||
| 49 | api_get_self().'?recover_id='.$file['id'], |
||
| 50 | ['class' => 'btn btn-default'] |
||
| 51 | ), |
||
| 52 | ]; |
||
| 53 | } |
||
| 54 | } |
||
| 55 | $headers = [ |
||
| 56 | get_lang('FileName'), |
||
| 57 | get_lang('UploadedDate'), |
||
| 58 | get_lang('Action'), |
||
| 59 | ]; |
||
| 60 | echo Display::table($headers, $rows); |
||
| 61 | } |
||
| 62 | Display::display_footer(); |
||
| 63 |