Пример #1
0
 function fenye($page, $order, $linkPage, $userid, $keyword, $deleted = 0, $select = 0, $version = 0)
 {
     global $page_size;
     $linkPage .= strpos($linkPage, "?") > 0 ? "&" : "?";
     //$self = $_SERVER["PHP_SELF"];
     $by = "order by ";
     switch ($order) {
         case 1:
             $by .= "time desc";
             break;
         case 2:
             $by .= "time";
             break;
         case 3:
             $by .= "userid";
             break;
         case 4:
             $by .= "title";
             break;
     }
     $where = "where deleted=" . $deleted;
     if ($keyword != "") {
         $where .= " and (title like '%" . $keyword . "%' or description like '%" . $keyword . "%')";
     }
     if ($userid) {
         $where .= " and userid=" . $userid;
     }
     $sql = "select * from courseunit {$where}";
     //die($sql);
     $result = mysql_query($sql);
     $amount = mysql_num_rows($result);
     //表中的总纪录数
     if ($amount) {
         $page_total = ceil($amount / $page_size);
     } else {
         echo "没有记录";
         return;
     }
     if ($page > $page_total) {
         $page = $page_total;
     }
     $page_start = ($page - 1) * $page_size;
     if ($select) {
         echo "<table border='1' width='100%' cellspacing='0' cellpadding='0'>\n\t\t\t\t\t<tr>";
         if (!$version) {
             echo "<th width='10%' align='center' class='th1'></th>";
         }
         echo "<th width='40%' align='center' class='th1'>课程单元名称</th>\n\t\t\t\t\t<th width='10%' align='center' class='th1'>创建者</th>\n\t\t\t\t\t<th width='15%' align='center' class='th1'>创建时间</th>\n\t\t\t\t</tr>";
     } else {
         echo "<table border='1' width='100%' cellspacing='0' cellpadding='0'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th width='40%' align='center' class='th1'>课程单元名称</th>\n\t\t\t\t\t\t<th width='10%' align='center' class='th1'>创建者</th>\n\t\t\t\t\t\t<th width='15%' align='center' class='th1'>创建时间</th>\n\t\t\t\t\t\t<th width='10%' align='center' class='th1'>操作</th>\n\t\t\t\t\t</tr>";
     }
     $res = mysql_query("select * from courseunit {$where} {$by} limit {$page_start},{$page_size}");
     if ($deleted) {
         //只显示已删除的课程单元
         while ($arr = mysql_fetch_array($res)) {
             //if($arr["lpid"]){
             //$title = "<a href='scormShow.php?id=$arr[lpid]' target='_blank'><img src='../img/scorm.png' width='25' title='Scorm'>".$arr["title"]."</a>";
             //}else{
             $title = "<a href='courseUnitShow.php?id={$arr['id']}'>" . $arr["title"] . "</a>";
             //}
             $userinfo = getUserinfoById($arr["userid"]);
             echo "<tr><td>{$title}</td><td><a href=''>" . $userinfo["realname"] . "</a></td><td>{$arr['time']}</td><td><a href='revertTodo.php?type=1&id={$arr['id']}'><img src='../img/document-revert.png' width='22' title='恢复' alt='恢复'></a> <a href='delete.php?type=101&id={$arr['id']}'><img src='../img/delete.png' title='彻底删除' alt='彻底删除'></a></td></tr>";
         }
     } else {
         //只显示未删除的课程单元
         if ($select) {
             //分页复选模式显示
             if ($version) {
                 //显示课程单元所有版本信息
                 $index = 0;
                 while ($arr = mysql_fetch_array($res)) {
                     $index++;
                     $title = "<a href='courseUnitShow.php?id={$arr['id']}' target='_blank'>" . $arr["title"] . "</a>";
                     $userinfo = getUserinfoById($arr["userid"]);
                     echo "<tr><td>" . $title . "<br>";
                     $res_courseunitversion_rel_attachment = mysql_query("select * from courseunitversion_rel_attachment where deleted=0 and courseunitid=" . $arr["id"]);
                     $i = 1;
                     $num = mysql_num_rows($res_courseunitversion_rel_attachment);
                     if ($num >= 1) {
                         while ($arr_courseunitversion_rel_attachment = mysql_fetch_array($res_courseunitversion_rel_attachment)) {
                             //$c = $i++==$num ? "checked" : "";
                             echo "<label><input class='subitem_check' type='checkbox' value='{$arr_courseunitversion_rel_attachment['id']}' name='v-{$arr['id']}' title='创建日期:{$arr_courseunitversion_rel_attachment['time']}'>{$arr_courseunitversion_rel_attachment['versionname']}</label> &nbsp;";
                         }
                     }
                     echo "</td><td><a href=''>" . $userinfo["realname"] . "</a></td><td>{$arr['time']}</td></tr>";
                 }
             } else {
                 //不显示课程单元所有版本信息
                 while ($arr = mysql_fetch_array($res)) {
                     $title = "<a href='courseUnitShow.php?id={$arr['id']}' target='_blank'>" . $arr["title"] . "</a>";
                     $userinfo = getUserinfoById($arr["userid"]);
                     echo "<tr><td><input type='checkbox' value='" . $arr["id"] . "'></td><td>{$title}</td><td><a href=''>" . $userinfo["realname"] . "</a></td><td>{$arr['time']}</td></tr>";
                 }
             }
         } else {
             //正常显示,即只显示课程单元列表
             while ($arr = mysql_fetch_array($res)) {
                 //if($arr["lpid"]){
                 //$title = "<a href='scormShow.php?id=$arr[lpid]' target='_blank'><img src='../img/scorm.png' width='25' title='Scorm'>".$arr["title"]."</a>";
                 //}else{
                 $title = "<a href='courseUnitShow.php?id={$arr['id']}'>" . $arr["title"] . "</a>";
                 //}
                 $userinfo = getUserinfoById($arr["userid"]);
                 echo "<tr><td>{$title}</td><td><a href=''>" . $userinfo["realname"] . "</a></td><td>{$arr['time']}</td><td><a href='courseUnitSetting.php?id={$arr['id']}&title={$arr['title']}'><img src='../img/edit.png' title='编辑' alt='编辑'></a> <a href='delete.php?type=3&id={$arr['id']}'><img src='../img/delete.png' title='删除' alt='删除'></a></td></tr>";
             }
         }
     }
     echo "</table>";
     //显示[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]
     function pp($a, $page, $page_total, $linkpage, $userid)
     {
         global $page_size, $keyword, $order;
         for ($i = $page - $a; $i <= $page + $a; $i++) {
             if ($i > 0 && $i <= $page_total) {
                 if ($i == $page) {
                     echo " <font color='red'>[{$i}]</font> ";
                 } else {
                     echo " <a href='{$linkpage}" . "page={$i}&userid={$userid}&k={$keyword}&order={$order}'>[{$i}]</a> ";
                 }
             }
         }
     }
     $page_up = $page - 1;
     $page_down = $page + 1;
     if ($page == 1) {
         $s = "首页 | 上一页 | ";
     } else {
         $s = "<a href='{$linkPage}" . "page=1&userid={$userid}&k={$keyword}&order={$order}'>首页</a> | \n\t\t\t\t<a href='{$linkPage}" . "page={$page_up}&userid={$userid}&k={$keyword}&order={$order}'>上一页</a> | ";
     }
     if ($page == $page_total) {
         $x = " | 下一页 | 尾页<br />";
     } else {
         $x = " | <a href='{$linkPage}" . "page={$page_down}&userid={$userid}&k={$keyword}&order={$order}'>下一页</a> | \n\t\t\t\t<a href='{$linkPage}" . "page={$page_total}&userid={$userid}&k={$keyword}&order={$order}'>尾页</a><br />";
     }
     echo "<p /><center>共 {$amount} 条记录,每页显示 {$page_size} 条<br />";
     echo $s;
     pp(5, $page, $page_total, "{$linkPage}", $userid);
     echo $x;
     echo "转到第<input type='text' size=1 maxlength=7 value={$page} onchange='window.location=\"{$linkPage}" . "userid={$userid}&k={$keyword}&order={$order}&page=\"+this.value'>页&nbsp;&nbsp;<font color=blue>跳转</font>&nbsp;&nbsp;共 {$page_total} 页,当前第 {$page} 页";
 }
