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


PHP DocumentManager::get_document_data_by_id方法代码示例

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


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

示例1: set_time_limit

set_time_limit(0);
//require_once '../inc/global.inc.php';
api_protect_course_script();
$sysCoursePath = api_get_path(SYS_COURSE_PATH);
$courseInfo = api_get_course_info();
$courseId = api_get_course_int_id();
$sessionId = api_get_session_id();
$groupId = api_get_group_id();
$courseCode = api_get_course_id();
// Check if folder exists in current course.
$documentInfo = DocumentManager::get_document_data_by_id($_GET['id'], $courseCode, false, 0);
if (!empty($sessionId)) {
    /* If no data found and session id exists
       try to look the file inside the session */
    if (empty($documentInfo)) {
        $documentInfo = DocumentManager::get_document_data_by_id($_GET['id'], $courseCode, false, $sessionId);
    }
}
$path = $documentInfo['path'];
if (empty($path)) {
    $path = '/';
}
// A student should not be able to download a root shared directory
if (($path == '/shared_folder' || $path == '/shared_folder_session_' . api_get_session_id()) && (!api_is_allowed_to_edit() || !api_is_platform_admin())) {
    api_not_allowed(true);
    exit;
}
// Creating a ZIP file.
$tempZipFile = api_get_path(SYS_ARCHIVE_PATH) . api_get_unique_id() . ".zip";
$zip = new PclZip($tempZipFile);
$doc_table = Database::get_course_table(TABLE_DOCUMENT);
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:downloadfolder.inc.php

示例2: scorm_export_to_pdf

 public function scorm_export_to_pdf($lp_id)
 {
     $lp_id = intval($lp_id);
     $files_to_export = array();
     $course_data = api_get_course_info($this->cc);
     if (!empty($course_data)) {
         $scorm_path = api_get_path(SYS_COURSE_PATH) . $course_data['path'] . '/scorm/' . $this->path;
         $list = self::get_flat_ordered_items_list($lp_id);
         if (!empty($list)) {
             foreach ($list as $item_id) {
                 $item = $this->items[$item_id];
                 switch ($item->type) {
                     case 'document':
                         //Getting documents from a LP with chamilo documents
                         $file_data = DocumentManager::get_document_data_by_id($item->path, $this->cc);
                         $file_path = api_get_path(SYS_COURSE_PATH) . $course_data['path'] . '/document' . $file_data['path'];
                         if (file_exists($file_path)) {
                             $files_to_export[] = array('title' => $item->get_title(), 'path' => $file_path);
                         }
                         break;
                     case 'asset':
                         //commes from a scorm package generated by chamilo
                     //commes from a scorm package generated by chamilo
                     case 'sco':
                         $file_path = $scorm_path . '/' . $item->path;
                         if (file_exists($file_path)) {
                             $files_to_export[] = array('title' => $item->get_title(), 'path' => $file_path);
                         }
                         break;
                     case 'dokeos_chapter':
                     case 'dir':
                     case 'chapter':
                         $files_to_export[] = array('title' => $item->get_title(), 'path' => null);
                         break;
                 }
             }
         }
         $pdf = new PDF();
         $result = $pdf->html_to_pdf($files_to_export, $this->name, $this->cc, true);
         return $result;
     }
     return false;
 }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:43,代码来源:learnpath.class.php

示例3: create_unexisting_directory

    $dir = $sys_course_path . $course_dir;
    $createdDir = create_unexisting_directory(
        $courseInfo,
        api_get_user_id(),
        api_get_session_id(),
        null,
        null,
        $dir,
        '/'.$folderName,
        $folderName
    );
    if ($createdDir) {
        $path = '/'.$folderName;
    }
} else {
    $data = DocumentManager::get_document_data_by_id($documentId, $courseInfo['code']);
    $path = $data['path'];
}

if (empty($path)) {
    exit;
}

$files = array(
    'file' => $_FILES['Filedata']
);

