Install MRBS Scheduling Calendar on SFU Fraser
PHP icalendar Google Calendar and PHP icalendar MRBS Room booking Calendar  Feed2JS (RSS Feed to JavaScript)

Setting up MRBS

This is out of date, the newer version of MRBS is fantastic. Drop me a line if you have any questions.

MRBS is an online calendar for scheduling/ reserving/ booking rooms, equipment, facilities, people and other resources. More about MRBS is available at the SourceForge website.

Our setup allows anyone to view the calendar, but using SFU's maillists and CAS for authentication only people in our department can make reservations (this differs from the default distribution by putting the add/edit and admin files in an .htaccess restricted subfolder). Selected staff manage the calendar (edit/delete other peoples bookings). Because our setup uses existing SFU mail lists, the calendar requires no extra maintenance such as adding users. Many other authentication possibilities exist.

You may setup a script to send notification reminders (using cron). MRBS has a setting for confirmation emails.

I also modified MRBS to allow confidential booking of our undergraduate student advisors . This was with an earlier version with and adding fields (Student number or student id, and phone number), plus other minor modifications. If you are interested in specifics contact me, as well as look at mrbs_mysql_quick.txt and mrbs-advising.html.

MRBS is also used by the SFU Library, Faculty of Applied Sciences, Faculty of Communication, Art & Technology, SFU Surrey, and the Nano Imaging Facility.

Additional help is available from MRBS. My directions are for Macintosh OS X, using terminal, TextWrangler (BBEdit), and Sequel Pro (free) but you can use Windows, Putty and Crimson Editor or Notepad2 (any editor that will save with UNIX line endings). These instructions worked for me but I do not guarantee that they will work for you, or that they will meet your security needs (please share any suggestions you have with me!).


1) Request a mysql database be created by IT Services- follow these instructions.  If you already have a mysql database on fraser you may be able to use it.  mySQL databases on fraser are independent of the SFU computing ID, thus you may use one database in more than one account.

2)  Connect to your mySQL database with information you received in from IT Services (MySQL Cheatsheet).  Run the tables.my.sql script.  
9: youraccount_fraser% mysql -u sfuMySQLname -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 437638 to server version: 4.0.20-standard-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use database sfuDatabase_name; [2012: use sfuDatabase_name; ]

mysql> source /home/youraccount/sec_html/calendar/tables.my.sql;
Query OK, 0 rows affected (0.08 sec)

Query OK, 0 rows affected (0.02 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

        

3) Open a Terminal window and SSH to your SFU UNIX account (fraser). Follow IT Services instructions for creating a secure server at http://www.sfu.ca/itservices/publishing/publish_howto/enhanced_web_publishing/cgi-based_sites_usingperl.html, basically:

ssh YOURACCOUNT@fraser.sfu.ca
mkdir sec_html
chmod 711 sec_html
cd sec_html
mkdir calendar
(or whatever you want your directory to be called)
chmod 711 calendar

4) Download MRBS from http://mrbs.sourceforge.net/ on your computer.  

5)  Add this first line to most *.php files:
#!/usr/local/bin/php
so they know where PHP is on Fraser. The complete list of php files is here and on a mac if you put that file in the web folder you can use this script which is three lines

 
cat files_to_add_shebang.txt | xargs -I {} sed -i bak '1i\
#!/usr/local/bin/php
' {}
to add the 'shebang' lines (Thanks to Mike Stanger & Graham Ballantyne for the script!).

6) Transfer the files to Fraser. I use the free Cyberduck to transfer files to sftp://YOURACCOUNT@fraser.sfu.ca/. The files in the web folder are the only ones you need for the web- you may rename the web folder for a better address.

7) Give the proper permissions to the files and folders after they are on Fraser. In Terminal, secure shell into Fraser

ssh youraccount@fraser.sfu.ca
and then cd to where the MRBS web files are. Paste these lines into your terminal window (a single copy and paste of all the lines should work- check before hand that paths have not changed and afterwards for errors.):

