} } // else anonymous : record nothing ! // Get info about launched module $module = Database::get()->querySingle("SELECT `contentType`, `startAsset_id`, `name`\n FROM `lp_module`\n WHERE `module_id` = ?d\n AND `course_id` = ?d", $_SESSION['lp_module_id'], $course_id); $assetPath = Database::get()->querySingle("SELECT `path` FROM `lp_asset` WHERE `asset_id` = ?d", $module->startAsset_id)->path; // Get path of file of the starting asset to launch switch ($module->contentType) { case CTDOCUMENT_: if ($uid) { // Directly pass this module directly_pass_lp_module($TABLEUSERMODULEPROGRESS, (int) $uid, (int) $learnPathModuleId); } // else anonymous : record nothing $file_url = file_url($assetPath); $play_url = file_playurl($assetPath); $furl = $file_url; if (MultimediaHelper::isSupportedMedia($module->name)) { $furl = $play_url; } $moduleStartAssetPage = $furl; break; case CTEXERCISE_: // clean session vars of exercise unset($_SESSION['objExercise']); unset($_SESSION['objQuestion']); unset($_SESSION['objAnswer']); unset($_SESSION['questionList']); unset($_SESSION['exerciseResult']); unset($_SESSION['exeStartTime']); $moduleStartAssetPage = "showExercise.php?course={$course_code}&exerciseId=" . $assetPath;
if ($is_editor) { $link_title_extra .= ' external'; } } } if ($can_upload and $entry['editable']) { $edit_url = "new.php?course={$course_code}&editPath={$entry['path']}" . ($groupset ? "&{$groupset}" : ''); $link_title_extra .= ' ' . icon('edit', $langEdit, $edit_url); } if ($copyid = $entry['copyrighted'] and $copyicon = $copyright_icons[$copyid]) { $link_title_extra .= " " . icon($copyicon, $copyright_titles[$copyid], $copyright_links[$copyid], null, 'png', 'target="_blank"'); } $dload_msg = $langSave; $dObj = $entry['object']; $dObj->setAccessURL($file_url); $dObj->setPlayURL(file_playurl($cmdDirName, $entry['filename'])); if ($is_in_tinymce && !$compatiblePlugin) { // use Access/DL URL for non-modable tinymce plugins $dObj->setPlayURL($dObj->getAccessURL()); } $link_href = MultimediaHelper::chooseMediaAhref($dObj); } if (!$entry['extra_path'] or common_doc_path($entry['extra_path'])) { // Normal or common document $download_url = $base_url . "download={$cmdDirName}"; } else { // External document $download_url = $entry['extra_path']; } $tool_content .= "<tr {$style}><td class='text-center'>{$img_href}</td>\n <td>{$link_href} {$link_title_extra}"; // comments
function display_my_documents($dialogBox, $style) { global $curDirName; global $curDirPath; global $parentDir; global $langUp; global $langName; global $langSize; global $langDate; global $langAddModulesButton; global $fileList; global $themeimg; global $langSelection, $langDirectory, $course_code; $output = ''; /* * DISPLAY */ $dspCurDirName = htmlspecialchars($curDirName); // $cmdCurDirPath = rawurlencode($curDirPath); $cmdParentDir = rawurlencode($parentDir); $output .= '<form action="' . $_SERVER['SCRIPT_NAME'] . '?course=' . $course_code . '" method="POST">'; /* -------------------------------------- DIALOG BOX SECTION -------------------------------------- */ $colspan = 5; if (!empty($dialogBox)) { $output .= disp_message_box($dialogBox, $style) . "<br />"; } /* -------------------------------------- CURRENT DIRECTORY LINE -------------------------------------- */ /* CURRENT DIRECTORY */ if ($curDirName) { $output .= ' <table class="table-default"> <tr> <td width="1" class="right">' . icon('fa-folder-o') . '</td> <td>' . $langDirectory . ': <b>' . $dspCurDirName . '</b></td>'; /* GO TO PARENT DIRECTORY */ if ($curDirName) { $linkup = "<a href='{$_SERVER['SCRIPT_NAME']}?course={$course_code}&openDir={$cmdParentDir}'>"; $output .= "<td width='1'>{$linkup}<img src='{$themeimg}/folder_up.png' " . "hspace='5' alt='{$langUp}' title='langUp' /></a></td>" . "<td width='10' class='right'><small>{$linkup}{$langUp}</a></small></td>"; } $output .= '</tr></table>'; } $output .= ' <div class="table-responsive"> <table class="table-default" >'; $output .= "\n <tr class='list-header'>\n <th colspan='2'><div align='left'> {$langName}</div></th>\n <th>{$langSize}</th>\n <th>{$langDate}</th>\n <th>{$langSelection}</th>\n </tr>"; /* -------------------------------------- DISPLAY FILE LIST -------------------------------------- */ if ($fileList) { $iterator = 0; $ind = 1; while (list($fileKey, $fileName) = each($fileList['name'])) { if ($ind % 2 == 0) { $style = 'class="even"'; } else { $style = 'class="odd"'; } $dspFileName = htmlspecialchars($fileList['filename'][$fileKey]); $cmdFileName = str_replace("%2F", "/", rawurlencode($curDirPath . "/" . $fileName)); if ($fileList['visible'][$fileKey] == 0) { continue; // skip the display of this file } if ($fileList['type'][$fileKey] == A_FILE) { $image = choose_image($fileName); $size = format_file_size($fileList['size'][$fileKey]); $date = nice_format($fileList['date'][$fileKey]); $file_url = file_url($fileList['path'][$fileKey], $dspFileName); $play_url = file_playurl($fileList['path'][$fileKey], $dspFileName); $urlFileName = MultimediaHelper::chooseMediaAhrefRaw($file_url, $play_url, $dspFileName, $dspFileName); } elseif ($fileList['type'][$fileKey] == A_DIRECTORY) { $image = 'fa-folder'; $size = ' '; $date = ' '; $urlFileName = '<a href="' . $_SERVER['SCRIPT_NAME'] . '?course=' . $course_code . '&openDir=' . $cmdFileName . '">' . $dspFileName . '</a>'; } $output .= ' <tr ' . $style . '> <td class="center" width="1">' . icon($image, '') . '</td> <td align="left">' . $urlFileName . '</td> <td width="80" class="center">' . $size . '</td> <td width="80" class="center">' . $date . '</td>'; if ($fileList['type'][$fileKey] == A_FILE) { $iterator++; $output .= ' <td width="10" class="center"> <input type="checkbox" name="insertDocument_' . $iterator . '" id="insertDocument_' . $iterator . '" value="' . $curDirPath . "/" . $fileName . '" /> <input type="hidden" name="filenameDocument_' . $iterator . '" id="filenameDocument_' . $iterator . '" value="' . $dspFileName . '" /> </td>'; } else { $output .= '<td> </td>'; } $output .= '</tr>'; /* COMMENTS */ if ($fileList['comment'][$fileKey] != "") { $fileList['comment'][$fileKey] = htmlspecialchars($fileList['comment'][$fileKey]); $fileList['comment'][$fileKey] = parse_user_text($fileList['comment'][$fileKey]); $output .= ' <tr class="even"> <td> </td> <td colspan="' . $colspan . '"><span class="comment">' . $fileList['comment'][$fileKey] . '</span></td> </tr>'; } $ind++; } // end each ($fileList) // form button $output .= ' <tr> <th colspan="' . $colspan . '"><div class="pull-right"> <input type="hidden" name="openDir" value="' . $curDirPath . '" /> <input type="hidden" name="maxDocForm" value ="' . $iterator . '" /> <input class="btn btn-primary" type="submit" name="submitInsertedDocument" value="' . $langAddModulesButton . '"> </th> </tr>'; } else { $output .= '<tr><td colspan="4"> </td></tr>'; } $output .= '</table></div></form>'; return $output; }
/** * @brief display resource documents * @global type $is_editor * @global type $course_id * @global type $langWasDeleted * @global type $urlServer * @global type $id * @global type $course_code * @param type $title * @param type $comments * @param type $resource_id * @param type $file_id * @return string */ function show_doc($title, $comments, $resource_id, $file_id) { global $is_editor, $course_id, $langWasDeleted, $head_content, $urlServer, $id, $course_code; $file = Database::get()->querySingle("SELECT * FROM document WHERE course_id = ?d AND id = ?d", $course_id, $file_id); if (!$file) { if (!$is_editor) { return ''; } $status = 'del'; $image = 'fa-times'; $link = "<span class='not_visible'>" . q($title) . " ($langWasDeleted)</span>"; } else { $status = $file->visible; if (!$is_editor and ( !resource_access($file->visible, $file->public))) { return ''; } if ($file->format == '.dir') { $image = 'fa-folder-o'; $download_hidden_link = ''; $link = "<a href='{$urlServer}modules/document/index.php?course=$course_code&openDir=$file->path&unit=$id'>$file->filename</a>"; } else { $image = choose_image('.' . $file->format); $download_url = "{$urlServer}modules/document/index.php?course=$course_code&download=$file->path"; $download_hidden_link = "<input type='hidden' value='$download_url'>"; $file_obj = MediaResourceFactory::initFromDocument($file); $file_obj->setAccessURL(file_url($file->path, $file->filename)); $file_obj->setPlayURL(file_playurl($file->path, $file->filename)); $link = MultimediaHelper::chooseMediaAhref($file_obj); } } $class_vis = ($status == '0' or $status == 'del') ? ' class="not_visible"' : ''; if (!empty($comments)) { $comment = '<br />' . $comments; } else { $comment = ''; } return " <tr$class_vis> <td width='1'>" . icon($image, '') . "</a></td> <td align='left'>$download_hidden_link$link$comment</td>" . actions('doc', $resource_id, $status) . '</tr>'; }
/** * list documents while inserting them in course unit * @global type $id * @global type $webDir * @global type $course_code * @global type $tool_content * @global type $group_sql * @global type $langDirectory * @global type $langUp * @global type $langName * @global type $langSize * @global type $langDate * @global type $langType * @global type $langAddModulesButton * @global type $langChoice * @global type $langNoDocuments * @global type $course_code */ function list_docs() { global $id, $webDir, $course_code, $tool_content, $group_sql, $langDirectory, $langUp, $langName, $langSize, $langDate, $langType, $langAddModulesButton, $langChoice, $langNoDocuments, $course_code, $langCommonDocs, $pageName; $basedir = $webDir . '/courses/' . $course_code . '/document'; $path = get_dir_path('path'); $dir_param = get_dir_path('dir'); $dir_setter = $dir_param ? ('&dir=' . $dir_param) : ''; $dir_html = $dir_param ? "<input type='hidden' name='dir' value='$dir_param'>" : ''; if ($id == -1) { $common_docs = true; $pageName = $langCommonDocs; $group_sql = "course_id = -1 AND subsystem = " . COMMON . ""; $basedir = $webDir . '/courses/commondocs'; $visible_sql = 'visible = 1 AND'; } else { $common_docs = false; $visible_sql = ''; } $result = Database::get()->queryArray("SELECT id, course_id, path, filename, format, title, extra_path, date_modified, visible, copyrighted, comment, IF(title = '', filename, title) AS sort_key FROM document WHERE $group_sql AND $visible_sql path LIKE ?s AND path NOT LIKE ?s ORDER BY sort_key COLLATE utf8_unicode_ci", "$path/%", "$path/%/%"); $fileinfo = array(); $urlbase = $_SERVER['SCRIPT_NAME'] . "?course=$course_code$dir_setter&type=doc&id=$id&path="; foreach ($result as $row) { $fullpath = $basedir . $row->path; if ($row->extra_path) { $size = 0; } else { $size = file_exists($fullpath)? filesize($fullpath): 0; } $fileinfo[] = array( 'id' => $row->id, 'is_dir' => is_dir($fullpath), 'size' => $size, 'title' => $row->title, 'name' => htmlspecialchars($row->filename), 'format' => $row->format, 'path' => $row->path, 'visible' => $row->visible, 'comment' => $row->comment, 'copyrighted' => $row->copyrighted, 'date' => $row->date_modified, 'object' => MediaResourceFactory::initFromDocument($row)); } if (count($fileinfo) == 0) { $tool_content .= "<div class='alert alert-warning'>$langNoDocuments</div>"; } else { if (!empty($path)) { $dirname = Database::get()->querySingle("SELECT filename FROM document WHERE $group_sql AND path = ?s", $path); $parentpath = dirname($path); $dirname = htmlspecialchars($dirname->filename); $parentlink = $urlbase . $parentpath; $parenthtml = "<span class='pull-right'><a href='$parentlink'>$langUp " . icon('fa-level-up') . "</a></span>"; $colspan = 4; } $tool_content .= "<form action='insert.php?course=$course_code' method='post'><input type='hidden' name='id' value='$id' />" . "<table class='table-default'>"; if( !empty($path)) { $tool_content .= "<tr>" . "<th colspan='$colspan'><div class='text-left'>$langDirectory: $dirname$parenthtml</div></th>" . "</tr>" ; } $tool_content .= "<tr class='list-header'>" . "<th class='text-left'>$langName</th>" . "<th class='text-center'>$langSize</th>" . "<th class='text-center'>$langDate</th>" . "<th style='width:20px;' class='text-center'>$langChoice</th>" . "</tr>"; $counter = 0; foreach (array(true, false) as $is_dir) { foreach ($fileinfo as $entry) { if ($entry['is_dir'] != $is_dir) { continue; } $dir = $entry['path']; if ($is_dir) { $image = 'fa-folder-o'; $file_url = $urlbase . $dir; $link_text = $entry['name']; $link_href = "<a href='$file_url'>$link_text</a>"; } else { $image = choose_image('.' . $entry['format']); $file_url = file_url($entry['path'], $entry['name'], $common_docs ? 'common' : $course_code); $dObj = $entry['object']; $dObj->setAccessURL($file_url); $dObj->setPlayURL(file_playurl($entry['path'], $entry['name'], $common_docs ? 'common' : $course_code)); $link_href = MultimediaHelper::chooseMediaAhref($dObj); } if ($entry['visible'] == 'i') { $vis = 'invisible'; } else { $vis = ''; } $tool_content .= "<tr class='$vis'>"; $tool_content .= "<td>" . icon($image, '')." $link_href"; /* * * comments ** */ if (!empty($entry['comment'])) { $tool_content .= "<br /><div class='comment'>" . standard_text_escape($entry['comment']) . "</div>"; } $tool_content .= "</td>"; if ($is_dir) { // skip display of date and time for directories $tool_content .= "<td> </td><td> </td>"; } else { $size = format_file_size($entry['size']); $date = nice_format($entry['date'], true, true); $tool_content .= "<td class='text-right'>$size</td><td class='text-center'>$date</td>"; } $tool_content .= "<td class='text-center'><input type='checkbox' name='document[]' value='$entry[id]' /></td>"; $tool_content .= "</tr>"; $counter++; } } $tool_content .= "</table>"; $tool_content .= "<div class='text-right'>"; $tool_content .= "<input class='btn btn-primary' type='submit' name='submit_doc' value='$langAddModulesButton' /></div>$dir_html</form>"; } }
/** * list documents while inserting them in course unit * @global type $id * @global type $webDir * @global type $course_code * @global type $tool_content * @global type $group_sql * @global type $langDirectory * @global type $langUp * @global type $langName * @global type $langSize * @global type $langDate * @global type $langType * @global type $langAddModulesButton * @global type $langChoice * @global type $langNoDocuments * @global type $course_code */ function list_docs() { global $id, $webDir, $course_code, $tool_content, $group_sql, $langDirectory, $langUp, $langName, $langSize, $langDate, $langType, $langAddModulesButton, $langChoice, $langNoDocuments, $course_code, $langCommonDocs, $pageName; $basedir = $webDir . '/courses/' . $course_code . '/document'; $path = get_dir_path('path'); $dir_param = get_dir_path('dir'); $dir_setter = $dir_param ? '&dir=' . $dir_param : ''; $dir_html = $dir_param ? "<input type='hidden' name='dir' value='{$dir_param}'>" : ''; if ($id == -1) { $common_docs = true; $pageName = $langCommonDocs; $group_sql = "course_id = -1 AND subsystem = " . COMMON . ""; $basedir = $webDir . '/courses/commondocs'; $result = Database::get()->queryArray("SELECT * FROM document\n WHERE {$group_sql} AND\n visible = 1 AND\n path LIKE ?s AND\n path NOT LIKE ?s", "{$path}/%", "{$path}/%/%"); } else { $common_docs = false; $result = Database::get()->queryArray("SELECT * FROM document\n WHERE {$group_sql} AND\n path LIKE ?s AND\n path NOT LIKE ?s", "{$path}/%", "{$path}/%/%"); } $fileinfo = array(); $urlbase = $_SERVER['SCRIPT_NAME'] . "?course={$course_code}{$dir_setter}&type=doc&id={$id}&path="; foreach ($result as $row) { $fullpath = $basedir . $row->path; if ($row->extra_path) { $size = 0; } else { $size = file_exists($fullpath) ? filesize($fullpath) : 0; } $fileinfo[] = array('id' => $row->id, 'is_dir' => is_dir($fullpath), 'size' => $size, 'title' => $row->title, 'name' => htmlspecialchars($row->filename), 'format' => $row->format, 'path' => $row->path, 'visible' => $row->visible, 'comment' => $row->comment, 'copyrighted' => $row->copyrighted, 'date' => $row->date_modified, 'object' => MediaResourceFactory::initFromDocument($row)); } if (count($fileinfo) == 0) { $tool_content .= "<div class='alert alert-warning'>{$langNoDocuments}</div>"; } else { if (empty($path)) { $dirname = ''; $parenthtml = ''; $colspan = 5; } else { $dirname = Database::get()->querySingle("SELECT filename FROM document\n WHERE {$group_sql} AND path = ?s", $path); $parentpath = dirname($path); $dirname = "/" . htmlspecialchars($dirname); $parentlink = $urlbase . $parentpath; $parenthtml = "<th class='right'><a href='{$parentlink}'>{$langUp}</a> " . icon('fa-upload', $langUp, $parentlink) . "</th>"; $colspan = 4; } $tool_content .= "<form action='insert.php?course={$course_code}' method='post'><input type='hidden' name='id' value='{$id}' />" . "<table class='table-default'>" . "<tr>" . "<th colspan='{$colspan}'><div align='left'>{$langDirectory}: {$dirname}</div></th>" . $parenthtml . "</tr>" . "<tr>" . "<th>{$langType}</th>" . "<th><div align='left'>{$langName}</div></th>" . "<th width='100'>{$langSize}</th>" . "<th width='80'>{$langDate}</th>" . "<th width='80'>{$langChoice}</th>" . "</tr>"; $counter = 0; foreach (array(true, false) as $is_dir) { foreach ($fileinfo as $entry) { if ($entry['is_dir'] != $is_dir) { continue; } $dir = $entry['path']; if ($is_dir) { $image = 'fa-folder-o'; $file_url = $urlbase . $dir; $link_text = $entry['name']; $link_href = "<a href='{$file_url}'>{$link_text}</a>"; } else { $image = choose_image('.' . $entry['format']); $file_url = file_url($entry['path'], $entry['name'], $common_docs ? 'common' : $course_code); $dObj = $entry['object']; $dObj->setAccessURL($file_url); $dObj->setPlayURL(file_playurl($entry['path'], $entry['name'], $common_docs ? 'common' : $course_code)); $link_href = MultimediaHelper::chooseMediaAhref($dObj); } if ($entry['visible'] == 'i') { $vis = 'invisible'; } else { $vis = ''; } $tool_content .= "<tr class='{$vis}'>"; $tool_content .= "<td width='1' class='center'>" . icon($image, '') . "</td>"; $tool_content .= "<td>{$link_href}"; /* * * comments ** */ if (!empty($entry['comment'])) { $tool_content .= "<br /><div class='comment'>" . standard_text_escape($entry['comment']) . "</div>"; } $tool_content .= "</td>"; if ($is_dir) { // skip display of date and time for directories $tool_content .= "<td> </td><td> </td>"; } else { $size = format_file_size($entry['size']); $date = nice_format($entry['date'], true, true); $tool_content .= "<td class='center'>{$size}</td><td class='center'>{$date}</td>"; } $tool_content .= "<td class='center'><input type='checkbox' name='document[]' value='{$entry['id']}' /></td>"; $tool_content .= "</tr>"; $counter++; } } $tool_content .= "<tr><th colspan={$colspan}><div align='right'>"; $tool_content .= "<input class='btn btn-primary' type='submit' name='submit_doc' value='{$langAddModulesButton}' /></div></th>"; $tool_content .= "</tr></table>{$dir_html}</form>"; } }
/** * @brief get user documents newer than one month * @global type $langNoDocsExist * @param type $param * @return string */ function getUserDocuments($lesson_id) { global $langNoDocsExist, $group_sql; $last_month = strftime('%Y-%m-%d', strtotime('now -1 month')); $found = false; $doc_content = '<table width="100%">'; foreach ($lesson_id as $lid) { $q = Database::get()->queryArray("SELECT document.path, document.course_id, document.filename,\n document.title, document.date_modified,\n document.format, document.visible,\n document.id\n FROM document, course_module\n WHERE document.course_id = ?d AND \n subsystem = " . MAIN . " AND\n document.visible = 1 AND\n date_modified >= '{$last_month}' AND\n format <> '.dir' AND\n course_module.module_id = " . MODULE_ID_DOCS . " AND\n course_module.visible = 1 AND\n course_module.course_id = ?d\n ORDER BY date_modified DESC", $lid, $lid); if ($q) { $found = true; $doc_content .= "<tr><td class='sub_title1'>" . q(ellipsize(course_id_to_title($lid), 70)) . "</td></tr>"; foreach ($q as $course_file) { $group_sql = "course_id = " . $lid . " AND subsystem = " . MAIN; $url = file_url($course_file->path, $course_file->filename, course_id_to_code($lid)); $dObj = MediaResourceFactory::initFromDocument($course_file); $dObj->setAccessURL($url); $dObj->setPlayURL(file_playurl($course_file->path, $course_file->filename, course_id_to_code($lid))); $href = MultimediaHelper::chooseMediaAhref($dObj); $doc_content .= "<tr><td class='smaller'><ul class='custom_list'><li>" . $href . ' - (' . nice_format(date('Y-m-d', strtotime($course_file->date_modified))) . ")</li></ul></td></tr>"; } } } $doc_content .= "</table>"; if ($found) { return $doc_content; } else { return "<div class='alert alert-warning'>{$langNoDocsExist}</div>"; } }