DocumentManager::upload_document(
    $files,
    $path,
    $_FILES['Filedata']['name'],
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:31,代码来源:upload.php

示例4: api_get_path

        }
    );
});
</script>';
$_SESSION['whereami'] = 'document/create';
$this_section = SECTION_COURSES;
$lib_path = api_get_path(LIBRARY_PATH);
require_once api_get_path(SYS_CODE_PATH) . 'document/document.inc.php';
$course_info = api_get_course_info();
$group_id = api_get_group_id();
if (api_is_in_group()) {
    $group_properties = GroupManager::get_group_properties($group_id);
}
$dir = '/';
if (isset($_GET['id'])) {
    $document_data = DocumentManager::get_document_data_by_id($_GET['id'], api_get_course_id(), true);
    $document_id = $document_data['id'];
    $file = $document_data['path'];
    $parent_id = DocumentManager::get_document_id($course_info, dirname($file));
    $dir = dirname($document_data['path']);
    $dir_original = $dir;
    $doc = basename($file);
    $my_cur_dir_path = isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : null;
    $readonly = $document_data['readonly'];
}
if (empty($document_data)) {
    api_not_allowed();
}
$is_certificate_mode = DocumentManager::is_certificate_mode($dir);
//Call from
$call_from_tool = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : null;
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:31,代码来源:edit_document.php

示例5: WSDeleteLp

/**
 * @param array $params
 * @return int|string
 */
function WSDeleteLp($params)
{
    global $debug;
    if (!WSHelperVerifyKey($params)) {
        return return_error(WS_ERROR_SECRET_KEY);
    }
    require_once api_get_path(SYS_CODE_PATH) . 'newscorm/learnpathList.class.php';
    require_once api_get_path(SYS_CODE_PATH) . 'newscorm/learnpath.class.php';
    require_once api_get_path(SYS_CODE_PATH) . 'newscorm/learnpathItem.class.php';
    $courseIdName = $params['course_id_name'];
    $courseIdValue = $params['course_id_value'];
    $lpId = $params['lp_id'];
    $sessionIdName = isset($params['session_id_name']) ? $params['session_id_name'] : null;
    $sessionIdValue = isset($params['session_id_value']) ? $params['session_id_value'] : null;
    $courseInfo = CourseManager::getCourseInfoFromOriginalId($courseIdValue, $courseIdName);
    if (empty($courseInfo)) {
        if ($debug) {
            error_log("Course not found: {$courseIdName} : {$courseIdValue}");
        }
        return 'Course not found';
    }
    $courseId = $courseInfo['real_id'];
    $courseCode = $courseInfo['code'];
    $sessionId = 0;
    /*
    if (!empty($sessionIdName) && !empty($sessionIdValue)) {
        $sessionId = SessionManager::get_session_id_from_original_id(
            $sessionIdValue,
            $sessionIdName
        );
    
        if (empty($sessionId)) {
    
            if ($debug) error_log('Session not found');
            return 'Session not found';
        }
    }
    */
    $lp = new learnpath($courseCode, $lpId, null);
    if ($lp) {
        if ($debug) {
            error_log("LP deleted {$lpId}");
        }
        $course_dir = $courseInfo['directory'] . '/document';
        $sys_course_path = api_get_path(SYS_COURSE_PATH);
        $base_work_dir = $sys_course_path . $course_dir;
        $items = $lp->get_flat_ordered_items_list($lpId, 0, $courseId);
        if (!empty($items)) {
            /** @var $item learnpathItem */
            foreach ($items as $itemId) {
                $item = new learnpathItem($itemId, null, $courseId);
                if ($item) {
                    $documentId = $item->get_path();
                    if ($debug) {
                        error_log("lp item id found #{$itemId}");
                    }
                    $documentInfo = DocumentManager::get_document_data_by_id($documentId, $courseInfo['code'], false, $sessionId);
                    if (!empty($documentInfo)) {
                        if ($debug) {
                            error_log("Document id deleted #{$documentId}");
                        }
                        DocumentManager::delete_document($courseInfo, null, $base_work_dir, $sessionId, $documentId);
                    } else {
                        if ($debug) {
                            error_log("No document found for id #{$documentId}");
                        }
                    }
                } else {
                    if ($debug) {
                        error_log("Document not found #{$itemId}");
                    }
                }
            }
        }
        $lp->delete($courseInfo, $lpId, 'remove');
        return 1;
    }
    return 0;
}
开发者ID:daffef,项目名称:chamilo-lms,代码行数:83,代码来源:lp.php

