[root@moodle mod_tmp]# diff -urNwbBE mrbs/web/week.php ../blocks/mrbs/web/week.php
--- mrbs/web/week.php 2012-10-21 19:24:42.000000000 +0800
+++ ../blocks/mrbs/web/week.php 2014-09-23 10:14:56.724583441 +0800
@@ -33,6 +33,7 @@
$pview = optional_param('pview', 0, PARAM_INT);
$timetohighlight = optional_param('timetohighlight', -1, PARAM_INT);
+if ( $room != 0 and $room != $USER->id and authGetUserLevel($USER->id) != 2) {return;} //dywang
$num_of_days = $cfg_mrbs->weeklength;
if ($num_of_days==0) {
$num_of_days=7; //if user has not configured this, default to 7
@@ -75,7 +76,8 @@
if ($area > 0) {
$thisurl->param('area', $area);
} else {
- $area = get_default_area();
+ $area = $DB->get_field('block_mrbs_room', 'area_id', array('description'=>$USER->lastname));
}
if ($room > 0) {
$thisurl->param('room', $area);
@@ -113,12 +114,14 @@
$this_room_name = "";
// Show all areas
- echo "<td width=\"30%\"><u>".get_string('areas','block_mrbs')."</u><br>";
}
// show either a select box or the normal html list
if ($area_list_format == "select") {
+ if ( authGetUserLevel($USER->id) == '2') { //dywang
echo make_area_select_html('week.php', $area, $year, $month, $day); // from functions.php
+ }
$this_area_name = $DB->get_field('block_mrbs_area', 'area_name', array('id'=>$area));
$this_room_name = $DB->get_field('block_mrbs_room', 'room_name', array('id'=>$room));
$this_room_description = $DB->get_field('block_mrbs_room', 'description', array('id'=>$room));
@@ -140,17 +143,23 @@
}
if ( $pview != 1) {
- echo "</td>\n";
// Show all rooms in the current area
- echo "<td width=\"30%\"><u>".get_string('rooms','block_mrbs')."</u><br>";
+ echo "<td width=\"10%\"><u>".get_string('rooms','block_mrbs')."</u><br>";
}
// should we show a drop-down for the room list, or not?
-if ($area_list_format == "select") {
+if ( authGetUserLevel($USER->id) == 2) { //dywang
echo make_room_select_html('week.php', $area, $room, $year, $month, $day); // from functions.php
} else {
- $rooms = $DB->get_records('block_mrbs_room', array('area_id'=>$area), 'room_name');
+ $rooms = $DB->get_records('block_mrbs_room', array('description'=>$USER->lastname), 'room_name,area_id');
foreach ($rooms as $dbroom) {
if ( $pview != 1 ) {
echo '<a href="'.($baseurl->out(true, array('area'=>$area, 'room'=>$dbroom->id))).'" title="'.$dbroom->room_name.'">';
@@ -170,8 +179,27 @@
if ( $pview != 1 ) {
echo "</td>\n";
+ if ( authGetUserLevel($USER->id) == 2) { //dywang
+ //insert the goto room form
+ $gotoroom = new moodle_url('/blocks/mrbs/web/gotoroom.php');
+ $gostr = get_string('goroom', 'block_mrbs');
+ $gotoval = ”;
+ $gotomsg = ”;
+ if ($roomnotfound) {
+ $gotoval = $roomnotfound;
+ $gotomsg = ' '.get_string('noroomsfound', 'block_mrbs');
+ }
+ echo "<td width=\"20%\"><h3>".get_string('findroom', 'block_mrbs')."</h3>
+ <form action='$gotoroom' method='get'>
+ <input type='text' name='room' value='$gotoval'>
+ <input type='hidden' name='day' value='$day'>
+ <input type='hidden' name='month' value='$month'>
+ <input type='hidden' name='year' value='$year'>
+ <input type='submit' value='$gostr'>$gotomsg
+ </form></td>";
+ }
//Draw the three month calendars
- minicals($year, $month, $day, $area, $room, 'week');
+ //minicals($year, $month, $day, $area, $room, 'week'); //dywang
echo "</tr></table>\n";
}
@@ -215,6 +243,21 @@
$roomdata = $DB->get_record('block_mrbs_room', array('id'=>$room));
$allowedtobook = allowed_to_book($USER, $roomdata);
+$sql = " firstname = ? AND lastname = ?"; //dywang begin
+$users = $DB->get_records_select('user', $sql, array($roomdata->room_name, $roomdata->description));
+foreach ($users as $user) {
+ $user_id=$user->id;
+}
+$courses = enrol_get_users_courses($user_id);
+foreach($courses as $course) {
+ $courseids .= $course->id.',';
+}
+$courseids .= $room;
+
//Get all appointments for this week in the room that we care about
// This data will be retrieved day-by-day
for ($j = 0; $j<=($num_of_days-1) ; $j++) {
@@ -228,10 +271,15 @@
// Note: weekday here is relative to the $weekstarts configuration variable.
// If 0, then weekday=0 means Sunday. If 1, weekday=0 means Monday.
- $sql = 'room_id = ? AND start_time <= ? AND end_time > ?';
- $entries = $DB->get_records_select('block_mrbs_entry', $sql, array($room, $pm7[$j], $am7[$j]));
+ $sql = "room_id in($courseids) AND start_time <= ? AND end_time > ?"; //dywang
+ $entries = $DB->get_records_select('block_mrbs_entry', $sql, array($pm7[$j], $am7[$j])); //dywang
foreach ($entries as $entry) {
@@ -255,6 +302,7 @@
$end_t = min(round_t_up($entry->end_time, $resolution, $am7[$j]) - $resolution, $pm7[$j]);
for ($t = $start_t; $t <= $end_t; $t += $resolution) {
$d[$j][date($format,$t)]["id"] = $entry->id;
+ $d[$j][date($format,$t)]["room_id"] = $entry->room_id; //dywang
$d[$j][date($format,$t)]["color"] = $entry->type;
$d[$j][date($format,$t)]["data"] = "";
$d[$j][date($format,$t)]["long_descr"] = "";
@@ -312,7 +361,7 @@
echo "<table cellspacing=0 border=1 width=\"100%\">";
// The header row contains the weekday names and short dates.
-echo "<tr><th width=\"1%\"><br>".($enable_periods ? get_string('period','block_mrbs') : get_string('time'))."</th>";
+echo "<tr><th width=\"5%\"><br>".($enable_periods ? get_string('period','block_mrbs') : get_string('time'))."</th>"; //dywang
if (empty($dateformat)) {
$dformat = "%a<br>%b %d";
} else {
@@ -328,7 +377,7 @@
}
// next line to display times on right side
if ( FALSE != $times_right_side ) {
- echo "<th width=\"1%\"><br>"
+ echo "<th width=\"5%\"><br>" //dywang
. ( $enable_periods ? get_string('period','block_mrbs') : get_string('time') )
. "</th>";
}
@@ -390,6 +439,7 @@
if(isset($d[$thisday][$time_t]["id"])) {
$id = $d[$thisday][$time_t]["id"];
+ $room_id = $d[$thisday][$time_t]["room_id"];
$color = $d[$thisday][$time_t]["color"];
$descr = s($d[$thisday][$time_t]["data"]);
$long_descr = s($d[$thisday][$time_t]["long_descr"]);
@@ -459,7 +509,10 @@
$viewentry = new moodle_url('/blocks/mrbs/web/view_entry.php',
array('id'=>$id, 'area'=>$area, 'day'=>$wday,
'month'=>$wmonth, 'year'=>$wyear));
- echo ' <a href="'.$viewentry.'" title="'.$long_descr.'">'.$descr.'</a>';
+ if ( $room_id != $room and authGetUserLevel($USER->id) != 2) { echo "$long_descr/$descr";} //dywang
+ else {echo ' <a href="'.$viewentry.'" title="'.$long_descr.'">'.$long_descr.'/'.$descr.'</a>';} //dywang
} else {
echo " \" ";
}