chamilo /
chamilo-lms
| 1 | <?php |
||||||
| 2 | /** |
||||||
| 3 | * (c) Copyright Ascensio System SIA 2025. |
||||||
| 4 | * |
||||||
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
| 6 | * you may not use this file except in compliance with the License. |
||||||
| 7 | * You may obtain a copy of the License at |
||||||
| 8 | * |
||||||
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
||||||
| 10 | * |
||||||
| 11 | * Unless required by applicable law or agreed to in writing, software |
||||||
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
||||||
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
| 14 | * See the License for the specific language governing permissions and |
||||||
| 15 | * limitations under the License. |
||||||
| 16 | */ |
||||||
| 17 | require_once __DIR__.'/../../main/inc/global.inc.php'; |
||||||
| 18 | |||||||
| 19 | use ChamiloSession as Session; |
||||||
| 20 | |||||||
| 21 | $plugin = OnlyofficePlugin::create(); |
||||||
| 22 | $appSettings = new OnlyofficeAppsettings($plugin); |
||||||
| 23 | $documentManager = new OnlyofficeDocumentManager($appSettings, []); |
||||||
| 24 | |||||||
| 25 | $mapFileFormat = [ |
||||||
| 26 | 'text' => $plugin->get_lang('document'), |
||||||
| 27 | 'spreadsheet' => $plugin->get_lang('spreadsheet'), |
||||||
| 28 | 'presentation' => $plugin->get_lang('presentation'), |
||||||
| 29 | 'formTemplate' => $plugin->get_lang('formTemplate'), |
||||||
| 30 | ]; |
||||||
| 31 | |||||||
| 32 | $userId = !empty($_GET['userId']) ? $_GET['userId'] : 0; |
||||||
| 33 | $sessionId = !empty($_GET['sessionId']) ? $_GET['sessionId'] : 0; |
||||||
| 34 | $courseId = !empty($_GET['courseId']) ? $_GET['courseId'] : 0; |
||||||
| 35 | $groupId = !empty($_GET['groupId']) ? $_GET['groupId'] : 0; |
||||||
| 36 | $folderId = !empty($_GET['folderId']) ? $_GET['folderId'] : 0; |
||||||
| 37 | |||||||
| 38 | $courseInfo = api_get_course_info_by_id($courseId); |
||||||
| 39 | $courseCode = $courseInfo['code']; |
||||||
| 40 | |||||||
| 41 | $isMyDir = false; |
||||||
| 42 | if (!empty($folderId)) { |
||||||
| 43 | $folderInfo = DocumentManager::get_document_data_by_id( |
||||||
|
0 ignored issues
–
show
|
|||||||
| 44 | $folderId, |
||||||
| 45 | $courseCode, |
||||||
| 46 | true, |
||||||
| 47 | $sessionId |
||||||
| 48 | ); |
||||||
| 49 | $isMyDir = DocumentManager::is_my_shared_folder( |
||||||
|
0 ignored issues
–
show
The method
is_my_shared_folder() does not exist on DocumentManager.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||||
| 50 | $userId, |
||||||
| 51 | $folderInfo['absolute_path'], |
||||||
| 52 | $sessionId |
||||||
| 53 | ); |
||||||
| 54 | } |
||||||
| 55 | $groupRights = Session::read('group_member_with_upload_rights'); |
||||||
| 56 | $isAllowToEdit = api_is_allowed_to_edit(true, true); |
||||||
| 57 | if (!($isAllowToEdit || $isMyDir || $groupRights)) { |
||||||
| 58 | api_not_allowed(true); |
||||||
| 59 | } |
||||||
| 60 | |||||||
| 61 | $form = new FormValidator( |
||||||
| 62 | 'doc_create', |
||||||
| 63 | 'post', |
||||||
| 64 | api_get_path(WEB_PLUGIN_PATH).'Onlyoffice/create.php?userId='.Security::remove_XSS($userId) |
||||||
| 65 | .'&groupId='.Security::remove_XSS($groupId) |
||||||
| 66 | .'&courseId='.Security::remove_XSS($courseId) |
||||||
| 67 | .'&sessionId='.Security::remove_XSS($sessionId) |
||||||
| 68 | .'&folderId='.Security::remove_XSS($folderId) |
||||||
| 69 | ); |
||||||
| 70 | |||||||
| 71 | $form->addText('fileName', $plugin->get_lang('title'), true); |
||||||
| 72 | $form->addSelect('fileFormat', $plugin->get_lang('chooseFileFormat'), $mapFileFormat); |
||||||
| 73 | $form->addButtonCreate($plugin->get_lang('create')); |
||||||
| 74 | |||||||
| 75 | if ($form->validate()) { |
||||||
| 76 | $values = $form->exportValues(); |
||||||
| 77 | |||||||
| 78 | $fileType = $values['fileFormat']; |
||||||
| 79 | $fileExt = $documentManager->getDocExtByType($fileType); |
||||||
| 80 | |||||||
| 81 | $result = OnlyofficeDocumentManager::createFile( |
||||||
| 82 | $values['fileName'], |
||||||
| 83 | $fileExt, |
||||||
| 84 | $folderId, |
||||||
| 85 | $userId, |
||||||
| 86 | $sessionId, |
||||||
| 87 | $courseId, |
||||||
| 88 | $groupId |
||||||
| 89 | ); |
||||||
| 90 | |||||||
| 91 | if (isset($result['error'])) { |
||||||
| 92 | Display::addFlash( |
||||||
| 93 | Display::return_message( |
||||||
| 94 | $plugin->get_lang($result['error']), |
||||||
| 95 | 'error' |
||||||
| 96 | ) |
||||||
| 97 | ); |
||||||
| 98 | } else { |
||||||
| 99 | header('Location: '.OnlyofficeDocumentManager::getUrlToLocation($courseCode, $sessionId, $groupId, $folderId)); |
||||||
| 100 | exit; |
||||||
| 101 | } |
||||||
| 102 | } |
||||||
| 103 | |||||||
| 104 | $goBackUrl = OnlyofficeDocumentManager::getUrlToLocation($courseCode, $sessionId, $groupId, $folderId); |
||||||
| 105 | $actionsLeft = '<a href="'.$goBackUrl.'">'.Display::return_icon('back.png', get_lang('Back').' '.get_lang('To').' '.get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM).'</a>'; |
||||||
| 106 | |||||||
| 107 | Display::display_header($plugin->get_lang('createNewDocument')); |
||||||
| 108 | echo Display::toolbarAction('actions-documents', [$actionsLeft]); |
||||||
| 109 | echo $form->returnForm(); |
||||||
| 110 | Display::display_footer(); |
||||||
| 111 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.