示例6: pathinfo

            if (isset($_FILES["{$type}-blob"])) {
                $fileName = $_POST["{$type}-filename"];
                //$file = $_FILES["${type}-blob"]["tmp_name"];
                $file = $_FILES["{$type}-blob"];
                $fileInfo = pathinfo($fileName);
                $file['name'] = 'rec_' . date('Y-m-d_His') . '_' . uniqid() . '.' . $fileInfo['extension'];
                $file['file'] = $file;
                $lpPathInfo['dir'] = api_remove_trailing_slash($lpPathInfo['dir']);
                $result = DocumentManager::upload_document($file, $lpPathInfo['dir'], $file['name'], null, 0, 'overwrite', false, false);
                if (!empty($result) && is_array($result)) {
                    $newDocId = $result['id'];
                    $courseId = $result['c_id'];
                    $lp->set_modified_on();
                    $lpItem = new learnpathItem($_REQUEST['lp_item_id']);
                    $lpItem->add_audio_from_documents($newDocId);
                    $data = DocumentManager::get_document_data_by_id($newDocId, $course_info['code']);
                    echo $data['document_url'];
                    exit;
                }
            }
        }
        break;
    default:
        echo '';
}
exit;
/*
 * Classes to create a special data structure to manipulate LP Items
 * used only in this file
 * @todo move in a file
 */
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:31,代码来源:lp.ajax.php

示例7: pathinfo

<?php

/* For licensing terms, see /license.txt */
/**
 * ODF document editor script (maybe unused)
 * @package chamilo.document
 */
/**
 * Init
 */
require_once '../inc/global.inc.php';
exit;
$document_id = $_GET['id'];
if ($document_id) {
    $document_data = DocumentManager::get_document_data_by_id($document_id);
    if (empty($document_data)) {
        api_not_allowed();
    }
} else {
    api_not_allowed();
}
//Check user visibility
//$is_visible = DocumentManager::is_visible_by_id($document_id, $course_info, api_get_session_id(), api_get_user_id());
$is_visible = DocumentManager::check_visibility_tree($document_id, api_get_course_id(), api_get_session_id(), api_get_user_id());
if (!api_is_allowed_to_edit() && !$is_visible) {
    api_not_allowed(true);
}
$header_file = $document_data['path'];
$pathinfo = pathinfo($header_file);
$show_web_odf = false;
$web_odf_supported_files = DocumentManager::get_web_odf_extension_list();
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:edit_odf.php

示例8: api_get_course_id

<?php

/* For licensing terms, see /license.txt */
/**
 * ODF document editor script (maybe unused)
 * @package chamilo.document
 */