Пример #2
0
 function fenye($page, $order, $linkPage, $userid, $keyword, $deleted = 0, $select = 0)
 {
     global $page_size;
     $linkPage .= strpos($linkPage, "?") > 0 ? "&" : "?";
     //$self = $_SERVER["PHP_SELF"];
     $by = "order by ";
     switch ($order) {
         case 1:
             $by .= "time desc";
             break;
         case 2:
             $by .= "time";
             break;
         case 3:
             $by .= "userid";
             break;
         case 4:
             $by .= "title";
             break;
         case 5:
             $by .= "type desc";
             break;
     }
     $where = "where deleted=" . $deleted;
     if ($keyword != "") {
         $where .= " and (title like '%" . $keyword . "%' or description like '%" . $keyword . "%')";
     }
     if ($userid) {
         $where .= " and userid=" . $userid;
     }
     $sql = "select * from course {$where}";
     //echo $sql;
     //die();
     $result = mysql_query($sql);
     //在course表中查询所有课程信息
     $amount = mysql_num_rows($result);
     //表中的总纪录数
     if ($amount) {
         $page_total = ceil($amount / $page_size);
     } else {
         echo "没有记录";
         return;
     }
     if ($page > $page_total) {
         $page = $page_total;
     }
     $page_start = ($page - 1) * $page_size;
     if ($select) {
         echo "<table border='1' width='100%' cellspacing='0' cellpadding='0'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th width='10%' align='center' class='th1'></th>\n\t\t\t\t\t\t<th width='20%' align='center' class='th1'>课程名称</th>\n\t\t\t\t\t\t<th width='20%' align='center' class='th1'>课程类别</th>\n\t\t\t\t\t\t<th width='10%' align='center' class='th1'>创建者</th>\n\t\t\t\t\t\t<th width='15%' align='center' class='th1'>课程开始时间</th>\n\t\t\t\t\t\t<th width='15%' align='center' class='th1'>课程结束时间</th>\n\t\t\t\t\t</tr>";
     } else {
         echo "<table border='1' width='100%' cellspacing='0' cellpadding='0'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th width='20%' align='center' class='th1'>课程名称</th>\n\t\t\t\t\t\t\t<th width='10%' align='center' class='th1'>课程类别</th>\n\t\t\t\t\t\t\t<th width='10%' align='center' class='th1'>创建者</th>\n\t\t\t\t\t\t\t<th width='15%' align='center' class='th1'>创建时间</th>\n\t\t\t\t\t\t\t<th width='15%' align='center' class='th1'>课程开始时间</th>\n\t\t\t\t\t\t\t<th width='15%' align='center' class='th1'>课程结束时间</th>\n\t\t\t\t\t\t\t<th width='15%' align='center' class='th1'>操作</th>\n\t\t\t\t\t\t</tr>";
     }
     $res = mysql_query("select * from course {$where} {$by} limit {$page_start},{$page_size}");
     //在course表中查询符合条件的所有课程
     //输出课程
     if ($deleted) {
         //只显示已删除的课程
         while ($arr = mysql_fetch_array($res)) {
             $userinfo = getUserinfoById($arr["userid"]);
             $type = $arr["type"] ? "学习课程" : "参考课程";
             echo "<tr><td><a href='courseCategory_for_course.php?id={$arr['id']}&title={$arr['title']}'>" . $arr["title"] . "</a></td><td>{$type}</td><td><a href=''>" . $userinfo["realname"] . "</a></td><td>{$arr['time']}</td><td>{$arr['starttime']}</td><td>{$arr['endtime']}</td><td><a href='revertTodo.php?type=2&id={$arr['id']}'><img src='../img/document-revert.png' width='22' title='恢复' alt='恢复'></a> <a href='delete.php?type=102&id={$arr['id']}' title='彻底删除' alt='彻底删除'><img src='../img/delete.png'></a></td></tr>";
         }
     } else {
         //只显示未删除的课程
         if ($select) {
             //分页复选模式
             while ($arr = mysql_fetch_array($res)) {
                 $userinfo = getUserinfoById($arr["userid"]);
                 $type = $arr["type"] ? "学习课程" : "参考课程";
                 echo "<tr>\n\t\t\t\t\t\t<td><input type='checkbox' value='" . $arr["id"] . "'></td>\n\t\t\t\t\t\t<td>" . $arr["title"] . "</td>\n\t\t\t\t\t\t<td>{$type}</td>\n\t\t\t\t\t\t<td>" . $userinfo["realname"] . "</td>\n\t\t\t\t\t\t<td>" . $arr["starttime"] . "</td>\n\t\t\t\t\t\t<td>" . $arr["endtime"] . "</td>\n\t\t\t\t\t\t</tr>";
             }
         } else {
             //正常显示
             while ($arr = mysql_fetch_array($res)) {
                 $userinfo = getUserinfoById($arr["userid"]);
                 $type = $arr["type"] ? "学习课程" : "参考课程";
                 $title = urlencode($arr['title']);
                 echo "<tr><td><a href='courseCategory_for_course.php?id={$arr['id']}&title={$title}'>" . $arr["title"] . "</a></td><td>{$type}</td><td><a href=''>" . $userinfo["realname"] . "</a></td><td>{$arr['time']}</td><td>{$arr['starttime']}</td><td>{$arr['endtime']}</td><td><a href='javascript:;' onclick='copy(\"{$arr['id']}\")'><img src='../img/copy.png' width='22' title='复制' alt='复制'></a> <a href='courseAdd.php?id={$arr['id']}'><img src='../img/edit.png' title='编辑' alt='编辑'></a> <a href='delete.php?type=4&id={$arr['id']}' title='删除' alt='删除'><img src='../img/delete.png'></a></td></tr>";
             }
         }
     }
     echo "</table>";
     //显示[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]
     function pp($a, $page, $page_total, $linkpage, $userid)
     {
         global $page_size, $keyword, $order;
         for ($i = $page - $a; $i <= $page + $a; $i++) {
             if ($i > 0 && $i <= $page_total) {
                 if ($i == $page) {
                     echo " <font color='red'>[{$i}]</font> ";
                 } else {
                     echo " <a href='{$linkpage}" . "page={$i}&userid={$userid}&k={$keyword}&order={$order}'>[{$i}]</a> ";
                 }
             }
         }
     }
     $page_up = $page - 1;
     $page_down = $page + 1;
     if ($page == 1) {
         $s = "首页 | 上一页 | ";
     } else {
         $s = "<a href='{$linkPage}" . "page=1&userid={$userid}&k={$keyword}&order={$order}'>首页</a> | \n\t\t\t\t<a href='{$linkPage}" . "page={$page_up}&userid={$userid}&k={$keyword}&order={$order}'>上一页</a> | ";
     }
     if ($page == $page_total) {
         $x = " | 下一页 | 尾页<br />";
     } else {
         $x = " | <a href='{$linkPage}" . "page={$page_down}&userid={$userid}&k={$keyword}&order={$order}'>下一页</a> | \n\t\t\t\t<a href='{$linkPage}" . "page={$page_total}&userid={$userid}&k={$keyword}&order={$order}'>尾页</a><br />";
     }
     echo "<p /><center>共 {$amount} 条记录,每页显示 {$page_size} 条<br />";
     echo $s;
     pp(5, $page, $page_total, "{$linkPage}", $userid);
     echo $x;
     echo "转到第<input type='text' size=1 maxlength=7 value={$page} onchange='window.location=\"{$linkPage}" . "userid={$userid}&k={$keyword}&order={$order}&page=\"+this.value'>页&nbsp;&nbsp;<font color=blue>跳转</font>&nbsp;&nbsp;共 {$page_total} 页,当前第 {$page} 页";
 }
