当前位置: 首页>>代码示例>>PHP>>正文


PHP DocumentManager::get_document_id方法代码示例

本文整理汇总了PHP中DocumentManager::get_document_id方法的典型用法代码示例。如果您正苦于以下问题:PHP DocumentManager::get_document_id方法的具体用法?PHP DocumentManager::get_document_id怎么用?PHP DocumentManager::get_document_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DocumentManager的用法示例。


在下文中一共展示了DocumentManager::get_document_id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: processNewDir

 /**
  * Create new directories.
  * If in safe_mode, nothing happens.
  * @return boolean true if created, false otherwise.
  */
 function processNewDir()
 {
     if ($this->config['safe_mode']) {
         return false;
     }
     if (isset($_GET['newDir']) && isset($_GET['dir'])) {
         $newDir = rawurldecode($_GET['newDir']);
         $dir = rawurldecode($_GET['dir']);
         $path = Files::makePath($this->getBaseDir(), $dir);
         $fullpath = Files::makePath($path, Files::escape($newDir));
         if (is_dir($fullpath)) {
             return false;
         } else {
             //adding to the DB
             // now the create_unexisting_directory will create the folder
             //$result = Files::createFolder($fullpath);
             global $_course;
             if (isset($_course) && !empty($_course) && isset($_course['code'])) {
                 //@todo make this str to functions
                 $base_dir = substr($path, 0, strpos($path, '/document/') + 9);
                 //
                 $new_dir = substr($fullpath, strlen($base_dir), -1);
                 //
                 create_unexisting_directory($_course, api_get_user_id(), api_get_session_id(), 0, 0, $base_dir, $new_dir, $newDir);
                 $doc_id = DocumentManager::get_document_id($_course, $new_dir);
                 api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', api_get_user_id(), null, null, null, null, api_get_session_id());
             } else {
                 return Files::createFolder($fullpath);
             }
             return true;
         }
     }
 }
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:38,代码来源:ImageManager.php