chmod 711 Blowfish
chmod 711 css
chmod 711 File
chmod 711 File/Passwd
chmod 711 Mail
chmod 711 Net
chmod 711 Themes
chmod 711 Themes/default
chmod 711 Themes/classic126
chmod 711 js
chmod 700 *.php
chmod 700 Blowfish/*.php
chmod 700 css/*.php
chmod 700 File/Passwd/*.php
chmod 700 File/*.php
chmod 700 js/*.php
chmod 700 Mail/*.php
chmod 700 Net/*.php

chmod_files_directories.txt
        
[Later if you see "#!/usr/local/bin/php" at the top of a web page, it should be removed from the file calling it. If you get "Internal Server Error. The server encountered an internal error or misconfiguration and was unable to complete your request." you should add it to the file or check that you have used chmod properly.]        

8) Modify config.inc.php by copying portions from systemdefaults.inc.php and areadefaults.inc.php - see the sample configuration file (two old sample files- one without email notification, the other with) (search for 'SFU' to see changes made.). To use CAS authentication, use at least MRBS version 1.4.1 and .htaccess files, 'remote_user', and 'none' in the authentication settings, e.g.:

$auth["session"] = "remote_user"; // How to get and keep the user ID. One of
           // "http" "php" "cookie" "ip" "host" "nt" "omni"
           // "remote_user"

$auth["type"] = "none";
 Note the change from $unicode_encoding = 1;  to $unicode_encoding = 0;


Old Stuff
In admin.php (for aesthetics) change
# add space  before parenthesis approx. line 94
echo "<li>" . htmlspecialchars($row[1]) . " (" . htmlspecialchars($row[2])

9) If you have problems, you may have to make some files visible to the world...

chmod 644 /home/YOURACCOUNT/sec_html/calendar/.htaccess
chmod 644 /home/YOURACCOUNT/sec_html/calendar/images/*.*
chmod 644 /home/YOURACCOUNT/sec_html/calendar/css/*.css
chmod 644 /home/YOURACCOUNT/sec_html/calendar/*.html

10) Now you should be able to go to a web browser and view the calendar-

https://cgi.sfu.ca/~YOURACCOUNT/whatever

https://cgi.sfu.ca/~science/calendar/biology/booking/web/


It should work- if not, search on the error message or email me. Once you get it to work you can modify things to restrict access or create additional folders (websites) with different administrators.

Setting up MRBS on fraser.sfu.ca- Customizations

I created a .htaccess restricted subdirectory named restricted. Then I copied all the files to the subdirectory (chmod as required), and changed the files in the unrestricted directory to point to the restricted directory [e.g. in day.php etc, href=\"restricted/edit_entry.php] and removed the links to admin.php. I deleted the edit_entry.php and admin.php in the unrestricted directory.

If you only use english you may modify wording by changing the lang.en file and change config.inc.php to disable_automatic_language_changing = 1; (0 is the default and sets the language based on the user's preference).


We get the error message [Warning: Server failed to set locale to "_" (Unix)] so we used the command 'locale -a' on fraser, e.g.,

science_fraser% locale -a
C
POSIX
en_CA
en_CA.ISO8859-1
en_CA.UTF-8
en_US  [etc]
Then set the locale in config.inc.php as shown here:
// Set this to a valid locale (for the OS you run the MRBS server on)
// if you want to override the automatic locale determination MRBS
// performs
$override_locale = "en_CA.UTF-8";  //SFU changed to n_CA.UTF-8 from blank
and the error message was gone.


In order to show that a booking is part of a series in day.php I added an asterisk to the booking:

Line 182: changed sql $tbl_entry.description AS entry_description to

$tbl_entry.description AS entry_description, entry_type

Line 233: Added line after $today[$row['room_id']][date($format,$t)]["long_descr"] = "";

$today[$row['room_id']][date($format,$t)]["repeatdc"]  = ($row['entry_type'] ? '*' : '');	//Added SFU to show repeating

Line 423: Added line after $long_descr = htmlspecialchars($today[$room_id][$time_t]["long_descr"]);

$repeatdc = $today[$room_id][$time_t]["repeatdc"];   //Added by Dave Carmean SFU to show repeating

Line 500: Added $repeatdc to show asterisk in

echo "<a href=\"view_entry.php?id=$id&area=$area&day=$day&month=$month&year=$year\" title=\"$long_descr\">$descr$repeatdc</a>\n";


I commented out the "lastmonth" table cell at the bottom of mincals.inc to remove the small calendar for the previous month (people generally don't want to know what rooms were available in the past, and it made extra space for comments).

See my comments about creating additional tables in tables.my.sql. so you can have different administrators and different websites.


In day.php I changed it so depending on the area it would display capacity as "(seats ##)"  or not display capacity (e.g, most people do not want their capacity shown).
        echo "<th width=\"$room_column_width%\">"
            . htmlspecialchars($row[0]) . ($row[1] > 0 ? "<small> (seats $row[1])</small>" : " ") . "</th>";

The original (which has links) was:
        echo "<th width=\"$room_column_width%\">
            <a href=\"week.php?year=$year&month=$month&day=$day&area=$area&room=$row[2]\"
            title=\"" . get_vocab("viewweek") . " &#10;&#10;$row[3]\">"
            . htmlspecialchars($row[0]) . ($row[1] > 0 ? "($row[1])" : "") . "</a></th>";


Last login: Fri Feb 22 19:46:31 on console
account-iMac:~ account$ ssh account@fraser.sfu.ca
Password: 
 
Assigned terminal type is: xterm-color

1: account_fraser% cd sec_html
/home/account/sec_html

[On the mac I renamed the downloaded mrbs-1.4.9.tar.gz to mrbs.tar.gz and dragged it to the open sec_html directory]
5: account_fraser% ls
.                .AppleDouble     mrbs.tar.gz
..               :2e_mrbs.tar.gz

6: account_fraser% tar -xvzf mrbs.tar.gz
tar: z: unknown function modifier

8: account_fraser% gtar  -xvzf mrbs.tar.gz
mrbs-1.4.9/
mrbs-1.4.9/grant.pg.sql
.... [approx 1300 files extracted]


9: account_fraser% chmod 711 mrbs

10: account_fraser% cd mrbs
/home/account/sec_html/mrbs

11: account_fraser% chmod 711 web

12: account_fraser% cd web
/home/account/sec_html/mrbs/web

13: account_fraser% mysql -h mysql.server.sfu.ca -u mysqluser -p 
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2638668
Server version: 5.1.xx-log MySQL Community Server (GPL) by Remi

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql> source /home/account/sec_html/mrbs/tables.my.sql;
Current database: dept_advising

Query OK, 0 rows affected (0.08 sec)
...
Query OK, 0 rows affected (0.01 sec)
Query OK, 0 rows affected (0.03 sec)
Query OK, 1 row affected (0.00 sec)
Query OK, 1 row affected (0.00 sec)
mysql> show tables;
+------------------------+
| Tables_in_dept_advising |
+------------------------+
| mrbs_dept_area         | 
| mrbs_dept_entry        | 
| mrbs_dept_repeat       | 
| mrbs_dept_room         | 
| mrbs_dept_users        | 
| mrbs_dept_variables    | 
| mrbs_dept_zoneinfo     | 
+------------------------+
20 rows in set (0.00 sec)
mysql> exit;
Bye

14: account_fraser% cd web
~/sec_html/mrbs/web 
/home/account/sec_html/mrbs/web

15: account_fraser% chmod 644 *.html

16: account_fraser% chmod 644 *.txt

33: account_fraser% cat .htaccess
<Files ~ "\.inc$">
   Order allow,deny
   Deny from all
</Files>

34: account_fraser% pico .htaccess
[added lines to control access to all sfu accounts]

35: account_fraser% cat .htaccess
AuthType CAS
require valid-sfu-user
<Files ~ "\.inc$">
   Order allow,deny
   Deny from all
</Files>

23: account_fraser% chmod 644 .htaccess

24: account_fraser% chmod 700 *.php

25: account_fraser% chmod 711 css

26: account_fraser% cd css
/home/account/sec_html/mrbs/web/css

27: account_fraser% chmod 644 *.css

28: account_fraser% chmod 700 *.php

32: account_fraser% cd ..
/home/account/sec_html/mrbs/web

36: account_fraser% chmod 711 Themes

37: account_fraser% cd Themes 
/home/account/sec_html/mrbs/web/Themes

38: account_fraser% chmod 711 default

39: account_fraser% cd default
/home/account/sec_html/mrbs/web/Themes/default

41: account_fraser% cd /home/account/sec_html/mrbs/web/images
/home/account/sec_html/mrbs/web/images

42: account_fraser% chmod 644 *.*

43: account_fraser% chmod 711 /home/account/sec_html/mrbs/web/images

29: account_fraser% locale -a
C
POSIX
en_CA
en_CA.ISO8859-1
en_CA.UTF-8
en_US
....


2014:
ssh youraccount@fraser.sfu.ca

53: userhome_fraser% cd /home/user/sec_html/
/home/user/sec_html

54: userhome_fraser% mkdir web

55: userhome_fraser% chmod 711 web

56: userhome_fraser% cd web
/home/user/sec_html/web

57: userhome_fraser% pico .htaccess

58: userhome_fraser% chmod 644 .htaccess

59: userhome_fraser% cat .htaccess
AuthType CAS
require valid-sfu-user
<Files ~ "\.inc$">
   Order allow,deny
   Deny from all
</Files>

60: userhome_fraser% chmod 711 Blowfish
chmod 711 css
chmod 711 File
chmod 711 File/Passwd
chmod 711 Mail
chmod 711 Net
chmod 711 Themes
chmod 711 Themes/default
chmod 711 Themes/classic126
chmod 711 js

chmod 700 *.php
chmod 700 Blowfish/*.php
chmod 700 css/*.php
chmod 700 File/Passwd/*.php
chmod 700 File/*.php
chmod 700 js/*.php
chmod 700 Mail/*.php
chmod 700 Net/*.php

61: userhome_fraser% 
...
78: userhome_fraser%