Пример #3
0
    case 4:
        $by .= "title";
        break;
    case 5:
        $by .= "type desc";
        break;
}
//选择
//die("select * from course where deleted=0 and id in ($ids) order by time desc");
$res = $mysql->query("select * from course where deleted=0 and id in ({$ids}) and (title like '%" . $keyword . "%' or description like '%" . $keyword . "%') {$by}");
$time = date("Y-m-d H:i:s");
//显示课程列表(判断是否有课程)
if (@($arr = mysql_fetch_array($res))) {
    echo "<table border='1' width='100%' cellspacing='0' cellpadding='0'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th width='20%' align='center' class='th1'>课程名称</th>\n\t\t\t\t\t\t<th width='10%' align='center' class='th1'>课程类别</th>\n\t\t\t\t\t\t<th width='10%' align='center' class='th1'>创建者</th>\n\t\t\t\t\t\t<th width='20%' align='center' class='th1'>创建时间</th>\n\t\t\t\t\t\t<th width='20%' align='center' class='th1'>课程开始时间</th>\n\t\t\t\t\t\t<th width='20%' align='center' class='th1'>课程结束时间</th>\n\t\t\t\t\t</tr>";
    do {
        $userinfo = getUserinfoById($arr["userid"]);
        $type = $arr["type"] ? "学习课程" : "参考课程";
        echo "<tr><td><a href='courseCategory_for_course.php?id={$arr['id']}&title={$arr['title']}'>" . $arr["title"] . "</a></td><td>{$type}</td><td><a href=''>" . $userinfo["realname"] . "</a></td><td>{$arr['time']}</td><td>{$arr['starttime']}</td><td>{$arr['endtime']}</td></tr>";
    } while ($arr = mysql_fetch_array($res));
    echo "</table>";
} else {
    echo "无相关课程记录!";
}
?>
			</ul>
			</div>

			<div class="info"></div>
			<div class="list_courseUnit">
			<ul>
			<?php 
