skala
Julio Montoya 15 years ago
commit 5c75de8473
  1. 27
      main/coursecopy/classes/CourseRestorer.class.php
  2. 11
      main/inc/lib/fileUpload.lib.php

@ -197,18 +197,30 @@ class CourseRestorer
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:0770);
$dirs = explode('/', dirname($document->path));
if (count($dirs)==1) {
if ($this->file_type==FOLDER) {
$new = substr($document->path, 8);
$created_dir = create_unexisting_directory($destination_course,api_get_user_id(),0, 0 ,$path.'document',$new,basename($new));
}
} else {
//if (count($dirs)==1) {
if ($document->file_type==FOLDER) {
$visibility = $document->item_properties[0]['visibility'];
$new = substr($document->path, 8);
if (!is_dir($path.'document/'.$new)) {
$sql = "SELECT id FROM ".$table." WHERE path='/".Database::escape_string($new)."'";
$res = Database::query($sql, __FILE__, __LINE__);
$num_result = Database::num_rows($res);
if ($num_result==0) {
$created_dir = create_unexisting_directory($destination_course,api_get_user_id(),0, 0 ,$path.'document',$new,basename($new),$visibility);
}
}
}
//}
/*
else {
$my_temp = '';
for ($i=1; $i<=count($dirs); $i++) {
$my_temp .= $dirs[$i];
if (!is_dir($path.'document/'.$my_temp)) {
$sql = "SELECT id FROM ".$table." WHERE path='/".Database::escape_string($my_temp)."'";
//echo '<br>';
$res = Database::query($sql, __FILE__, __LINE__);
$num_result = Database::num_rows($res);
if ($num_result==0) {
@ -218,6 +230,7 @@ class CourseRestorer
$my_temp .= '/';
}
}
*/
/*
echo '<br>';
echo '------------------------';

@ -1380,7 +1380,7 @@ function search_img_from_html($htmlFile)
* boolean false otherwise
*/
function create_unexisting_directory($_course,$user_id,$to_group_id,$to_user_id,$base_work_dir,$desired_dir_name, $title = null)
function create_unexisting_directory($_course,$user_id,$to_group_id,$to_user_id,$base_work_dir,$desired_dir_name, $title = null, $visibility = '')
{
$nb = '';
while ( file_exists($base_work_dir.$desired_dir_name.$nb) )
@ -1400,8 +1400,13 @@ function create_unexisting_directory($_course,$user_id,$to_group_id,$to_user_id,
if ($document_id)
{
//update document item_property
$current_session_id = api_get_session_id();
api_item_property_update($_course,TOOL_DOCUMENT,$document_id,'FolderCreated',$user_id,$to_group_id,$to_user_id,null,null,$current_session_id);
$current_session_id = api_get_session_id();
if ($visibility !== '') {
$visibilities = array(0 => 'invisible', 1 => 'visible', 2 => 'delete');
api_item_property_update($_course,TOOL_DOCUMENT,$document_id,$visibilities[$visibility],$user_id,$to_group_id,$to_user_id,null,null,$current_session_id);
} else {
api_item_property_update($_course,TOOL_DOCUMENT,$document_id,'FolderCreated',$user_id,$to_group_id,$to_user_id,null,null,$current_session_id);
}
return $desired_dir_name.$nb;
}
}

Loading…
Cancel
Save