Пример #1
0
*/
// We show the documents in the following cases
// 1. the link to add documenets in the resource linker was clicked
// 2. we come to the resource linker for the first time (documents = default). In this case it can only be shown if
//  			a. one is a teacher (documents can be shown even if the tool is inactive)
//				b. one is a student AND the documents tool is active. Student cannot add documents if the documents tool is inactive (teacher can do this)
if ($content == "Document" OR (empty($content) AND (api_is_allowed_to_edit() OR in_array(TOOL_DOCUMENT,$active_modules))) AND !$_GET['showresources'])
{
	// setting variables for file locations
	$baseServDir = $_configuration['root_sys'];
	$courseDir = $_course['path']."/document";
	$baseWorkDir = $baseServDir.$courseDir;
	// showing the link to move one folder up (when not in the root folder)
	show_folder_up();
	// showing the blue bar with the path in it when we are not in the root
	if (get_levels($folder))
	{
		echo "<table width=\"100%\"><tr><td bgcolor=\"#4171B5\">";
		echo "<img src=\"../img/opendir.gif\" alt='directory'><font color=\"#ffffff\"><b>";
		echo $folder."</b></font></td></tr></table>";
	}

	// showing the documents and subfolders of the folder we are in.
	show_documents($folder);
	//echo "<hr>";
}

/*
-----------------------------------------------------------
	Ad Valvas
-----------------------------------------------------------
Пример #2
0
/**
 * Shows the documents of the document tool
 * @param $folder
 */
function show_documents($folder)
{
    global $_course;
    global $source_id, $action, $learnpath_id, $chapter_id, $originalresource;
    // Documents are a special case: The teacher can add an invisible document (it will be viewable by the user)
    // other tools do not have this feature.
    if (api_is_allowed_to_edit()) {
        $visibility = "ip.visibility<>'2'";
    } else {
        $visibility = "ip.visibility='1'";
    }
    $course_id = api_get_course_int_id();
    $item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
    $document_table = Database::get_course_table(TABLE_DOCUMENT);
    $sql = "SELECT * from {$document_table} docs , {$item_property_table} ip\n            WHERE\n                docs.c_id = {$course_id} AND\n                ip.c_id = {$course_id} AND\n                docs.id=ip.ref AND\n                ip.tool = '" . TOOL_DOCUMENT . "' AND\n                {$visibility} AND\n                (ip.to_group_id = 0 OR ip.to_group_id IS NULL)AND\n                ip.to_user_id IS NULL\n            ORDER BY docs.path ASC";
    $result = Database::query($sql);
    while ($row = Database::fetch_array($result)) {
        if (!$folder) {
            if (get_levels($row['path']) - 1 == 1) {
                // showing the right icon.
                if (file_or_folder($row['path'])) {
                    echo '<img src="../img/file.gif" align="middle" />';
                } else {
                    $image = choose_image($row['path']);
                    echo "<img src=\"../img/{$image}\" align=\"middle\" />";
                }
                // Folders should be clickable.
                if (file_or_folder($row['path'])) {
                    echo "<a href='" . api_get_self() . "?content=Document";
                    echo "&folder=" . substr($row['path'], 1) . "&source_id={$source_id}&source_forum=" . $_GET['source_forum'] . "&action={$action}&lp_id={$learnpath_id}&parent_item_id={$chapter_id}&originalresource=no'>" . substr($row['path'], 1) . '</a><br />';
                } else {
                    echo substr($row['path'], 1) . ' ';
                    echo showorhide_addresourcelink('Document', $row['id']);
                    echo '<br />';
                }
            }
        } else {
            // We calculate the level we are in by using the $folder in the url.
            // We put +1 because it does not start with an / and in the database it does
            $level = get_levels($folder) + 1;
            // We calculate each level of the database entry.
            $file_level = get_levels($row['path']) - 1;
            // If the level of the database entry is equal to the level we ar in, we put it into an array
            // as this is a potential good entry.
            if ($file_level == $level) {
                $good_paths[] = $row['path'];
                $good_ids[] = $row['id'];
            }
            //$haystack=$row['path'];
            //$conform_folder=strstr($haystack, $folder);
            //if (str_replace($folder.'/', '', $conform_folder) !== $folder) {
            //	$good_folders[] = $row['path'];
            //echo str_replace($folder.'/', '', $conform_folder);
            //	echo '<br />';
            //	}// if (str_replace($folder.'/','',$conform_folder)!==$folder)
        }
        // else (if (!$folder))
    }
    //while ($row=Database::fetch_array($result))
    // This is code for the case that we are in a subfolder.
    if ($good_paths) {
        // We have all the potential good database entries, the good ones are those that start with $folder
        foreach ($good_paths as $path) {
            if (strstr($path, $folder)) {
                $good_key = key($good_paths);
                // Showing the right icon.
                if (file_or_folder($path)) {
                    echo '<img src="../img/file.gif" align="middle" />';
                } else {
                    $image = choose_image($path);
                    echo "<img src=\"../img/{$image}\" align=\"middle\" />";
                }
                // Folders should be clickable
                if (file_or_folder($path)) {
                    $path = substr($path, 1);
                    // Remove the first / in folder_up.
                    $uri = str_replace($folder, $path, $_SERVER['REQUEST_URI']);
                    $newuri = str_replace('add=', 'addnot=', $uri);
                    // Using the correct name of the folder.
                    $folder_name = str_replace($folder . '/', '', $path);
                    echo "<a href='{$newuri}'>" . $folder_name . '</a><br />';
                } else {
                    echo str_replace("/{$folder}/", '', $path) . ' ';
                    echo showorhide_addresourcelink('Document', $good_ids[$good_key]);
                    echo '<br />';
                }
            }
            next($good_paths);
        }
    }
}
function course_table($cls_data)
{
    $output = '<table>' . "\n";
    $output .= '<tr><td style="width: 150px">Class Title</td><td>' . $cls_data['cls_title'] . "</td>\n";
    $output .= '<td style="width: 150px">Teacher</td><td>' . $cls_data['cls_teacher'] . "</td></tr>\n";
    $output .= '<tr><td style="width: 150px">Room:</td><td>' . $cls_data['cls_room'] . "</td>\n";
    $output .= '<td style="width: 150px">Class Level</td><td>' . get_levels($cls_data['cls_level']) . "</td></tr>\n";
    $output .= '<tr><td style="width: 150px">Class Time</td><td>';
    $output .= "(Fri)" . "(" . get_option('class_start_time') . "-" . get_option('class_end_time') . ")</td>";
    $output .= '<td colspan="2"><label>Class instructed in ' . ($cls_data['cls_language'] == "1" ? 'English' : 'Mandarin') . "</td></tr>\n";
    $output .= '<tr><td>Description</td><td colspan="3">' . $cls_data['cls_description'] . "</td></tr>\n";
    if ($cls_data['cls_additionals']) {
        $output .= '<tr><td colspan="4">' . $cls_data['cls_additionals'] . "</td></tr>\n";
    }
    $output .= "</table>\n";
    return $output;
}