$parentlink = $base_url . 'openDir=' . $cmdParentDir; $tool_content .= " <div class='pull-right'>\n <a href='{$parentlink}' type='button' class='btn btn-success'><i class='fa fa-level-up'></i> {$langUp}</a>\n </div>"; } $tool_content .= "</div>\n </div>\n </div>\n </div>\n <div class='row'>\n <div class='col-md-12'>\n <div class='table-responsive'>\n <table class='table-default'>\n <tr>"; $tool_content .= "<th class='center'><b>" . headlink($langType, 'type') . '</b></th>' . "<th><div class='text-left'>" . headlink($langName, 'name') . '</div></th>' . "<th class='center'><b>{$langSize}</b></th>" . "<th class='text-center'><b>" . headlink($langDate, 'date') . '</b></th>'; if (!$is_in_tinymce) { $tool_content .= "<th class='text-center'>" . icon('fa-gears', $langCommands) . "</th>"; } $tool_content .= "</tr>"; // ------------------------------------- // Display directories first, then files // ------------------------------------- foreach (array(true, false) as $is_dir) { foreach ($fileinfo as $entry) { $link_title_extra = ''; if ($entry['is_dir'] != $is_dir or !$can_upload and !resource_access($entry['visible'], $entry['public'])) { continue; } $cmdDirName = $entry['path']; if (!$entry['visible']) { $style = ' class="not_visible"'; } else { $style = ''; } if ($is_dir) { $img_href = icon('fa-folder-o'); $file_url = $base_url . "openDir={$cmdDirName}"; $link_title = q($entry['filename']); $dload_msg = $langDownloadDir; $link_href = "<a href='{$file_url}'>{$link_title}</a>"; } else {
'url' => "#", 'icon' => 'fa-copy'), array('title' => $langPurgeExerciseResults, 'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&choice=purge&exerciseId=$row->id", 'icon' => 'fa-eraser', 'confirm' => $langConfirmPurgeExerciseResults), array('title' => $langDelete, 'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&choice=delete&exerciseId=$row->id", 'icon' => 'fa-times', 'class' => 'delete', 'confirm' => $langConfirmPurgeExercise) ))."</td></tr>"; // student only } else { if (!resource_access($row->active, $row->public)) { continue; } $currentDate = new DateTime('NOW'); $temp_StartDate = new DateTime($row->start_date); $temp_EndDate = isset($row->end_date) ? new DateTime($row->end_date) : null; if (($currentDate >= $temp_StartDate) && (!isset($temp_EndDate) || isset($temp_EndDate) && $currentDate <= $temp_EndDate)) { $tool_content .= "<td><a$link_class href='exercise_submit.php?course=$course_code&exerciseId=$row->id'>" . q($row->title) . "</a>$lock_icon"; } elseif ($currentDate <= $temp_StartDate) { // exercise has not yet started $tool_content .= "<td class='not_visible'>" . q($row->title) . "$lock_icon "; } else { // exercise has expired $tool_content .= "<td>" . q($row->title) . "$lock_icon (<font color='red'>$m[expired]</font>)"; } $tool_content .= "<br />" . $row->description . "</td><td class='smaller' align='center'>
/** * @brief display resource exercise * @global type $id * @global type $urlServer * @global type $is_editor * @global type $langWasDeleted * @global type $course_id * @global type $course_code * @global type $langInactiveModule * @param type $title * @param type $comments * @param type $resource_id * @param type $exercise_id * @param type $visibility * @return string */ function show_exercise($title, $comments, $resource_id, $exercise_id, $visibility) { global $id, $urlServer, $is_editor, $langWasDeleted, $course_id, $course_code, $langInactiveModule; $module_visible = visible_module(MODULE_ID_EXERCISE); // checks module visibility if (!$module_visible and !$is_editor) { return ''; } $comment_box = $class_vis = $imagelink = $link = ''; $title = q($title); $exercise = Database::get()->querySingle("SELECT * FROM exercise WHERE course_id = ?d AND id = ?d", $course_id, $exercise_id); if (!$exercise) { // check if it was deleted if (!$is_editor) { return ''; } else { $status = 'del'; $imagelink = icon('fa-times'); $exlink = "<span class='not_visible'>{$title} ({$langWasDeleted})</span>"; } } else { $status = $exercise->active; if (!$is_editor and !resource_access($exercise->active, $exercise->public)) { return ''; } $link = "<a href='{$urlServer}modules/exercise/exercise_submit.php?course={$course_code}&exerciseId={$exercise_id}&unit={$id}'>"; $exlink = $link . "{$title}</a>"; if (!$module_visible) { $exlink .= " <i>({$langInactiveModule})</i>"; } $imagelink = $link . "" . icon('fa-pencil-square-o') . "</a>"; } $class_vis = ($status == '0' or $status == 'del') ? ' class="not_visible"' : ' '; if (!empty($comments)) { $comment_box = "<br />{$comments}"; } else { $comment_box = ""; } return "\n <tr{$class_vis}>\n <td width='3'>{$imagelink}</td>\n <td>{$exlink} {$comment_box}</td>" . actions('lp', $resource_id, $visibility) . "\n </tr>"; }
/** * @brief Creates mapping between encoded filenames and real filenames * @global type $group_sql * @param type $downloadDir * @param type $include_invisible */ function create_map_to_real_filename($downloadDir, $include_invisible) { global $group_sql; $prefix = strlen(preg_replace('|[^/]*$|', '', $downloadDir)) - 1; $encoded_filenames = $decoded_filenames = $filename = array(); $hidden_dirs = array(); $sql = Database::get()->queryArray("SELECT path, filename, visible, format, extra_path, public FROM document\n WHERE {$group_sql} AND\n path LIKE '{$downloadDir}%'"); foreach ($sql as $files) { if ($cpath = common_doc_path($files->extra_path, true)) { if ($GLOBALS['common_doc_visible'] and ($include_invisible or $files->visible == 1)) { $GLOBALS['common_docs'][$files->path] = $cpath; } } $GLOBALS['path_visibility'][$files->path] = ($include_invisible or resource_access($files->visible, $files->public)); array_push($encoded_filenames, $files->path); array_push($filename, $files->filename); if (!$include_invisible and $files->format == '.dir' and !resource_access($files->visible, $files->public)) { $parentdir = preg_replace('|/[^/]+$|', '', $files->path); // Don't need to check lower-level hidden dir if parent is there if (array_search($parentdir, $hidden_dirs) === false) { array_push($hidden_dirs, $files->path); } } } if (!$include_invisible) { if (count($hidden_dirs)) { $hidden_regexp = '#^(' . implode('|', $hidden_dirs) . ')#'; } else { $hidden_regexp = false; } } $decoded_filenames = $encoded_filenames; foreach ($encoded_filenames as $position => $name) { if (!$include_invisible and $hidden_regexp and preg_match($hidden_regexp, $name)) { $GLOBALS['path_visibility'][$name] = false; } $last_name_component = substr(strrchr($name, "/"), 1); foreach ($decoded_filenames as &$newname) { $newname = str_replace($last_name_component, $filename[$position], $newname); } unset($newname); } foreach ($decoded_filenames as &$s) { $s = substr($s, $prefix); } // create global array with mappings $GLOBALS['map_filenames'] = array_combine($encoded_filenames, $decoded_filenames); }
if (isset($_REQUEST['id'])) { $id = intval($_REQUEST['id']); } $pageName = ''; $lang_editor = $language; load_js('tools.js'); ModalBoxHelper::loadModalBox(true); if (isset($_REQUEST['edit_submit'])) { units_set_maxorder(); $tool_content .= handle_unit_info_edit(); } $form = process_actions(); // check if we are trying to access a protected resource directly $access = Database::get()->querySingle("SELECT public FROM course_units WHERE id = ?d", $id); if ($access) { if (!resource_access(1, $access->public)) { $tool_content .= "<div class='alert alert-danger'>{$langForbidden}</div>"; draw($tool_content, 2, null, $head_content); exit; } } if ($is_editor) { $base_url = $urlAppend . "modules/units/insert.php?course={$course_code}&id={$id}&type="; $tool_content .= "\n <div class='row'>\n <div class='col-md-12'>" . action_bar(array(array('title' => $langEditUnitSection, 'url' => "info.php?course={$course_code}&edit={$id}&next=1", 'icon' => 'fa fa-edit', 'level' => 'primary-label', 'button-class' => 'btn-success'), array('title' => $langAdd . ' ' . $langInsertExercise, 'url' => $base_url . 'exercise', 'icon' => 'fa fa-paste', 'level' => 'secondary'), array('title' => $langAdd . ' ' . $langInsertDoc, 'url' => $base_url . 'doc', 'icon' => 'fa fa-paste', 'level' => 'secondary'), array('title' => $langAdd . ' ' . $langInsertText, 'url' => $base_url . 'text', 'icon' => 'fa fa-paste', 'level' => 'secondary'), array('title' => $langAdd . ' ' . $langInsertLink, 'url' => $base_url . 'link', 'icon' => 'fa fa-paste', 'level' => 'secondary'), array('title' => $langAdd . ' ' . $langLearningPath1, 'url' => $base_url . 'lp', 'icon' => 'fa fa-paste', 'level' => 'secondary'), array('title' => $langAdd . ' ' . $langInsertVideo, 'url' => $base_url . 'video', 'icon' => 'fa fa-paste', 'level' => 'secondary'), array('title' => $langAdd . ' ' . $langInsertForum, 'url' => $base_url . 'forum', 'icon' => 'fa fa-paste', 'level' => 'secondary'), array('title' => $langAdd . ' ' . $langInsertEBook, 'url' => $base_url . 'ebook', 'icon' => 'fa fa-paste', 'level' => 'secondary'), array('title' => $langAdd . ' ' . $langInsertWork, 'url' => $base_url . 'work', 'icon' => 'fa fa-paste', 'level' => 'secondary'), array('title' => $langAdd . ' ' . $langInsertPoll, 'url' => $base_url . 'poll', 'icon' => 'fa fa-paste', 'level' => 'secondary'), array('title' => $langAdd . ' ' . $langInsertWiki, 'url' => $base_url . 'wiki', 'icon' => 'fa fa-paste', 'level' => 'secondary'))) . "\n </div>\n </div>"; } if ($is_editor) { $visibility_check = ''; } else { $visibility_check = "AND visible=1"; } if (isset($id) and $id !== false) {
$course_id = $_SESSION['course_id']; } // anonymous with access token needs course id set } require_once 'doc_init.php'; require_once 'include/lib/forcedownload.php'; if (defined('GROUP_DOCUMENTS')) { if (!$uid) { error($langNoRead); } if (!($is_editor or $is_member)) { error($langNoRead); } } $file_info = public_path_to_disk_path($path_components); if (!$is_editor and !resource_access($file_info->visible, $file_info->public)) { error($langNoRead); } if ($file_info->extra_path) { // $disk_path is set if common file link $disk_path = common_doc_path($file_info->extra_path, true); if (!$disk_path) { // external file URL header("Location: {$file_info->extra_path}"); exit; } elseif (!$common_doc_visible) { forbidden(preg_replace('/^.*file\\.php/', '', $uri)); } } else { // Normal file $disk_path = $basedir . $file_info->path;
/** * @brief display links of category (if category is defined) else display all * @global type $is_in_tinymce * @global type $themeimg * @global type $tool_content * @global type $is_editor * @global type $course_id * @global type $course_code * @global type $langDelete * @global type $langViewHide * @global type $langViewShow * @global type $langPreview * @global type $langDownload * @global type langResourceAccessLock * @global type langResourceAccessUnlock * @global type $langEditChange * @global type $langConfirmDelete * @global type $filterv * @global type $filterl * @param type $cat_id */ function showlinksofcategory($cat_id = 0) { global $course_id, $is_in_tinymce, $tool_content, $is_editor, $course_code, $langDelete, $langViewHide, $langViewShow, $langConfirmDelete, $display_tools, $is_in_tinymce, $langDownload, $langResourceAccessLock, $langResourceAccessUnlock, $langEditChange, $filterv, $filterl, $order, $compatiblePlugin, $langcreator, $langpublisher; if ($is_editor) { $vis_q = ''; } else { $vis_q = "AND visible = 1"; } if ($cat_id > 0) { $results['video'] = Database::get()->queryArray("SELECT * FROM video $filterv AND course_id = ?d AND category = ?d $vis_q $order", $course_id, $cat_id); $results['videolink'] = Database::get()->queryArray("SELECT * FROM videolink $filterl AND course_id = ?d AND category = ?d $vis_q $order", $course_id, $cat_id); } else { $results['video'] = Database::get()->queryArray("SELECT * FROM video $filterv AND course_id = ?d AND (category IS NULL OR category = 0) $vis_q $order", $course_id); $results['videolink'] = Database::get()->queryArray("SELECT * FROM videolink $filterl AND course_id = ?d AND (category IS NULL OR category = 0) $vis_q $order", $course_id); } foreach ($results as $table => $result) { foreach ($result as $myrow) { $myrow->course_id = $course_id; if (resource_access($myrow->visible, $myrow->public) || $is_editor) { switch ($table) { case 'video': $vObj = MediaResourceFactory::initFromVideo($myrow); if ($is_in_tinymce && !$compatiblePlugin) { // use Access/DL URL for non-modable tinymce plugins $vObj->setPlayURL($vObj->getAccessURL()); } $link_href = MultimediaHelper::chooseMediaAhref($vObj); $link_to_save = $vObj->getAccessURL() . '&attachment'; break; case "videolink": $vObj = MediaResourceFactory::initFromVideoLink($myrow); $link_href = MultimediaHelper::chooseMedialinkAhref($vObj); $link_to_save = $vObj->getPath(); break; default: exit; } $row_class = !$myrow->visible ? "class='not_visible'" : ""; $tool_content .= "<tr $row_class><td class='nocategory-link'>" . $link_href; if (!$is_in_tinymce and ( !empty($myrow->creator) or ! empty($myrow->publisher))) { $tool_content .= '<br><small>'; if ($myrow->creator == $myrow->publisher) { $tool_content .= "$langcreator: " . q($myrow->creator); } else { $emit = false; if (!empty($myrow->creator)) { $tool_content .= "$langcreator: " . q($myrow->creator); $emit = true; } if (!empty($myrow->publisher)) { $tool_content .= ($emit ? ', ' : '') . "$langpublisher: " . q($myrow->publisher); } } $tool_content .= "</small>"; } $tool_content .= "</td> <td class='text-center'>" . nice_format(date('Y-m-d', strtotime($myrow->date))) . "</td>"; if (!$is_in_tinymce) { if ($display_tools) { $tool_content .= "<td class='option-btn-cell'>" . action_button(array( array('title' => $langEditChange, 'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&id=$myrow->id&table_edit=$table", 'icon' => 'fa-edit', 'show' => !$is_in_tinymce and $is_editor), array('title' => $myrow->visible ? $langViewHide : $langViewShow, 'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&vid=$myrow->id&table=$table&vis=" . ($myrow->visible ? '0' : '1'), 'icon' => $myrow->visible ? 'fa-eye-slash' : 'fa-eye'), array('title' => $myrow->public ? $langResourceAccessLock : $langResourceAccessUnlock, 'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&vid=$myrow->id&table=$table&" . ($myrow->public ? 'limited=1' : 'public=1'), 'icon' => $myrow->public ? 'fa-lock' : 'fa-unlock', 'show' => !$is_in_tinymce and $is_editor and course_status($course_id) == COURSE_OPEN), array('title' => $langDownload, 'url' => $link_to_save, 'icon' => 'fa-download'), array('title' => $langDelete, 'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&id=$myrow->id&delete=yes&table=$table", 'icon' => 'fa-times', 'confirm' => $langConfirmDelete, 'class' => 'delete'))) . "</td>"; } else { $tool_content .= "<td class='text-center'>" . ($table == 'video'? icon('fa-download', $langDownload, $link_to_save): ' ') . '</td>'; } } $tool_content .= "</tr>"; } // end of check resource access } // foreach row } // foreach table }
* Contact address: GUnet Asynchronous eLearning Group, * Network Operations Center, University of Athens, * Panepistimiopolis Ilissia, 15784, Athens, Greece * e-mail: info@openeclass.org * ======================================================================== */ /** * @file: video.php * * @abstract Handle old links to media files for backward compatibility with 2.x code */ $require_current_course = true; require_once '../../include/baseTheme.php'; if (isset($_GET['course']) and isset($_GET['id'])) { $video = Database::get()->querySingle('SELECT * FROM video WHERE course_id = ?d AND path = ?s', $course_id, $_GET['id']); if ($video and resource_access($video->visible, $video->public)) { $url = 'modules/video/file.php?course=' . urlencode($course_code) . '&id=' . $video->id; if (isset($_GET['action']) and $_GET['action'] == 'download') { $url .= 'attachment'; } redirect_to_home_page($url); } } not_found();
if (!$is_in_tinymce) { $tool_content .= "<th class='text-center'>".icon('fa-gears', $langCommands)."</th>"; } $tool_content .= "</tr>"; if (!count($fileinfo)) { $tool_content .= "<tr><td colspan=10><p class='not_visible text-center'> - " . q($langNoDocuments) . " - </td></tr>"; } else { // ------------------------------------- // Display directories first, then files // ------------------------------------- foreach (array(true, false) as $is_dir) { foreach ($fileinfo as $entry) { $link_title_extra = ''; if (($entry['is_dir'] != $is_dir) or ( !$can_upload and ( !resource_access($entry['visible'], $entry['public'])))) { continue; } $cmdDirName = $entry['path']; if (!$entry['visible']) { $style = ' class="not_visible"'; } else { $style = ' class="visible"'; } if ($is_dir) { $img_href = icon('fa-folder'); $file_url = $base_url . "openDir=$cmdDirName"; $link_title = q($entry['filename']); $dload_msg = $langDownloadDir; $link_href = "<a href='$file_url'>$link_title</a>"; } else {
/** * @brief display links of category (if category is defined) else display all * @global type $is_in_tinymce * @global type $themeimg * @global type $tool_content * @global type $is_editor * @global type $course_id * @global type $course_code * @global type $langDelete * @global type $langVisible * @global type $langPreview * @global type $langSave * @global type $langResourceAccess * @global type $langResourceAccess * @global type $langModify * @global type $langConfirmDelete * @global type $filterv * @global type $filterl * @param type $cat_id */ function showlinksofcategory($cat_id = 0) { global $course_id, $is_in_tinymce, $themeimg, $tool_content, $is_editor, $course_code; global $langDelete, $langVisible, $langConfirmDelete; global $langPreview, $langSave, $langResourceAccess, $langResourceAccess, $langModify; global $filterv, $filterl, $compatiblePlugin, $langcreator, $langpublisher; if ($is_editor) { $vis_q = ''; } else { $vis_q = "AND visible = 1"; } if ($cat_id > 0) { $results['video'] = Database::get()->queryArray("SELECT * FROM video {$filterv} AND course_id = ?d AND category = ?d {$vis_q} ORDER BY title", $course_id, $cat_id); $results['videolink'] = Database::get()->queryArray("SELECT * FROM videolink {$filterl} AND course_id = ?d AND category = ?d {$vis_q} ORDER BY title", $course_id, $cat_id); } else { $results['video'] = Database::get()->queryArray("SELECT * FROM video {$filterv} AND course_id = ?d AND (category IS NULL OR category = 0) {$vis_q} ORDER BY title", $course_id); $results['videolink'] = Database::get()->queryArray("SELECT * FROM videolink {$filterl} AND course_id = ?d AND (category IS NULL OR category = 0) {$vis_q} ORDER BY title", $course_id); } $i = 0; foreach ($results as $table => $result) { foreach ($result as $myrow) { $myrow->course_id = $course_id; if (resource_access($myrow->visible, $myrow->public) || $is_editor) { switch ($table) { case 'video': $vObj = MediaResourceFactory::initFromVideo($myrow); if ($is_in_tinymce && !$compatiblePlugin) { // use Access/DL URL for non-modable tinymce plugins $vObj->setPlayURL($vObj->getAccessURL()); } $link_href = MultimediaHelper::chooseMediaAhref($vObj); $link_to_save = $vObj->getAccessURL(); break; case "videolink": $vObj = MediaResourceFactory::initFromVideoLink($myrow); $link_href = MultimediaHelper::chooseMedialinkAhref($vObj); $link_to_save = $vObj->getPath(); break; default: exit; } $row_class = !$myrow->visible ? "class='not_visible'" : ""; $tool_content .= "<tr {$row_class}><td>" . $link_href; if (!$is_in_tinymce and (!empty($myrow->creator) or !empty($myrow->publisher))) { $tool_content .= '<br><small>'; if ($myrow->creator == $myrow->publisher) { $tool_content .= "{$langcreator}: " . q($myrow->creator); } else { $emit = false; if (!empty($myrow->creator)) { $tool_content .= "{$langcreator}: " . q($myrow->creator); $emit = true; } if (!empty($myrow->publisher)) { $tool_content .= ($emit ? ', ' : '') . "{$langpublisher}: " . q($myrow->publisher); } } $tool_content .= '</small>'; } $tool_content .= "</td><td class='text-center'>" . nice_format(date('Y-m-d', strtotime($myrow->date))) . "</td><td class='option-btn-cell'>" . action_button(array(array('title' => $langDelete, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&id={$myrow->id}&delete=yes&table={$table}", 'icon' => 'fa-times', 'confirm' => $langConfirmDelete, 'class' => 'delete'), array('title' => $langSave, 'url' => $link_to_save, 'icon' => 'fa-floppy-o'), array('title' => $langModify, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&id={$myrow->id}&table_edit={$table}", 'icon' => 'fa-edit', 'show' => !$is_in_tinymce and $is_editor), array('title' => $langVisible, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&vid={$myrow->id}&table={$table}&vis=" . ($myrow->visible ? '0' : '1'), 'icon' => $myrow->visible ? 'fa-eye-slash' : 'fa-eye'), array('title' => $langResourceAccess, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&vid={$myrow->id}&table={$table}&" . ($myrow->public ? 'limited=1' : 'public=1'), 'icon' => $myrow->public ? 'fa-unlock' : 'fa-lock', 'show' => !$is_in_tinymce and $is_editor and course_status($course_id) == COURSE_OPEN))) . "</td></tr>"; } // end of check resource access } // foreach row } // foreach table }