예제 #1
0
     api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $_user['user_id'], null, null, null, null, $current_session_id);
 }
 if (!is_file($filepath . 'css/frames.css')) {
     // Make a copy of the current css for the new document
     copy(api_get_path(SYS_CSS_PATH) . 'themes/' . api_get_setting('stylesheets') . '/frames.css', $filepath . 'css/frames.css');
     $doc_id = FileManager::add_document($_course, $dir . 'css/frames.css', 'file', filesize($filepath . 'css/frames.css'), 'frames.css');
     api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], null, null, null, null, $current_session_id);
     api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $_user['user_id'], null, null, null, null, $current_session_id);
 }
 $file_size = filesize($filepath . $filename . '.' . $extension);
 $save_file_path = $dir . $filename . '.' . $extension;
 $document_id = FileManager::add_document($_course, $save_file_path, 'file', $file_size, $title, null, $readonly);
 if ($document_id) {
     api_item_property_update($_course, TOOL_DOCUMENT, $document_id, 'DocumentAdded', $_user['user_id'], $groupId, null, null, null, $current_session_id);
     // Update parent folders
     FileManager::item_property_update_on_folder($_course, $dir, $_user['user_id']);
     $new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : '';
     $new_comment = Database::escape_string($new_comment);
     $new_title = isset($_POST['title']) ? trim($_POST['title']) : '';
     $new_title = htmlspecialchars($new_title);
     $new_title = Database::escape_string($new_title);
     if ($new_comment || $new_title) {
         $ct = '';
         if ($new_comment) {
             $ct .= ", comment='{$new_comment}'";
         }
         if ($new_title) {
             $ct .= ", title='{$new_title}'";
         }
         Database::query("UPDATE {$doc_table} SET" . substr($ct, 1) . " WHERE c_id = {$course_id} AND id = '{$document_id}'");
     }
예제 #2
0
             if (!is_file($filepath . 'css/frames.css')) {
                 $platform_theme = api_get_setting('stylesheets');
                 if (file_exists(api_get_path(SYS_CSS_PATH) . 'themes/' . $platform_theme . '/frames.css')) {
                     copy(api_get_path(SYS_CSS_PATH) . 'themes/' . $platform_theme . '/frames.css', $filepath . 'css/frames.css');
                     $doc_id = FileManager::add_document($_course, $dir . 'css/frames.css', 'file', filesize($filepath . 'css/frames.css'), 'frames.css');
                     api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', api_get_user_id(), null, null, null, null, $current_session_id);
                     api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', api_get_user_id(), null, null, null, null, $current_session_id);
                 }
             }
             // "WHAT'S NEW" notification: update table item_property
             $document_id = DocumentManager::get_document_id($_course, $file);
             if ($document_id) {
                 FileManager::update_existing_document($_course, $document_id, $file_size, $read_only_flag);
                 api_item_property_update($_course, TOOL_DOCUMENT, $document_id, 'DocumentUpdated', api_get_user_id(), null, null, null, null, $current_session_id);
                 // Update parent folders
                 FileManager::item_property_update_on_folder($_course, $dir, api_get_user_id());
                 header('Location: document.php?id=' . $document_data['parent_id']);
                 exit;
             } else {
                 $msgError = get_lang('Impossible');
             }
         } else {
             $msgError = get_lang('Impossible');
         }
     } else {
         if ($document_id) {
             FileManager::update_existing_document($_course, $document_id, $file_size, $read_only_flag);
         }
     }
 } else {
     if ($document_id) {
예제 #3
0
         $basename_chat = 'messages-' . $date_now . '_sid-' . $session_id;
     } else {
         $basename_chat = 'messages-' . $date_now;
     }
 }
 if ($reset && $isMaster) {
     $i = 1;
     while (file_exists($chat_path . $basename_chat . '-' . $i . '.log.html')) {
         $i++;
     }
     @rename($chat_path . $basename_chat . '.log.html', $chat_path . $basename_chat . '-' . $i . '.log.html');
     @fclose(fopen($chat_path . $basename_chat . '.log.html', 'w'));
     $doc_id = FileManager::add_document($_course, $basepath_chat . '/' . $basename_chat . '-' . $i . '.log.html', 'file', filesize($chat_path . $basename_chat . '-' . $i . '.log.html'), $basename_chat . '-' . $i . '.log.html');
     api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], $group_id, null, null, null, $session_id);
     api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $_user['user_id'], $group_id, null, null, null, $session_id);
     FileManager::item_property_update_on_folder($_course, $basepath_chat, $_user['user_id']);
     $doc_id = DocumentManager::get_document_id($_course, $basepath_chat . '/' . $basename_chat . '.log.html');
     FileManager::update_existing_document($_course, $doc_id, 0);
 }
 $remove = 0;
 $content = array();
 if (file_exists($chat_path . $basename_chat . '.log.html')) {
     $content = file($chat_path . $basename_chat . '.log.html');
     $nbr_lines = sizeof($content);
     $remove = $nbr_lines - 100;
 }
 if ($remove < 0) {
     $remove = 0;
 }
 array_splice($content, 0, $remove);
 require 'header_frame.inc.php';