Пример #4
0
<div id="wrapper">

<?php 
session_start();
include "inc/config.php";
setcookie(session_name(), session_id(), time() + $sessionTime, "/");
if (!(isset($_SESSION["userid"]) && $_SESSION["userid"] != 0)) {
    //判断之前的session是否已经结束,如果结束,则重新登录
    header("Location:index.php");
    exit;
}
include "inc/mysql.php";
include "inc/function.php";
include "inc/navigation_root.php";
$userid = $_SESSION["userid"];
$arr = getUserinfoById($userid);
//从数据库user表中获取用户信息
$username = $arr["username"];
$realname = $arr["realname"];
$mail = $arr["mail"];
$department = $arr["department"];
?>

<div class="clear">&nbsp;</div>
<div id="main"> <!-- start of #main wrapper for #content and #menu divs -->
<!--   Begin Of script Output   -->
<div id="content" class="maxcontent">

	<div id="content_with_menu">
		<div id="container">
			<div class="info">个人资料</div>
function getChildren($groupid, $grouptype)
{
    //获得group的children grouptype(1:用户(组),2:课程单元(组),3:课程(组))返回类型为item
    global $mysql;
    $childrenitems = array();
    $childrenitem = array();
    //开始获取组里面的个体
    if ($grouptype == 1) {
        //获取用户
        $res = $mysql->query("select * from usergroup where groupid=" . $groupid);
        $arr = $mysql->fetch_array($res);
        $userids = substr($arr["userids"], 1, -1);
        //获取所有课程id
        $res_user = $mysql->query("select * from user where deleted=0 and id in ({$userids}) order by time desc");
        //根据courseid获取course表中的课程
        while ($arr_user = $mysql->fetch_array($res_user)) {
            //逐行取出用户
            //开始获取用户所需信息,并添加到item中
            $childrenitem["id"] = $arr_user["id"];
            $childrenitem["title"] = $arr_user["realname"];
            $childrenitem["time"] = $arr_user["time"];
            $childrenitem["creator"] = "无";
            $childrenitem["children"] = null;
            //将item添加到items中
            $childrenitems[] = $childrenitem;
        }
    } else {
        if ($grouptype == 2) {
            //获取课程单元
        } else {
            if ($grouptype == 3) {
                //获取课程
                $res = $mysql->query("select * from coursegroup where groupid=" . $groupid);
                $arr = $mysql->fetch_array($res);
                $courseids = substr($arr["courseids"], 1, -1);
                //获取所有课程id
                $res_course = $mysql->query("select * from course where deleted=0 and id in ({$courseids}) order by time desc");
                //根据courseid获取course表中的课程
                while ($arr_course = $mysql->fetch_array($res_course)) {
                    //逐行取出课程
                    $userinfo = getUserinfoById($arr_course["userid"]);
                    //开始获取课程所需信息,并添加到item中
                    $childrenitem["id"] = $arr_course["id"];
                    $childrenitem["title"] = $arr_course["title"];
                    $childrenitem["time"] = $arr_course["time"];
                    $childrenitem["creator"] = $userinfo["realname"];
                    $childrenitem["children"] = null;
                    //将item添加到items中
                    $childrenitems[] = $childrenitem;
                }
            } else {
                //$grouptype参数错误
            }
        }
    }
    //如果组里包含组,则开始获取组里面的组(以后再实现)
    return $childrenitems;
    //返回items
}