From 4d50dc3ccfc50c3102b5a30637b65f08363ba4a7 Mon Sep 17 00:00:00 2001 From: Eric Marguin Date: Wed, 9 Apr 2008 16:44:54 +0200 Subject: [PATCH] [svn r14805] document tool : apply permissions on files setting when creating / uploading a doc (FS#2422) --- main/document/create_document.php | 6 +++++- main/inc/lib/fileUpload.lib.php | 12 ++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/main/document/create_document.php b/main/document/create_document.php index 8d659002c7..cc55013fa4 100644 --- a/main/document/create_document.php +++ b/main/document/create_document.php @@ -1,5 +1,5 @@ validate()) fputs($fp, $content); fclose($fp); + + $files_perm = api_get_setting('permissions_for_new_files'); + $files_perm = octdec(!empty($files_perm)?$files_perm:'0770'); + chmod($filepath.$filename.'.'.$extension,$files_perm); $perm = api_get_setting('permissions_for_new_directories'); $perm = octdec(!empty($perm)?$perm:'0770'); diff --git a/main/inc/lib/fileUpload.lib.php b/main/inc/lib/fileUpload.lib.php index b263cf0f1a..bf6a6818a5 100644 --- a/main/inc/lib/fileUpload.lib.php +++ b/main/inc/lib/fileUpload.lib.php @@ -359,6 +359,10 @@ function handle_uploaded_document($_course,$uploaded_file,$base_work_dir,$upload $document_name = get_document_title($uploaded_file['name']); //size of the uploaded file (in bytes) $file_size = $uploaded_file['size']; + + $files_perm = api_get_setting('permissions_for_new_files'); + $files_perm = octdec(!empty($files_perm)?$files_perm:'0770'); + //what to do if the target file exists switch ($what_if_file_exists) { @@ -376,6 +380,7 @@ function handle_uploaded_document($_course,$uploaded_file,$base_work_dir,$upload } if (@move_uploaded_file($uploaded_file['tmp_name'], $store_path)) { + chmod($store_path,$files_perm); if($file_exists) { //UPDATE DATABASE! @@ -426,6 +431,8 @@ function handle_uploaded_document($_course,$uploaded_file,$base_work_dir,$upload if (@move_uploaded_file($uploaded_file['tmp_name'], $store_path)) { + chmod($store_path,$files_perm); + //put the document data in the database $document_id = add_document($_course,$new_file_path,'file',$file_size,$document_name); if ($document_id) @@ -457,8 +464,9 @@ function handle_uploaded_document($_course,$uploaded_file,$base_work_dir,$upload else { if (@move_uploaded_file($uploaded_file['tmp_name'], $store_path)) - { - + { + chmod($store_path,$files_perm); + //put the document data in the database $document_id = add_document($_course,$file_path,'file',$file_size,$document_name); if ($document_id)