Example #1
0
         $user_file = array();
         $ff_id = 10000000;
         while ($rs = $db->fetch_array($q)) {
             $rs['ff_id'] = $ff_id;
             $ff_id++;
             $rs['file_time'] = date('Y-m-d H:i:s', $rs['file_time']);
             $rs['parent_id'] = $rs['folder_id'];
             $rs['is_file'] = 1;
             $user_file[] = $rs;
         }
         unset($rs);
         //混合文件
         $user_folder_file = array_merge($user_folder, $user_file);
         PHPTree::$config['primary_key'] = 'ff_id';
         PHPTree::$config['parent_key'] = 'parent_id';
         $user_folder_file = PHPTree::makeTreeForHtml($user_folder_file);
         //获取用户已经选取的视频
         $sql = "SELECT file_id FROM {$tpf}file_cs_relation fcr LEFT JOIN {$tpf}course c ON c.courseid = fcr.course_id WHERE user_id={$pd_uid} AND fcr.course_id = {$course_id} AND fcr.cs_id = {$cs_id}";
         $q = $db->query($sql);
         $user_select_file = array();
         while ($rs = $db->fetch_array($q)) {
             $user_select_file[] = $rs['file_id'];
         }
         unset($rs);
         $ref = $_SERVER['HTTP_REFERER'];
         require_once template_echo($item, $user_tpl_dir);
     } else {
         $sysmsg[] = "缺失courseid或csid,非法操作";
         tb_redirect('reload', $sysmsg);
     }
 }
Example #2
0
function get_chapter_section_list($course_id)
{
    global $tpf, $db, $defineChaptersSections, $defineFileChaptersSections;
    //获取章节
    require PHPDISK_ROOT . 'includes/class/phptree.class.php';
    $sql = "SELECT * FROM {$tpf}course_chapter_section WHERE course_id = {$course_id}";
    $q = $db->query($sql);
    $chapter_section_array = array();
    while ($rs = $db->fetch_array($q)) {
        $rs['ff_id'] = $rs['csid'];
        $rs['create_date'] = date('Y-m-d H:i:s', $rs[create_date]);
        $rs['update_date'] = date('Y-m-d H:i:s', $rs[update_date]);
        $rs['status'] = $defineChaptersSections[$rs['status']] ? $defineChaptersSections[$rs['status']] : '未定义状态';
        $rs['a_edit'] = urr("mydisk", "item=course&action=modify_chapter_section&cs_id={$rs['csid']}&course_id={$course_id}");
        $rs['a_del'] = urr("mydisk", "item=course&action=chapter_section_delete&cs_id={$rs['csid']}&course_id={$course_id}");
        $rs['a_add_file'] = urr("mydisk", "item=course&action=add_file_cs_relation&cs_id={$rs['csid']}&course_id={$course_id}");
        $rs['is_cs'] = 1;
        $chapter_section_array[] = $rs;
    }
    unset($rs);
    //获取章节下的文件
    $sql = "SELECT * FROM {$tpf}file_cs_relation fcr LEFT JOIN {$tpf}files f ON fcr.file_id = f.file_id WHERE course_id = {$course_id} AND is_del =0";
    $q = $db->query($sql);
    $file_array = array();
    $ff_id = 10000000;
    while ($rs = $db->fetch_array($q)) {
        $rs['ff_id'] = $ff_id;
        $ff_id++;
        $rs['parent_id'] = $rs['cs_id'];
        $rs['file_time'] = date('Y-m-d H:i:s', $rs[file_time]);
        $rs['status'] = $defineFileChaptersSections[$rs['status']] ? $defineFileChaptersSections[$rs['status']] : '未定义状态';
        $rs['a_del'] = urr("mydisk", "item=course&action=file_cs_relation_delete&cs_id={$rs['cs_id']}&file_id={$rs['file_id']}&course_id={$rs['course_id']}");
        $rs['is_file'] = 1;
        $file_array[] = $rs;
    }
    unset($rs);
    //合并数组
    $cs_file = array_merge($chapter_section_array, $file_array);
    PHPTree::$config['primary_key'] = 'ff_id';
    PHPTree::$config['parent_key'] = 'parent_id';
    $chapter_section_array = !empty($chapter_section_array) ? PHPTree::makeTreeForHtml($cs_file) : array();
    return $chapter_section_array;
}