示例2: getFileAction

 /**
  * @param string $courseCode
  * @param string $fileName
  * @return \Symfony\Component\HttpFoundation\BinaryFileResponse
  */
 public function getFileAction($courseCode, $fileName)
 {
     $courseInfo = api_get_course_info($courseCode);
     $sessionId = $this->getRequest()->get('id_session');
     $docId = \DocumentManager::get_document_id($courseInfo, "/" . $fileName);
     $filePath = null;
     if ($docId) {
         $isVisible = \DocumentManager::is_visible_by_id($docId, $courseInfo, $sessionId, api_get_user_id());
         $documentData = \DocumentManager::get_document_data_by_id($docId, $courseCode);
         $filePath = $documentData['absolute_path'];
         event_download($filePath);
     }
     if (!api_is_allowed_to_edit() && !$isVisible) {
         $this->abort(500);
     }
     return $this->sendFile($filePath);
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:22,代码来源:CourseHomeController.php

示例3: array

$language_file = array('document');
//require_once '../inc/global.inc.php';
$_SESSION['whereami'] = 'document/createpaint';
$this_section = SECTION_COURSES;
require_once 'document.inc.php';
$nameTools = get_lang('PhotoRetouching');
api_protect_course_script();
api_block_anonymous_users();
if (api_get_setting('enabled_support_paint') == 'false') {
    api_not_allowed(true);
}
$document_data = DocumentManager::get_document_data_by_id($_GET['id'], api_get_course_id(), true);
if (empty($document_data)) {
    if (api_is_in_group()) {
        $group_properties = GroupManager::get_group_properties(api_get_group_id());
        $document_id = DocumentManager::get_document_id(api_get_course_info(), $group_properties['directory']);
        $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id());
    }
}
$document_id = $document_data['id'];
$dir = $document_data['path'];
//$dir = isset($_GET['dir']) ? Security::remove_XSS($_GET['dir']) : Security::remove_XSS($_POST['dir']);
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
//path for pixlr save
$_SESSION['paint_dir'] = Security::remove_XSS($dir);
if ($_SESSION['paint_dir'] == '/') {
    $_SESSION['paint_dir'] = '';
}
$_SESSION['paint_file'] = get_lang('NewImage');
// Please, do not modify this dirname formatting
if (strstr($dir, '..')) {
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:31,代码来源:create_paint.php

示例4: mkdir

             mkdir($filepath . 'css', api_get_permissions_for_new_directories());
             $doc_id = FileManager::add_document($_course, $dir . 'css', 'folder', 0, 'css');
             api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderCreated', 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);
         }
         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) {
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:31,代码来源:edit_document.php

示例5: showQuestion


//.........这里部分代码省略.........
                    if ($answerCorrect) {
                        $s .= Display::div($counterAnswer, ['id' => "drop_{$windowId}", 'class' => 'droppable col-md-2']);
                        $counterAnswer++;
                    }
                }
                $s .= '</div>';
                // row
                $s .= '</div>';
                // col-md-12
                $s .= '</div>';
                // col-md-12 ui-widget ui-helper-clearfix
            }
            if (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) {
                $s .= '</div>';
                //drag_question
            }
            $s .= '</div>';
            //question_options row
            // destruction of the Answer object
            unset($objAnswerTmp);
            // destruction of the Question object
            unset($objQuestionTmp);
            if ($origin != 'export') {
                echo $s;
            } else {
                return $s;
            }
        } elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_DELINEATION) {
            global $exerciseId, $exe_id;
            // Question is a HOT_SPOT
            //checking document/images visibility
            if (api_is_platform_admin() || api_is_course_admin()) {
                $course = api_get_course_info();
                $doc_id = DocumentManager::get_document_id($course, '/images/' . $pictureName);
                if (is_numeric($doc_id)) {
                    $images_folder_visibility = api_get_item_visibility($course, 'document', $doc_id, api_get_session_id());
                    if (!$images_folder_visibility) {
                        //This message is shown only to the course/platform admin if the image is set to visibility = false
                        Display::display_warning_message(get_lang('ChangeTheVisibilityOfTheCurrentImage'));
                    }
                }
            }
            $questionName = $objQuestionTmp->selectTitle();
            $questionDescription = $objQuestionTmp->selectDescription();
            if ($freeze) {
                echo "\n                    <script>\n                        \$(document).on('ready', function () {\n                            new " . ($answerType == HOT_SPOT ? "HotspotQuestion" : "DelineationQuestion") . "({\n                                questionId: {$questionId},\n                                exerciseId: {$exerciseId},\n                                selector: '#hotspot-preview-{$questionId}',\n                                for: 'preview'\n                            });\n                        });\n                    </script>\n                    <div id=\"hotspot-preview-{$questionId}\"></div>\n                ";
                return;
            }
            // Get the answers, make a list
            $objAnswerTmp = new Answer($questionId);
            $nbrAnswers = $objAnswerTmp->selectNbrAnswers();
            // get answers of hotpost
            $answers_hotspot = array();
            for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
                $answers = $objAnswerTmp->selectAnswerByAutoId($objAnswerTmp->selectAutoId($answerId));
                $answers_hotspot[$answers['id']] = $objAnswerTmp->selectAnswer($answerId);
            }
            $answerList = '';
            if ($answerType != HOT_SPOT_DELINEATION) {
                $answerList = '
                    <div class="well well-sm">
                        <h5 class="page-header">' . get_lang('HotspotZones') . '</h5>
                        <ol>
                ';
                if (!empty($answers_hotspot)) {
                    ksort($answers_hotspot);
开发者ID:feroli1000,项目名称:chamilo-lms,代码行数:67,代码来源:exercise.lib.php

示例6: addFileToDocumentTool

 /**
  * @param string $filePath
  * @param string $path
  * @param $courseInfo
  * @param string $whatIfFileExists overwrite|rename
  * @param null $userId
  * @param null $groupId
  * @param null $toUserId
  * @return bool|path
  */
 public static function addFileToDocumentTool($filePath, $path, $courseInfo, $userId, $whatIfFileExists = 'overwrite', $groupId = null, $toUserId = null)
 {
     if (!file_exists($filePath)) {
         return false;
     }
     $fileInfo = pathinfo($filePath);
     $file = array('name' => $fileInfo['basename'], 'tmp_name' => $filePath, 'size' => filesize($filePath), 'from_file' => true);
     $course_dir = $courseInfo['path'] . '/document';
     $baseWorkDir = api_get_path(SYS_COURSE_PATH) . $course_dir;
     $filePath = handle_uploaded_document($courseInfo, $file, $baseWorkDir, $path, $userId, $groupId, $toUserId, false, $whatIfFileExists, false);
     if ($filePath) {
         return DocumentManager::get_document_id($courseInfo, $filePath);
     }
     return false;
 }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:25,代码来源:document.lib.php

示例7: array

/*	INIT SECTION */
$language_file = array('document');
require_once '../inc/global.inc.php';
$_SESSION['whereami'] = 'document/editdraw';
$this_section = SECTION_COURSES;
require_once api_get_path(SYS_CODE_PATH) . 'document/document.inc.php';
api_protect_course_script();
api_block_anonymous_users();
$document_data = DocumentManager::get_document_data_by_id($_GET['id'], api_get_course_id(), true);
if (empty($document_data)) {
    api_not_allowed();
} else {
    $document_id = $document_data['id'];
    $file_path = $document_data['path'];
    $dir = dirname($document_data['path']);
    $parent_id = DocumentManager::get_document_id(api_get_course_info(), $dir);
    $my_cur_dir_path = Security::remove_XSS($_GET['curdirpath']);
}
$dir = str_replace('\\', '/', $dir);
//and urlencode each url $curdirpath (hack clean $curdirpath under Windows - Bug #3261)
/* Constants & Variables */
$current_session_id = api_get_session_id();
$group_id = api_get_group_id();
//path for svg-edit save
$_SESSION['draw_dir'] = Security::remove_XSS($dir);
if ($_SESSION['draw_dir'] == '/') {
    $_SESSION['draw_dir'] = '';
}
$_SESSION['draw_file'] = basename(Security::remove_XSS($file_path));
$get_file = Security::remove_XSS($file_path);
$file = basename($get_file);
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:edit_draw.php

示例8: while

     } 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 = 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', $userId, $group_id, null, null, null, $session_id);
     api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $userId, $group_id, null, null, null, $session_id);
     item_property_update_on_folder($_course, $basepath_chat, $userId);
     $doc_id = DocumentManager::get_document_id($_course, $basepath_chat . '/' . $basename_chat . '.log.html');
     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';
 if (isset($_GET['origin']) && $_GET['origin'] == 'whoisonline') {
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:31,代码来源:chat_chat.php

示例9: build_missing_files_form

/**
 * This function builds a form that asks for the missing images in a html file
 * maybe we should do this another way?
 *
 * @param array $missing_files
 * @param string $upload_path
 * @param string $file_name
 * @return string the form
 */
function build_missing_files_form($missing_files, $upload_path, $file_name)
{
    // Do we need a / or not?
    $added_slash = $upload_path == '/' ? '' : '/';
    $folder_id = DocumentManager::get_document_id(api_get_course_info(), $upload_path);
    // Build the form
    $form = "<p><strong>" . get_lang('MissingImagesDetected') . "</strong></p>" . "<form method=\"post\" action=\"" . api_get_self() . "\" enctype=\"multipart/form-data\">" . "<input type=\"hidden\" name=\"related_file\" value=\"" . $upload_path . $added_slash . $file_name . "\" />" . "<input type=\"hidden\" name=\"upload_path\" value=\"" . $upload_path . "\" />" . "<input type=\"hidden\" name=\"id\" value=\"" . $folder_id . "\" />" . "<table border=\"0\">";
    foreach ($missing_files as &$this_img_file_path) {
        $form .= "<tr>" . "<td>" . basename($this_img_file_path) . " : </td>" . "<td>" . "<input type=\"file\" name=\"img_file[]\"/>" . "<input type=\"hidden\" name=\"img_file_path[]\" value=\"" . $this_img_file_path . "\" />" . "</td>" . "</tr>";
    }
    $form .= "</table>" . "<button type='submit' name=\"cancel_submit_image\" value=\"" . get_lang('Cancel') . "\" class=\"cancel\">" . get_lang('Cancel') . "</button>" . "<button type='submit' name=\"submit_image\" value=\"" . get_lang('Ok') . "\" class=\"save\">" . get_lang('Ok') . "</button>" . "</form>";
    return $form;
}
开发者ID:daffef,项目名称:chamilo-lms,代码行数:22,代码来源:fileUpload.lib.php

示例10: restore_documents

 /**
  * Restore documents
  *
  * @param int $session_id
  * @param bool $respect_base_content
  * @param string $destination_course_code
  */
 public function restore_documents($session_id = 0, $respect_base_content = false, $destination_course_code = '')
 {
     $course_info = api_get_course_info($destination_course_code);
     if ($this->course->has_resources(RESOURCE_DOCUMENT)) {
         $table = Database::get_course_table(TABLE_DOCUMENT);
         $resources = $this->course->resources;
         $path = api_get_path(SYS_COURSE_PATH) . $this->course->destination_path . '/';
         foreach ($resources[RESOURCE_DOCUMENT] as $id => $document) {
             if (empty($document->item_properties[0]['id_session'])) {
                 $my_session_id = 0;
             } else {
                 $my_session_id = $session_id;
             }
             if ($document->file_type == FOLDER) {
                 $visibility = $document->item_properties[0]['visibility'];
                 $new = substr($document->path, 8);
                 $folderList = explode('/', $new);
                 $tempFolder = '';
                 // Check if the parent path exists.
                 foreach ($folderList as $folder) {
                     $folderToCreate = $tempFolder . $folder;
                     $sysFolderPath = $path . 'document' . $folderToCreate;
                     $tempFolder .= $folder . '/';
                     if (empty($folderToCreate)) {
                         continue;
                     }
                     $title = basename($sysFolderPath);
                     // File doesn't exist in file system.
                     if (!is_dir($sysFolderPath)) {
                         // Creating directory
                         create_unexisting_directory($course_info, api_get_user_id(), $my_session_id, 0, 0, $path . 'document', $folderToCreate, $title, $visibility);
                     } else {
                         // File exist in file system.
                         $documentData = DocumentManager::get_document_id($course_info, $folderToCreate, $my_session_id);
                         if (empty($documentData)) {
                             /* This means the folder exists in the
                                filesystem but not in the DB, trying to fix it */
                             add_document($course_info, $folderToCreate, 'folder', 0, $title, null, null, false, null, $my_session_id);
                         }
                     }
                 }
             } elseif ($document->file_type == DOCUMENT) {
                 //Checking if folder exists in the database otherwise we created it
                 $dir_to_create = dirname($document->path);
                 if (!empty($dir_to_create) && $dir_to_create != 'document' && $dir_to_create != '/') {
                     if (is_dir($path . dirname($document->path))) {
                         $sql = "SELECT id FROM {$table}\n                                    WHERE\n                                        c_id = " . $this->destination_course_id . " AND\n                                        path = '/" . self::DBUTF8escapestring(substr(dirname($document->path), 9)) . "'";
                         $res = Database::query($sql);
                         if (Database::num_rows($res) == 0) {
                             //continue;
                             $visibility = $document->item_properties[0]['visibility'];
                             $new = '/' . substr(dirname($document->path), 9);
                             $title = str_replace('/', '', $new);
                             // This code fixes the possibility for a file without a directory entry to be
                             $document_id = add_document($course_info, $new, 'folder', 0, $title, null, null, false);
                             api_item_property_update($course_info, TOOL_DOCUMENT, $document_id, 'FolderCreated', $document->item_properties[0]['insert_user_id'], $document->item_properties[0]['to_group_id'], $document->item_properties[0]['to_user_id'], null, null, $my_session_id);
                         }
                     }
                 }
                 if (file_exists($path . $document->path)) {
                     switch ($this->file_option) {
                         case FILE_OVERWRITE:
                             $origin_path = $this->course->backup_path . '/' . $document->path;
                             if (file_exists($origin_path)) {
                                 copy($origin_path, $path . $document->path);
                                 $sql = "SELECT id FROM {$table}\n                                            WHERE\n                                                c_id = " . $this->destination_course_id . " AND\n                                                path = '/" . self::DBUTF8escapestring(substr($document->path, 9)) . "'";
                                 $res = Database::query($sql);
                                 $count = Database::num_rows($res);
                                 if ($count == 0) {
                                     $params = ['path' => "/" . self::DBUTF8(substr($document->path, 9)), 'c_id' => $this->destination_course_id, 'comment' => self::DBUTF8($document->comment), 'title' => self::DBUTF8($document->title), 'filetype' => self::DBUTF8($document->file_type), 'size' => self::DBUTF8($document->size), 'session_id' => $my_session_id];
                                     $document_id = Database::insert($table, $params);
                                     if ($document_id) {
                                         $sql = "UPDATE {$table} SET id = iid WHERE iid = {$document_id}";
                                         Database::query($sql);
                                     }
                                     $this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $document_id;
                                     api_item_property_update($course_info, TOOL_DOCUMENT, $document_id, 'DocumentAdded', $document->item_properties[0]['insert_user_id'], $document->item_properties[0]['to_group_id'], $document->item_properties[0]['to_user_id'], null, null, $my_session_id);
                                 } else {
                                     $obj = Database::fetch_object($res);
                                     $document_id = $obj->id;
                                     $params = ['path' => "/" . self::DBUTF8(substr($document->path, 9)), 'c_id' => $this->destination_course_id, 'comment' => self::DBUTF8($document->comment), 'title' => self::DBUTF8($document->title), 'filetype' => self::DBUTF8($document->file_type), 'size' => self::DBUTF8($document->size), 'session_id' => $my_session_id];
                                     Database::update($table, $params, ['c_id = ? AND path = ?' => [$this->destination_course_id, "/" . self::DBUTF8escapestring(substr($document->path, 9))]]);
                                     $this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $obj->id;
                                     api_item_property_update($course_info, TOOL_DOCUMENT, $obj->id, 'default', $document->item_properties[0]['insert_user_id'], $document->item_properties[0]['to_group_id'], $document->item_properties[0]['to_user_id'], null, null, $my_session_id);
                                 }
                                 // Replace old course code with the new destination code
                                 $file_info = pathinfo($path . $document->path);
                                 if (in_array($file_info['extension'], array('html', 'htm'))) {
                                     $content = file_get_contents($path . $document->path);
                                     if (UTF8_CONVERT) {
                                         $content = utf8_encode($content);
                                     }
                                     $content = DocumentManager::replace_urls_inside_content_html_from_copy_course($content, $this->course->code, $this->course->destination_path, $this->course->backup_path, $this->course->info['path']);
//.........这里部分代码省略.........
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:101,代码来源:CourseRestorer.class.php

示例11: file_put_contents

$documentPath = $saveDir . '/' . $drawFileName;
//add new document to disk
file_put_contents($documentPath, $contents);
if ($currentTool == 'document/createdraw') {
    //add document to database
    $doc_id = add_document($_course, $relativeUrlPath . '/' . $drawFileName, 'file', filesize($documentPath), $title);
    api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], $groupId, null, null, null, $current_session_id);
} elseif ($currentTool == 'document/editdraw') {
    //check path
    if (!isset($_SESSION['draw_file'])) {
        api_not_allowed();
        //from Chamilo
        die;
    }
    if ($_SESSION['draw_file'] == $drawFileName) {
        $document_id = DocumentManager::get_document_id($_course, $relativeUrlPath . '/' . $drawFileName);
        update_existing_document($_course, $document_id, filesize($documentPath), null);
        api_item_property_update($_course, TOOL_DOCUMENT, $document_id, 'DocumentUpdated', $_user['user_id'], $groupId, null, null, null, $current_session_id);
    } else {
        //add a new document
        $doc_id = add_document($_course, $relativeUrlPath . '/' . $drawFileName, 'file', filesize($documentPath), $title);
        api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], $groupId, null, null, null, $current_session_id);
    }
}
//clean sessions and add messages and return to current document list
unset($_SESSION['draw_dir']);
unset($_SESSION['draw_file']);
unset($_SESSION['whereami']);
if ($suffix != 'png') {
    if ($relativeUrlPath == '') {
        $relativeUrlPath = '/';
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:savefile_config.php

示例12: upload_document

 /**
  * Uploads a document
  *
  * @param array     the $_FILES variable
  * @param string    $path
  * @param string    title
  * @param string    comment
  * @param int       unzip or not the file
  * @param int       if_exists overwrite, rename or warn if exists (default)
  * @param bool      index document (search xapian module)
  * @param bool      print html messages
  * @return unknown_type
  */
 public static function upload_document($files, $path, $title = null, $comment = null, $unzip = 0, $if_exists = null, $index_document = false, $show_output = false)
 {
     $course_info = api_get_course_info();
     $course_dir = $course_info['path'] . '/document';
     $sys_course_path = api_get_path(SYS_COURSE_PATH);
     $base_work_dir = $sys_course_path . $course_dir;
     if (isset($files['file'])) {
         $upload_ok = FileManager::process_uploaded_file($files['file'], $show_output);
         if ($upload_ok) {
             // File got on the server without problems, now process it
             $new_path = FileManager::handle_uploaded_document($course_info, $files['file'], $base_work_dir, $path, api_get_user_id(), api_get_group_id(), null, $unzip, $if_exists, $show_output);
             if ($new_path) {
                 $docid = DocumentManager::get_document_id($course_info, $new_path);
                 if (!empty($docid)) {
                     $table_document = Database::get_course_table(TABLE_DOCUMENT);
                     $params = array();
                     if (!empty($title)) {
                         $params['title'] = FileManager::get_document_title($title);
                     } else {
                         if (isset($if_exists) && $if_exists == 'rename') {
                             $new_path = basename($new_path);
                             $params['title'] = FileManager::get_document_title($new_path);
                         } else {
                             $params['title'] = FileManager::get_document_title($files['file']['name']);
                         }
                     }
                     if (!empty($comment)) {
                         $params['comment'] = trim($comment);
                     }
                     Database::update($table_document, $params, array('id = ? AND c_id = ? ' => array($docid, $course_info['real_id'])));
                 }
                 // Showing message when sending zip files
                 if ($new_path === true && $unzip == 1 && $show_output) {
                     Display::display_confirmation_message(get_lang('UplUploadSucceeded') . '<br />', false);
                 }
                 if ($index_document) {
                     self::index_document($docid, $course_info['code'], null, $_POST['language'], $_REQUEST, $if_exists);
                 }
                 if (!empty($docid) && is_numeric($docid)) {
                     $document_data = self::get_document_data_by_id($docid, $course_info['code']);
                     return $document_data;
                 }
             }
         }
     }
     return false;
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:60,代码来源:document.lib.php

示例13: add_all_documents_in_folder_to_database

 /**
  * This recursive function can be used during the upgrade process form older versions of Chamilo
  * It crawls the given directory, checks if the file is in the DB and adds it if it's not
  *
  * @param string $base_work_dir
  * @param string $current_path, needed for recursivity
  */
 public static function add_all_documents_in_folder_to_database($_course, $user_id, $base_work_dir, $current_path = '', $to_group_id = 0)
 {
     $current_session_id = api_get_session_id();
     $path = $base_work_dir . $current_path;
     // Open dir
     $handle = opendir($path);
     if (is_dir($path)) {
         // Run trough
         while ($file = readdir($handle)) {
             if ($file == '.' || $file == '..') {
                 continue;
             }
             $completepath = "{$path}/{$file}";
             // Directory?
             if (is_dir($completepath)) {
                 $title = self::get_document_title($file);
                 $safe_file = api_replace_dangerous_char($file);
                 @rename($path . '/' . $file, $path . '/' . $safe_file);
                 // If we can't find the file, add it
                 if (!DocumentManager::get_document_id($_course, $current_path . '/' . $safe_file)) {
                     $document_id = self::add_document($_course, $current_path . '/' . $safe_file, 'folder', 0, $title);
                     api_item_property_update($_course, TOOL_DOCUMENT, $document_id, 'DocumentAdded', $user_id, $to_group_id, null, null, null, $current_session_id);
                     //echo $current_path.'/'.$safe_file.' added!<br />';
                 }
                 // Recursive
                 self::add_all_documents_in_folder_to_database($_course, $user_id, $base_work_dir, $current_path . '/' . $safe_file, $to_group_id);
             } else {
                 //Rename
                 $safe_file = self::disable_dangerous_file(api_replace_dangerous_char($file, 'strict'));
                 @rename($base_work_dir . $current_path . '/' . $file, $base_work_dir . $current_path . '/' . $safe_file);
                 $document_id = DocumentManager::get_document_id($_course, $current_path . '/' . $safe_file);
                 if (!$document_id) {
                     $title = self::get_document_title($file);
                     $size = filesize($base_work_dir . $current_path . '/' . $safe_file);
                     $document_id = self::add_document($_course, $current_path . '/' . $safe_file, 'file', $size, $title);
                     api_item_property_update($_course, TOOL_DOCUMENT, $document_id, 'DocumentAdded', $user_id, $to_group_id, null, null, null, $current_session_id);
                     //echo $current_path.'/'.$safe_file.' added!<br />';
                 } else {
                     api_item_property_update($_course, TOOL_DOCUMENT, $document_id, 'DocumentUpdated', $user_id, $to_group_id, null, null, null, $current_session_id);
                 }
             }
         }
     }
 }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:51,代码来源:fileManager.lib.php

示例14: build_edit_icons

/**
 * Creates the row of edit icons for a file/folder
 *
 * @param string $curdirpath current path (cfr open folder)
 * @param string $type (file/folder)
 * @param string $path dbase path of file/folder
 * @param int $visibility (1/0)
 * @param int $id dbase id of the document
 * @return string html img tags with hyperlinks
 */
function build_edit_icons($document_data, $id, $is_template, $is_read_only = 0, $visibility)
{
    if (isset($_SESSION['_gid'])) {
        $req_gid = '&gidReq=' . $_SESSION['_gid'];
    } else {
        $req_gid = '';
    }
    $document_id = $document_data['id'];
    $type = $document_data['filetype'];
    $is_read_only = $document_data['readonly'];
    $path = $document_data['path'];
    $parent_id = DocumentManager::get_document_id(api_get_course_info(), dirname($path));
    $curdirpath = dirname($document_data['path']);
    $is_certificate_mode = DocumentManager::is_certificate_mode($path);
    $curdirpath = urlencode($curdirpath);
    $extension = pathinfo($path, PATHINFO_EXTENSION);
    // Build URL-parameters for table-sorting
    $sort_params = array();
    if (isset($_GET['column'])) {
        $sort_params[] = 'column=' . Security::remove_XSS($_GET['column']);
    }
    if (isset($_GET['page_nr'])) {
        $sort_params[] = 'page_nr=' . Security::remove_XSS($_GET['page_nr']);
    }
    if (isset($_GET['per_page'])) {
        $sort_params[] = 'per_page=' . Security::remove_XSS($_GET['per_page']);
    }
    if (isset($_GET['direction'])) {
        $sort_params[] = 'direction=' . Security::remove_XSS($_GET['direction']);
    }
    $sort_params = implode('&amp;', $sort_params);
    $visibility_icon = $visibility == 0 ? 'invisible' : 'visible';
    $visibility_command = $visibility == 0 ? 'set_visible' : 'set_invisible';
    $modify_icons = '';
    // If document is read only *or* we're in a session and the document
    // is from a non-session context, hide the edition capabilities
    if ($is_read_only) {
        if (api_is_course_admin() || api_is_platform_admin()) {
            if ($extension == 'svg' && api_browser_support('svg') && api_get_setting('enabled_support_svg') == 'true') {
                $modify_icons = '<a href="edit_draw.php?' . api_get_cidreq() . '&id=' . $document_id . $req_gid . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
            } elseif ($extension == 'png' || $extension == 'jpg' || $extension == 'jpeg' || $extension == 'bmp' || $extension == 'gif' || $extension == 'pxd' && api_get_setting('enabled_support_pixlr') == 'true') {
                $modify_icons = '<a href="edit_paint.php?' . api_get_cidreq() . '&id=' . $document_id . $req_gid . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
            } else {
                $modify_icons = '<a href="edit_document.php?' . api_get_cidreq() . '&id=' . $document_id . $req_gid . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
            }
        } else {
            $modify_icons = Display::return_icon('edit_na.png', get_lang('Modify'), '', ICON_SIZE_SMALL);
        }
        $modify_icons .= '&nbsp;' . Display::return_icon('move_na.png', get_lang('Move'), array(), ICON_SIZE_SMALL);
        if (api_is_allowed_to_edit() || api_is_platform_admin()) {
            $modify_icons .= '&nbsp;' . Display::return_icon($visibility_icon . '.png', get_lang('VisibilityCannotBeChanged'), '', ICON_SIZE_SMALL);
        }
        $modify_icons .= '&nbsp;' . Display::return_icon('delete_na.png', get_lang('Delete'), array(), ICON_SIZE_SMALL);
    } else {
        //Edit button
        if (in_array($path, DocumentManager::get_system_folders())) {
            $modify_icons = Display::return_icon('edit_na.png', get_lang('Modify'), '', ICON_SIZE_SMALL);
        } elseif ($is_certificate_mode) {
            // gradebook category doesn't seem to be taken into account
            $modify_icons = '<a href="edit_document.php?' . api_get_cidreq() . '&amp;id=' . $document_id . $req_gid . '&curdirpath=/certificates">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
        } else {
            if (api_get_session_id()) {
                if ($document_data['session_id'] == api_get_session_id()) {
                    if ($extension == 'svg' && api_browser_support('svg') && api_get_setting('enabled_support_svg') == 'true') {
                        $modify_icons = '<a href="edit_draw.php?' . api_get_cidreq() . '&amp;id=' . $document_id . $req_gid . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
                    } elseif ($extension == 'png' || $extension == 'jpg' || $extension == 'jpeg' || $extension == 'bmp' || $extension == 'gif' || $extension == 'pxd' && api_get_setting('enabled_support_pixlr') == 'true') {
                        $modify_icons = '<a href="edit_paint.php?' . api_get_cidreq() . '&amp;id=' . $document_id . $req_gid . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
                    } else {
                        $modify_icons = '<a href="edit_document.php?' . api_get_cidreq() . '&amp;id=' . $document_id . $req_gid . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
                    }
                } else {
                    $modify_icons .= '&nbsp;' . Display::return_icon('edit_na.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>';
                }
            } else {
                if ($extension == 'svg' && api_browser_support('svg') && api_get_setting('enabled_support_svg') == 'true') {
                    $modify_icons = '<a href="edit_draw.php?' . api_get_cidreq() . '&amp;id=' . $document_id . $req_gid . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
                } elseif ($extension == 'png' || $extension == 'jpg' || $extension == 'jpeg' || $extension == 'bmp' || $extension == 'gif' || $extension == 'pxd' && api_get_setting('enabled_support_pixlr') == 'true') {
                    $modify_icons = '<a href="edit_paint.php?' . api_get_cidreq() . '&amp;id=' . $document_id . $req_gid . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
                } else {
                    $modify_icons = '<a href="edit_document.php?' . api_get_cidreq() . '&amp;id=' . $document_id . $req_gid . '">' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
                }
            }
        }
        //Move button
        if ($is_certificate_mode || in_array($path, DocumentManager::get_system_folders())) {
            $modify_icons .= '&nbsp;' . Display::return_icon('move_na.png', get_lang('Move'), array(), ICON_SIZE_SMALL) . '</a>';
        } else {
            if (api_get_session_id()) {
                if ($document_data['session_id'] == api_get_session_id()) {
                    $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;id=' . $parent_id . '&amp;move=' . $document_id . $req_gid . '">' . Display::return_icon('move.png', get_lang('Move'), array(), ICON_SIZE_SMALL) . '</a>';
//.........这里部分代码省略.........
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:101,代码来源:document.inc.php

示例15: showQuestion


//.........这里部分代码省略.........
                            $lines_count++;
                        }
                        // end while()
                    }
                    // end if()
                    $matching_correct_answer++;
                }
            }
        }
        // end for()
        if ($show_comment) {
            $s .= '</table>';
        } else {
            if ($answerType == MATCHING || $answerType == UNIQUE_ANSWER_NO_OPTION || $answerType == MULTIPLE_ANSWER_TRUE_FALSE || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
                $s .= '</table>';
            }
        }
        $s .= '</div>';
        // destruction of the Answer object
        unset($objAnswerTmp);
        // destruction of the Question object
        unset($objQuestionTmp);
        if ($origin != 'export') {
            echo $s;
        } else {
            return $s;
        }
    } elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_DELINEATION) {
        // Question is a HOT_SPOT
        //checking document/images visibility
        if (api_is_platform_admin() || api_is_course_admin()) {
            require_once api_get_path(LIBRARY_PATH) . 'document.lib.php';
            $course = api_get_course_info();
            $doc_id = DocumentManager::get_document_id($course, '/images/' . $pictureName);
            if (is_numeric($doc_id)) {
                $images_folder_visibility = api_get_item_visibility($course, 'document', $doc_id, api_get_session_id());
                if (!$images_folder_visibility) {
                    //This message is shown only to the course/platform admin if the image is set to visibility = false
                    Display::display_warning_message(get_lang('ChangeTheVisibilityOfTheCurrentImage'));
                }
            }
        }
        $questionName = $objQuestionTmp->selectTitle();
        $questionDescription = $objQuestionTmp->selectDescription();
        if ($freeze) {
            echo Display::img($objQuestionTmp->selectPicturePath());
            return;
        }
        // Get the answers, make a list
        $objAnswerTmp = new Answer($questionId);
        $nbrAnswers = $objAnswerTmp->selectNbrAnswers();
        // get answers of hotpost
        $answers_hotspot = array();
        for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
            $answers = $objAnswerTmp->selectAnswerByAutoId($objAnswerTmp->selectAutoId($answerId));
            $answers_hotspot[$answers['id']] = $objAnswerTmp->selectAnswer($answerId);
        }
        // display answers of hotpost order by id
        $answer_list = '<div style="padding: 10px; margin-left: 0px; border: 1px solid #A4A4A4; height: 408px; width: 200px;"><b>' . get_lang('HotspotZones') . '</b><dl>';
        if (!empty($answers_hotspot)) {
            ksort($answers_hotspot);
            foreach ($answers_hotspot as $key => $value) {
                $answer_list .= '<dt>' . $key . '.- ' . $value . '</dt><br />';
            }
        }
        $answer_list .= '</dl></div>';
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:67,代码来源:exercise.lib.php


注:本文中的DocumentManager::get_document_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。