".get_lang('MissingImagesDetected')."
" .""; return $form; } /** * This recursive function can be used during the upgrade process form older * versions of Chamilo * It crawls the given directory, checks if the file is in the DB and adds * it if it's not * * @param array $courseInfo * @param array $userInfo * @param string $base_work_dir * @param string $folderPath * @param int $sessionId * @param int $groupId group.id * @param bool $output * @param array $parent * @param string $uploadPath * */ function add_all_documents_in_folder_to_database( $courseInfo, $userInfo, $base_work_dir, $folderPath, $sessionId = 0, $groupId = 0, $output = false, $parent = array() ) { if (empty($userInfo) || empty($courseInfo)) { return false; } $userId = $userInfo['user_id']; // Open dir $handle = opendir($folderPath); if (is_dir($folderPath)) { // Run trough while ($file = readdir($handle)) { if ($file == '.' || $file == '..') { continue; } $parentPath = null; if (!empty($parent) && isset($parent['path'])) { $parentPath = $parent['path']; if ($parentPath == '/') { $parentPath = null; } } $completePath = $parentPath.'/'.$file; $sysFolderPath = $folderPath.'/'.$file; // Is directory? if (is_dir($sysFolderPath)) { $folderExists = DocumentManager::folderExists( $completePath, $courseInfo, $sessionId, $groupId ); if ($folderExists === true) { $documentId = DocumentManager::get_document_id($courseInfo, $completePath, $sessionId); if ($documentId) { $newFolderData = DocumentManager::get_document_data_by_id( $documentId, $courseInfo, false, $sessionId ); } } else { $newFolderData = create_unexisting_directory( $courseInfo, $userId, $sessionId, $groupId, null, $base_work_dir, $completePath, null, null, false ); } // Recursive add_all_documents_in_folder_to_database( $courseInfo, $userInfo, $base_work_dir, $sysFolderPath, $sessionId, $groupId, $output, $newFolderData ); } else { // Rename $uploadedFile = array( 'name' => $file, 'tmp_name' => $sysFolderPath, 'size' => filesize($sysFolderPath), 'type' => null, 'from_file' => true, 'move_file' => true ); handle_uploaded_document( $courseInfo, $uploadedFile, $base_work_dir, $parentPath, $userId, $groupId, null, 0, 'overwrite', $output, false, null, $sessionId ); } } } }