예제 #1
0
$contentManager = new ContentManager($db, $course_id);
$handler = new ContentOutputParser();
$parser = new XML_HTMLSax();
$parser->set_object($handler);
$parser->set_element_handler('openHandler', 'closeHandler');
if (authenticate(AT_PRIV_CONTENT, AT_PRIV_RETURN)) {
    $sql = "SELECT *, UNIX_TIMESTAMP(last_modified) AS u_ts FROM %scontent WHERE course_id=%d ORDER BY content_parent_id, ordering";
    $rows_content = queryDB($sql, array(TABLE_PREFIX, $course_id));
} else {
    $sql = "SELECT *, UNIX_TIMESTAMP(last_modified) AS u_ts FROM %scontent WHERE course_id=%d ORDER BY content_parent_id, ordering";
    $rows_content = queryDB($sql, array(TABLE_PREFIX, $course_id));
}
$cid = $_REQUEST['cid'];
//takes care of some system which lost the REQUEST[cid]
foreach ($rows_content as $row) {
    if (authenticate(AT_PRIV_CONTENT, AT_PRIV_RETURN) || $contentManager->isReleased($row['content_id']) === TRUE) {
        $content[$row['content_parent_id']][] = $row;
        if ($cid == $row['content_id']) {
            $top_content = $row;
            $top_content_parent_id = $row['content_parent_id'];
        }
    }
}
if ($cid) {
    /* filter out the top level sections that we don't want */
    $top_level = $content[$top_content_parent_id];
    foreach ($top_level as $page) {
        if ($page['content_id'] == $cid) {
            $content[$top_content_parent_id] = array($page);
        } else {
            /* this is a page we don't want, so might as well remove it's children too */