next up previous contents
Next: session_php.php 程式修改 Up: Timetable 課表 Previous: function.php 程式修改   Contents

gotoroom.php 程式修改

  1. 修改資料庫查詢方式,因已只顯示個人「課表」,故直接查詢用戶名的課表。原方式查詢造成系統非常大的負擔。
    [root@moodle mod_tmp]# diff -urNwbBE mrbs/web/gotoroom.php ../blocks/mrbs/web/gotoroom.php
    --- mrbs/web/gotoroom.php	2012-10-21 19:24:42.000000000 +0800
    +++ ../blocks/mrbs/web/gotoroom.php	2013-09-21 07:54:19.000000000 +0800
    @@ -47,17 +47,17 @@
         showAccessDenied($day, $month, $year, NULL);
         exit;
     }
    +$sql = "SELECT area_id, id FROM {block_mrbs_room} WHERE room_name = ? OR description = ?"; //dywang
    +$area = $DB->get_record_sql($sql, array($room, $room), IGNORE_MULTIPLE);
     
    -$sql = "SELECT area_id, area_name FROM {block_mrbs_room} AS r JOIN {block_mrbs_area} AS a ON a.id = r.area_id WHERE room_name = ? OR room_name = ?";
    -
    -
    -$area = $DB->get_record_sql($sql, array($room, '0'.$room), IGNORE_MULTIPLE);
    
  2. 修改查詢結果以「週」顯示。
    -if ($area) {
    -    $areaurl = new moodle_url('/blocks/mrbs/web/day.php',
    -                              array('day'=>$day, 'month'=>$month, 'year'=>$year, 'area'=>$area->area_id));
    +if (!empty($area)) {
    +    $areaurl = new moodle_url('/blocks/mrbs/web/week.php',
    +                              array('day'=>$day, 'month'=>$month, 'year'=>$year, 'area'=>$area->area_id,'room'=>$area->id));
         redirect($areaurl);
     } else {
    -    $notfoundurl = new moodle_url('/blocks/mrbs/web/day.php',
    +    $notfoundurl = new moodle_url('/blocks/mrbs/web/week.php',
                                       array('day'=>$day, 'month'=>$month, 'year'=>$year, 'roomnotfound'=>$room));
         redirect($notfoundurl);
     }
    



2017-08-04