예제 #4
0
}
//missing images are submitted
if (isset($_POST['submit_image'])) {
    $number_of_uploaded_images = count($_FILES['img_file']['name']);
    //if images are uploaded
    if ($number_of_uploaded_images > 0) {
        //we could also create a function for this, I'm not sure...
        //create a directory for the missing files
        $img_directory = str_replace('.', '_', $_POST['related_file'] . "_files");
        $missing_files_dir = FileManager::create_unexisting_directory($_course, $_user['user_id'], api_get_session_id(), $to_group_id, $to_user_id, $base_work_dir, $img_directory);
        //put the uploaded files in the new directory and get the paths
        $paths_to_replace_in_file = FileManager::move_uploaded_file_collection_into_directory($_course, $_FILES['img_file'], $base_work_dir, $missing_files_dir, $_user['user_id'], $to_group_id, $to_user_id, $max_filled_space);
        //open the html file and replace the paths
        FileManager::replace_img_path_in_html_file($_POST['img_file_path'], $paths_to_replace_in_file, $base_work_dir . $_POST['related_file']);
        //update parent folders
        FileManager::item_property_update_on_folder($_course, $_POST['curdirpath'], $_user['user_id']);
    }
}
//they want to create a directory
if (isset($_POST['create_dir']) && $_POST['dirname'] != '') {
    $added_slash = $path == '/' ? '' : '/';
    $dir_name = $path . $added_slash . api_replace_dangerous_char($_POST['dirname']);
    $created_dir = FileManager::create_unexisting_directory($_course, $_user['user_id'], api_get_session_id(), $to_group_id, $to_user_id, $base_work_dir, $dir_name, $_POST['dirname']);
    if ($created_dir) {
        //Display::display_normal_message("<strong>".$created_dir."</strong> was created!");
        Display::display_normal_message(get_lang('DirCr'));
        $path = $created_dir;
    } else {
        display_error(get_lang('CannotCreateDir'));
    }
}
예제 #5
0
 /**
  * changes the exercise sound file
  *
  * @author - Olivier Brouckaert
  * @param - string $sound - exercise sound file
  * @param - string $delete - ask to delete the file
  */
 public function updateSound($sound, $delete)
 {
     global $audioPath, $documentPath;
     $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
     if ($sound['size'] && (strstr($sound['type'], 'audio') || strstr($sound['type'], 'video'))) {
         $this->sound = $sound['name'];
         if (@move_uploaded_file($sound['tmp_name'], $audioPath . '/' . $this->sound)) {
             $query = "SELECT 1 FROM {$TBL_DOCUMENT}  WHERE c_id = " . $this->course_id . " AND path='" . str_replace($documentPath, '', $audioPath) . '/' . $this->sound . "'";
             $result = Database::query($query);
             if (!Database::num_rows($result)) {
                 $id = FileManager::add_document($this->course, str_replace($documentPath, '', $audioPath) . '/' . $this->sound, 'file', $sound['size'], $sound['name']);
                 api_item_property_update($this->course, TOOL_DOCUMENT, $id, 'DocumentAdded', api_get_user_id());
                 FileManager::item_property_update_on_folder($this->course, str_replace($documentPath, '', $audioPath), api_get_user_id());
             }
         }
     } elseif ($delete && is_file($audioPath . '/' . $this->sound)) {
         $this->sound = '';
     }
 }