Ejemplo n.º 1
0
        // Get the document data from the ID
        $document_info = DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true, $session_id);
        $file = $sys_course_path . $courseInfo['directory'] . '/document' . $document_info['path'];
        $fileInfo = pathinfo($file);
        if ($fileInfo['extension'] == $formatTarget) {
            Display::addFlash(Display::return_message(get_lang('ConversionToSameFileFormat'), 'warning'));
        } elseif (!in_array($fileInfo['extension'], DocumentManager::getJodconverterExtensionList('from', $formatType)) || !in_array($formatTarget, DocumentManager::getJodconverterExtensionList('to', $formatType))) {
            Display::addFlash(Display::return_message(get_lang('FileFormatNotSupported'), 'warning'));
        } else {
            $convertedFile = $fileInfo['dirname'] . DIRECTORY_SEPARATOR . $fileInfo['filename'] . '_from_' . $fileInfo['extension'] . '.' . $formatTarget;
            $convertedTitle = $document_info['title'];
            $obj = new OpenofficePresentation(true);
            if (file_exists($convertedFile)) {
                Display::addFlash(Display::return_message(get_lang('FileExists'), 'error'));
            } else {
                $result = $obj->convertCopyDocument($file, $convertedFile, $convertedTitle);
                if (empty($result)) {
                    Display::addFlash(Display::return_message(get_lang('CopyFailed'), 'error'));
                } else {
                    $cidReq = Security::remove_XSS($_GET['cidReq']);
                    $id_session = api_get_session_id();
                    $gidReq = Security::remove_XSS($_GET['gidReq']);
                    $file_link = Display::url(get_lang('SeeFile'), api_get_path(WEB_CODE_PATH) . 'document/showinframes.php?' . 'cidReq=' . $cidReq . '&id_session=' . $id_session . '&' . 'gidReq=' . $gidReq . '&id=' . current($result));
                    Display::addFlash(Display::return_message(get_lang('CopyMade') . ' ' . $file_link, 'confirmation', false));
                }
            }
        }
        break;
}
// I'm in the certification module?
$is_certificate_mode = false;