@@ 2554-2580 (lines=27) @@ | ||
2551 | if (file_exists($origin_filepath)) { |
|
2552 | $filepath_dir = dirname($destination_filepath); |
|
2553 | ||
2554 | if (!is_dir($filepath_dir)) { |
|
2555 | $perm = api_get_permissions_for_new_directories(); |
|
2556 | $result = @mkdir($filepath_dir, $perm, true); |
|
2557 | if ($result) { |
|
2558 | $filepath_to_add = str_replace(array($dest_course_path, 'document'), '', $filepath_dir); |
|
2559 | ||
2560 | //Add to item properties to the new folder |
|
2561 | $doc_id = add_document( |
|
2562 | $destination_course_info, |
|
2563 | $filepath_to_add, |
|
2564 | 'folder', |
|
2565 | 0, |
|
2566 | basename($filepath_to_add) |
|
2567 | ); |
|
2568 | api_item_property_update( |
|
2569 | $destination_course_info, |
|
2570 | TOOL_DOCUMENT, |
|
2571 | $doc_id, |
|
2572 | 'FolderCreated', |
|
2573 | $user_id, |
|
2574 | null, |
|
2575 | null, |
|
2576 | null, |
|
2577 | null |
|
2578 | ); |
|
2579 | } |
|
2580 | } |
|
2581 | ||
2582 | if (!file_exists($destination_filepath)) { |
|
2583 | $result = @copy($origin_filepath, $destination_filepath); |
|
@@ 2582-2608 (lines=27) @@ | ||
2579 | } |
|
2580 | } |
|
2581 | ||
2582 | if (!file_exists($destination_filepath)) { |
|
2583 | $result = @copy($origin_filepath, $destination_filepath); |
|
2584 | if ($result) { |
|
2585 | $filepath_to_add = str_replace(array($dest_course_path, 'document'), '', $destination_filepath); |
|
2586 | $size = filesize($destination_filepath); |
|
2587 | ||
2588 | // Add to item properties to the file |
|
2589 | $doc_id = add_document( |
|
2590 | $destination_course_info, |
|
2591 | $filepath_to_add, |
|
2592 | 'file', |
|
2593 | $size, |
|
2594 | basename($filepath_to_add) |
|
2595 | ); |
|
2596 | api_item_property_update( |
|
2597 | $destination_course_info, |
|
2598 | TOOL_DOCUMENT, |
|
2599 | $doc_id, |
|
2600 | 'FolderCreated', |
|
2601 | $user_id, |
|
2602 | null, |
|
2603 | null, |
|
2604 | null, |
|
2605 | null |
|
2606 | ); |
|
2607 | } |
|
2608 | } |
|
2609 | } |
|
2610 | ||
2611 | // Replace origin course path by destination course path. |