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