require_once '../inc/global.inc.php';
//exit;
$document_id = $_GET['id'];
$courseCode = api_get_course_id();
if ($document_id) {
    $document_data = DocumentManager::get_document_data_by_id($document_id, $courseCode);
    if (empty($document_data)) {
        api_not_allowed();
    }
} else {
    api_not_allowed();
}
//Check user visibility
//$is_visible = DocumentManager::is_visible_by_id($document_id, $course_info, api_get_session_id(), api_get_user_id());
$is_visible = DocumentManager::check_visibility_tree($document_id, api_get_course_id(), api_get_session_id(), api_get_user_id(), api_get_group_id());
if (!api_is_allowed_to_edit() && !$is_visible) {
    api_not_allowed(true);
}
$header_file = $document_data['path'];
$pathinfo = pathinfo($header_file);
$show_web_odf = false;
$web_odf_supported_files = DocumentManager::get_web_odf_extension_list();
if (in_array(strtolower($pathinfo['extension']), $web_odf_supported_files)) {
    $show_web_odf = true;
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:31,代码来源:edit_odf.php

示例9: api_get_path

// Including additional libraries
require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
// Adding extra javascript to the form
//$htmlHeadXtra[] = api_get_jquery_libraries_js(array('jquery-ui', 'jquery-upload'));
// Variables
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$_course = api_get_course_info();
$groupId = api_get_group_id();
$courseDir = $_course['path'] . '/document';
$sys_course_path = api_get_path(SYS_COURSE_PATH);
$base_work_dir = $sys_course_path . $courseDir;
$sessionId = api_get_session_id();
$selectcat = isset($_GET['selectcat']) ? Security::remove_XSS($_GET['selectcat']) : null;
$document_data = DocumentManager::get_document_data_by_id($_REQUEST['id'], api_get_course_id(), true, $sessionId);
if ($sessionId != 0 && !$document_data) {
    $document_data = DocumentManager::get_document_data_by_id($_REQUEST['id'], api_get_course_id(), true, 0);
}
if (empty($document_data)) {
    $document_id = $parent_id = 0;
    $path = '/';
} else {
    $document_id = $document_data['id'];
    $path = $document_data['path'];
    $parent_id = DocumentManager::get_document_id(api_get_course_info(), dirname($path));
}
$group_properties = array();
$htmlHeadXtra[] = '<script>

function check_unzip() {
    if (document.upload.unzip.checked){
        document.upload.if_exists[0].disabled=true;
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:31,代码来源:upload.php

示例10: api_get_course_id

 // Create directory with $_POST data
 if (isset($_POST['create_dir']) && $_POST['dirname'] != '') {
     // Needed for directory creation
     $post_dir_name = $_POST['dirname'];
     if ($post_dir_name == '../' || $post_dir_name == '.' || $post_dir_name == '..') {
         $message = Display::return_message(get_lang('CannotCreateDir'), 'error');
     } else {
         // dir_id is the parent folder id.
         if (!empty($_POST['dir_id'])) {
             // Get the document data from the ID
             $document_data = DocumentManager::get_document_data_by_id($_POST['dir_id'], api_get_course_id(), false, $sessionId);
             if ($sessionId != 0 && !$document_data) {
                 // If there is a session defined and asking for the
                 // document * from the session* didn't work, try it from
                 // the course (out of a session context)
                 $document_data = DocumentManager::get_document_data_by_id($_POST['dir_id'], api_get_course_id(), false, 0);
             }
             $curdirpath = $document_data['path'];
         }
         $added_slash = $curdirpath == '/' ? '' : '/';
         $dir_name = $curdirpath . $added_slash . api_replace_dangerous_char($post_dir_name);
         $dir_name = disable_dangerous_file($dir_name);
         $dir_check = $base_work_dir . $dir_name;
         $visibility = empty($groupId) ? null : 1;
         $newFolderData = create_unexisting_directory($courseInfo, api_get_user_id(), $sessionId, $groupId, $to_user_id, $base_work_dir, $dir_name, $post_dir_name, $visibility);
         if (!empty($newFolderData)) {
             $message = Display::return_message(get_lang('DirCr') . ' ' . $newFolderData['title'], 'confirmation');
         } else {
             $message = Display::return_message(get_lang('CannotCreateDir'), 'error');
         }
     }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:document.php

示例11: create_unexisting_directory

/**
 * Creates a new directory trying to find a directory name
 * that doesn't already exist
 * (we could use unique_name() here...)
 *
 * @author  Hugues Peeters <hugues.peeters@claroline.net>
 * @author  Bert Vanderkimpen
 * @param   array   $_course current course information
 * @param   int     $user_id current user id
 * @param   int     $session_id
 * @param   int     $to_group_id
 * @param   int     $to_user_id
 * @param   string  $base_work_dir /var/www/chamilo/courses/ABC/document
 * @param   string  $desired_dir_name complete path of the desired name
 * Example: /folder1/folder2
 * @param   string  $title "folder2"
 * @param   int     $visibility (0 for invisible, 1 for visible, 2 for deleted)
 * @param   bool $generateNewNameIfExists
 * @return  string  actual directory name if it succeeds,
 *          boolean false otherwise
 */
function create_unexisting_directory($_course, $user_id, $session_id, $to_group_id, $to_user_id, $base_work_dir, $desired_dir_name, $title = null, $visibility = null, $generateNewNameIfExists = false)
{
    $course_id = $_course['real_id'];
    $session_id = intval($session_id);
    $folderExists = DocumentManager::folderExists($desired_dir_name, $_course, $session_id, $to_group_id);
    if ($folderExists == true) {
        if ($generateNewNameIfExists) {
            $counter = 1;
            while (1) {
                $folderExists = DocumentManager::folderExists($desired_dir_name . '_' . $counter, $_course, $session_id, $to_group_id);
                if ($folderExists == false) {
                    break;
                }
                $counter++;
            }
            $desired_dir_name = $desired_dir_name . '_' . $counter;
        } else {
            return false;
        }
    }
    $systemFolderName = $desired_dir_name;
    // Adding suffix
    $suffix = DocumentManager::getDocumentSuffix($_course, $session_id, $to_group_id);
    $systemFolderName .= $suffix;
    if ($title == null) {
        $title = basename($desired_dir_name);
    }
    if (!is_dir($base_work_dir . $systemFolderName)) {
        $result = mkdir($base_work_dir . $systemFolderName, api_get_permissions_for_new_directories(), true);
        if ($result) {
            // Check if pathname already exists inside document table
            $tbl_document = Database::get_course_table(TABLE_DOCUMENT);
            $sql = "SELECT id, path FROM {$tbl_document}\n                    WHERE\n                        c_id = {$course_id} AND\n                        (\n                            path = '" . $systemFolderName . "'\n                        )\n            ";
            $rs = Database::query($sql);
            if (Database::num_rows($rs) == 0) {
                $document_id = add_document($_course, $systemFolderName, 'folder', 0, $title, null, 0, true, $to_group_id);
                if ($document_id) {
                    // Update document item_property
                    if (!empty($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, $session_id);
                    } else {
                        api_item_property_update($_course, TOOL_DOCUMENT, $document_id, 'FolderCreated', $user_id, $to_group_id, $to_user_id, null, null, $session_id);
                    }
                    $documentData = DocumentManager::get_document_data_by_id($document_id, $_course['code'], false, $session_id);
                    return $documentData;
                }
            } else {
                $document = Database::fetch_array($rs);
                $documentData = DocumentManager::get_document_data_by_id($document['id'], $_course['code'], false, $session_id);
                /* This means the folder NOT exist in the filesystem
                   (now this was created) but there is a record in the Database*/
                return $documentData;
            }
        }
    }
    return false;
}
开发者ID:daffef,项目名称:chamilo-lms,代码行数:79,代码来源:fileUpload.lib.php

示例12: getAllDocumentsFromWorkToString

/**
 * @param int $workId
 * @param array $courseInfo
 * @return string
 */
function getAllDocumentsFromWorkToString($workId, $courseInfo)
{
    $documents = getAllDocumentToWork($workId, $courseInfo['real_id']);
    $content = null;
    if (!empty($documents)) {
        $content .= '<ul class="nav nav-list well">';
        $content .= '<li class="nav-header">'.get_lang('Documents').'</li>';
        foreach ($documents as $doc) {
            $docData = DocumentManager::get_document_data_by_id($doc['document_id'], $courseInfo['code']);
            if ($docData) {
                $content .= '<li><a target="_blank" href="'.$docData['url'].'">'.$docData['title'].'</a></li>';
            }
        }
        $content .= '</ul><br />';
    }
    return $content;
}
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:22,代码来源:work.lib.php

示例13: rl_get_resource_link_for_learnpath

 /**
  * Returns an HTML-formatted link to a resource, to incorporate directly into
  * the new learning path tool.
  *
  * The function is a big switch on tool type.
  * In each case, we query the corresponding table for information and build the link
  * with that information.
  * @author	Yannick Warnier <ywarnier@beeznest.org> - rebranding based on previous work (display_addedresource_link_in_learnpath())
  * @param	int	$course_id Course code
  * @param	int $learnpath_id The learning path ID (in lp table)
  * @param   int $id_in_path the unique index in the items table
  * @param int $lpViewId
  */
 public static function rl_get_resource_link_for_learnpath($course_id, $learnpath_id, $id_in_path, $lpViewId)
 {
     $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
     $course_info = api_get_course_info_by_id($course_id);
     $course_id = $course_info['real_id'];
     $course_code = $course_info['code'];
     $session_id = api_get_session_id();
     $learnpath_id = intval($learnpath_id);
     $id_in_path = intval($id_in_path);
     $lpViewId = intval($lpViewId);
     $sql = "SELECT * FROM {$tbl_lp_item}\n             WHERE\n                c_id = {$course_id} AND\n                lp_id = {$learnpath_id} AND\n                id = {$id_in_path}\n            ";
     $res_item = Database::query($sql);
     if (Database::num_rows($res_item) < 1) {
         return -1;
     }
     $row_item = Database::fetch_array($res_item, 'ASSOC');
     $type = strtolower($row_item['item_type']);
     $id = strcmp($row_item['path'], '') == 0 ? '0' : $row_item['path'];
     $origin = 'learnpath';
     $main_dir_path = api_get_path(WEB_CODE_PATH);
     $main_course_path = api_get_path(WEB_COURSE_PATH) . $course_info['directory'] . '/';
     $link = '';
     switch ($type) {
         case 'dokeos_chapter':
             $link .= $main_dir_path . 'newscorm/blank.php';
         case TOOL_CALENDAR_EVENT:
             $link .= $main_dir_path . 'calendar/agenda.php?origin=' . $origin . '&agenda_id=' . $id;
             break;
         case TOOL_ANNOUNCEMENT:
             $link .= $main_dir_path . 'announcements/announcements.php?origin=' . $origin . '&ann_id=' . $id;
             break;
         case TOOL_LINK:
             $TABLETOOLLINK = Database::get_course_table(TABLE_LINK);
             $result = Database::query("SELECT * FROM {$TABLETOOLLINK} WHERE c_id = {$course_id} AND id={$id}");
             $myrow = Database::fetch_array($result);
             $thelink = $myrow["url"];
             $link .= $thelink;
             break;
         case TOOL_QUIZ:
             if (!empty($id)) {
                 $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
                 $sql = "SELECT * FROM {$TBL_EXERCICES} WHERE c_id = {$course_id} AND id={$id}";
                 $result = Database::query($sql);
                 $myrow = Database::fetch_array($result);
                 if ($row_item['title'] != '') {
                     $myrow['title'] = $row_item['title'];
                 }
                 $link .= $main_dir_path . 'exercice/overview.php?cidReq=' . $course_code . '&session_id=' . $session_id . '&lp_init=1&origin=' . $origin . '&learnpath_id=' . $learnpath_id . '&learnpath_item_id=' . $id_in_path . '&exerciseId=' . $id;
             }
             break;
         case 'hotpotatoes':
             //lowercase because of strtolower above
             $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
             $result = Database::query("SELECT * FROM " . $TBL_DOCUMENT . " WHERE c_id = {$course_id} AND id={$id}");
             $myrow = Database::fetch_array($result);
             $path = $myrow['path'];
             $link .= $main_dir_path . 'exercice/showinframes.php?file=' . $path . '' . '&origin=' . $origin . '&cid=' . $course_code . '&uid=' . api_get_user_id() . '' . '&learnpath_id=' . $learnpath_id . '&learnpath_item_id=' . $id_in_path . '&lp_view_id=' . $lpViewId;
             break;
         case TOOL_FORUM:
             $link .= $main_dir_path . 'forum/viewforum.php?forum=' . $id . '&lp=true&origin=learnpath';
             break;
         case TOOL_THREAD:
             //forum post
             $tbl_topics = Database::get_course_table(TABLE_FORUM_THREAD);
             if (!empty($id)) {
                 $sql = "SELECT * FROM {$tbl_topics} WHERE c_id = {$course_id} AND thread_id={$id}";
                 $result = Database::query($sql);
                 $myrow = Database::fetch_array($result);
                 $link .= $main_dir_path . 'forum/viewthread.php?origin=learnpath&thread=' . $id . '' . '&forum=' . $myrow['forum_id'] . '&lp=true';
             }
             break;
         case TOOL_POST:
             $tbl_post = Database::get_course_table(TABLE_FORUM_POST);
             $result = Database::query("SELECT * FROM {$tbl_post} WHERE c_id = {$course_id} AND post_id={$id}");
             $myrow = Database::fetch_array($result);
             $title = $myrow['post_title'];
             //$desc = $row_item['description'];
             $posternom = $myrow['poster_name'];
             $posttime = $myrow['post_date'];
             $posttext = $myrow['post_text'];
             $posttitle = $title;
             $posttext = str_replace('"', "'", $posttext);
             $link .= $main_dir_path . 'forum/viewthread.php?post=' . $id . '' . '&thread=' . $myrow['thread_id'] . '&forum=' . $myrow['forum_id'] . '' . '&lp=true';
             break;
         case TOOL_DOCUMENT:
             $documentInfo = DocumentManager::get_document_data_by_id($id, $course_code, true, $session_id);
             $documentPathInfo = pathinfo($documentInfo['absolute_path']);
//.........这里部分代码省略.........
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:101,代码来源:learnpath.class.php

示例14: generateDefaultCertificate

 /**
  * Generate a default certificate for a courses
  *
  * @global string $css CSS directory
  * @global string $img_dir image directory
  * @global string $default_course_dir Course directory
  * @global string $js JS directory
  * @param array $courseData The course info
  * @param bool $fromBaseCourse
  * @param int $sessionId
  */
 public static function generateDefaultCertificate($courseData, $fromBaseCourse = false, $sessionId = 0)
 {
     global $css, $img_dir, $default_course_dir, $js;
     $codePath = api_get_path(REL_CODE_PATH);
     $dir = '/certificates';
     $title = get_lang('DefaultCertificate');
     $comment = null;
     $fileName = api_replace_dangerous_char($title);
     $filePath = api_get_path(SYS_COURSE_PATH) . "{$courseData['path']}/document{$dir}";
     $fileFullPath = "{$filePath}/{$fileName}.html";
     $fileSize = 0;
     $fileType = 'file';
     $templateContent = file_get_contents(api_get_path(SYS_CODE_PATH) . 'gradebook/certificate_template/template.html');
     $search = array('{CSS}', '{IMG_DIR}', '{REL_CODE_PATH}', '{COURSE_DIR}');
     $replace = array($css . $js, $img_dir, $codePath, $default_course_dir);
     $fileContent = str_replace($search, $replace, $templateContent);
     $saveFilePath = "{$dir}/{$fileName}.html";
     if (!is_dir($filePath)) {
         mkdir($filePath, api_get_permissions_for_new_directories());
     }
     if ($fromBaseCourse) {
         $defaultCertificateId = self::get_default_certificate_id($courseData['code'], 0);
         if (!empty($defaultCertificateId)) {
             // We have a certificate from the course base
             $documentData = DocumentManager::get_document_data_by_id($defaultCertificateId, $courseData['code'], false, 0);
             if ($documentData) {
                 $fileContent = file_get_contents($documentData['absolute_path']);
             }
         }
     }
     $defaultCertificateFile = $fp = @fopen($fileFullPath, 'w');
     if ($defaultCertificateFile != false) {
         @fputs($defaultCertificateFile, $fileContent);
         fclose($defaultCertificateFile);
         chmod($fileFullPath, api_get_permissions_for_new_files());
         $fileSize = filesize($fileFullPath);
     }
     $documentId = add_document($courseData, $saveFilePath, $fileType, $fileSize, $title, $comment, 0, true, null, $sessionId);
     api_item_property_update($courseData, TOOL_DOCUMENT, $documentId, 'DocumentAdded', api_get_user_id(), null, null, null, null, $sessionId);
     $defaultCertificateId = self::get_default_certificate_id($courseData['code'], $sessionId);
     if (!isset($defaultCertificateId)) {
         self::attach_gradebook_certificate($courseData['code'], $documentId, $sessionId);
     }
 }
开发者ID:daffef,项目名称:chamilo-lms,代码行数:55,代码来源:document.lib.php

示例15: isset

$header_file = isset($_GET['file']) ? Security::remove_XSS($_GET['file']) : null;
$document_id = intval($_GET['id']);
$courseInfo = api_get_course_info();
$course_code = api_get_course_id();
$session_id = api_get_session_id();
if (empty($courseInfo)) {
    api_not_allowed(true);
}
$show_web_odf = false;
// Generate path
if (!$document_id) {
    $document_id = DocumentManager::get_document_id($courseInfo, $header_file);
}
$document_data = DocumentManager::get_document_data_by_id($document_id, $course_code, true, $session_id);
if ($session_id != 0 and !$document_data) {
    $document_data = DocumentManager::get_document_data_by_id($document_id, $course_code, true, 0);
}
if (empty($document_data)) {
    api_not_allowed(true);
}
$header_file = $document_data['path'];
$name_to_show = $document_data['title'];
$path_array = explode('/', str_replace('\\', '/', $header_file));
$path_array = array_map('urldecode', $path_array);
$header_file = implode('/', $path_array);
$file = Security::remove_XSS(urldecode($document_data['path']));
$file_root = $courseInfo['path'] . '/document' . str_replace('%2F', '/', $file);
$file_url_sys = api_get_path(SYS_COURSE_PATH) . $file_root;
$file_url_web = api_get_path(WEB_COURSE_PATH) . $file_root;
if (!file_exists($file_url_sys)) {
    api_not_allowed(true);
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:31,代码来源:showinframes.php


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