course_document.lib.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @package chamilo.include
  5. */
  6. /**
  7. * Code
  8. */
  9. function getlist ($directory) {
  10. //global $delim, $win;
  11. if ($d = @opendir($directory)) {
  12. while (($filename = @readdir($d)) !== false) {
  13. $path = $directory . $filename;
  14. if ($filename != '.' && $filename != '..' && $filename != '.svn')
  15. {
  16. $file = array(
  17. "lastedit_date" =>date("Y-m-d H:i:s",9876),//date ("Y-m-d H:i:s", filemtime($path)),
  18. "visibility" => 1,
  19. "path" => $path,
  20. "title" => basename($path),
  21. "filetype" => filetype($path),
  22. "size" => filesize ($path)
  23. );
  24. $files[] = $file;
  25. }
  26. }
  27. return $files;
  28. }
  29. else
  30. {
  31. return false;
  32. }
  33. }
  34. function check_and_create_resource_directory($repository_path, $resource_directory, $resource_directory_name)
  35. {
  36. global $permissions_for_new_directories;
  37. $resource_directory_full_path = substr($repository_path, 0, strlen($repository_path) - 1) . $resource_directory . '/';
  38. if (!is_dir($resource_directory_full_path))
  39. {
  40. if (@mkdir($resource_directory_full_path, $permissions_for_new_directories))
  41. {
  42. // While we are in a course: Registering the newly created folder in the course's database.
  43. if (api_is_in_course())
  44. {
  45. global $_course, $_user;
  46. global $group_properties, $to_group_id;
  47. $group_directory = !empty($group_properties['directory']) ? $group_properties['directory'] : '';
  48. $doc_id = add_document($_course, $group_directory.$resource_directory, 'folder', 0, $resource_directory_name);
  49. api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderCreated', $_user['user_id'], $to_group_id);
  50. }
  51. return true;
  52. }
  53. return false;
  54. }
  55. return true;
  56. }
  57. ?>