merged heads
authorRoland Hieber <devnull@localhost>
Thu, 5 Feb 2009 02:06:52 +0000 (03:06 +0100)
committerRoland Hieber <devnull@localhost>
Thu, 5 Feb 2009 02:06:52 +0000 (03:06 +0100)
47 files changed:
Doxyfile
Makefile
debian/changelog
debian/postinst
debian/postrm [new file with mode: 0644]
debian/preinst [new file with mode: 0755]
debian/prerm
debian/rules
doc/TODO
img/16/mod_room-reservation_config.png [deleted file]
inc/exceptions.inc [new file with mode: 0644]
inc/functions.inc [new file with mode: 0644]
inc/globals.inc [new file with mode: 0644]
inc/mod_roomReservationBooking.inc [new file with mode: 0644]
inc/mod_roomReservationBookingPage.inc [new file with mode: 0644]
inc/mod_roomReservationBookingTable.inc [new file with mode: 0644]
inc/mod_roomReservationBookingsManager.inc [new file with mode: 0644]
inc/mod_roomReservationConfig.inc [new file with mode: 0644]
inc/mod_roomReservationConfigPage.inc [new file with mode: 0644]
inc/mod_roomReservationControl.inc [new file with mode: 0644]
inc/mod_roomReservationPage.inc [new file with mode: 0644]
inc/mod_roomReservationRoom.inc [new file with mode: 0644]
inc/mod_roomReservationRoomWhitelistListBox.inc [new file with mode: 0644]
inc/mod_roomReservationRoomsManager.inc [new file with mode: 0644]
inc/mod_roomReservationTimeslice.inc [new file with mode: 0644]
inc/mod_roomReservationTimesliceListBox.inc [new file with mode: 0644]
includes/exceptions.inc [deleted file]
includes/functions.inc [deleted file]
includes/globals.inc [deleted file]
includes/mod_roomReservationBooking.inc [deleted file]
includes/mod_roomReservationBookingPage.inc [deleted file]
includes/mod_roomReservationBookingTable.inc [deleted file]
includes/mod_roomReservationBookingsManager.inc [deleted file]
includes/mod_roomReservationConfig.inc [deleted file]
includes/mod_roomReservationConfigPage.inc [deleted file]
includes/mod_roomReservationControl.inc [deleted file]
includes/mod_roomReservationPage.inc [deleted file]
includes/mod_roomReservationRoom.inc [deleted file]
includes/mod_roomReservationRoomWhitelistListBox.inc [deleted file]
includes/mod_roomReservationRoomsManager.inc [deleted file]
includes/mod_roomReservationTimeslice.inc [deleted file]
includes/mod_roomReservationTimesliceListBox.inc [deleted file]
lang/mod_room-reservation.po
maint/update-iserv1-iserv2.pl
nav/admin/99mod_room-reservation.mod
src/admin/index.php [deleted file]
src/config.php [new file with mode: 0644]

index 3867e5c..237f545 100644 (file)
--- a/Doxyfile
+++ b/Doxyfile
 # Doxyfile 1.5.5
-
 # This file describes the settings to be used by the documentation system
 # doxygen (www.doxygen.org) for a project
 #
-# All text after a hash (#) is considered a comment and will be ignored
-# The format is:
-#       TAG = value [value, ...]
-# For lists items can also be appended using:
-#       TAG += value [value, ...]
-# Values that contain spaces should be placed between quotes (" ")
-
-#---------------------------------------------------------------------------
-# Project related configuration options
-#---------------------------------------------------------------------------
-
-# The PROJECT_NAME tag is a single word (or a sequence of words surrounded 
-# by quotes) that should identify the project.
-
-PROJECT_NAME = iserv-mod-room-reservation
-
-# The PROJECT_NUMBER tag can be used to enter a project or revision number. 
-# This could be handy for archiving the generated documentation or 
-# if some version control system is used.
-
-PROJECT_NUMBER = 3.0
-
-# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
-# base path where the generated documentation will be put. 
-# If a relative path is entered, it will be relative to the location 
-# where doxygen was started. If left blank the current directory will be used.
-
+PROJECT_NAME = iserv-mod-room-reservation_original
+PROJECT_NUMBER = 9.01.09
 OUTPUT_DIRECTORY = doc/source
-
-# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 
-# 4096 sub-directories (in 2 levels) under the output directory of each output 
-# format and will distribute the generated files over these directories. 
-# Enabling this option can be useful when feeding doxygen a huge amount of 
-# source files, where putting all generated files in the same directory would 
-# otherwise cause performance problems for the file system.
-
 CREATE_SUBDIRS = NO
-
-# The OUTPUT_LANGUAGE tag is used to specify the language in which all 
-# documentation generated by doxygen is written. Doxygen will use this 
-# information to generate all constant output in the proper language. 
-# The default language is English, other supported languages are: 
-# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, 
-# Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek, 
-# Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages), 
-# Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish, 
-# Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, 
-# and Ukrainian.
-
 OUTPUT_LANGUAGE = English
-
-# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 
-# include brief member descriptions after the members that are listed in 
-# the file and class documentation (similar to JavaDoc). 
-# Set to NO to disable this.
-
 BRIEF_MEMBER_DESC = YES
-
-# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 
-# the brief description of a member or function before the detailed description. 
-# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 
-# brief descriptions will be completely suppressed.
-
 REPEAT_BRIEF = YES
-
-# This tag implements a quasi-intelligent brief description abbreviator 
-# that is used to form the text in various listings. Each string 
-# in this list, if found as the leading text of the brief description, will be 
-# stripped from the text and the result after processing the whole list, is 
-# used as the annotated text. Otherwise, the brief description is used as-is. 
-# If left blank, the following values are used ("$name" is automatically 
-# replaced with the name of the entity): "The $name class" "The $name widget" 
-# "The $name file" "is" "provides" "specifies" "contains" 
-# "represents" "a" "an" "the"
-
 ABBREVIATE_BRIEF = 
-
-# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 
-# Doxygen will generate a detailed section even if there is only a brief 
-# description.
-
 ALWAYS_DETAILED_SEC = NO
-
-# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all 
-# inherited members of a class in the documentation of that class as if those 
-# members were ordinary class members. Constructors, destructors and assignment 
-# operators of the base classes will not be shown.
-
 INLINE_INHERITED_MEMB = YES
-
-# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 
-# path before files name in the file list and in the header files. If set 
-# to NO the shortest path that makes the file name unique will be used.
-
 FULL_PATH_NAMES = YES
-
-# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 
-# can be used to strip a user-defined part of the path. Stripping is 
-# only done if one of the specified strings matches the left-hand part of 
-# the path. The tag can be used to show relative paths in the file list. 
-# If left blank the directory from which doxygen is run is used as the 
-# path to strip.
-
 STRIP_FROM_PATH = 
-
-# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of 
-# the path mentioned in the documentation of a class, which tells 
-# the reader which header file to include in order to use a class. 
-# If left blank only the name of the header file containing the class 
-# definition is used. Otherwise one should specify the include paths that 
-# are normally passed to the compiler using the -I flag.
-
 STRIP_FROM_INC_PATH = 
-
-# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 
-# (but less readable) file names. This can be useful is your file systems 
-# doesn't support long names like on DOS, Mac, or CD-ROM.
-
 SHORT_NAMES = YES
-
-# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 
-# will interpret the first line (until the first dot) of a JavaDoc-style 
-# comment as the brief description. If set to NO, the JavaDoc 
-# comments will behave just like regular Qt-style comments 
-# (thus requiring an explicit @brief command for a brief description.)
-
 JAVADOC_AUTOBRIEF = YES
-
-# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen 
-# treat a multi-line C++ special comment block (i.e. a block of //! or /// 
-# comments) as a brief description. This used to be the default behaviour. 
-# The new default is to treat a multi-line C++ comment block as a detailed 
-# description. Set this tag to YES if you prefer the old behaviour instead.
-
 MULTILINE_CPP_IS_BRIEF = 
-
-# If the DETAILS_AT_TOP tag is set to YES then Doxygen 
-# will output the detailed description near the top, like JavaDoc.
-# If set to NO, the detailed description appears after the member 
-# documentation.
-
 DETAILS_AT_TOP = YES
-
-# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 
-# member inherits the documentation from any documented member that it 
-# re-implements.
-
 INHERIT_DOCS = YES
-
-# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce 
-# a new page for each member. If set to NO, the documentation of a member will 
-# be part of the file/class/namespace that contains it.
-
 SEPARATE_MEMBER_PAGES = YES
-
-# The TAB_SIZE tag can be used to set the number of spaces in a tab. 
-# Doxygen uses this value to replace tabs by spaces in code fragments.
-
 TAB_SIZE = 4
-
-# This tag can be used to specify a number of aliases that acts 
-# as commands in the documentation. An alias has the form "name=value". 
-# For example adding "sideeffect=\par Side Effects:\n" will allow you to 
-# put the command \sideeffect (or @sideeffect) in the documentation, which 
-# will result in a user-defined paragraph with heading "Side Effects:". 
-# You can put \n's in the value part of an alias to insert newlines.
-
 ALIASES = 
-
-# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C 
-# sources only. Doxygen will then generate output that is more tailored for C. 
-# For instance, some of the names that are used will be different. The list 
-# of all members will be omitted, etc.
-
 OPTIMIZE_OUTPUT_FOR_C = NO
-
-# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java 
-# sources only. Doxygen will then generate output that is more tailored for 
-# Java. For instance, namespaces will be presented as packages, qualified 
-# scopes will look different, etc.
-
 OPTIMIZE_OUTPUT_JAVA = NO
-
-# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want 
-# to include (a tag file for) the STL sources as input, then you should 
-# set this tag to YES in order to let doxygen match functions declarations and 
-# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. 
-# func(std::string) {}). This also make the inheritance and collaboration 
-# diagrams that involve STL classes more complete and accurate.
-
 BUILTIN_STL_SUPPORT = NO
-
-# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 
-# tag is set to YES, then doxygen will reuse the documentation of the first 
-# member in the group (if any) for the other members of the group. By default 
-# all members of a group must be documented explicitly.
-
 DISTRIBUTE_GROUP_DOC = YES
-
-# Set the SUBGROUPING tag to YES (the default) to allow class member groups of 
-# the same type (for instance a group of public functions) to be put as a 
-# subgroup of that type (e.g. under the Public Functions section). Set it to 
-# NO to prevent subgrouping. Alternatively, this can be done per class using 
-# the \nosubgrouping command.
-
 SUBGROUPING = 
-
-#---------------------------------------------------------------------------
-# Build related configuration options
-#---------------------------------------------------------------------------
-
-# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 
-# documentation are documented, even if no documentation was available. 
-# Private class members and static file members will be hidden unless 
-# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
-
 EXTRACT_ALL = YES
-
-# If the EXTRACT_PRIVATE tag is set to YES all private members of a class 
-# will be included in the documentation.
-
 EXTRACT_PRIVATE = NO
-
-# If the EXTRACT_STATIC tag is set to YES all static members of a file 
-# will be included in the documentation.
-
 EXTRACT_STATIC = YES
-
-# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 
-# defined locally in source files will be included in the documentation. 
-# If set to NO only classes defined in header files are included.
-
 EXTRACT_LOCAL_CLASSES = YES
-
-# This flag is only useful for Objective-C code. When set to YES local 
-# methods, which are defined in the implementation section but not in 
-# the interface are included in the documentation. 
-# If set to NO (the default) only methods in the interface are included.
-
 EXTRACT_LOCAL_METHODS = 
-
-# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 
-# undocumented members of documented classes, files or namespaces. 
-# If set to NO (the default) these members will be included in the 
-# various overviews, but no documentation section is generated. 
-# This option has no effect if EXTRACT_ALL is enabled.
-
 HIDE_UNDOC_MEMBERS = NO
-
-# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 
-# undocumented classes that are normally visible in the class hierarchy. 
-# If set to NO (the default) these classes will be included in the various 
-# overviews. This option has no effect if EXTRACT_ALL is enabled.
-
 HIDE_UNDOC_CLASSES = NO
-
-# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all 
-# friend (class|struct|union) declarations. 
-# If set to NO (the default) these declarations will be included in the 
-# documentation.
-
 HIDE_FRIEND_COMPOUNDS = 
-
-# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any 
-# documentation blocks found inside the body of a function. 
-# If set to NO (the default) these blocks will be appended to the 
-# function's detailed documentation block.
-
 HIDE_IN_BODY_DOCS = 
-
-# The INTERNAL_DOCS tag determines if documentation 
-# that is typed after a \internal command is included. If the tag is set 
-# to NO (the default) then the documentation will be excluded. 
-# Set it to YES to include the internal documentation.
-
 INTERNAL_DOCS = 
-
-# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 
-# file names in lower-case letters. If set to YES upper-case letters are also 
-# allowed. This is useful if you have classes or files whose names only differ 
-# in case and if your file system supports case sensitive file names. Windows 
-# and Mac users are advised to set this option to NO.
-
 CASE_SENSE_NAMES = YES
-
-# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 
-# will show members with their full class and namespace scopes in the 
-# documentation. If set to YES the scope will be hidden.
-
 HIDE_SCOPE_NAMES = 
-
-# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 
-# will put a list of the files that are included by a file in the documentation 
-# of that file.
-
 SHOW_INCLUDE_FILES = YES
-
-# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 
-# is inserted in the documentation for inline members.
-
 INLINE_INFO = 
-
-# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 
-# will sort the (detailed) documentation of file and class members 
-# alphabetically by member name. If set to NO the members will appear in 
-# declaration order.
-
 SORT_MEMBER_DOCS = YES
-
-# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the 
-# brief documentation of file, namespace and class members alphabetically 
-# by member name. If set to NO (the default) the members will appear in 
-# declaration order.
-
 SORT_BRIEF_DOCS = YES
-
-# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be 
-# sorted by fully-qualified names, including namespaces. If set to 
-# NO (the default), the class list will be sorted only by class name, 
-# not including the namespace part. 
-# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
-# Note: This option applies only to the class list, not to the 
-# alphabetical list.
-
 SORT_BY_SCOPE_NAME = NO
-
-# The GENERATE_TODOLIST tag can be used to enable (YES) or 
-# disable (NO) the todo list. This list is created by putting \todo 
-# commands in the documentation.
-
 GENERATE_TODOLIST = YES
-
-# The GENERATE_TESTLIST tag can be used to enable (YES) or 
-# disable (NO) the test list. This list is created by putting \test 
-# commands in the documentation.
-
 GENERATE_TESTLIST = YES
-
-# The GENERATE_BUGLIST tag can be used to enable (YES) or 
-# disable (NO) the bug list. This list is created by putting \bug 
-# commands in the documentation.
-
 GENERATE_BUGLIST = YES
-
-# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or 
-# disable (NO) the deprecated list. This list is created by putting 
-# \deprecated commands in the documentation.
-
 GENERATE_DEPRECATEDLIST = YES
-
-# The ENABLED_SECTIONS tag can be used to enable conditional 
-# documentation sections, marked by \if sectionname ... \endif.
-
 ENABLED_SECTIONS = 
-
-# The MAX_INITIALIZER_LINES tag determines the maximum number of lines 
-# the initial value of a variable or define consists of for it to appear in 
-# the documentation. If the initializer consists of more lines than specified 
-# here it will be hidden. Use a value of 0 to hide initializers completely. 
-# The appearance of the initializer of individual variables and defines in the 
-# documentation can be controlled using \showinitializer or \hideinitializer 
-# command in the documentation regardless of this setting.
-
 MAX_INITIALIZER_LINES = 30
-
-# Set the SHOW_USED_FILES tag to NO to disable the list of files generated 
-# at the bottom of the documentation of classes and structs. If set to YES the 
-# list will mention the files that were used to generate the documentation.
-
 SHOW_USED_FILES = YES
-
-# If the sources in your project are distributed over multiple directories 
-# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy 
-# in the documentation. The default is NO.
-
 SHOW_DIRECTORIES = NO
-
-# The FILE_VERSION_FILTER tag can be used to specify a program or script that 
-# doxygen should invoke to get the current version for each file (typically from 
-# the version control system). Doxygen will invoke the program by executing (via 
-# popen()) the command <command> <input-file>, where <command> is the value of 
-# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file 
-# provided by doxygen. Whatever the program writes to standard output 
-# is used as the file version. See the manual for examples.
-
 FILE_VERSION_FILTER = 
-
-#---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
-#---------------------------------------------------------------------------
-
-# The QUIET tag can be used to turn on/off the messages that are generated 
-# by doxygen. Possible values are YES and NO. If left blank NO is used.
-
 QUIET = YES
-
-# The WARNINGS tag can be used to turn on/off the warning messages that are 
-# generated by doxygen. Possible values are YES and NO. If left blank 
-# NO is used.
-
 WARNINGS = YES
-
-# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings 
-# for undocumented members. If EXTRACT_ALL is set to YES then this flag will 
-# automatically be disabled.
-
 WARN_IF_UNDOCUMENTED = YES
-
-# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for 
-# potential errors in the documentation, such as not documenting some 
-# parameters in a documented function, or documenting parameters that 
-# don't exist or using markup commands wrongly.
-
 WARN_IF_DOC_ERROR = YES
-
-# This WARN_NO_PARAMDOC option can be abled to get warnings for 
-# functions that are documented, but have no documentation for their parameters 
-# or return value. If set to NO (the default) doxygen will only warn about 
-# wrong or incomplete parameter documentation, but not about the absence of 
-# documentation.
-
 WARN_NO_PARAMDOC = YES
-
-# The WARN_FORMAT tag determines the format of the warning messages that 
-# doxygen can produce. The string should contain the $file, $line, and $text 
-# tags, which will be replaced by the file and line number from which the 
-# warning originated and the warning text. Optionally the format may contain 
-# $version, which will be replaced by the version of the file (if it could 
-# be obtained via FILE_VERSION_FILTER)
-
 WARN_FORMAT = "$file:$line: $text"
-
-# The WARN_LOGFILE tag can be used to specify a file to which warning 
-# and error messages should be written. If left blank the output is written 
-# to stderr.
-
 WARN_LOGFILE = 
-
-#---------------------------------------------------------------------------
-# configuration options related to the input files
-#---------------------------------------------------------------------------
-
-# The INPUT tag can be used to specify the files and/or directories that contain 
-# documented source files. You may enter file names like "myfile.cpp" or 
-# directories like "/usr/src/myproject". Separate the files or directories 
-# with spaces.
-
-INPUT = includes
-
-# If the value of the INPUT tag contains directories, you can use the 
-# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
-# and *.h) to filter out the source-files in the directories. If left 
-# blank the following patterns are tested: 
-# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx 
-# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
-
+INPUT = inc
 FILE_PATTERNS = 
-
-# The RECURSIVE tag can be used to turn specify whether or not subdirectories 
-# should be searched for input files as well. Possible values are YES and NO. 
-# If left blank NO is used.
-
 RECURSIVE = YES
-
-# The EXCLUDE tag can be used to specify files and/or directories that should 
-# excluded from the INPUT source files. This way you can easily exclude a 
-# subdirectory from a directory tree whose root is specified with the INPUT tag.
-
 EXCLUDE = 
-
-# The EXCLUDE_SYMLINKS tag can be used select whether or not files or 
-# directories that are symbolic links (a Unix filesystem feature) are excluded 
-# from the input.
-
 EXCLUDE_SYMLINKS = NO
-
-# If the value of the INPUT tag contains directories, you can use the 
-# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 
-# certain files from those directories. Note that the wildcards are matched 
-# against the file with absolute path, so to exclude all test directories 
-# for example use the pattern */test/*
-
 EXCLUDE_PATTERNS = 
-
-# The EXAMPLE_PATH tag can be used to specify one or more files or 
-# directories that contain example code fragments that are included (see 
-# the \include command).
-
 EXAMPLE_PATH = 
-
-# If the value of the EXAMPLE_PATH tag contains directories, you can use the 
-# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
-# and *.h) to filter out the source-files in the directories. If left 
-# blank all files are included.
-
 EXAMPLE_PATTERNS = 
-
-# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be 
-# searched for input files to be used with the \include or \dontinclude 
-# commands irrespective of the value of the RECURSIVE tag. 
-# Possible values are YES and NO. If left blank NO is used.
-
 EXAMPLE_RECURSIVE = NO
-
-# The IMAGE_PATH tag can be used to specify one or more files or 
-# directories that contain image that are included in the documentation (see 
-# the \image command).
-
 IMAGE_PATH = 
-
-# The INPUT_FILTER tag can be used to specify a program that doxygen should 
-# invoke to filter for each input file. Doxygen will invoke the filter program 
-# by executing (via popen()) the command <filter> <input-file>, where <filter> 
-# is the value of the INPUT_FILTER tag, and <input-file> is the name of an 
-# input file. Doxygen will then use the output that the filter program writes 
-# to standard output.  If FILTER_PATTERNS is specified, this tag will be 
-# ignored.
-
 INPUT_FILTER = 
-
-# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern 
-# basis.  Doxygen will compare the file name with each pattern and apply the 
-# filter if there is a match.  The filters are a list of the form: 
-# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further 
-# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER 
-# is applied to all files.
-
 FILTER_PATTERNS = 
-
-# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 
-# INPUT_FILTER) will be used to filter the input files when producing source 
-# files to browse (i.e. when SOURCE_BROWSER is set to YES).
-
 FILTER_SOURCE_FILES = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to source browsing
-#---------------------------------------------------------------------------
-
-# If the SOURCE_BROWSER tag is set to YES then a list of source files will 
-# be generated. Documented entities will be cross-referenced with these sources. 
-# Note: To get rid of all source code in the generated output, make sure also 
-# VERBATIM_HEADERS is set to NO.
-
 SOURCE_BROWSER = YES
-
-# Setting the INLINE_SOURCES tag to YES will include the body 
-# of functions and classes directly in the documentation.
-
 INLINE_SOURCES = NO
-
-# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 
-# doxygen to hide any special comment blocks from generated source code 
-# fragments. Normal C and C++ comments will always remain visible.
-
 STRIP_CODE_COMMENTS = YES
-
-# If the REFERENCED_BY_RELATION tag is set to YES (the default) 
-# then for each documented function all documented 
-# functions referencing it will be listed.
-
 REFERENCED_BY_RELATION = YES
-
-# If the REFERENCES_RELATION tag is set to YES (the default) 
-# then for each documented function all documented entities 
-# called/used by that function will be listed.
-
 REFERENCES_RELATION = YES
-
-# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
-# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
-# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
-# link to the source code.  Otherwise they will link to the documentstion.
-
 REFERENCES_LINK_SOURCE = NO
-
-# If the USE_HTAGS tag is set to YES then the references to source code 
-# will point to the HTML generated by the htags(1) tool instead of doxygen 
-# built-in source browser. The htags tool is part of GNU's global source 
-# tagging system (see http://www.gnu.org/software/global/global.html). You 
-# will need version 4.8.6 or higher.
-
 USE_HTAGS = NO
-
-# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 
-# will generate a verbatim copy of the header file for each class for 
-# which an include is specified. Set to NO to disable this.
-
 VERBATIM_HEADERS = YES
-
-#---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
-#---------------------------------------------------------------------------
-
-# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 
-# of all compounds will be generated. Enable this if the project 
-# contains a lot of classes, structs, unions or interfaces.
-
 ALPHABETICAL_INDEX = YES
-
-# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 
-# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 
-# in which this list will be split (can be a number in the range [1..20])
-
 COLS_IN_ALPHA_INDEX = 5
-
-# In case all classes in a project start with a common prefix, all 
-# classes will be put under the same header in the alphabetical index. 
-# The IGNORE_PREFIX tag can be used to specify one or more prefixes that 
-# should be ignored while generating the index headers.
-
 IGNORE_PREFIX = 
-
-#---------------------------------------------------------------------------
-# configuration options related to the HTML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_HTML tag is set to YES (the default) Doxygen will 
-# generate HTML output.
-
 GENERATE_HTML = YES
-
-# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
-# put in front of it. If left blank `html' will be used as the default path.
-
 HTML_OUTPUT = html
-
-# The HTML_FILE_EXTENSION tag can be used to specify the file extension for 
-# each generated HTML page (for example: .htm,.php,.asp). If it is left blank 
-# doxygen will generate files with .html extension.
-
 HTML_FILE_EXTENSION = .html
-
-# The HTML_HEADER tag can be used to specify a personal HTML header for 
-# each generated HTML page. If it is left blank doxygen will generate a 
-# standard header.
-
 HTML_HEADER = 
-
-# The HTML_FOOTER tag can be used to specify a personal HTML footer for 
-# each generated HTML page. If it is left blank doxygen will generate a 
-# standard footer.
-
 HTML_FOOTER = 
-
-# The HTML_STYLESHEET tag can be used to specify a user-defined cascading 
-# style sheet that is used by each HTML page. It can be used to 
-# fine-tune the look of the HTML output. If the tag is left blank doxygen 
-# will generate a default style sheet. Note that doxygen will try to copy 
-# the style sheet file to the HTML output directory, so don't put your own 
-# stylesheet in the HTML output directory as well, or it will be erased!
-
 HTML_STYLESHEET = 
-
-# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, 
-# files or namespaces will be aligned in HTML using tables. If set to 
-# NO a bullet list will be used.
-
 HTML_ALIGN_MEMBERS = YES
-
-# If the GENERATE_HTMLHELP tag is set to YES, additional index files 
-# will be generated that can be used as input for tools like the 
-# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) 
-# of the generated HTML documentation.
-
 GENERATE_HTMLHELP = NO
-
-# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can 
-# be used to specify the file name of the resulting .chm file. You 
-# can add a path in front of the file if the result should not be 
-# written to the html output directory.
-
 CHM_FILE = 
-
-# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 
-# be used to specify the location (absolute path including file name) of 
-# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run 
-# the HTML help compiler on the generated index.hhp.
-
 HHC_LOCATION = 
-
-# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag 
-# controls if a separate .chi index file is generated (YES) or that 
-# it should be included in the master .chm file (NO).
-
 GENERATE_CHI = NO
-
-# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag 
-# controls whether a binary table of contents is generated (YES) or a 
-# normal table of contents (NO) in the .chm file.
-
 BINARY_TOC = 
-
-# The TOC_EXPAND flag can be set to YES to add extra items for group members 
-# to the contents of the HTML help documentation and to the tree view.
-
 TOC_EXPAND = 
-
-# The DISABLE_INDEX tag can be used to turn on/off the condensed index at 
-# top of each HTML page. The value NO (the default) enables the index and 
-# the value YES disables it.
-
 DISABLE_INDEX = NO
-
-# This tag can be used to set the number of enum values (range [1..20]) 
-# that doxygen will group on one line in the generated HTML documentation.
-
 ENUM_VALUES_PER_LINE = 4
-
-# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
-# generated containing a tree-like index structure (just like the one that 
-# is generated for HTML Help). For this to work a browser that supports 
-# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, 
-# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are 
-# probably better off using the HTML help feature.
-
 GENERATE_TREEVIEW = YES
-
-# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 
-# used to set the initial width (in pixels) of the frame in which the tree 
-# is shown.
-
 TREEVIEW_WIDTH = 250
-
-#---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
-# generate Latex output.
-
 GENERATE_LATEX = NO
-
-# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
-# put in front of it. If left blank `latex' will be used as the default path.
-
 LATEX_OUTPUT = latex
-
-# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 
-# invoked. If left blank `latex' will be used as the default command name.
-
 LATEX_CMD_NAME = latex
-
-# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to 
-# generate index for LaTeX. If left blank `makeindex' will be used as the 
-# default command name.
-
 MAKEINDEX_CMD_NAME = makeindex
-
-# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 
-# LaTeX documents. This may be useful for small projects and may help to 
-# save some trees in general.
-
 COMPACT_LATEX = NO
-
-# The PAPER_TYPE tag can be used to set the paper type that is used 
-# by the printer. Possible values are: a4, a4wide, letter, legal and 
-# executive. If left blank a4wide will be used.
-
 PAPER_TYPE = a4wide
-
-# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 
-# packages that should be included in the LaTeX output.
-
 EXTRA_PACKAGES = 
-
-# The LATEX_HEADER tag can be used to specify a personal LaTeX header for 
-# the generated latex document. The header should contain everything until 
-# the first chapter. If it is left blank doxygen will generate a 
-# standard header. Notice: only use this tag if you know what you are doing!
-
 LATEX_HEADER = 
-
-# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 
-# is prepared for conversion to pdf (using ps2pdf). The pdf file will 
-# contain links (just like the HTML output) instead of page references 
-# This makes the output suitable for online browsing using a pdf viewer.
-
 PDF_HYPERLINKS = YES
-
-# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 
-# plain latex in the generated Makefile. Set this option to YES to get a 
-# higher quality PDF documentation.
-
 USE_PDFLATEX = YES
-
-# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 
-# command to the generated LaTeX files. This will instruct LaTeX to keep 
-# running if errors occur, instead of asking the user for help. 
-# This option is also used when generating formulas in HTML.
-
 LATEX_BATCHMODE = YES
-
-# If LATEX_HIDE_INDICES is set to YES then doxygen will not 
-# include the index chapters (such as File Index, Compound Index, etc.) 
-# in the output.
-
 LATEX_HIDE_INDICES = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the RTF output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 
-# The RTF output is optimized for Word 97 and may not look very pretty with 
-# other RTF readers or editors.
-
 GENERATE_RTF = NO
-
-# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
-# put in front of it. If left blank `rtf' will be used as the default path.
-
 RTF_OUTPUT = rtf
-
-# If the COMPACT_RTF tag is set to YES Doxygen generates more compact 
-# RTF documents. This may be useful for small projects and may help to 
-# save some trees in general.
-
 COMPACT_RTF = NO
-
-# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 
-# will contain hyperlink fields. The RTF file will 
-# contain links (just like the HTML output) instead of page references. 
-# This makes the output suitable for online browsing using WORD or other 
-# programs which support those fields. 
-# Note: wordpad (write) and others do not support links.
-
 RTF_HYPERLINKS = NO
-
-# Load stylesheet definitions from file. Syntax is similar to doxygen's 
-# config file, i.e. a series of assignments. You only have to provide 
-# replacements, missing definitions are set to their default value.
-
 RTF_STYLESHEET_FILE = 
-
-# Set optional variables used in the generation of an rtf document. 
-# Syntax is similar to doxygen's config file.
-
 RTF_EXTENSIONS_FILE = 
-
-#---------------------------------------------------------------------------
-# configuration options related to the man page output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_MAN tag is set to YES (the default) Doxygen will 
-# generate man pages
-
 GENERATE_MAN = NO
-
-# The MAN_OUTPUT tag is used to specify where the man pages will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
-# put in front of it. If left blank `man' will be used as the default path.
-
 MAN_OUTPUT = man
-
-# The MAN_EXTENSION tag determines the extension that is added to 
-# the generated man pages (default is the subroutine's section .3)
-
 MAN_EXTENSION = .3
-
-# If the MAN_LINKS tag is set to YES and Doxygen generates man output, 
-# then it will generate one additional man file for each entity 
-# documented in the real man page(s). These additional files 
-# only source the real man page, but without them the man command 
-# would be unable to find the correct page. The default is NO.
-
 MAN_LINKS = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the XML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_XML tag is set to YES Doxygen will 
-# generate an XML file that captures the structure of 
-# the code including all documentation.
-
 GENERATE_XML = NO
-
-# The XML_OUTPUT tag is used to specify where the XML pages will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
-# put in front of it. If left blank `xml' will be used as the default path.
-
 XML_OUTPUT = xml
-
-# The XML_SCHEMA tag can be used to specify an XML schema, 
-# which can be used by a validating XML parser to check the 
-# syntax of the XML files.
-
 XML_SCHEMA = 
-
-# The XML_DTD tag can be used to specify an XML DTD, 
-# which can be used by a validating XML parser to check the 
-# syntax of the XML files.
-
 XML_DTD = 
-
-# If the XML_PROGRAMLISTING tag is set to YES Doxygen will 
-# dump the program listings (including syntax highlighting 
-# and cross-referencing information) to the XML output. Note that 
-# enabling this will significantly increase the size of the XML output.
-
 XML_PROGRAMLISTING = YES
-
-#---------------------------------------------------------------------------
-# configuration options for the AutoGen Definitions output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will 
-# generate an AutoGen Definitions (see autogen.sf.net) file 
-# that captures the structure of the code including all 
-# documentation. Note that this feature is still experimental 
-# and incomplete at the moment.
-
 GENERATE_AUTOGEN_DEF = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the Perl module output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_PERLMOD tag is set to YES Doxygen will 
-# generate a Perl module file that captures the structure of 
-# the code including all documentation. Note that this 
-# feature is still experimental and incomplete at the 
-# moment.
-
 GENERATE_PERLMOD = NO
-
-# If the PERLMOD_LATEX tag is set to YES Doxygen will generate 
-# the necessary Makefile rules, Perl scripts and LaTeX code to be able 
-# to generate PDF and DVI output from the Perl module output.
-
 PERLMOD_LATEX = NO
-
-# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be 
-# nicely formatted so it can be parsed by a human reader.  This is useful 
-# if you want to understand what is going on.  On the other hand, if this 
-# tag is set to NO the size of the Perl module output will be much smaller 
-# and Perl will parse it just the same.
-
 PERLMOD_PRETTY = YES
-
-# The names of the make variables in the generated doxyrules.make file 
-# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. 
-# This is useful so different doxyrules.make files included by the same 
-# Makefile don't overwrite each other's variables.
-
 PERLMOD_MAKEVAR_PREFIX = 
-
-#---------------------------------------------------------------------------
-# Configuration options related to the preprocessor   
-#---------------------------------------------------------------------------
-
-# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 
-# evaluate all C-preprocessor directives found in the sources and include 
-# files.
-
 ENABLE_PREPROCESSING = 
-
-# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 
-# names in the source code. If set to NO (the default) only conditional 
-# compilation will be performed. Macro expansion can be done in a controlled 
-# way by setting EXPAND_ONLY_PREDEF to YES.
-
 MACRO_EXPANSION = 
-
-# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 
-# then the macro expansion is limited to the macros specified with the 
-# PREDEFINED and EXPAND_AS_DEFINED tags.
-
 EXPAND_ONLY_PREDEF = 
-
-# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 
-# in the INCLUDE_PATH (see below) will be search if a #include is found.
-
 SEARCH_INCLUDES = 
-
-# The INCLUDE_PATH tag can be used to specify one or more directories that 
-# contain include files that are not input files but should be processed by 
-# the preprocessor.
-
 INCLUDE_PATH = 
-
-# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 
-# patterns (like *.h and *.hpp) to filter out the header-files in the 
-# directories. If left blank, the patterns specified with FILE_PATTERNS will 
-# be used.
-
 INCLUDE_FILE_PATTERNS = 
-
-# The PREDEFINED tag can be used to specify one or more macro names that 
-# are defined before the preprocessor is started (similar to the -D option of 
-# gcc). The argument of the tag is a list of macros of the form: name 
-# or name=definition (no spaces). If the definition and the = are 
-# omitted =1 is assumed. To prevent a macro definition from being 
-# undefined via #undef or recursively expanded use the := operator 
-# instead of the = operator.
-
 PREDEFINED = 
-
-# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
-# this tag can be used to specify a list of macro names that should be expanded. 
-# The macro definition that is found in the sources will be used. 
-# Use the PREDEFINED tag if you want to use a different macro definition.
-
 EXPAND_AS_DEFINED = 
-
-# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 
-# doxygen's preprocessor will remove all function-like macros that are alone 
-# on a line, have an all uppercase name, and do not end with a semicolon. Such 
-# function macros are typically used for boiler-plate code, and will confuse 
-# the parser if not removed.
-
 SKIP_FUNCTION_MACROS = 
-
-#---------------------------------------------------------------------------
-# Configuration::additions related to external references   
-#---------------------------------------------------------------------------
-
-# The TAGFILES option can be used to specify one or more tagfiles. 
-# Optionally an initial location of the external documentation 
-# can be added for each tagfile. The format of a tag file without 
-# this location is as follows: 
-#   TAGFILES = file1 file2 ... 
-# Adding location for the tag files is done as follows: 
-#   TAGFILES = file1=loc1 "file2 = loc2" ... 
-# where "loc1" and "loc2" can be relative or absolute paths or 
-# URLs. If a location is present for each tag, the installdox tool 
-# does not have to be run to correct the links.
-# Note that each tag file must have a unique name
-# (where the name does NOT include the path)
-# If a tag file is not located in the directory in which doxygen 
-# is run, you must also specify the path to the tagfile here.
-
 TAGFILES = 
-
-# When a file name is specified after GENERATE_TAGFILE, doxygen will create 
-# a tag file that is based on the input files it reads.
-
 GENERATE_TAGFILE = 
-
-# If the ALLEXTERNALS tag is set to YES all external classes will be listed 
-# in the class index. If set to NO only the inherited external classes 
-# will be listed.
-
 ALLEXTERNALS = NO
-
-# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed 
-# in the modules index. If set to NO, only the current project's groups will 
-# be listed.
-
 EXTERNAL_GROUPS = YES
-
-# The PERL_PATH should be the absolute path and name of the perl script 
-# interpreter (i.e. the result of `which perl').
-
 PERL_PATH = /usr/bin/perl
-
-#---------------------------------------------------------------------------
-# Configuration options related to the dot tool   
-#---------------------------------------------------------------------------
-
-# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 
-# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base 
-# or super classes. Setting the tag to NO turns the diagrams off. Note that 
-# this option is superseded by the HAVE_DOT option below. This is only a 
-# fallback. It is recommended to install and use dot, since it yields more 
-# powerful graphs.
-
 CLASS_DIAGRAMS = NO
-
-# If set to YES, the inheritance and collaboration graphs will hide 
-# inheritance and usage relations if the target is undocumented 
-# or is not a class.
-
 HIDE_UNDOC_RELATIONS = YES
-
-# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is 
-# available from the path. This tool is part of Graphviz, a graph visualization 
-# toolkit from AT&T and Lucent Bell Labs. The other options in this section 
-# have no effect if this option is set to NO (the default)
-
 HAVE_DOT = NO
-
-# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen 
-# will generate a graph for each documented class showing the direct and 
-# indirect inheritance relations. Setting this tag to YES will force the 
-# the CLASS_DIAGRAMS tag to NO.
-
 CLASS_GRAPH = YES
-
-# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen 
-# will generate a graph for each documented class showing the direct and 
-# indirect implementation dependencies (inheritance, containment, and 
-# class references variables) of the class with other documented classes.
-
 COLLABORATION_GRAPH = YES
-
-# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen 
-# will generate a graph for groups, showing the direct groups dependencies
-
 GROUP_GRAPHS = YES
-
-# If the UML_LOOK tag is set to YES doxygen will generate inheritance and 
-# collaboration diagrams in a style similar to the OMG's Unified Modeling 
-# Language.
-
 UML_LOOK = YES
-
-# If set to YES, the inheritance and collaboration graphs will show the 
-# relations between templates and their instances.
-
 TEMPLATE_RELATIONS = NO
-
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT 
-# tags are set to YES then doxygen will generate a graph for each documented 
-# file showing the direct and indirect include dependencies of the file with 
-# other documented files.
-
 INCLUDE_GRAPH = YES
-
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and 
-# HAVE_DOT tags are set to YES then doxygen will generate a graph for each 
-# documented header file showing the documented files that directly or 
-# indirectly include this file.
-
 INCLUDED_BY_GRAPH = YES
-
-# If the CALL_GRAPH and HAVE_DOT options are set to YES then 
-# doxygen will generate a call dependency graph for every global function 
-# or class method. Note that enabling this option will significantly increase 
-# the time of a run. So in most cases it will be better to enable call graphs 
-# for selected functions only using the \callgraph command.
-
 CALL_GRAPH = NO
-
-# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then 
-# doxygen will generate a caller dependency graph for every global function 
-# or class method. Note that enabling this option will significantly increase 
-# the time of a run. So in most cases it will be better to enable caller 
-# graphs for selected functions only using the \callergraph command.
-
 CALLER_GRAPH = NO
-
-# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 
-# will graphical hierarchy of all classes instead of a textual one.
-
 GRAPHICAL_HIERARCHY = YES
-
-# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES 
-# then doxygen will show the dependencies a directory has on other directories 
-# in a graphical way. The dependency relations are determined by the #include
-# relations between the files in the directories.
-
 DIRECTORY_GRAPH = YES
-
-# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images 
-# generated by dot. Possible values are png, jpg, or gif
-# If left blank png will be used.
-
 DOT_IMAGE_FORMAT = png
-
-# The tag DOT_PATH can be used to specify the path where the dot tool can be 
-# found. If left blank, it is assumed the dot tool can be found in the path.
-
 DOT_PATH = 
-
-# The DOTFILE_DIRS tag can be used to specify one or more directories that 
-# contain dot files that are included in the documentation (see the 
-# \dotfile command).
-
 DOTFILE_DIRS = 
-
-# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the 
-# graphs generated by dot. A depth value of 3 means that only nodes reachable 
-# from the root by following a path via at most 3 edges will be shown. Nodes 
-# that lay further from the root node will be omitted. Note that setting this 
-# option to 1 or 2 may greatly reduce the computation time needed for large 
-# code bases. Also note that the size of a graph can be further restricted by 
-# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
-
 MAX_DOT_GRAPH_DEPTH = 0
-
-# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent 
-# background. This is enabled by default, which results in a transparent 
-# background. Warning: Depending on the platform used, enabling this option 
-# may lead to badly anti-aliased labels on the edges of a graph (i.e. they 
-# become hard to read).
-
 DOT_TRANSPARENT = YES
-
-# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output 
-# files in one run (i.e. multiple -o and -T options on the command line). This 
-# makes dot run faster, but since only newer versions of dot (>1.8.10) 
-# support this, this feature is disabled by default.
-
 DOT_MULTI_TARGETS = NO
-
-# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 
-# generate a legend page explaining the meaning of the various boxes and 
-# arrows in the dot generated graphs.
-
 GENERATE_LEGEND = YES
-
-# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will 
-# remove the intermediate dot files that are used to generate 
-# the various graphs.
-
 DOT_CLEANUP = YES
-
-#---------------------------------------------------------------------------
-# Configuration::additions related to the search engine   
-#---------------------------------------------------------------------------
-
-# The SEARCHENGINE tag specifies whether or not a search engine should be 
-# used. If set to NO the values of all tags below this one will be ignored.
-
 SEARCHENGINE = NO
index f639d30..b847b0d 100644 (file)
--- a/Makefile
+++ b/Makefile
 #\r
 \r
 DESTDIR?=\r
-SOURCEFILES=src/*.php includes/*.inc\r
-MODULE_DOC_FILES=doc/source/html/* doc/source/latex/*\r
 LN=ln -f\r
 RM=rm -rf\r
 MKDIR=mkdir -p\r
 \r
 # hardlink the files to their destinations\r
-# TODO move documentation where Jörg wants it ;)\r
-links:\r
+links: sourcedoc\r
        # documentation\r
-       $(MKDIR) $(DESTDIR)/usr/share/doc/iserv/mod/room-reservation/source/\r
-       $(LN) doc/{TODO,changelog.html} $(DESTDIR)/usr/share/doc/iserv/mod/room-reservation/\r
-       $(LN) doc/source/* $(DESTDIR)/usr/share/doc/iserv/mod/room-reservation/source/\r
-       $(LN) -s $(DESTDIR)/usr/share/doc/iserv-mod-room-reservation $(DESTDIR)/usr/share/doc/iserv/mod/room-reservation\r
-\r
+       $(MKDIR) $(DESTDIR)/usr/share/doc/iserv-mod-room-reservation/source/\r
+       if [ ! -d $(DESTDIR)/usr/share/doc/iserv/mod/ ]; then $(MKDIR) $(DESTDIR)/usr/share/doc/iserv/mod/; fi\r
+       $(LN) doc/{TODO,changelog.old.html} $(DESTDIR)/usr/share/doc/iserv-mod-room-reservation/\r
+       $(LN) doc/source/* $(DESTDIR)/usr/share/doc/iserv-mod-room-reservation/source/\r
+       $(RM) $(DESTDIR)/usr/share/doc/iserv/mod/room-reservation\r
+       $(LN) -s ../../iserv-mod-room-reservation $(DESTDIR)/usr/share/doc/iserv/mod/room-reservation\r
+       \r
        # images\r
        if [ ! -d $(DESTDIR)/usr/share/iserv/www/img/default/16/ ]; then $(MKDIR) $(DESTDIR)/usr/share/iserv/www/img/default/16/; fi\r
        $(LN) img/16/*.png $(DESTDIR)/usr/share/iserv/www/img/default/16/\r
@@ -50,10 +49,10 @@ links:
        \r
        # includes\r
        $(MKDIR) $(DESTDIR)/usr/share/iserv/www/inc/mod_room-reservation\r
-       $(LN) includes/*.inc $(DESTDIR)/usr/share/iserv/www/inc/mod_room-reservation/\r
+       $(LN) inc/*.inc $(DESTDIR)/usr/share/iserv/www/inc/mod_room-reservation/\r
        if [ ! -e $(DESTDIR)/usr/share/iserv/www/inc/mod_room-reservation/config.inc ] ; then touch $(DESTDIR)/usr/share/iserv/www/inc/mod_room-reservation/config.inc; fi\r
-ifeq ($(shell id -u),0)\r
-       chmod g+w $(DESTDIR)/usr/share/iserv/www/inc/mod_room-reservation/config.inc\r
+ifeq ($(USER),root)\r
+       chmod u+rw $(DESTDIR)/usr/share/iserv/www/inc/mod_room-reservation/config.inc\r
        chown www-data $(DESTDIR)/usr/share/iserv/www/inc/mod_room-reservation/config.inc\r
 endif\r
        \r
@@ -76,9 +75,8 @@ endif
        $(LN) sql/log_module/* $(DESTDIR)/usr/share/iserv/db/log_module\r
        \r
        # web pages\r
-       $(MKDIR) $(DESTDIR)/usr/share/iserv/www/mod_room-reservation/admin\r
-       $(LN) src/index.php $(DESTDIR)/usr/share/iserv/www/mod_room-reservation/\r
-       $(LN) src/admin/*.php $(DESTDIR)/usr/share/iserv/www/mod_room-reservation/admin/\r
+       $(MKDIR) $(DESTDIR)/usr/share/iserv/www/mod_room-reservation\r
+       $(LN) src/{config,index}.php $(DESTDIR)/usr/share/iserv/www/mod_room-reservation/\r
        \r
        # additional files\r
        $(MKDIR) $(DESTDIR)/usr/share/iserv/modules/room-reservation\r
@@ -91,8 +89,8 @@ sourcedoc:
        mv doc/source/html/* doc/source/ && rm -rf doc/source/html\r
 \r
 # install everything\r
-install: sourcedoc links\r
-ifeq ($(shell echo $USER),root)\r
+install: links\r
+ifeq ($(USER),root)\r
        chkdb -r\r
        chkpriv\r
        chklocale\r
@@ -100,7 +98,8 @@ endif
 \r
 # uninstalling\r
 uninstall:\r
-       $(RM) $(DESTDIR)/usr/share/doc/iserv/mod/mod_room-reservation\r
+       $(RM) $(DESTDIR)/usr/share/doc/iserv/mod/room-reservation\r
+       $(RM) $(DESTDIR)/usr/share/doc/iserv-mod-room-reservation\r
        $(RM) $(DESTDIR)/usr/share/iserv/locale/de/mod_room-reservation.po\r
        $(RM) $(DESTDIR)/usr/share/iserv/db/mod_room-reservation.sql\r
        $(RM) $(DESTDIR)/usr/share/iserv/db/log_module/mod_room-reservation\r
@@ -127,4 +126,4 @@ clean: distclean
 distclean:\r
        $(RM) doc/source\r
 \r
-.PHONY: clean\r
+.PHONY: clean distclean install\r
index 4893b47..390b8cd 100644 (file)
@@ -1,3 +1,43 @@
+iserv-mod-room-reservation (9.01.09-0) unstable; urgency=low
+
+  * fixed error messages concerning rooms_archive on update to IServ2 (see
+      http://wiki.iserv.eu/w/index.php?title=Raumbelegungsplan/Probleme#Update-Skript_von_IServ1_auf_IServ2_zeigt_Fehlermeldungen)
+
+ -- Roland Hieber (Package Signing Key) <roland.hieber@wilhelm-gym.net>  Fri,  9 Jan 2009 19:54:14 +0100
+
+iserv-mod-room-reservation (8.09.13-0) unstable; urgency=low
+
+  * fixed translation: if it is not granted at all, the admin privilege does
+    _not_ apply to all users but to no users
+
+ -- Roland Hieber (Package Signing Key) <roland.hieber@wilhelm-gym.net>  Sat, 13 Sep 2008 16:53:48 +0200
+
+iserv-mod-room-reservation (8.08.03-0) stable; urgency=low
+
+  * if weekends are not shown, show the next week _also_ on sunday
+
+ -- Roland Hieber (Package Signing Key) <roland.hieber@wilhelm-gym.net>  Sun,  3 Aug 2008 15:58:25 +0200
+
+iserv-mod-room-reservation (8.07.30-1) stable; urgency=low
+
+  * debian/postinst: touch config file if it has for unexplicable reasons been
+    deleted
+
+ -- Roland Hieber (Package Signing Key) <roland.hieber@wilhelm-gym.net>  Wed, 30 Jul 2008 21:23:20 +0200
+
+iserv-mod-room-reservation (8.07.30-0) stable; urgency=low
+
+  * fixed log messages: when whitelisting a room, the log message for
+    un-whitelisting was shown, and vice versa...
+
+ -- Roland Hieber (Package Signing Key) <roland.hieber@wilhelm-gym.net>  Wed, 30 Jul 2008 19:13:17 +0200
+
+iserv-mod-room-reservation (8.07.27-0) stable; urgency=low
+
+  * documentation was symlinked wrong
+
+ -- Roland Hieber (Package Signing Key) <roland.hieber@wilhelm-gym.net>  Sat, 26 Jul 2008 22:50:00 +0200
+
 iserv-mod-room-reservation (8.07.26-0) stable; urgency=low
 
   * renamed package, added Conflicts and Replaces header for dpkg
@@ -6,7 +46,7 @@ iserv-mod-room-reservation (8.07.26-0) stable; urgency=low
     /usr/share/doc/iserv-mod-room-reservation, with
     /usr/share/iserv/mod/room-reservation symlinking there
 
- -- Roland Hieber <roland.hieber@iserv.zuhause.test>  Sat, 26 Jul 2008 21:20:19 +0200
+ -- Roland Hieber (Package Signing Key) <roland.hieber@wilhelm-gym.net>  Sat, 26 Jul 2008 21:20:19 +0200
 
 iserv-room-reservation (3.0-2) stable; urgency=low
 
index 16b6a14..f5e9b4d 100755 (executable)
@@ -1,8 +1,8 @@
 #!/bin/sh
+touch /usr/share/iserv/www/inc/mod_room-reservation/config.inc
 chmod g+w /usr/share/iserv/www/inc/mod_room-reservation/config.inc
 chgrp www-data /usr/share/iserv/www/inc/mod_room-reservation/config.inc
 chkdb -r
 chkpriv
 chklocale
-ln -fs /usr/share/doc/iserv/mod/room-reservation /usr/share/doc/iserv-mod-room-reservation
 #DEBHELPER#
diff --git a/debian/postrm b/debian/postrm
new file mode 100644 (file)
index 0000000..9185142
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+psql -c "DELETE FROM log_module WHERE module='Room Reservation Schedule';"
+chklocale
+
+#DEBHELPER#
+
+if [ "$1" = "purge" ]; then
+  echo
+  echo If you do not need the SQL tables anymore, remove them by running
+  echo '  psql -c "DROP TABLE mod_roomreservation_bookings;"'
+  echo After that, all bookings are unrecoverably deleted!
+  echo
+fi;
diff --git a/debian/preinst b/debian/preinst
new file mode 100755 (executable)
index 0000000..746ff84
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+# repair broken symlinks 
+rm -rf /usr/share/doc/iserv/mod/room-reservation # from 3.0
+rm -rf /usr/share/doc/iserv-mod-room-reservation/room-reservation # from 8.07.26-0, symlink is broken
+#DEBHELPER#
index 56d96db..c37b2f9 100755 (executable)
@@ -1,17 +1,5 @@
 #!/bin/sh
-psql -c "DELETE FROM log_module WHERE module='Room Reservation Schedule';"
-chklocale
-
 if [ "$1" = "purge" ]; then
   rm -f /usr/share/iserv/www/inc/mod_room-reservation/config.inc
 fi;
-
 #DEBHELPER#
-
-if [ "$1" = "purge" ]; then
-  echo
-  echo If you do not need the SQL tables anymore, remove them by running
-  echo '  psql -c "DROP TABLE mod_roomreservation_bookings;"'
-  echo After that, all bookings are unrecoverably deleted!
-  echo
-fi;
index 9a88844..bd00f34 100755 (executable)
@@ -14,11 +14,13 @@ binary-indep:
        dh_clean -k 
        dh_installdirs
        $(MAKE) DESTDIR=$(CURDIR)/debian/iserv-mod-room-reservation install
-       
+
+       # we rather install the documentation via dh_installdocs
+       rm -rf $(CURDIR)/debian/iserv-mod-room-reservation/usr/share/doc/iserv-mod-room-reservation
        dh_testdir
        dh_testroot
        dh_installchangelogs 
-       dh_installdocs doc/{changelog.html,TODO} doc/source/
+       dh_installdocs doc/{changelog.old.html,TODO} doc/source/
        #dh_installexamples
        ##dh_install
        ##dh_installmenu
@@ -43,6 +45,7 @@ binary-indep:
        dh_gencontrol
        dh_md5sums
        dh_builddeb
+       rm -rf $(CURDIR)/debian/iserv-mod-room-reservation
 
 # needed for lintian
 binary-arch:
index 47ce0ea..ee202e7 100644 (file)
--- a/doc/TODO
+++ b/doc/TODO
@@ -1,22 +1,14 @@
-= TO DO =\r
-\r
-== Wichtig ==\r
-- VOR PACKAGE: config.inc auf Standardwerte setzen\r
-\r
+== TO DO ==\r
 \r
 === Bugs: ===\r
 - Wenn eine einmalige Buchung erstellt wird, kann an diesem Termin keine feste Buchung mehr erstellt werden.\r
   Feste Buchungen sind aber vorrangig!\r
   => am besten bei fester Buchung Abfrage, ob der Benutzer mit lockerer Buchung per Mail benachrichtigt werden soll\r
-- Räume mit + sind nicht möglich => URL-Kodierung fehlt (https://mzbs.de/idesk/msg/msg.php?forums/public/Module/Raumbelegungsplan/156)\r
-- Nach dem Löschen wieder zur vorigen Ansicht zurückkehren (https://mzbs.de/idesk/msg/msg.php?forums/public/Module/Raumbelegungsplan/157)\r
-- Zeitauswahl bei Buchung auch mit Stunden (1.-10. Stunde statt 7:45-16:15) oder gleich beides möglich machen\r
-\r
 \r
-== Features ==\r
+=== Features ===\r
 - ordentliche Statistik?\r
-- Räume "buchbar" machen, d.h. andere Räume werden nicht zur Buchungsauswahl angezeigt\r
-  => Realisierung per SQL-Tabelle, um die Fremdschlüssel einhalten zu können\r
+- bei sich wiederholenden Buchungen einzelne Buchungen ausblenden, für entfallene Lehrer\r
+  => eigene SQL-Tabelle mit solchen buchungen\r
 \r
 == Erstmal unwichtig ==\r
 - Ferientermine mit einbauen => keine Buchungen dann möglich bzw. Warnung\r
diff --git a/img/16/mod_room-reservation_config.png b/img/16/mod_room-reservation_config.png
deleted file mode 100644 (file)
index 5b5261b..0000000
Binary files a/img/16/mod_room-reservation_config.png and /dev/null differ
diff --git a/inc/exceptions.inc b/inc/exceptions.inc
new file mode 100644 (file)
index 0000000..8d7c688
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+/**\r
+ * @file exceptions.inc
+ * Some custom exceptions\r
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
+ * @date 27.05.2008\r
+ * \r
+ * Copyright © 2007 Roland Hieber\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included in\r
+ * all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+ * THE SOFTWARE.\r
+ */\r
+
+/**
+ * An exception while trying to do a SQL query.
+ */
+class SQLException extends Exception {}
+
+/**
+ * An exception while trying to access something 
+ */
+class AccessException extends Exception {}
+
+/**
+ * An exception while trying to write or read something 
+ */
+class IOException extends Exception {}
+
+?>
\ No newline at end of file
diff --git a/inc/functions.inc b/inc/functions.inc
new file mode 100644 (file)
index 0000000..78e3690
--- /dev/null
@@ -0,0 +1,279 @@
+<?php
+/**
+ * @file functions.inc
+ * additional functions for iserv-mod-room-reservation
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)
+ * @date 22.12.2007
+ * 
+ * Copyright © 2007 Roland Hieber
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ * 
+ * @todo move some functions into M Class Library
+ */
+
+require_once("share.inc");
+require_once("db.inc");
+require_once("user.inc");
+require_once("sec/secure.inc");
+
+/**
+ * @page errorcodes Error Codes
+ * @{
+ */
+/** Access denied. This can be due to missing access rights. */
+define("MOD_ROOM_RESERVATION_ERROR_ACCESS_DENIED", 
+  _c("room-reservation:Access denied."));
+/** Error while querying the database */
+define("MOD_ROOM_RESERVATION_ERROR_SQL", 
+  _c("room-reservation:Error while trying to query the database."));
+/** Error while trying to open a file */
+define("MOD_ROOM_RESERVATION_ERROR_OPEN_FILE",
+  _c("room-reservation:Could not open file."));
+/** Error while trying to write a file */
+define("MOD_ROOM_RESERVATION_ERROR_WRITE_FILE",
+  _c("room-reservation:Could not write to file."));
+/** Error while trying to lock a file */
+define("MOD_ROOM_RESERVATION_ERROR_LOCK_FILE",
+  _c("room-reservation:Could not lock file."));
+/** Error while trying to unlock a file */
+define("MOD_ROOM_RESERVATION_ERROR_UNLOCK_FILE",
+  _c("room-reservation:Could not unlock file."));
+/** The current booking overlaps with an existing booking */
+define("MOD_ROOM_RESERVATION_ERROR_BOOKING_OVERLAPS", _c("room-reservation:".
+  "The current booking overlaps with an existing booking."));
+/** The booking ends before it begins */
+define("MOD_ROOM_RESERVATION_ERROR_END_BEFORE_BEGIN", _c("room-reservation:".
+  "The ending of your booking cannot lie before the beginning."));
+define("MOD_ROOM_RESERVATION_ERROR_NO_REASON", _c("room-reservation:Please ".
+ "give a reason."));
+/** A new timeslice overlaps with an existing timeslice */
+define("MOD_ROOM_RESERVATION_ERROR_CONFIG_OVERLAPPING_TIMESLICE",
+  _c("room-reservation:The period overlaps with an existing one."));
+/** There is no such timeslice */
+define("MOD_ROOM_RESERVATION_ERROR_CONFIG_NO_SUCH_TIMESLICE",
+  _c("room-reservation:The specified period does not exist."));
+/** There is no such account */
+define("MOD_ROOM_RESERVATION_ERROR_NO_SUCH_ACCOUNT", _c("room-reservation:".
+  "The specified account does not exist."));
+/** The room is not available for booking */
+define("MOD_ROOM_RESERVATION_ERROR_ROOM_NOT_WHITELISTED",
+  _c("room-reservation:This room is not available for booking."));
+/**
+ * @}
+ */
+
+/**
+ * Determine if the specified user exists. Throws an SQLException if an error
+ * occured.
+ * @param $strAct (string) Account name of the user
+ * @throws SQLException
+ * @return (bool)
+ */
+function isAct($strAct) {
+  $hQuery = db_query("SELECT * FROM users WHERE act = $1;", $strAct);
+  if(!is_resource($hQuery)) {
+    throw new SQLException(MOD_ROOM_RESERVATION_ERROR_SQL);
+    return null;
+  }
+  return (pg_num_rows($hQuery) > 0);
+}
+
+/**
+ * Get the real user name for an account name
+ * @param $strAct (string) Account name of the user to look up
+ * @return (string) The real name of the user. If the function fails, it returns <tt>null</tt>.
+ *  Call getLastError() to get more information about the error.
+ */
+function getRealUserName($strAct) {
+  $hQuery = db_query("SELECT firstname, lastname FROM users WHERE act = $1;", $strAct);
+  if(!is_resource($hQuery)) {
+    // TODO throw exception
+    setLastError(RS_ERROR_SQL);
+    return null;
+  }
+  if(pg_num_rows($hQuery) == 0) {
+    return $strAct;     // User not found in database, return account name
+  }
+  $arResult = pg_fetch_array($hQuery);
+  return user_join_name($arResult);
+}
+
+/**
+ * Determine if a specified group exists
+ * @param $strAct (string) Account name of the group
+ * @return  (bool / null) If the function fails, it returns <tt>null</tt>. Call getLastError() to
+ *  get more information about the error.
+ */
+function isGroup($strAct) {
+  $hQuery = db_query("SELECT * FROM groups WHERE act = $1;", $strAct);
+  if(!is_resource($hQuery)) {
+    // TODO throw exception
+    setLastError(RS_ERROR_SQL);
+    return null;
+  }
+  return (pg_num_rows($hQuery) > 0);
+}
+
+/**
+ * Look up the name of a group
+ * @param $strAct (string) Account name of the group
+ * @return (string) The name of the group. If the function fails, it returns <tt>null</tt>.
+ *  Call getLastError() to get more information about the error.
+ */
+function getGroupName($strAct) {
+  $hQuery = db_query("SELECT * FROM groups WHERE act = $1;", $strAct);
+  if(!is_resource($hQuery)) {
+    // TODO throw exception
+    setLastError(RS_ERROR_SQL);
+    return null;
+  }
+  if(pg_num_rows($hQuery) == 0) {
+    return $strAct;     // Group not found in database, return account name
+  }
+  $arResult = pg_fetch_array($hQuery);
+  return $arResult["name"];
+}
+
+/**
+ * Create a link to write a mail to the specified account name.
+ * This function returns a link if the specified account exists, otherwise it returns the
+ * account name.
+ * @param $strAct (string) Account name
+ * @param $strColor (string) Background color for icon()
+ * @param $strParams (string) additional URL parameters
+ * @return string
+ */
+function mailToUserLink($strAct, $strColor = "bl", $strParams = "") {
+  if(!isAct($strAct)) {
+    return $strAct;
+  }
+  return popup(relroot("msg/write/?to=".user_mail_addr($strAct).$strParams),
+    600, 400, nobr(icon("mail-reply-usr", array("size" => 16, "bg" => 
+    $strColor)) . getRealUserName($strAct)));
+}
+
+/**
+ * Determine if a specified string is a valid mail address
+ * @param $strAddr string
+ * @return string
+ */
+function isMailAddress($strAddr) {
+  return ((preg_match("/([a-zA-Z0-9_\-\.]*(@[a-zA-Z0-9\-\.]*)?(\s*,\s*)?)+/", $strAddr) > 0)
+  and (preg_match("/(\s*,\s*)$/", $strAddr) == 0));
+}
+
+/**
+ * Module-specific logging function.
+ * Prefixes the log message with a module-specific string and writes it to the logs.
+ * @param $strLog (string) Log message
+ * @return void
+ */
+function rrInsertLog($strLog) {
+ log_insert($strLog, null, "Room Reservation Schedule");
+}
+
+/**
+ * Get the SQL day number from a given timestamp.
+ * @param $ts (timestamp)
+ * @return (int) 0-6 for Sunday to Monday
+ */
+function rrDateToSQLDayNumber($ts) {
+  $aDays = array("Sun" => 0, "Mon" => 1, "Tue" => 2,
+    "Wed" => 3, "Thu" => 4, "Fri" => 5, "Sat" => 6);
+  return $aDays[date("D", $ts)];
+}
+
+/**
+ * Convert a UNIX timestamp to an SQL date string
+ * @param $ts (timestamp)
+ * @return string
+ */
+function dateToSql($ts) { return date("Y\-m\-d", intval($ts)); }
+
+/**
+ * Calculate the timestamp of the monday in the current week
+ * @param $ts (timestamp) Calculate the value relative to this date
+ * @return timestamp
+ */
+function rrGetMonday($ts = null) {
+  if($ts === null) {
+    $ts = time();
+  }
+  if(date("D", $ts) == "Mon") {
+    // Today is monday
+    return strtotime("00:00", $ts);
+  } else {
+    return strtotime("last monday", $ts);
+  }
+}
+
+/** (array of strings) Additional CSS rules */
+$GLOBALS["rrLocalCss"] = array();
+
+/**
+ * Add CSS rules to the page
+ * @param $s (string)
+ * @return void
+ */
+function rrAddCss($s) {
+  rrDebug("rrAddCss: add \"$s\"");
+  $GLOBALS["rrLocalCss"][] = $s;
+}
+
+/**
+ * Get CSS rules that have been added with rrAddCss()
+ * @return string
+ */
+function rrGetCss() {
+  rrDebug("rrGetCss: Local CSS is ".var_export($GLOBALS["rrLocalCss"], true));
+  return implode("\n", $GLOBALS["rrLocalCss"]);
+}
+
+function rrDebug($s, $bReturn = false) {
+  if(isset($_GET["debug"])) {
+    if(!$bReturn) {
+      echo "<!-- $s -->\n";
+    } else {
+      return $s;
+    }
+  }
+}
+
+/**
+ * sprintf with support for ordinal numbers.
+ * This version of sprintf replaces all substrings of the type <tt>/\\d+#/</tt>
+ * (i.e. a decimal number with a hash sign appended) in the input string with
+ * the corresponding english ordinal number prefices (st, nd, rd, th).
+ * @param $str (string) Input string
+ * @param $args (mixed) Additional parameters to be passed to sprintf()
+ * @return (string)
+ */
+function _sprintf_ord($str, $args /*leave this parameters for doxygen*/) {
+  $args = func_get_args();
+  if(preg_match_all("/%[bcdufosxX]/", $args[0], $temp) != func_num_args()-1) {
+    trigger_error("Too few arguments", E_USER_ERROR);
+    return false;
+  }
+  $str = call_user_func_array("sprintf", $args);
+  while(preg_match("/(.*)(\d+)#(.*)/", $str, $m))
+    $str = $m[1]._(append_ord_suffix($m[2])).$m[3];
+  return $str;
+}
+?>
diff --git a/inc/globals.inc b/inc/globals.inc
new file mode 100644 (file)
index 0000000..eb2977e
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+/**
+ * @file globals.inc 
+ * Include all the stuff that we need
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)
+ * @date 27.01.2008
+ * 
+ * Copyright © 2007 Roland Hieber
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *  
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+require_once("mod_room-reservation/functions.inc");
+require_once("mod_room-reservation/exceptions.inc");
+require_once("mod_room-reservation/mod_roomReservationBookingsManager.inc");
+require_once("mod_room-reservation/mod_roomReservationRoomsManager.inc");
+require_once("mod_room-reservation/mod_roomReservationConfig.inc");
+
+/** A global instance of the mod_roomReservationConfig class */
+$g_rrCfg = new mod_roomReservationConfig();
+/** A global instance of the mod_roomReservationBookingsManager class */
+$g_rrBm = new mod_roomReservationBookingsManager($g_rrCfg);
+/** A global instance of the mod_roomReservationRoomsManager class */
+$g_rrRm = new mod_roomReservationRoomsManager($g_rrCfg);
+
+/**
+ * @mainpage iserv-mod-room-reservation -- Simple reservation of rooms
+ * The room reservation module allows the users of your IServ Portalserver
+ * to reserve a room, e.g. for meetings, lessons etc.
+ */
+?>
diff --git a/inc/mod_roomReservationBooking.inc b/inc/mod_roomReservationBooking.inc
new file mode 100644 (file)
index 0000000..a6a1c8a
--- /dev/null
@@ -0,0 +1,201 @@
+<?php
+/**
+ * @file mod_roomReservationBooking.inc
+ * Container class for the representation of a single booking
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)
+ * @date 12.11.2007
+ * 
+ * Copyright © 2007 Roland Hieber
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+/** @todo document */
+/**
+ * Container class for the representation of a single booking
+ */
+class mod_roomReservationBooking {
+  
+  /** (int / null) Unique ID in database */
+  protected $nUid;
+  /** (string) Name of the room */
+  protected $strRoom;
+  /** (timestamp) Date when the booking takes place */
+  protected $tsDate;
+  /** (int) Number of the first timeslice */
+  protected $nTsFirst;
+  /** (int) Number of the last timeslice (may be nBegin) */
+  protected $nTsLast;
+  /** (string) Account name of the owner */
+  protected $strAct;
+  /** (string) Reason for the booking */
+  protected $strReason;
+  /** (bool) Recurrence interval in weeks */
+  protected $nInterval;
+  
+  /***************************************************************************/
+  /**
+   * @name Constructor
+   * @{
+   */
+  /**
+   * Constructor.
+   * @param $strRoom (string) Name of the room
+   * @param $tsDate (timestamp) Date when the booking takes place
+   * @param $nTsFirst (int) Number of the first timeslice 
+   * @param $nTsLast (int) Number of the last timeslice (may be nBegin) 
+   * @param $strAct (string) Account name of the owner
+   * @param $strReason (string) Reason for the booking
+   * @param $nInterval (int) Recurrence interval, 0 for no recurrence
+   * @return mod_roomReservationBooking
+   */
+  public function __construct($strRoom, $tsDate, $nTsFirst, $nTsLast, $strAct,
+    $strReason, $nInterval = 0) {
+    $this->setUid(null);
+    $this->setRoom($strRoom);
+    $this->setDate($tsDate);
+    $this->setTsFirst($nTsFirst);
+    $this->setTsLast($nTsLast);
+    $this->setAct($strAct);
+    $this->setReason($strReason);
+    $this->setInterval($nInterval);
+  }
+  
+  /***************************************************************************/
+  /**
+   * @}
+   * @name Access to attributes
+   * @{
+   */
+  
+  /**
+   * Set the unique ID in database
+   * @param $n (int) Unique ID in database
+   * @return void
+   */
+  public function setUid($n) {
+    if(is_null($n)) {
+      $this->nUid = null;
+    } else {
+      $this->nUid = intval($n);
+    }
+  }
+  
+  /**
+   * Set the name of the room
+   * @param $str (string) Name of the room
+   * @return void
+   */
+  public function setRoom($str) { $this->strRoom = $str; }
+  
+  /**
+   * Set the date when the booking takes place
+   * @param $ts (timestamp) Date, only the date part is taken care of
+   * @return void
+   */
+  public function setDate($ts) {
+    // Only take the date part
+    $this->tsDate = intval(strtotime(date("Y\-m\-d", intval($ts))));  }
+
+  /**
+   * Set the first timeslice
+   * @param $n (int) Number of the first timeslice
+   * @return void
+   */
+  public function setTsFirst($n) { $this->nTsFirst = intval($n); }
+  
+  /**
+   * Set the end timeslice
+   * @param $n (int) Number of the last timeslice (may be the start timeslice) 
+   * @return void
+   */
+  public function setTsLast($n) { $this->nTsLast = intval($n); }
+  
+  /**
+   * Set the account name of the owner
+   * @param $str (string) Account name
+   * @return void
+   */
+  public function setAct($str) { $this->strAct = $str; }
+  
+  /**
+   * Set the reason for the booking
+   * @param $str (string) Reason
+   * @return void
+   */
+  public function setReason($str) { $this->strReason = $str; }
+  
+  /**
+   * Set the flag whether the booking repeates every week
+   * @param $n (int) interval in weeks, 0 for no recurrence
+   * @return void
+   */
+  public function setInterval($n) { $this->nInterval = intval(abs($n)); }
+
+  /**
+   * Get the unique ID in database
+   * @return int / null
+   */
+  public function getUid() { return intval($this->nUid); }
+  
+  /**
+   * Get the name of the room
+   * @return string
+   */
+  public function getRoom() { return $this->strRoom; }
+  
+  /**
+   * Get the date when the booking takes place
+   * @return timestamp
+   */
+  public function getDate() { return intval($this->tsDate); }
+  
+  /**
+   * Get the the number of the first timeslice
+   * @return int
+   */
+  public function getTsFirst() { return intval($this->nTsFirst); }
+  
+  /**
+   * Get the number of the last timeslice (may be the start timeslice)
+   * @return int
+   */
+  public function getTsLast() { return intval($this->nTsLast); }
+  
+  /**
+   * Get the account name of the owner
+   * @return string
+   */
+  public function getAct() { return $this->strAct; }
+  
+  /**
+   * Get the reason for the booking
+   * @return string
+   */
+  public function getReason() { return $this->strReason; }
+  
+  /**
+   * Get the recurrence interval
+   * @return int
+   */
+  public function getInterval() { return $this->nInterval; }
+
+  /**@}*/
+}
+?>
diff --git a/inc/mod_roomReservationBookingPage.inc b/inc/mod_roomReservationBookingPage.inc
new file mode 100644 (file)
index 0000000..219c7bd
--- /dev/null
@@ -0,0 +1,215 @@
+<?php
+/**
+ * @file mod_roomReservationBookingPage.inc
+ * Page that shows the booking table
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)
+ * @date 24.02.2008
+ * 
+ * Copyright © 2007 Roland Hieber
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+require_once("share.inc");
+require_once("ctrl.inc");
+require_once("mod_room-reservation/mod_roomReservationPage.inc");
+require_once("mod_room-reservation/mod_roomReservationBookingTable.inc");
+require_once("mod_room-reservation/mod_roomReservationBookingsManager.inc");
+require_once("mod_room-reservation/mod_roomReservationConfig.inc");
+
+/**
+ * Page that shows the booking table
+ * @todo document, don't forget GET parameters 
+ */
+class mod_roomReservationBookingPage extends mod_roomReservationPage {
+  
+       /** (mod_roomReservationConfig) Reference to the configuration object */
+  protected $oCfg;
+  /** 
+   * (mod_roomReservationRoomsManager) Reference to the rooms manager object 
+   */
+  protected $oRm;
+  /** 
+   * (mod_roomReservationBookingsManager) Reference to the bookings manager 
+   * object
+   */
+  protected $oBm;
+  /** (timestamp) Starting date of the booking table */
+  protected $tsStart;
+  /** (int) Name of the room to show in the booking table */
+  protected $strRoom;
+  
+  /** (mod_roomReservationBookingTable) The booking table */
+  protected $oBt;
+  
+  /***************************************************************************/
+  /**
+   * @name Constructor
+   * @{
+   * Constructor
+   * @param $oCfg (mod_roomReservationConfig) Reference to the configuration
+   *  object
+   * @param $oRm (mod_roomReservationRoomsManager) Reference to the rooms
+   *  manager object
+   * @param $oBm (mod_roomReservationBookingsManager) Reference to the
+   *  bookings manager object
+   * @return mod_roomReservationBookingPage
+   */
+  public function __construct(mod_roomReservationConfig &$oCfg, 
+    mod_roomReservationRoomsManager &$oRm,
+    mod_roomReservationBookingsManager &$oBm) {
+    $this->oCfg = $oCfg;
+    $this->oRm = $oRm;
+    $this->oBm = $oBm;
+
+    // create the booking table here, so the CSS is already added
+    /** @todo maybe move it into beforeAddCSS()... ? */
+    $this->oBt = new mod_roomReservationBookingsTable($this->oCfg, $this->oRm,
+      $this->oBm, "?bookingpage[action]=edit", "?bookingpage[action]=delete");
+
+    parent::__construct($oCfg);
+    $this->setTitle(_c("Room Reservation Schedule"));
+    $this->setIcon("mod_room-reservation_index");
+  }
+
+  /***************************************************************************/
+  /**
+   * @}
+   * @name Initialization
+   * @{
+   */
+
+  /**
+   * Process the REQUEST variables and preset the some variables
+   * @return void
+   */
+  protected function processRequestVariables() {
+    // take all settings from the booking table
+    $this->setRoom($this->oBt->getRoom());
+    $this->setStart($this->oBt->getDate());
+  }
+  
+  /***************************************************************************/
+  /**
+   * @}
+   * @name Access to attributes
+   * @{
+   */
+  
+  /**
+   * Set the starting date
+   * @param $ts (timestamp)
+   */
+  public function setStart($ts) { $this->tsStart = intval($ts); }
+
+  /**
+   * Set the room to show in the booking table
+   * @param $str (string) Name of the room
+   */
+  public function setRoom($str) { $this->strRoom = $str; }
+
+  /**
+   * Get the starting date
+   * @return int
+   */
+  public function getStart() { return intval($this->tsStart); }
+  
+  /**
+   * Get the name of the room to show in the booking table
+   * @return string
+   */
+  public function getRoom() { return $this->strRoom; }
+  
+  /***************************************************************************/
+  /**
+   * @}
+   * @name Output
+   * @{
+   */
+  
+  /**
+   * Show the page.
+   * @return void
+   */
+  public function doShow() {
+    // Protect access
+    if(!$this->oCfg->userCanView()) {
+      echo sprintf("<p class='err'>%s</p>", 
+        MOD_ROOM_RESERVATION_ERROR_ACCESS_DENIED);
+      _PageBlue();
+      die();
+    }
+    
+    Title(_c("room-reservation:Book rooms"));
+    
+    // Form for room selection
+    /** @todo checkbox for recurring booking */ 
+    echo sprintf("<form name='room' method='get' action='%s'>",
+      $_SERVER["PHP_SELF"]);
+    echo sprintf("<input type='hidden' name='mod_roomReservationBookingTable".
+      "[date]' value='%d' />\n", $this->getStart());
+    
+    // Show rooms only if it is whitelisted
+    try {
+      $aor = $this->oCfg->getWhitelistedRooms();
+    } catch(SQLException $e) {
+      trigger_error($e->getMessage());
+    }
+    if(count($aor) > 0) {
+      echo _c("room-reservation:Room:") . sprintf(" <select onchange=".
+        "'document.forms[\"room\"].submit()' width='250' ".
+       "name='mod_roomReservationBookingTable[room]'>\n", $this->getStart());
+      foreach($aor as $or) {
+        // note to myself: no qu() here, seems this is being done automagically
+        echo sprintf("<option value='%s'%s>%s</option>\n", $or->getName(),
+          ($or->getName() == $this->getRoom()) ? " selected='selected'" : "",
+          $or->getName());
+      }
+      echo sprintf("</select>&nbsp;<%s value='%s' /></form><p />\n",
+        $GLOBALS["stdbtn"], _("Change"));
+    } else {
+      printf("<p>%s</p>\n", _c("room-reservation:No rooms have been ".
+       "configured yet."));
+      return;
+    }
+        
+    // Print line with next 5 or so weeks
+    $strSep = "&nbsp;| ";
+    $strLink = sprintf("<a href='%s?mod_roomReservationBookingTable[date]=%%d".
+       "&mod_roomReservationBookingTable[room]=%%s'>%%s</a>",
+      $_SERVER["PHP_SELF"]);
+    echo "<p>".sprintf($strLink, time(), qu($this->getRoom()),
+      _c("room-reservation:Current Week")) . $strSep;
+    echo sprintf($strLink, strtotime("1 week ago", $this->getStart()),
+      qu($this->getRoom()), _c("room-reservation:&lt; Back")) . $strSep;
+    echo sprintf("<b>%s</b>", _sprintf_ord(_c("room-reservation:%d# week"), 
+      date("W", $this->getStart()))) . $strSep;
+    for($i = 1; $i <= 5; $i++) {
+      $nNextWeek = strtotime("$i week", $this->getStart());
+      echo sprintf($strLink, $nNextWeek, qu($this->getRoom()), _sprintf_ord(
+        _c("room-reservation:%d# week"), date("W", $nNextWeek)));
+      echo $strSep;
+    }
+    echo sprintf($strLink, strtotime("1 week", $this->getStart()), 
+      qu($this->getRoom()), _c("room-reservation:Next &gt;"))."</p>\n";
+    
+    $this->oBt->show();
+  }
+}
+?>
diff --git a/inc/mod_roomReservationBookingTable.inc b/inc/mod_roomReservationBookingTable.inc
new file mode 100644 (file)
index 0000000..fd85ef1
--- /dev/null
@@ -0,0 +1,783 @@
+<?php
+/**
+ * @file mod_roomReservationBookingTable.inc
+ * A timetable-like representation of bookings
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)
+ * @date 03.02.2008
+ *
+ * Copyright © 2007 Roland Hieber
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+require_once("mod_room-reservation/mod_roomReservationConfig.inc");
+require_once("mod_room-reservation/mod_roomReservationBookingsManager.inc");
+require_once("mod_room-reservation/mod_roomReservationRoomsManager.inc");
+
+/*****************************************************************************/
+/**
+ * @page bookingtable_actions Actions of a mod_roomReservationBookingTable
+ *  instance
+ * @{
+ * The following constants describe the actions that a
+ * mod_roomReservationBookingTable instance can handle. They are used in
+ * processRequestVariables() to determine the action that should be done when
+ * the table is shown.
+ */
+/** Show the booking table (default action) */
+define("MOD_ROOM_RESERVATION_BT_ACTION_SHOW", 0);
+/** Show the form for a new booking */
+define("MOD_ROOM_RESERVATION_BT_ACTION_BOOK", 1);
+/** The booking form has been submitted, process the booking */
+define("MOD_ROOM_RESERVATION_BT_ACTION_SUBMIT", 2);
+/** Edit a booking */
+define("MOD_ROOM_RESERVATION_BT_ACTION_EDIT", 3);
+/** Show the deletion form */
+define("MOD_ROOM_RESERVATION_BT_ACTION_DELETE", 4);
+/** The deletion form has been submitted, delete the booking */
+define("MOD_ROOM_RESERVATION_BT_ACTION_SUBMITDELETE", 5);
+/** @} */
+
+/*****************************************************************************/
+/**
+ * @page bookingtable_printbooking_flags Flags for
+ *  mod_roomReservationBookingTable::printBooking
+ * @{
+ * The following constants describe the flags for the second parameter of
+ * mod_roomReservationBookingTable::printBooking().
+ */
+/** 
+ * This booking is new. New bookings are printed with a different background
+ * color.
+ */
+define("MOD_ROOM_RESERVATION_BTPB_NEW", 2);
+/** This booking is requested for deletion. Show delete button. */
+define("MOD_ROOM_RESERVATION_BTPB_DELETE", 4);
+/** @} */
+
+/*****************************************************************************/
+/**
+ * A timetable-like representation of bookings
+ * @todo document
+ */
+class mod_roomReservationBookingsTable /* extends mclWidget */ {
+
+  /** (mod_roomReservationConfig) Reference to the configuration object */
+  protected $oCfg;
+  /**
+   * (mod_roomReservationRoomsManager) Reference to the rooms manager object
+   */
+  protected $oRm;
+  /**
+   * (mod_roomReservationBookingsManager) Reference to the bookings manager
+   * object
+   */
+  protected $oBm;
+  /**
+   * (constant) The action to be performed.
+   * See @ref bookingtable_actions for a list of possible values.
+   */
+  protected $cAction;
+  /**
+        * (timestamp) The date of the requested booking or the date to show in the
+        * booking table
+        */
+  protected $tsDate;
+  /**
+   * (string) The name of the room of the requested booking or the room to be
+   * shown in the booking table
+   */
+  protected $strRoom;
+  /** (int) The starting timeslice of the requested booking */
+  protected $nTsFirst;
+  /** (int) The ending timeslice of the requested booking */
+  protected $nTsLast;
+  /** (string) The reason of the requested booking */
+  protected $strReason;
+  /** (int) UID of the booking to be deleted / edited */
+  protected $nDeleteUid;
+  /** (string) Value of the button that the user clicked */
+  protected $strSubmitButtonValue;
+  /** (string) Account of the owner, POST data */
+  protected $strPostAccount;
+  /** (int) recurrence interval, POST data */
+  protected $nPostInterval;
+  /** (string) Array of error messages */
+  protected $asErrors = array();
+  
+  /***************************************************************************/
+  /**
+   * @name Constructor
+   * @{
+   * Constructor
+   * @param $oCfg (reference to mod_roomReservationConfig) Reference to the
+   *  configuration
+   * @param $oRm (reference to mod_roomReservationRoomsManager) Reference to
+   *  the rooms manager object
+   * @param $oBm (reference to mod_roomReservationBookingsManager) Reference
+   *  to the bookings manager object
+   * @return mod_roomReservationBookingTable
+   */
+  public function __construct(mod_roomReservationConfig &$oCfg,
+    mod_roomReservationRoomsManager &$oRm,
+    mod_roomReservationBookingsManager &$oBm) {
+    $this->oCfg = $oCfg;
+    $this->oRm = $oRm;
+    $this->oBm = $oBm;
+   
+    try {
+      $this->processRequestVariables();
+    } catch(Exception $e) {
+      $this->asErrors[] = $e->getMessage();
+    }
+    $this->addCSS();
+  }
+
+  /***************************************************************************/
+  /**
+   * @}
+   * @name Initialization
+   * @{
+   */
+
+  /**
+   * Process the REQUEST variables and preset the some variables. Throws an
+   * exception if the room provided by the GET data is not allowed for booking
+   * @return void
+   * @throws Exception
+   */
+  protected function processRequestVariables() {
+    
+    // default values
+    $aoRooms = $this->oCfg->getWhitelistedRooms();
+    if(count($aoRooms) < 1) {
+      $this->setRoom("");
+    } else {
+      $this->setRoom($aoRooms[0]->getName());
+    }
+    // if weekends are not shown, show the next week already on saturday
+    if(!$this->oCfg->isShowWeekend() and (date("w") == 6 or date("w") == 0)) {
+      $this->setDate(strtotime("monday"));
+    } else {
+      $this->setDate(time());
+    }
+    $this->setAction(MOD_ROOM_RESERVATION_BT_ACTION_SHOW);
+    $this->nPostInterval = 0;
+   
+    // handle GET parameters
+    if(isset($_GET["mod_roomReservationBookingTable"])) {
+      $ga = isset($_GET["mod_roomReservationBookingTable"]["action"]) ?
+        $_GET["mod_roomReservationBookingTable"]["action"] : "";
+      $this->setAction(($ga == "book") ?
+        MOD_ROOM_RESERVATION_BT_ACTION_BOOK : (($ga == "edit") ?
+        MOD_ROOM_RESERVATION_BT_ACTION_EDIT : (($ga == "delete") ?
+        MOD_ROOM_RESERVATION_BT_ACTION_DELETE : (($ga == "submit") ?
+        MOD_ROOM_RESERVATION_BT_ACTION_SUBMIT : (($ga == "submitdelete") ?
+        MOD_ROOM_RESERVATION_BT_ACTION_SUBMITDELETE :
+        MOD_ROOM_RESERVATION_BT_ACTION_SHOW)))));
+      $this->setDate(isset($_GET["mod_roomReservationBookingTable"]["date"]) ?
+        intval($_GET["mod_roomReservationBookingTable"]["date"]) : time());
+      if(isset($_GET["mod_roomReservationBookingTable"]["room"])) {
+        $this->setRoom($_GET["mod_roomReservationBookingTable"]["room"]);
+      }
+      $this->setTsFirst(
+        isset($_GET["mod_roomReservationBookingTable"]["tsfirst"]) ?
+        intval($_GET["mod_roomReservationBookingTable"]["tsfirst"]) : 0);
+      $this->setTsLast($this->getTsFirst());
+     
+      // if deletion form is requested, set the right date, room etc.
+      if($this->getAction() == MOD_ROOM_RESERVATION_BT_ACTION_DELETE) {
+        if(isset($_GET["mod_roomReservationBookingTable"]["uid"]) &&
+          $_GET["mod_roomReservationBookingTable"]["uid"] >= 0) {
+          $this->setUid(intval(
+            $_GET["mod_roomReservationBookingTable"]["uid"]));
+        } else {
+          trigger_error("The UID is invalid.", E_USER_ERROR);
+        }
+        $ob = mod_roomReservationBookingsManager::getBookingByUid(
+          $this->getUid());
+        $this->setRoom($ob->getRoom());
+        if($ob->getInterval() > 0) {
+          // don't show the first date when the booking was created, but the
+          // date of the page where the user clicked the delete button
+          $this->setDate(
+            isset($_GET["mod_roomReservationBookingTable"]["date"]) ?
+            intval($_GET["mod_roomReservationBookingTable"]["date"]) : time());
+        } else {
+          $this->setDate($ob->getDate());
+        }
+        $this->setTsFirst($ob->getTsFirst());
+      }
+    }
+   
+    if(isset($_POST["mod_roomReservationBookingTable"])) {
+      if(isset($_POST["mod_roomReservationBookingTable"]["submitbooking"])) {
+        // submission of the booking form
+        // let POST variables overwrite the variables
+        $this->setDate(
+          isset($_POST["mod_roomReservationBookingTable"]["date"]) ?
+          intval($_POST["mod_roomReservationBookingTable"]["date"]) : time());
+        $this->setRoom(
+          isset($_POST["mod_roomReservationBookingTable"]["room"]) ?
+          $_POST["mod_roomReservationBookingTable"]["room"] : "");
+        $this->setTsFirst(
+          isset($_POST["mod_roomReservationBookingTable"]["tsfirst"]) ?
+          intval($_POST["mod_roomReservationBookingTable"]["tsfirst"]) : 0);
+        $this->setTsLast(
+          isset($_POST["mod_roomReservationBookingTable"]["tslast"]) ?
+          intval($_POST["mod_roomReservationBookingTable"]["tslast"]) :
+          $this->getTsFirst());
+        $this->setReason(
+          isset($_POST["mod_roomReservationBookingTable"]["reason"]) ?
+          $_POST["mod_roomReservationBookingTable"]["reason"] : "");
+        $this->nPostInterval =
+          isset($_POST["mod_roomReservationBookingTable"]["interval"]) ?
+          intval($_POST["mod_roomReservationBookingTable"]["interval"]) : 0;
+        $this->strPostAccount =
+          isset($_POST["mod_roomReservationBookingTable"]["account"]) ?
+          $_POST["mod_roomReservationBookingTable"]["account"] : "";
+      }
+     
+      if(isset($_POST["mod_roomReservationBookingTable"]["submitdelete"])) {
+        // submission of the deletion form
+        if(isset($_POST["mod_roomReservationBookingTable"]["uid"]) &&
+          $_POST["mod_roomReservationBookingTable"]["uid"] >= 0) {
+          $this->setUid(
+            intval($_POST["mod_roomReservationBookingTable"]["uid"]));
+        } else {
+          trigger_error("The UID is invalid.", E_USER_ERROR);
+        }
+        // set the right date, room etc.
+        $ob = mod_roomReservationBookingsManager::getBookingByUid(
+          $this->getUid());
+        $this->setRoom($ob->getRoom());
+        $this->setDate($ob->getDate());
+        $this->setTsFirst($ob->getTsFirst());
+        $this->setSubmitButtonValue(isset(
+          $_POST["mod_roomReservationBookingTable"]["submitdelete"]) ?
+          $_POST["mod_roomReservationBookingTable"]["submitdelete"] : "");
+      }
+    }
+  }
+  /***************************************************************************/
+  /**
+   * @}
+   * @name Access to attributes
+   * @{
+   */
+
+  /**
+   * Set the action that should be done
+   * @param $c (constant) See @ref bookingtable_actions for possible values
+   */
+  protected function setAction($c) { $this->cAction = intval($c); }
+  /**
+   * Set the starting timeslice of the requested booking
+   * @param $n (int)
+   */
+  protected function setTsFirst($n) { $this->nTsFirst = intval($n); }
+
+  /**
+   * Set the ending timeslice of the requested booking
+   * @param $n (int)
+   */
+  protected function setTsLast($n) { $this->nTsLast = intval($n); }
+  /**
+   * Set the date of the requested booking or the date to be shown in the
+   * booking table
+   * @param $ts (timestamp)
+   */
+  public function setDate($ts) { $this->tsDate = intval($ts); }
+  /**
+   * Set the room of the requested booking or the room to be shown in the
+   * booking table. Throws an Exception if the room is not allowed for booking.
+   * @param $str (string)
+   * @throws Exception
+   */
+  protected function setRoom($str) {
+    // only allow whitelisted rooms
+    if($this->oCfg->isRoomWhitelisted($str)) {
+      $this->strRoom = $str;
+    } else {
+      throw new Exception(_c("room-reservation:This room is not available ".
+       "for booking."));
+    }
+  }
+  /**
+   * Set the reason of the requested booking
+   * @param $str (string)
+   */
+  protected function setReason($str) { $this->strReason = $str; }
+
+  /**
+   * Set the UID of the booking to be deleted / edited
+   * @param $n (int)
+   */
+  protected function setUid($n) { $this->nUid = intval($n); }
+  /**
+   * Set the value of the submit button that the user clicked
+   * @param $str (string)
+   */
+  protected function setSubmitButtonValue($str) {
+    $this->strSubmitButtonValue = $str;
+  }
+  /**
+   * Get the name of the room of the requested booking or the room to show in
+   * the booking table
+   * @return string
+   */
+  public function getRoom() { return $this->strRoom; }
+   
+  /**
+   * Get the action that should be done
+   * @return constant See @ref bookingtable_actions for possible values
+   */
+  public function getAction() { return $this->cAction; }
+  /**
+   * Get the the starting timeslice of the requested booking
+   * @return int
+   */
+  public function getTsFirst() { return $this->nTsFirst; }
+
+  /**
+   * Get the the ending timeslice of the requested booking
+   * @return int
+   */
+  public function getTsLast() { return $this->nTsLast; }
+
+  /**
+   * Get the the date of the requested booking or the date to be shown in the
+   * booking table
+   * @return timestamp
+   */
+  public function getDate() { return $this->tsDate; }
+  /**
+   * Get the the reason of the requested booking
+   * @return string
+   */
+  public function getReason() { return $this->strReason; }
+  /**
+   * Get the UID of the booking to be deleted / edited
+   * @return int
+   */
+  public function getUid() { return $this->nUid; }
+  /**
+   * Get the value of the submit button that the user clicked
+   * @return string
+   */
+  public function getSubmitButtonValue() {
+    return $this->strSubmitButtonValue;
+  }
+  /***************************************************************************/
+  /**
+   * @}
+   * @name Output
+   * @{
+   */
+  /**
+   * Add the CSS rules needed for this page
+   * @return void
+   */
+  protected function addCSS() {
+    $strCss = <<<CSS
+#mod_roomReservationBookingTable .msg { font-weight:800; }
+#mod_roomReservationBookingTable td {
+  vertical-align: middle;
+  height: 5em;
+  border: 1px solid white;
+  padding:0.4em;
+}
+#mod_roomReservationBookingTable td.booking { background-color:#5276AB; }
+#mod_roomReservationBookingTable td.new { background-color:#008015; }
+#mod_roomReservationBookingTable td.recurring { background-color:#1C4174; }
+#mod_roomReservationBookingTable td.recurringnew { background-color:#006010; }
+#mod_roomReservationBookingTable td.heading { font-weight:bold; height:3em; }
+#mod_roomReservationBookingTable td.lesson { width:9%; }
+#mod_roomReservationBookingTable td.today { font-style:italic; }
+#mod_roomReservationBookingTable {
+  border:1px solid white;
+  border-collapse:collapse;
+  text-align:center; width:100%;
+}
+CSS;
+    if($this->oCfg->isShowWeekend()) {
+      $strCss .= "#mod_roomReservationBookingTable td.cell { width:13%; }";
+    } else {
+      $strCss .= "#mod_roomReservationBookingTable td.cell { width:18.2%; }";
+    }
+    rrAddCss($strCss);
+  }
+  /**
+   * Show the timetable
+   * @return void
+   * @throws AccessException
+   * @todo increase the height of the cells a little
+   */
+  public function show() {
+    // Protect access
+    if(!$this->oCfg->userCanView()) {
+      throw new AccessException(MOD_ROOM_RESERVATION_ERROR_ACCESS_DENIED);
+      return;
+    }
+    
+    // print error messages and return if there are any
+    if(count($this->asErrors) > 0) {
+      printf("<p class='err'>%s</p>", join("<br />\n", $this->asErrors));
+      return;
+    }
+    
+    // Print the header with the days
+    $ncTs = sizeof($this->oCfg->getTimeslices());
+    $nDays = ($this->oCfg->isShowWeekend()) ? 7 : 5;
+   
+    echo "<table id='mod_roomReservationBookingTable'><tr>";
+
+    // Print header with day names
+    echo "<td class='heading' />";
+    for($ts = rrGetMonday($this->getDate()), $i=0; $i < $nDays;
+      $ts = strtotime("1 day", $ts), $i++) {
+      // Use a different color for the current day
+      $strClass = "heading";
+      $strTitle = strftime("%A<br />%x", $ts);
+      if(date("Ymd") === date("Ymd", $ts)) {
+        $strClass .= " today";
+        $strTitle .= " "._c("room-reservation:(today)");
+      }
+      echo sprintf("<td class='%s'>%s</td>", $strClass, $strTitle);
+    }
+    echo "</tr>\n";
+
+    // Print timetable
+    // To take care of bookings with more than one timeslice, we use an array
+    // that tells us which cell in the current column is the next to fill
+    $anNextRow = array_fill(0, $nDays, 0);
+    // Iterate over the timeslices
+    for($nTs = 0; $nTs < $ncTs; $nTs++) {
+      $strLessons = $this->oCfg->isShowLessons() ?_sprintf_ord(
+        _c("room-reservation:%s# lesson"), $nTs + 1) . "<br />" : "";
+      $oTs = $this->oCfg->getTimeslice($nTs);
+      $strTs = sprintf("%s - %s", gmstrftime(_("%#I:%M %p"), $oTs->getBegin()),
+        gmstrftime(_("%#I:%M %p"), $oTs->getEnd()));
+      // First column: Lesson
+      echo sprintf("<tr><td class='lesson'>%s</td>", $strLessons . $strTs);
+     
+      // Iterate over the days
+      for($ts = rrGetMonday($this->getDate()), $i = 0; $i <= $nDays;
+        $ts = strtotime("1 day", $ts), $i++) {
+        // Don't print if there is a spanning booking on the current cell
+        if(isset($anNextRow[$i]) && $anNextRow[$i] == $nTs) {
+          if(($ob = $this->oBm->getBookingByTimeslice($this->getRoom(), $ts,
+            $nTs)) !== null) {
+            // a booking exists here
+            // print booking or deletion form or handle the deletion form
+
+            // deletion form is requested:
+            if(($this->getAction() == MOD_ROOM_RESERVATION_BT_ACTION_DELETE) &&
+              (date("Ymd", $this->getDate()) == date("Ymd", $ts)) &&
+              ($this->getTsFirst() == $nTs) &&
+              ($this->getRoom() == $this->getRoom())) {
+              $anNextRow[$i] += $this->printBooking($nTs, $ts, $ob,
+                MOD_ROOM_RESERVATION_BTPB_DELETE);
+
+            // deletion form is submitted:
+            } else if(($this->getAction() == 
+              MOD_ROOM_RESERVATION_BT_ACTION_SUBMITDELETE) &&
+              (date("Ymd", $this->getDate()) == date("Ymd", $ts)) &&
+              ($this->getTsFirst() == $nTs) &&
+              ($this->getRoom() == $this->getRoom())) {
+              if($this->getSubmitButtonValue() == _("Delete")) {
+                // the user clicked the "delete" button
+                $bSuccess = false;
+                try {
+                  $bSuccess = $this->oBm->delete($this->getUid());
+                } catch(Exception $e) {
+                  $anNextRow[$i] += $this->printBooking($nTs, $ts, $ob, 0,
+                    array($e->getMessage()));
+                }
+                // print booking link and a success message
+                if($bSuccess) {
+                  $anNextRow[$i] += $this->printBookingLink($nTs, $ts,
+                    array(_c("room-reservation:The booking was deleted.")));
+                }
+              } else {
+                // the user cancelled the request
+                $anNextRow[$i] += $this->printBooking($nTs, $ts, $ob);
+              }
+           
+            // Something else -- print booking
+            } else {
+              $anNextRow[$i] += $this->printBooking($nTs, $ts, $ob);
+            }
+          } else {
+            // no booking is here
+            // print booking link, booking form or handle booking form
+            $asErrors = array();
+           
+            // booking form is requested:
+            if(($this->getAction() == MOD_ROOM_RESERVATION_BT_ACTION_BOOK) &&
+              (date("Ymd", $this->getDate()) == date("Ymd", $ts)) &&
+              ($this->getTsFirst() == $nTs) &&
+              ($this->getRoom() == $this->getRoom())) {
+              $anNextRow[$i] += $this->printBookingForm($nTs, $ts, $asErrors);
+             
+            // booking form is submitted:
+            } else if(($this->getAction() == 
+              MOD_ROOM_RESERVATION_BT_ACTION_SUBMIT) &&
+              // only handle the request if the form was in the current cell
+              (date("Ymd", $this->getDate()) == date("Ymd", $ts)) &&
+              ($this->getTsFirst() == $nTs) &&
+              ($this->getRoom() == $this->getRoom())) {
+             
+              // try writing the booking to the database
+              $nNewUid = -1;
+              $oNewBooking = new mod_roomReservationBooking($this->getRoom(),
+                $this->getDate(), $this->getTsFirst(), $this->getTsLast(),
+                (trim($this->strPostAccount) == "") ? $_SESSION["act"] : 
+                $this->strPostAccount, $this->getReason(), 
+                $this->nPostInterval);
+              try {
+                $nNewUid = $this->oBm->write($oNewBooking);
+              } catch(Exception $s) {
+                // print the booking form again with the user's input
+                // @todo check for overlapping bookings and print them
+                $asErrors[] = $s->getMessage();
+                $anNextRow[$i] += $this->printBookingForm($nTs, $ts,
+                  $asErrors);
+              }
+              if($nNewUid > 0) {
+                // print new booking and increment the "next row" variable by
+                // the current span
+                $oNewBooking->setUid($nNewUid);
+                $anNextRow[$i] += $this->printBooking($nTs, $ts, $oNewBooking,
+                  MOD_ROOM_RESERVATION_BTPB_NEW);
+              }
+
+            // Something else -- print booking link:
+            } else {
+              $anNextRow[$i] += $this->printBookingLink($nTs, $ts);
+            }
+          }
+        }
+      }
+      echo "</tr>\n";
+    }
+    echo "</table><br />";
+  }
+
+  /**
+   * Print a single booking in the booking table.
+   * @param $nTs (int) current timeslice
+   * @param $ts (timestamp) current date
+   * @param $ob (mod_roomReservationBooking) the booking
+   * @param $cFlags (constant) Flags,
+   *   See @ref bookingtable_printbooking_flags for more information.
+   * @param $asMsgs (array of strings) Additional messages to be printed
+   *  inside the cell, one array element per message
+   * @return (int) the span of the booking
+   */
+  protected function printBooking($nTs, $ts, mod_roomReservationBooking $ob,
+    $cFlags = 0, $asMsgs = array()) {
+    $strAfter = "";
+    $strBefore = "";
+
+    // messages
+    if(count($asMsgs) > 0) {
+      $strBefore .= "<p class='msg'>".nl2br(q(join("\n", $asMsgs)))."</p>\n";
+    }
+     
+    // calculate the timespan of the current booking
+    $nSpan = $ob->getTsLast() - $ob->getTsFirst() + 1;
+   
+    if(($cFlags & MOD_ROOM_RESERVATION_BTPB_DELETE) == 
+      MOD_ROOM_RESERVATION_BTPB_DELETE) {
+
+      // Restrict access
+      if(!($this->oBm->userIsOwner($ob->getUid()) or
+        $this->oCfg->userIsAdmin())) {
+        $strBefore .= "<p class='msg'>" . 
+          MOD_ROOM_RESERVATION_ERROR_ACCESS_DENIED . "</p>\n";
+        #return $nSpan;
+      } else {
+        // print delete form
+        $strWarning = sprintf("<div>%s%s</div>", icon("dlg-warn",
+          array("bg" =>"gb")), _c("room-reservation:<b>Attention:</b> This ".
+          "booking is a recurring booking. If you delete it, the period will ".
+          "be deallocated for <b>every week</b>, not just this single week!"));
+        $strAfter .= sprintf("<p name='form' id='form' style='".
+               "text-align:center'><form action='%s?".
+               "mod_roomReservationBookingTable[action]=submitdelete#form' ".
+          "method='post'>%s%s<br /><%s name='mod_roomReservationBookingTable".
+          "[submitdelete]' value='%s' /> <%s name='".
+          "mod_roomReservationBookingTable[submitdelete]' value='%s' />".
+          "<input type='hidden' name='mod_roomReservationBookingTable[uid]' ".
+          "value='%d' /></form></p>", $_SERVER["PHP_SELF"],
+          _c("room-reservation:Delete this booking?"),
+          ($ob->getInterval() > 0 ? $strWarning : ""), $GLOBALS["smlbtn"],
+          _("Delete"), $GLOBALS["smlbtn"], _("Cancel"), $ob->getUid(),
+          $this->getRoom(), $this->getDate());
+      }
+    } else {
+      // delete and edit links, show only if user is allowed to
+      if($this->oBm->userIsOwner($ob->getUid()) ||
+        $this->oCfg->userIsAdmin()) {
+        /** @todo edit form */
+        $strAfter .= sprintf("<br />(<!-- <a href='%s?".
+          "mod_roomReservationBookingTable[action]=edit&".
+          "mod_roomReservationBookingTable[uid]=%d&".
+          "mod_roomReservationBookingTable[date]=%d#form' title='%s'>%s</a>, -->".
+          "<a href='%s?mod_roomReservationBookingTable[action]=delete&".
+          "mod_roomReservationBookingTable[uid]=%d&".
+          "mod_roomReservationBookingTable[date]=%d#form' title='%s'>%s</a>)",
+          $_SERVER["PHP_SELF"], $ob->getUid(), $ts,
+          _c("room-reservation:Edit this booking"),
+          _c("room-reservation:edit"), $_SERVER["PHP_SELF"], $ob->getUid(),
+          $ts, _c("room-reservation:Delete this booking"),
+          _c("room-reservation:delete"));
+      }
+    }
+       
+    // test if booking is new and should be highlighted
+    $strClass = "cell booking".($ob->getInterval() > 0 ? " recurring" : "");
+    if(($cFlags & MOD_ROOM_RESERVATION_BTPB_NEW) ==
+      MOD_ROOM_RESERVATION_BTPB_NEW) {
+      $strClass .= " new";
+    }
+    // Use a different style for the current day
+    $strClass .= (date("Ymd", $ob->getDate()) == date("Ymd") ? " today" : "");
+    /** @todo: add ?subject=... to mailto link */
+    echo sprintf("<td rowspan='%d' class='%s'>%s<a %s>%s</a><br />%s%s</td>\n",
+      $nSpan, $strClass, $strBefore, mailto($ob->getAct()),
+      q(getRealUserName($ob->getAct())), q($ob->getReason()), $strAfter);
+     
+    return $nSpan;
+  }
+
+  /**
+   * Print the booking form.
+   * @param $nTs (int) current timeslice
+   * @param $ts (timestamp) current date
+   * @param $asErrors (array of strings) Additional error message to be printed
+   *  inside the cell, one array element per message
+   * @return (int) the span of the booking (i.e., 1)
+   */
+  protected function printBookingForm($nTs, $ts, $asErrors = array()) {
+    // Restrict access
+    if(!($this->oCfg->userCanBook() or $this->oCfg->userIsAdmin())) {
+      printf("<td class='err'>%s</td>\n", 
+        MOD_ROOM_RESERVATION_ERROR_ACCESS_DENIED);
+      return 1;
+    }
+
+    $strErrors = "<p class='err'>".nl2br(q(join("\n", $asErrors)))."</p>";
+
+    // form to allow fixed bookings for admins
+    $sWeeklyForm = "";
+    if($this->oCfg->userIsAdmin()) {
+      $sWeeklyForm = sprintf("<label for='interval'>%s</label> %s<br />".
+       "<label for='account'>%s</label> <%s name='".
+       "mod_roomReservationBookingTable[account]' id='account' value='%s' ".
+        "size='15' /><br />", _c("room-reservation:Repetition:"), 
+        select("mod_roomReservationBookingTable[interval]",
+        $this->nPostInterval, array(0 => _c("Select:None"), 1 =>
+        _c("room-reservation:every week")), array("add" => "id='interval'")),
+        _c("room-reservation:Account, if not yourself:"), $GLOBALS["stdedt"],
+                               $this->strPostAccount);
+    }
+    
+    echo sprintf("<td name='form' id='form' style='text-align:left'>%s".
+       "<form action='%s?mod_roomReservationBookingTable[action]=".
+       "submit#form' method='post'><label for='tslast'>%s</label> %s".
+       "<br /><label for='reason'>%s</label> <%s id='reason' size='15' ".
+       "value='%s' name='mod_roomReservationBookingTable[reason]' /><br />%s".
+       "<%s name='mod_roomReservationBookingTable[submitbooking]' value='%s' />".
+       "<input type='hidden' name='mod_roomReservationBookingTable[date]' ".
+       "value='%s' /><input type='hidden' name='".
+       "mod_roomReservationBookingTable[room]' value='%s' /><input ".
+       "type='hidden' name='mod_roomReservationBookingTable[tsfirst]' ".
+       "value='%s' /></form></td>\n", (count($asErrors) > 0) ? $strErrors : "",
+      $_SERVER["PHP_SELF"], _c("room-reservation:until:"),
+      select("mod_roomReservationBookingTable[tslast]", $this->getTsLast(),
+      $this->oCfg->getTimesliceEndings(true)), _c("room-reservation:Reason:"),
+      $GLOBALS["stdedt"], $this->getReason(), $sWeeklyForm, $GLOBALS["smlbtn"],
+      _c("room-reservation:Book"), $this->getDate(), $this->getRoom(),
+      $this->getTsFirst());
+      return 1;
+  }
+  /**
+   * Print the booking link
+   * @param $nTs (int) current timeslice
+   * @param $ts (timestamp) current date
+   * @param $asMsgs (array of strings) Additional messages to be printed
+   *  inside the cell, one array element per message
+   * @return (int) the span of the booking (i.e., 1)
+   */
+  protected function printBookingLink($nTs, $ts, $asMsgs = array()) {
+    
+    // Restrict access
+    if(!($this->oCfg->userCanBook() or $this->oCfg->userIsAdmin())) {
+      echo "<td />\n";
+      return 1;
+    }
+
+    // messages
+    $strBefore = "";
+    if(count($asMsgs) > 0) {
+      $strBefore .= "<p class='msg'>".join("<br />", $asMsgs)."</p>\n";
+    }
+   
+    // print link to booking if the timeslice is later than now
+    $oTs = $this->oCfg->getTimeslice($nTs);
+    // note: only the timeslices are in GMT!
+    $tsCur = strtotime(date("Y-m-d ", $ts) . gmdate(" G:i",
+      $oTs->getEnd()));
+    if($tsCur > time()) {
+      $strURL = $_SERVER["PHP_SELF"] .
+        sprintf("?mod_roomReservationBookingTable[action]=book&".
+        "mod_roomReservationBookingTable[date]=%d&".
+        "mod_roomReservationBookingTable[room]=%s&".
+        "mod_roomReservationBookingTable[tsfirst]=%d#form", $ts,
+        qu($this->getRoom()), $nTs);
+      echo sprintf("<td class='cell'>%s<a href='%s' title='%s'>%s</a></td>\n",
+        $strBefore, $strURL, _c("room-reservation:Book this room from here"),
+        _c("room-reservation:(Book from here)"));
+    } else {
+      // only print the messages
+      echo sprintf("<td name='form' id='form' class='cell'>%s</td>\n",
+        $strBefore);
+    }
+    return 1;
+  }
+  /** @} */
+}
+?>
diff --git a/inc/mod_roomReservationBookingsManager.inc b/inc/mod_roomReservationBookingsManager.inc
new file mode 100644 (file)
index 0000000..124068d
--- /dev/null
@@ -0,0 +1,274 @@
+<?php
+/**
+ * @file mod_roomReservationBookingsManager.inc
+ * Class to manage a set of bookings
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)
+ * @date 23.11.2007
+ * 
+ * Copyright © 2007 Roland Hieber
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+require_once("sec/secure.inc");
+require_once("functions.inc");
+require_once("mod_room-reservation/mod_roomReservationConfig.inc");
+require_once("mod_room-reservation/mod_roomReservationBooking.inc");
+require_once("format.inc");
+
+db_query("SET DATESTYLE = ISO;");
+
+/**
+ * Management of a set of bookings
+ * @todo finish, document
+ */
+class mod_roomReservationBookingsManager {
+
+  /** (mod_roomReservationConfig) Reference to the configuration object */
+  protected $oCfg;
+  
+  /***************************************************************************/
+  /**
+   * @name Constructor
+   * @{
+   * Constructor.
+   * @param $oCfg (mod_roomReservationConfig) Reference to the configuration
+   * @return mod_roomReservationBookingsManager
+   */
+  function __construct(mod_roomReservationConfig &$oCfg) {
+    $this->oCfg = $oCfg;
+  }
+  
+  /***************************************************************************/
+  /**
+   * @}
+   * @name Retrieving bookings
+   * @{
+   */
+
+  /**
+   * Fetch a booking with the given unique ID from the SQL table
+   * @param $nUid (int) Unique ID of the booking
+   * @return mod_roomReservationBooking
+   */
+  public static function getBookingByUid($nUid) {
+    $h = db_query("SELECT * FROM mod_roomreservation_bookings WHERE rrb_uid = $1;", $nUid);
+    $a = pg_fetch_array($h);
+    $o = new mod_roomReservationBooking($a["rrb_room"], strtotime($a["rrb_date"]),
+      intval($a["rrb_tsfirst"]), intval($a["rrb_tslast"]), $a["rrb_act"],
+      $a["rrb_reason"], intval($a["rrb_interval"]));
+    $o->setUid(intval($a["rrb_uid"]));
+    return $o;
+  }
+  
+  /**
+   * Test if there is a booking which takes place on the specified position at
+   * the specified date.
+   * @param $strRoom (string) Name of the room
+   * @param $tsDate (timestamp) The date
+   * @param $nTimeslice (int) The number of the timeslice
+   * @return mod_roomReservationBooking The booking which takes place on the
+   *  specified time or <tt>null</tt> if no booking could be found.
+   */
+  public static function getBookingByTimeslice($strRoom, $tsDate,
+    $nTimeslice) {
+    $a = mod_roomReservationBookingsManager::getOverlappingBookings(
+      new mod_roomReservationBooking($strRoom, $tsDate, $nTimeslice,
+      $nTimeslice, null, null));
+    return isset($a[0]) ? $a[0] : null;
+  }
+  
+  /**
+   * Get all bookings in database which overlap with the given booking.
+   * @param $ob (mod_roomReservationBooking) New booking that should be tested
+   *  if it overlaps
+   * @return array with elements of type mod_roomReservationBooking
+   */
+  public static function getOverlappingBookings(
+    mod_roomReservationBooking $ob) {
+    // TODO: Test for bookings that only take place every n.th week (modulo n)
+    
+    // Two bookings overlap, when they are on the same day and if
+    // old beginning < new ending  AND  old ending > new beginning
+    $hQuery = db_query("SELECT * FROM mod_roomreservation_bookings WHERE ".
+      "rrb_room = $1 AND ((rrb_interval > 0 AND EXTRACT(DOW FROM rrb_date) ".
+      "= $2) OR (rrb_interval = 0 AND rrb_date = $3)) AND rrb_tsfirst <= ".
+      "$4 AND rrb_tslast >= $5 ORDER BY rrb_tsfirst;", $ob->getRoom(),
+      date("w", $ob->getDate()), date("Y-m-d", $ob->getDate()),
+      intval($ob->getTsLast()), intval($ob->getTsFirst()));
+    $aoReturn = array();
+    while($aResult = pg_fetch_array($hQuery)) {
+      $aoReturn[] = mod_roomReservationBookingsManager::getBookingByUid(
+        $aResult["rrb_uid"]);
+    }
+    return $aoReturn;
+  }
+  
+  /***************************************************************************/
+  /**
+   * @}
+   * @name Management of bookings
+   * @{
+   */
+  
+  /**
+   * Insert or update a booking in the database.
+   * The function throws an AccessException if the user was not allowed to
+   * write the booking, or an SQLException if there was an error while trying
+   * to insert or update the booking into the database.
+   * @param $ob (mod_roomReservationBooking) Booking to write to the database
+   * @return (int) The UID of the written booking
+   * @throws SQLException, AccessException
+   * @todo document
+   */
+  function write(mod_roomReservationBooking $ob) {
+    // protect access
+    if(($ob->getUid() != null and !$this->oCfg->userIsAdmin() and
+      !$this->userIsOwner($ob->nUid)) or
+      ($ob->getUid() == null and !$this->oCfg->userCanBook())) {
+      throw new AccessException(MOD_ROOM_RESERVATION_ERROR_ACCESS_DENIED);
+    }
+    
+    // test if room is whitelisted
+    if(!$this->oCfg->isRoomWhitelisted($ob->getRoom())) {
+      throw new Exception(MOD_ROOM_RESERVATION_ERROR_ROOM_NOT_WHITELISTED);
+    }
+    
+    $strWhere = null;
+    $strLog = "";
+
+    // check if everything is right and throw exceptions
+    if(trim($ob->getAct()) == "") {
+      $ob->setAct($SESSION["act"]);
+    } elseif(!isAct($ob->getAct())) {
+      throw new Exception(MOD_ROOM_RESERVATION_ERROR_NO_SUCH_ACCOUNT);
+      return false;
+    }
+    if($ob->getTsFirst() > $ob->getTsLast()) {
+      throw new SQLException(MOD_ROOM_RESERVATION_ERROR_END_BEFORE_BEGIN);
+      return false;
+    }
+    if(trim($ob->getReason()) == "") {
+      throw new SQLException(MOD_ROOM_RESERVATION_ERROR_NO_REASON);
+      return false;
+    }
+    
+    // Test for overlapping bookings
+    if($this->getOverlappingBookings($ob) != array()) {
+      throw new SQLException(MOD_ROOM_RESERVATION_ERROR_BOOKING_OVERLAPS);
+      return false;
+    }    
+    
+    // Show real times in log, but don't use the user's locale!
+    $oTsB = $this->oCfg->getTimesliceBeginnings(false);
+    $oTsE = $this->oCfg->getTimesliceEndings(false);
+    
+    // Update or insert?
+    if($ob->getUid() == null) {
+      // No UID yet, insert new booking
+      // @todo write interval and user if interval > 0
+      $strLog = sprintf("Raum „%s“ am %s von %s bis %s gebucht ".
+       "(Begründung: %s)", $ob->getRoom(), date("d\.m\.Y", $ob->getDate()),
+        gmdate("G:i", $oTsB[$ob->getTsFirst()]), gmdate("G:i",
+        $oTsE[$ob->getTsLast()]), $ob->getReason());
+    } else {
+      // Update an existing booking
+      // @todo write old and new times into log
+      $strWhere = "rs_uid = ".qdb(intval($ob->getUid()));
+      $strLog = sprintf("Buchung im Raum „%s“ auf %s von %s bis %s ".
+        "geändert (Begründung: „%s“)", $ob->getRoom(), date("d\.m\.Y",
+        $ob->getDate()), gmdate("G:i", $oTsB[$ob->getTsFirst()]), gmdate("G:i",
+        $oTsE[$ob->getTsLast()]), $ob->getReason());
+    }
+    $aPut["rrb_room"] = $ob->getRoom();
+    $aPut["rrb_date"] = date("Y\-m\-d", $ob->getDate());
+    $aPut["rrb_tsfirst"] = intval($ob->getTsFirst());
+    $aPut["rrb_tslast"] = intval($ob->getTsLast());
+    $aPut["rrb_act"] = $ob->getAct();
+    $aPut["rrb_reason"] = $ob->getReason();
+    $aPut["rrb_interval"] = intval($ob->getInterval());
+    
+    // @todo test if the foreign keys are being violated and throw an error
+    // message if neccessary
+    db_store("mod_roomreservation_bookings", $aPut, $strWhere);
+    
+    $hQuery = db_query("SELECT currval('mod_roomreservation_bookings_rrb_uid_seq');");
+    $nNewUid = pg_fetch_result($hQuery, 0, "currval");
+    
+    rrInsertLog($strLog);
+    
+    // Return new UID
+    return $nNewUid;
+  }
+  
+  /**
+   * Delete a booking from the database
+   * @param $nUid (int) Unique ID of the booking
+   * @return (bool) <tt>true</tt> on success, otherwise <tt>false</tt>.
+   * @todo test
+   */
+  public function delete($nUid) {
+    // Only administrators and owners are allowed to delete bookings
+    if(!($this->oCfg->userIsAdmin() or $this->userIsOwner($nUid))) {
+      throw new AccessException(MOD_ROOM_RESERVATION_ERROR_ACCESS_DENIED);
+      return false;
+    }
+    
+    // Don't use the user's locale!
+    $oTsB = $this->oCfg->getTimesliceBeginnings(false);
+    $oTsE = $this->oCfg->getTimesliceEndings(false);
+    $ob = $this->getBookingByUid($nUid);
+    $strLog = sprintf("Buchung in Raum „%s“ am %s von %s bis %s ".
+      "gelöscht (Begründung war: %s)", $ob->getRoom(), date("d\.m\.Y",
+      $ob->getDate()), gmdate("G:i", $oTsB[$ob->getTsFirst()]), gmdate("G:i",
+      $oTsE[$ob->getTsLast()]), $ob->getReason());
+    // Delete it from the database
+    if(!db_query("DELETE FROM mod_roomreservation_bookings WHERE ".
+       "rrb_uid = $1;", $nUid)) {
+      throw new SQLException(MOD_ROOM_RESERVATION_ERROR_SQL);
+      return false;
+    } else {
+      rrInsertLog($strLog);
+      return true;
+    }
+  }
+  
+  /**
+   * Determine if the current user is the owner of a specified error report.
+   * If this function fails, call getLastError() to get more information.
+   * @param $nID (int) Unique ID of the error report
+   * @throws SQLException
+   * @return bool
+   */
+  public static function userIsOwner($nID) {
+    if(!isset($_SESSION["act"])) {
+      return false;   // user is not logged in
+    } else {
+      $hQuery = db_query("SELECT rrb_act FROM mod_roomreservation_bookings WHERE ".
+       "rrb_uid = $1;", intval($nID));
+      if(!is_resource($hQuery)) {
+        throw new SQLException(MOD_ROOM_RESERVATION_ERROR_SQL);
+        return false;
+      }
+      $arResult = pg_fetch_array($hQuery);
+      return ($arResult["rrb_act"] == $_SESSION["act"]);
+    }
+  }
+}
+?>
diff --git a/inc/mod_roomReservationConfig.inc b/inc/mod_roomReservationConfig.inc
new file mode 100644 (file)
index 0000000..8dde982
--- /dev/null
@@ -0,0 +1,454 @@
+<?php
+/**
+ * @file mod_roomReservationConfig.inc 
+ * Handling of the configuration file
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)
+ * @date 10.01.2008
+ * 
+ * Copyright © 2007 Roland Hieber
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+require_once("sec/secure.inc");
+require_once("db.inc");
+require_once("mod_room-reservation/functions.inc");
+require_once("mod_room-reservation/mod_roomReservationTimeslice.inc");
+require_once("mod_room-reservation/mod_roomReservationRoomsManager.inc");
+
+/**
+ * Determines if a privilege has been assigned
+ * @param $sPriv (string) Privilege to test
+ * @return bool
+ */
+function rrPrivilegeAssigned($sPriv) {
+  $h = db_query("SELECT act FROM privileges_assign WHERE privilege = $1;",
+    $sPriv);
+  return pg_num_rows($h) > 0;
+}
+
+/**
+ * Retrieve all groups that have a privilege assigned
+ * @param $strPriv (string) Privilege to test
+ * @return array
+ */
+function rrPrivilegedGroups($strPriv) {
+  $aReturn = array();
+  $h = db_query("SELECT act FROM privileges_assign WHERE privilege = $1 ".
+    "ORDER BY act;", $strPriv);
+  if(pg_num_rows($h) > 0) {
+    while($a = pg_fetch_array($h)) {
+      $aReturn[] = $a["act"];
+    }
+  }
+  return $aReturn;
+}
+
+/**
+ * User-defined compare function to compare timeslices
+ * @param $oTs1 (mod_roomReservationTimeslice)
+ * @param $oTs2 (mod_roomReservationTimeslice)
+ * @return (int) <tt>-1</tt> if $oTs1 begins before $oTs2,
+ *  <tt>0</tt> if the $oTs1 and $oTs2 have the same beginning,
+ *  <tt>1</tt> if $oTs1 begins after $oTs2.
+ */
+function rrConfigSortTimeslices(mod_roomReservationTimeslice $oTs1, 
+  mod_roomReservationTimeslice $oTs2) {
+  if($oTs1->getBegin() == $oTs2->getBegin()) {
+    return 0;
+  } else {
+    return ($oTs1->getBegin() > $oTs2->getBegin()) ? 1 : -1;
+  }
+}
+
+define("MOD_ROOM_RESERVATION_CONFIGFILE_HEADER", "<?php
+/**
+ * configuration file for package iserv-mod-room-reservation
+ * This file is written by the configuration script. Do not change it manually.
+ */\n");
+
+/*****************************************************************************/
+/**
+ * Handling of the configuration file
+ * @todo document
+ */
+class mod_roomReservationConfig {
+  
+  /** (array of rmTimeslice's) Timeslices */
+  protected $aoTimeslices;
+  /** (bool) Determine if the weekend is shown */
+  protected $bShowWeekend;
+  /** (bool) Determine if the strings "1. lesson", "2. lesson" etc are shown */
+  protected $bShowLessons;
+  /** (array of strings) error messages */
+  protected $asMessages;
+  
+  /***************************************************************************/
+  /**
+   * @name Constructor
+   * @{
+   * Constructor.
+   * @return mod_roomReservationConfig
+   */
+  public function __construct() {
+    $this->flushTimeslices();
+    $this->setShowWeekend(false);
+    $this->setShowLessons(true);
+    $this->asMessages = array();
+    
+    $this->readConfig();
+  }
+  
+  /**
+   * **************************************************************************
+   * @}
+   * @name Access to attributes
+   * @{
+   */
+  
+       /**
+   * Add a timeslice. A check is done that the timeslices do not overlap, and
+   * in this case, an Exception is thrown.
+   * @param $oTs (mod_roomReservationTimeslice)
+   * @throws Exception
+   * @return void
+   */
+  public function addTimeslice(mod_roomReservationTimeslice $oTs) {
+    // Check for overlapping timeslices
+    foreach($this->aoTimeslices as $oOldTs) {
+      if(($oOldTs->getBegin() < $oTs->getEnd() and 
+        $oOldTs->getEnd() > $oTs->getBegin())) {
+        throw new Exception(
+          MOD_ROOM_RESERVATION_ERROR_CONFIG_OVERLAPPING_TIMESLICE);
+      }
+    }
+    $this->aoTimeslices[] = $oTs;
+    usort($this->aoTimeslices, "rrConfigSortTimeslices");
+    return;
+  }
+  
+  /**
+   * Delete a timeslice
+   * @param $oTs (mod_roomReservationTimeslice) the timeslice to delete. If
+   *  the timeslice is not found, an Exception is thrown.
+   * @throws Exception
+   * @return void
+   */
+  public function deleteTimeslice(mod_roomReservationTimeslice $oTs) {
+    for($i = 0; $i < count($this->aoTimeslices); $i++) {
+      if($this->aoTimeslices[$i]->getBegin() == $oTs->getBegin() and
+        $this->aoTimeslices[$i]->getEnd() == $oTs->getEnd()) {
+        // use array_splice because it renumbers the keys
+        array_splice($this->aoTimeslices, $i, 1);
+        return;
+      }
+    }
+    throw new Exception(MOD_ROOM_RESERVATION_ERROR_CONFIG_NO_SUCH_TIMESLICE);
+  }
+  
+  /**
+   * Delete all timeslices.
+   * @return void
+   */
+  public function flushTimeslices() { $this->aoTimeslices = array(); }
+  
+  /**
+   * Add a room to the list of rooms who can be booked. Throws an SQLException
+   * in case of an error.
+   * @param $sRoom (string) The name of the room
+   * @throws SQLException, Exception
+   * @return void
+   */
+  public function whitelistRoom($sRoom) {
+    if(!$this->isRoomWhitelisted($sRoom)) {
+      $r = db_store("mod_roomreservation_roomswhitelist",
+        array("rrr_name" => $sRoom));
+      if(!$r) {
+        throw new SQLException(MOD_ROOM_RESERVATION_ERROR_SQL);
+      } else {
+        log_insert(sprintf("Raum „%s“ für Buchungen zur Verfügung gestellt",
+         $sRoom));
+      }
+    }
+  }
+
+  /**
+   * Forbid bookings for a room. Throws an SQLException in case of an error.
+   * @param $sRoom The name of the room
+   * @throws SQLException
+   */
+  public function unWhitelistRoom($sRoom) {
+    $h = db_query("DELETE FROM mod_roomreservation_roomswhitelist WHERE ".
+       "rrr_name = $1;", $sRoom);
+    if(!$h) {
+      throw new SQLException(MOD_ROOM_RESERVATION_ERROR_SQL);
+    } else {
+      log_insert(sprintf("Raum „%s“ für Buchungen gesperrt", $sRoom));
+    }
+  }
+  
+  /**
+   * Determine if a room is allowed for booking. Throws an SQLException
+   * in case of an error.
+   * @param $sRoom (string) The name of the room
+   * @return bool
+   * @throws SQLException
+   */
+  public function isRoomWhitelisted($sRoom) {
+    $h = db_query("SELECT * FROM mod_roomreservation_roomswhitelist WHERE ".
+       "rrr_name=$1;", $sRoom);
+    if(!$h) {
+      throw new SQLException(MOD_ROOM_RESERVATION_ERROR_SQL);
+    }
+    return (pg_num_rows($h) > 0);
+  }
+
+  /**
+   * Get all rooms that are allowed for booking. Throws an SQLException
+   * in case of an error. 
+   * @throws SQLException
+   * @return array of mod_roomReservationRoomsManager objects
+   */
+  public function getWhitelistedRooms() {
+    $aor = mod_roomReservationRoomsManager::getRooms();
+    $ar = array();
+    foreach($aor as $key => $or) {
+      if($this->isRoomWhitelisted($or->getName())) {
+        $ar[] = $or;
+      }
+    }
+    return $ar;
+  }
+
+  /**
+   * Show or hide the weekend
+   * @param $b (bool)
+   */
+  public function setShowWeekend($b) { $this->bShowWeekend = ($b == true); }
+  
+  /**
+   * Show or hide the lesson strings in the booking table
+   * @param $b (bool)
+   */
+  public function setShowLessons($b) { $this->bShowLessons = ($b == true); }
+  
+  /**
+   * Add a message to the internal array of (error) messages
+   * @param $sMessage (string)
+   */
+  public function addMessage($sMessage) {
+    array_merge($this->asMessages, array($sMessage));
+  }
+  
+       /**
+   * Get all timeslices in chronological order
+   * @return array of rmTimeslice
+   */
+  public function getTimeslices() { return $this->aoTimeslices; }
+
+  /**
+   * Return the starting times of every timeslice
+   * @param $bFormat (bool) <tt>true</tt>: Format the times according to the
+   *  current locale
+   *  <tt>false</tt>: return just the timestamps
+   * @return array
+   */
+  public function getTimesliceBeginnings($bFormat = false) {
+    $aot = $this->getTimeslices();
+    $aRet = array();
+    foreach($aot as $ao) {
+      $aRet[] = $bFormat ? gmstrftime(_("%#I:%M %p"), $ao->getBegin()) : 
+        $ao->getBegin();
+    }
+    return $aRet;
+  }
+  
+  /**
+   * Return the ending times of every timeslice
+   * @param $bFormat (bool) <tt>true</tt>: Format the times according to the
+   *  current locale
+   *  <tt>false</tt>: return just the timestamps
+   * @return array
+   */
+  public function getTimesliceEndings($bFormat = false) {
+    $aot = $this->getTimeslices();
+    $aRet = array();
+    foreach($aot as $ao) {
+      $aRet[] = $bFormat ? gmstrftime(_("%#I:%M %p"), $ao->getEnd()) :
+        $ao->getEnd();
+    }
+    return $aRet;
+  }
+  
+  /**
+   * Get a timeslice
+   * @param $n (int) index of the timeslice in the array
+   * @return rmTimeslice
+   */
+  public function getTimeslice($n) { return $this->aoTimeslices[$n]; }
+  
+  /**
+   * Determine if the weekend is shown
+   * @return bool
+   */
+  public function isShowWeekend() { return ($this->bShowWeekend == true); }
+
+  /**
+   * Determine if the lesson strings in the booking table are shown
+   * @return bool
+   */
+  public function isShowLessons() { return ($this->bShowLessons == true); }
+
+  /**
+   * Determine if the current user has admin rights. This function tests 
+   * if the user is in a group which has the privilege of admin rights.
+   * @todo test
+   * @return bool
+   */
+  public function userIsAdmin() {
+    return secure_privilege("mod_roomreservation_admin");
+  }
+  
+  /**
+   * Determine if the current user can book rooms. This function tests 
+   * if the user is in a group which has the privilege to book rooms.
+   * If no group has this privilege, all users can book.
+   * @todo test
+   * @return bool
+   */
+  public function userCanBook() {
+    if(!rrPrivilegeAssigned("mod_roomreservation_book")) {
+      // If the privilege is not assigned to any group, all users can book
+      return true;
+    } else {
+      // If user is admin, it makes sense that he can book rooms ;-)
+      return secure_privilege("mod_roomreservation_book") ||
+        secure_privilege("mod_roomreservation_admin");
+    }
+  }
+  
+  /**
+   * Determine if the current user can view bookings. This function tests 
+   * if the user is in a group which has been configured as a group who
+   * can view bookings. If no groups are configured, any user can view the
+   * bookings table.
+   * @todo test
+   * @return bool
+   */
+  public function userCanView() {
+    if(!rrPrivilegeAssigned("mod_roomreservation_view")) {
+      // If the privilege is not assigned to any group, all users can view
+      return true;
+    } else {
+      // If user is admin or can book, it makes sense that he can view bookings
+      return secure_privilege("mod_roomreservation_admin") ||
+        secure_privilege("mod_roomreservation_book") ||
+        secure_privilege("mod_roomreservation_view");
+    }
+  }
+  
+  /**
+   * Get the messages that have been produced
+   * @return string
+   */
+  public function getMessages() {
+    return join("\n", $this->asMessages);
+  }
+  
+  /***************************************************************************/
+  /**
+   * @}
+   * @name Operations
+   * @{
+   */
+  
+  /**
+   * Write the current state of this instance to the config file.
+   * @throws IOException
+   * @return bool
+   */
+  public function writeConfig() {
+    // Open config file
+    $hFile = fopen("mod_room-reservation/config.inc", "w", true);
+    if(!is_resource($hFile)) {
+      throw new IOException(MOD_ROOM_RESERVATION_ERROR_OPEN_FILE);
+      return false;
+    }
+    // Try to lock file repeatedly
+    for($n = 0; !flock($hFile, LOCK_EX); $n++) {
+      if($n > 10) {
+        throw new IOException(MOD_ROOM_RESERVATION_ERROR_OPEN_FILE);
+        return false; // Give up
+      } else {
+        sleep(0.2);   // Retry after 100 ms
+      }
+    }
+    
+    // Create text for config file
+    $strFile = MOD_ROOM_RESERVATION_CONFIGFILE_HEADER;
+    
+    // Timeslices
+    $strFile .= "\$this->flushTimeslices();\n";
+    foreach($this->getTimeslices() as $oTs) {
+      $strFile .= sprintf("\$this->addTimeslice(new ".
+        "mod_roomReservationTimeslice(%d, %d));\n", $oTs->getBegin(),
+        $oTs->getEnd());
+    }
+    
+    // Show weekend
+    $strFile .= sprintf("\$this->setShowWeekend(%s);\n",
+      $this->isShowWeekend() ? "true" : "false");
+
+    // Show lessons
+    $strFile .= sprintf("\$this->setShowLessons(%s);\n",
+      $this->isShowLessons() ? "true" : "false");
+
+    $strFile .= "?>";
+      
+    // Write to config file and unlock it
+    if(fwrite($hFile, $strFile) == false) {
+      throw new IOException(MOD_ROOM_RESERVATION_ERROR_WRITE_FILE);
+      return false;
+    }
+    if(!flock($hFile, LOCK_UN)) {
+      throw new IOException(MOD_ROOM_RESERVATION_ERROR_UNLOCK_FILE);
+      return false;
+    }
+    
+    rrInsertLog("Konfiguration verändert");
+    return true;
+  }
+  
+  /**
+   * Read configuration from file. Returns <tt>false</tt> if an error occured,
+   * in this case getMessages() contains error messages.
+   * @return bool
+   */
+  public function readConfig() {
+    global $g_rmCfg;
+    try {
+      require("mod_room-reservation/config.inc");
+    } catch(Exception $e) {
+      $this->addMessage($e->getMessage());
+    }
+  }
+
+  /** @} */
+}
+?>
diff --git a/inc/mod_roomReservationConfigPage.inc b/inc/mod_roomReservationConfigPage.inc
new file mode 100644 (file)
index 0000000..4477ff2
--- /dev/null
@@ -0,0 +1,179 @@
+<?php
+/**\r
+ * @file mod_roomReservationConfigPage.inc\r
+ * The configuration page\r
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
+ * @date 24.06.2008\r
+ * \r
+ * Copyright © 2007 Roland Hieber\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included in\r
+ * all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+ * THE SOFTWARE.\r
+ */\r
+\r
+require_once("ctrl.inc");
+require_once("mod_room-reservation/mod_roomReservationPage.inc");
+require_once("mod_room-reservation/mod_roomReservationTimesliceListBox.inc");
+require_once("mod_room-reservation/mod_roomReservationRoomWhitelistListBox.inc");
+
+/** @todo document */
+class mod_roomReservationConfigPage extends mod_roomReservationPage {
+
+  protected $bPostShowWeekend;
+  protected $bPostShowLessons;
+  protected $asMessages = array();
+  protected $otlb;
+  protected $orwlb;
+  
+  public function __construct(mod_roomReservationConfig &$oCfg) {
+    parent::__construct($oCfg);
+    $this->otlb = new mod_roomReservationTimesliceListBox($this->oCfg);
+    $this->orwlb = new mod_roomReservationRoomWhitelistListBox($this->oCfg);
+    $this->setTitle(_c("room-reservation:Configuration"));
+    $this->setIcon("mod_room-reservation_config");
+  }
+
+  public function processRequestVariables() {
+    // default values
+    $this->bPostShowWeekend = $this->oCfg->isShowWeekend();
+    $this->bPostShowLessons = $this->oCfg->isShowLessons();
+    
+    if(isset($_POST["mod_roomReservationConfigPage"])) {
+      if(isset($_POST["mod_roomReservationConfigPage"]["showweekend"])) {
+        $this->bPostShowWeekend = 
+          ($_POST["mod_roomReservationConfigPage"]["showweekend"] == true);
+      }
+      
+      if(isset($_POST["mod_roomReservationConfigPage"]["showlessons"])) {
+        $this->bPostShowLessons = 
+          ($_POST["mod_roomReservationConfigPage"]["showlessons"] == true);
+      }
+      
+      // process the request
+      if(isset($_POST["mod_roomReservationConfigPage"]["submit"])) {
+        $this->oCfg->setShowWeekend($this->bPostShowWeekend);
+        $this->oCfg->setShowLessons($this->bPostShowLessons);
+        try {
+          $this->oCfg->writeConfig();
+        } catch(Exception $e) {
+          $this->asMessages[] = $e->getMessage();
+        }
+      }
+    }
+  }
+  
+  public function doShow() {
+    // error messages
+    if(count($this->asMessages) > 0) {
+      printf("<p>%s</p>", nl2br(q(join("\n", $this->asMessages))));
+    }
+    
+    // first column
+    echo "<table border='0' cellspacing='10' cellpadding='0'><tr>".
+       "<td style='width:50%;'>\n";
+    
+    GroupBox(_c("room-reservation:Available rooms"), "host");
+    printf("<p>%s</p>", _c("room-reservation:The following rooms are ".
+       "available for booking:"));
+    echo "<div style='margin:8px;'>";
+    $this->orwlb->show();
+    echo "</div>\n";
+    _GroupBox();
+    
+    GroupBox(_("Privileges"), "keys");
+    $asAdminGroups = rrPrivilegedGroups("mod_roomreservation_admin");
+    $asBookGroups = rrPrivilegedGroups("mod_roomreservation_book");
+    $asViewGroups = rrPrivilegedGroups("mod_roomreservation_view");
+    echo sprintf("<p>%s</p>\n<p>%s</p>\n<p>%s</p>", _c("room-reservation:This is ".
+      "a short summary of the privileges related to the room reservation ".
+      "schedulde and the groups which have them assigned."),
+      sprintf(_c("room-reservation:If one of these privileges is not assigned to ".
+      "any group, all users on this server are allowed to perform the specified ".
+      "action. Please use the %sgroup administration%s to assign and revoke ".
+      "privileges."), "<a href='/idesk/admin/act/groups.php'>", "</a>"),
+      _c("room-reservation:Please note that every group with the booking ".
+       "privilege can also implicitly view the booking table and every group with ".
+       "the administration privilege can also implicitly book and view the ".
+       "booking table."));
+    echo "<p><table style='width:100%'><tr>\n";
+    echo sprintf("<td>%s%s</td><td>%s</td>\n", icon("keys"),
+      _("View the booking table").":", $asViewGroups == array() ?
+      _c("room-reservation:all users") : icon("act-group") . join(", ", 
+      array_map("getGroupName", $asViewGroups)));
+    echo "</tr><tr>\n";
+    echo sprintf("<td>%s%s</td><td>%s</td>\n", icon("keys"),
+      _("Book rooms").":", $asBookGroups == array() ?
+      _c("room-reservation:all users") : icon("act-group") . join(", ",
+      array_map("getGroupName", $asBookGroups)));
+    echo "</tr><tr>\n";
+    echo sprintf("<td>%s%s</td><td>%s</td>\n", icon("keys"),
+      _("Administration of the room reservation schedule"),
+      $asAdminGroups == array() ? _c("room-reservation:no users") :
+      icon("act-group") . join(", ", array_map("getGroupName", $asAdminGroups)));
+    echo "</tr></table></p>\n";
+    _GroupBox();
+
+    // second column
+    echo "</td><td><!--second row-->\n";
+    
+    GroupBox(_c("room-reservation:Periods"), "mod_room-reservation_timeslice");
+    printf("<p>%s</p>", _c("room-reservation:Here you can fill in the ".
+       "periods where bookings can be undertaken. A booking period can ".
+       "e.&nbsp;g. correspond to a lesson."));
+    echo "<div style='margin:8px;'>";
+    $this->otlb->show();
+    echo "</div>\n";
+    _GroupBox();
+    
+    GroupBox(_c("room-reservation:Further options"), "manage");
+    printf("<div style='margin:8px;'><form action='%s' method='post'>".
+       "<table><tr>\n", $_SERVER["PHP_SELF"]);
+
+    printf("<td><input type='hidden' name='mod_roomReservationConfigPage".
+       "[showweekend]' value='0' /><%s name='mod_roomReservationConfigPage".
+       "[showweekend]' id='mod_roomReservationConfigPageShowWeekend' ".
+       "value='1' %s /></td><td><label for='".
+       "mod_roomReservationConfigPageShowWeekend'><b>%s</b></label><br />".
+       "<span class='mod_roomReservationConfigPageExplanation'>%s</span></p>",
+      $GLOBALS["smlchk"], $this->bPostShowWeekend ? "checked='checked' " : "",
+      _c("room-reservation:Show weekend"), _c("room-reservation:If ".
+      "selected, the weekdays saturday and sunday are also shown in the ".
+      "booking table."));
+
+    echo "</tr><tr>\n";
+    printf("<td><input type='hidden' name='mod_roomReservationConfigPage".
+       "[showlessons]' value='0' /><%s name='mod_roomReservationConfigPage".
+       "[showlessons]' id='mod_roomReservationConfigPageShowLessons' ".
+       "value='1'%s /></td><td><label for='".
+       "mod_roomReservationConfigPageShowLessons'><b>%s</b></label><br />".
+       "<span class='mod_roomReservationConfigPageExplanation'>%s</span></p>",
+      $GLOBALS["smlchk"], $this->bPostShowLessons ? "checked='checked' " : "",
+      _c("room-reservation:Show &bdquo;lesson&rdquo; texts"),
+      _c("room-reservation:Check this box to show texts like ".
+       "&bdquo;<i>n</i>th lesson&rdquo in the booking page. If this box is ".
+       "unchecked, none of these texts are shown."));
+      
+    printf("</tr><tr><td colspan='2'><%s name='mod_roomReservationConfigPage".
+       "[submit]' value='%s' /></td>", $GLOBALS["stdbtn"], _("OK"));
+    echo "</tr></table></form></div>\n";
+    _GroupBox();
+
+    echo "</td></tr></table>\n";
+  }
+}
+?>
\ No newline at end of file
diff --git a/inc/mod_roomReservationControl.inc b/inc/mod_roomReservationControl.inc
new file mode 100644 (file)
index 0000000..4d364c5
--- /dev/null
@@ -0,0 +1,114 @@
+<?php
+/**\r
+ * @file mod_roomReservationControl.inc\r
+ * Class that represents an abstract control\r
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
+ * @date 25.07.2008\r
+ * \r
+ * Copyright © 2007 Roland Hieber\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included in\r
+ * all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+ * THE SOFTWARE.\r
+ */\r
+
+require_once("quote.inc");
+require_once("functions.inc");
+\r
+/** @todo document */
+abstract class mod_roomReservationControl {
+  /** (array of strings) Errors that occur while processing the form */ 
+  protected $asMessages;
+  /** (mod_roomReservationConfig) Reference to the configuration object */
+  protected $oCfg;
+  
+  /***************************************************************************/
+  /**
+   * @name Constructor
+   * @{
+   * Constructor
+   * @param $oCfg (reference to mod_roomReservationConfig) Reference to the
+   *  configuration
+   * @return mod_roomReservationBookingTable
+   */
+  public function __construct(mod_roomReservationConfig &$oCfg) {
+    rrAddCss(".blue .treeview .err { color:red !important; }");
+    $this->oCfg = $oCfg;
+    $this->processRequestVariables();
+  }
+  /***************************************************************************/
+  /**
+   * @}
+   * @name Initialization
+   * @{
+   */
+
+  /**
+   * Process the REQUEST variables and preset the some variables
+   * @return void
+   */
+  protected function processRequestVariables() { }
+  
+  /***************************************************************************/
+  /**
+   * @}
+   * @name Output
+   * @{
+   */
+
+  /**
+   * Get the messages that have been produced. Returns HTML.
+   * @return string
+   */
+  protected function getMessages() {
+    if(count($this->asMessages) > 0) {
+      return sprintf("<div class='err'>%s</p>\n",
+        nl2br(q(join("\n", $this->asMessages))));
+    }
+  }
+
+  /**
+   * Show the beginning of the control.
+   * @return void
+   */
+  protected function beginShow() { }
+  
+  /**
+   * Show the control. Override this function to print your HTML code.
+   * @return void
+   */
+  protected abstract function doShow();
+  
+  /**
+   * Show the end of the control.
+   * @return void
+   */
+  protected function endShow() { }
+
+  /**
+   * Show the full control. You don't need to override this function. Instead,
+   * override doShow(). 
+   * @return void
+   */
+  public function show() {
+    $this->beginShow();
+    $this->doShow();
+    $this->endShow();
+  }
+}
+?>
\ No newline at end of file
diff --git a/inc/mod_roomReservationPage.inc b/inc/mod_roomReservationPage.inc
new file mode 100644 (file)
index 0000000..6d0e018
--- /dev/null
@@ -0,0 +1,150 @@
+<?php
+/**\r
+ * @file mod_roomReservationPage.inc\r
+ * A generic page class\r
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
+ * @date 24.06.2008\r
+ * \r
+ * Copyright © 2007 Roland Hieber\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included in\r
+ * all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+ * THE SOFTWARE.\r
+ */\r
+\r
+require_once("mod_room-reservation/mod_roomReservationConfig.inc");
+
+/** @todo document */
+abstract class mod_roomReservationPage {
+  /** (mod_roomReservationConfig) Reference to the configuration object */
+  protected $oCfg;
+  /** (string) Page title for PageBlue() */
+  protected $strTitle;
+  /** (string) Title icon for PageBlue() */
+  protected $strIcon;
+  
+  /***************************************************************************/
+  /**
+   * @name Constructor
+   * @{
+   * Constructor
+   * @param $oCfg (reference to mod_roomReservationConfig) Reference to the
+   *  configuration
+   * @return mod_roomReservationPage
+   */
+  function __construct(mod_roomReservationConfig &$oCfg) {
+    $this->oCfg = $oCfg;
+    
+    $this->processRequestVariables();
+  }
+
+  /***************************************************************************/
+  /**
+   * @}
+   * @name Initialization
+   * @{
+   */
+  
+  /**
+   * Process the REQUEST variables and preset the some variables. Override
+   * this function to process GET and POST parameters.
+   * @return void
+   */
+  protected function processRequestVariables() { }
+
+  /***************************************************************************/
+  /**
+   * @}
+   * @name Access to attributes
+   * @{
+   */
+  
+  /**
+   * Set the page title
+   * @param $str (string)
+   * @return void
+   */
+  public function setTitle($str) { $this->strTitle = $str; }
+  
+  /**
+   * Set the title icon
+   * @param $str (string)
+   * @return void
+   */
+  public function setIcon($str) { $this->strIcon = $str; }
+  
+  /**
+   * Get the page title
+   * @return string
+   */
+  public function getTitle() { return $this->strTitle; }
+
+  /**
+   * Get the title icon
+   * @return string
+   */
+  public function getIcon() { return $this->strIcon; }
+
+  /***************************************************************************/
+  /**
+   * @}
+   * @name Output
+   * @{
+   */
+
+  /**
+   * Show the beginning of the page.
+   * @return void
+   */
+  protected function beginShow() {
+    html_header("<style type='text/css'>\n".rrGetCss()."\n</style>\n");
+    PageBlue(q($this->getTitle()), $this->getIcon());
+    
+    // print error messages from the configuration
+    if($s = trim($this->oCfg->getMessages()) != "") {
+      printf("<p class='err'>%s</p>\n", nl2br(q($s)));
+    }
+  }
+  
+  /**
+   * Show the beginning of the page. Override this function to print your 
+   * HTML code.
+   * @return void
+   */
+  protected abstract function doShow();
+  
+  /**
+   * Show the end of the page.
+   * @return void
+   */
+  protected function endShow() {
+    _PageBlue();
+  }
+
+  /**
+   * Show the full page. You don't need to override this function. Instead,
+   * override doShow(). 
+   * @return void
+   */
+  public function show() {
+    $this->beginShow();
+    $this->doShow();
+    $this->endShow();
+  }
+
+}
+?>
\ No newline at end of file
diff --git a/inc/mod_roomReservationRoom.inc b/inc/mod_roomReservationRoom.inc
new file mode 100644 (file)
index 0000000..64ed6cb
--- /dev/null
@@ -0,0 +1,143 @@
+<?php
+/**
+ * @file mod_roomReservationRoom.inc 
+ * Container class for the representation of a room
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)
+ * @date 28.12.2007
+ * 
+ * Copyright © 2007 Roland Hieber
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ * 
+ * @todo move into M Class Library
+ */
+
+/**
+ * Container class for the representation of a room
+ */
+class mod_roomReservationRoom {
+  
+  /** (string) Name of the room */
+  protected $strName;
+  /** (string) Room number */
+  protected $strRoomNo;
+  /** (string) Floor */
+  protected $strFloor;
+  /** (string) Building */
+  protected $strBuilding;
+  /** (string) Location */
+  protected $strLocation;
+  
+  /***************************************************************************/
+  /**
+   * @name Constructor
+   * @{
+   * Constructor.
+   * @param $strName (string) Name of the room
+   * @return rmRoom
+   */
+  public function __construct($strName, $strRoomNo = "", $strFloor = "",
+    $strBuilding = "", $strLocation = "") {
+    $this->setName($strName);
+    $this->setRoomNo($strRoomNo);
+    $this->setFloor($strFloor);
+    $this->setBuilding($strBuilding);
+    $this->setLocation($strLocation);
+  }
+
+  /***************************************************************************/
+  /**
+   * @}
+   * @name Access to attributes
+   * @{
+   */
+  
+  /**
+   * Set the name of the room
+   * @param $str (string) 
+   * @return void
+   */
+  public function setName($str) { $this->strName = $str; }
+  
+  /**
+   * Set the room number
+   * @param $str (string) 
+   * @return void
+   */
+  public function setRoomNo($str) { $this->strRoomNo = $str; }
+  
+  /**
+   * Set the floor
+   * @param $str (string) 
+   * @return void
+   */
+  public function setFloor($str) { $this->strFloor = $str; }
+  
+  /**
+   * Set the building
+   * @param $str (string) 
+   * @return void
+   */
+  public function setBuilding($str) { $this->strBuilding = $str; }
+  
+  /**
+   * Set the location
+   * @param $str (string) 
+   * @return void
+   */
+  public function setLocation($str) { $this->strLocation = $str; }
+  
+  /**
+   * Get the name of the room
+   * @return string
+   */
+  public function getName() { return $this->strName; }
+
+  /**
+   * Get the room number
+   * @return string
+   */
+  public function geRoomNo() { return $this->strRoomNo; }
+
+  /**
+   * Get the floor
+   * @return string
+   */
+  public function getFloor() { return $this->strFloor; }
+
+  /**
+   * Get the building
+   * @return string
+   */
+  public function getBuilding() { return $this->strBuilding; }
+
+  /**
+   * Get the location
+   * @return string
+   */
+  public function getLocation() { return $this->strLocation; }
+
+  /**
+   * Conversion to string
+   * @return string
+   */
+  public function __toString() { return $this->getName(); /* name is key */ }
+  /**@}*/
+}
+?>
diff --git a/inc/mod_roomReservationRoomWhitelistListBox.inc b/inc/mod_roomReservationRoomWhitelistListBox.inc
new file mode 100644 (file)
index 0000000..27bd6c2
--- /dev/null
@@ -0,0 +1,214 @@
+<?php
+/**\r
+ * @file mod_roomReservationRoomWhitelistListBox.inc\r
+ * List box that shows the rooms who can be booked\r
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
+ * @date 24.07.2008\r
+ * \r
+ * Copyright © 2007 Roland Hieber\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included in\r
+ * all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+ * THE SOFTWARE.\r
+ */\r
+
+require_once("mod_roomReservationControl.inc");
+require_once("mod_roomReservationRoomsManager.inc");
+
+/*****************************************************************************/
+/**
+ * @page roomwhitelistlistbox_actions Actions of a 
+ * mod_roomReservationRoomWhitelistListBox instance
+ * @{
+ * The following constants describe the actions that a
+ * mod_roomReservationRoomWhitelistListBox instance can handle. They are used
+ * in processRequestVariables() to determine the action that should be done
+ * when the control is shown.
+ */
+/** Show the control (default action) */
+define("MOD_ROOM_RESERVATION_RWLB_ACTION_SHOW", 0);
+/** Show the addition form */
+define("MOD_ROOM_RESERVATION_RWLB_ACTION_ADD", 1);
+/** Process the addition form */
+define("MOD_ROOM_RESERVATION_RWLB_ACTION_SUBMITADD", 2);
+/** Show the deletion form */
+define("MOD_ROOM_RESERVATION_RWLB_ACTION_DELETE", 3);
+/** Process the deletion form */
+define("MOD_ROOM_RESERVATION_RWLB_ACTION_SUBMITDELETE", 4);
+/** @} */
+\r
+/** @todo document */
+class mod_roomReservationRoomWhitelistListBox 
+  extends mod_roomReservationControl {
+  /**
+   * (array of integers) OIDs of the rows in the rooms table that were 
+   * selected (POST data)
+   */
+  protected $anPostSelection = array();
+  /** (constant) Display mode, see @ref roomwhitelistlistbox_actions */
+  protected $cMode;
+  
+  protected function processRequestVariables() {
+    // default values
+    $this->cMode = MOD_ROOM_RESERVATION_RWLB_ACTION_SHOW;
+    
+    // POST data
+    if(isset($_POST["mod_roomReservationRoomWhitelistListBox"])) {
+      $aPost = $_POST["mod_roomReservationRoomWhitelistListBox"];
+      // mode
+      if(isset($aPost["action"])) {
+        if(isset($aPost["action"]["add"])) {
+          if($aPost["action"]["add"] == _("Add")) {
+            $this->cMode = MOD_ROOM_RESERVATION_RWLB_ACTION_ADD;
+          } elseif($aPost["action"]["add"] == _("OK")) {
+            $this->cMode = MOD_ROOM_RESERVATION_RWLB_ACTION_SUBMITADD;
+          }
+        } elseif(isset($aPost["action"]["delete"])) {
+          if($aPost["action"]["delete"] == _("Delete")) {
+            $this->cMode = MOD_ROOM_RESERVATION_RWLB_ACTION_DELETE;
+          } elseif($aPost["action"]["delete"] == _("OK")) {
+            $this->cMode = MOD_ROOM_RESERVATION_RWLB_ACTION_SUBMITDELETE;
+          }
+        }
+      }
+      // selection
+      if(isset($aPost["l"])) {
+        foreach($aPost["l"] as $nOid => $bChecked) {
+          if($bChecked) {
+            $this->anPostSelection[] = $nOid;
+          }
+        }
+      }
+    }
+    
+    // process the forms
+    if($this->cMode == MOD_ROOM_RESERVATION_RWLB_ACTION_SUBMITADD) {
+      $h = db_query("SELECT name FROM rooms WHERE oid IN ".
+        qdb_arr($this->anPostSelection));
+      while($a = pg_fetch_array($h)) {
+        $this->oCfg->whitelistRoom($a["name"]);
+      }
+    }
+
+    if($this->cMode == MOD_ROOM_RESERVATION_RWLB_ACTION_SUBMITDELETE) {
+      $h = db_query("SELECT name FROM rooms WHERE oid IN ".
+        qdb_arr($this->anPostSelection));
+      while($a = pg_fetch_array($h)) {
+        $this->oCfg->unWhitelistRoom($a["name"]);
+      }
+    }
+  }
+  
+  protected function doShow() {
+    echo "<form method='post'>";
+    TreeView(array(_("Room")));
+    switch($this->cMode) {
+      case MOD_ROOM_RESERVATION_RWLB_ACTION_DELETE:
+        $this->showDeleteForm();
+        break;
+      case MOD_ROOM_RESERVATION_RWLB_ACTION_ADD: $this->showAddForm(); break;
+      default:
+      case MOD_ROOM_RESERVATION_RWLB_ACTION_SHOW: $this->showForm(); break;
+    }
+    _TreeView();
+    echo "</form>\n";
+  }
+
+  /**
+   * Print the form if not delete nor add was requested
+   * @return void
+   */
+  protected function showForm() {
+    $aoRooms = $this->oCfg->getWhitelistedRooms();
+    // only show add button if there are still some unlisted rooms
+    if(count(mod_roomReservationRoomsManager::getRooms()) > count($aoRooms)) {
+      TreeViewLine(sprintf("<%s name='mod_roomReservationRoomWhitelistListBox".
+        "[action][add]' value='%s' /></form>", $GLOBALS["stdbtn"], _("Add")));
+    }
+    $this->showList($aoRooms);
+    // toolbar
+    printf("<tr><td class='tbbtm' colspan='%d'>", $GLOBALS["treeview_cols"]);
+    CheckCombo();
+    printf("<%s name='mod_roomReservationRoomWhitelistListBox[action]".
+       "[delete]' value='%s' />", $GLOBALS["stdbtn"], _("Delete"));
+    echo "</td></tr>\n";
+  }
+  
+  /**
+   * Print the addition form
+   * @return void
+   */
+  protected function showAddForm() {
+    // only list rooms that are not already whitelisted
+    $aoRooms = array_diff(mod_roomReservationRoomsManager::getRooms(),
+      $this->oCfg->getWhitelistedRooms());
+    TreeViewSubtitle(_("Add"));
+    $this->showList($aoRooms);
+    TreeViewLine(sprintf("<p><%s name='mod_roomReservationRoomWhitelistList".
+       "Box[action][add]' value='%s' /> <%s name='mod_roomReservationRoom".
+       "WhitelistListBox[action][add]' value='%s' /></p>", $GLOBALS["stdbtn"],
+       _("OK"), $GLOBALS["stdbtn"], _("Cancel")));
+  }
+  
+  /**
+   * Show the deletion form
+   * @return void
+   */
+  protected function showDeleteForm() {
+    // list rooms in selection
+    $aoRooms = array();
+    $h = db_query("SELECT name FROM rooms WHERE oid IN ".
+      qdb_arr($this->anPostSelection));
+    foreach($this->anPostSelection as $nOid) {
+      $aoRooms[] = mod_roomReservationRoomsManager::getRoomByOid($nOid);
+    }
+    TreeViewSubtitle(sprintf(_("Following %s will be deleted"),
+      _c("room-reservation:rooms")));
+    $this->showList($aoRooms, false);
+    TreeViewLine(sprintf("<p><%s name='mod_roomReservationRoomWhitelistList".
+       "Box[action][delete]' value='%s' /> <%s name='mod_roomReservationRoom".
+       "WhitelistListBox[action][delete]' value='%s' /></p>",
+       $GLOBALS["stdbtn"], _("OK"), $GLOBALS["stdbtn"], _("Cancel")));
+  }
+  
+  /**
+   * Show the list items
+   * @param $aoRooms (array of mod_roomReservationRoom objects) List items
+   * @param $bCheckboxes (bool) Whether to show checkboxes
+   */
+  protected function showList($aoRooms, $bCheckboxes = true) {
+    if(count($aoRooms) > 0) {
+      foreach($aoRooms as $o) {
+        // fetch oid from SQL table
+        $nOid = pg_fetch_result(db_query("SELECT oid FROM ".
+          "rooms WHERE name = $1", $o->getName()), 0, "oid");
+        $sBox = $bCheckboxes ? sprintf("<%s id='box%d' name='mod_room".
+               "ReservationRoomWhitelistListBox[l][%d]' value='1'%s /><label ".
+               "for='box%d'>%s%s</label>", $GLOBALS["smlchk"], $nOid, $nOid,
+          @$this->anPostSelection[$nOid] ? " checked='checked'" : "", $nOid,
+          icon("host"), $o->getName()) : 
+          sprintf("<input type='hidden' name='mod_roomReservationRoom".
+               "WhitelistListBox[l][%d]' value='1' />%s%s", $nOid, icon("host"),
+          $o->getName());
+        TreeViewLine($sBox);
+      }
+    } else {
+      TreeViewEmpty();
+    }
+  }
+}
+?>
\ No newline at end of file
diff --git a/inc/mod_roomReservationRoomsManager.inc b/inc/mod_roomReservationRoomsManager.inc
new file mode 100644 (file)
index 0000000..edce221
--- /dev/null
@@ -0,0 +1,165 @@
+<?php
+/**
+ * @file mod_roomReservationRoomsManager.inc
+ * Class for the management of rooms
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)
+ * @date 28.12.2007
+ * 
+ * TODO: move into M Class Library
+ * Copyright © 2007 Roland Hieber
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+require_once("db.inc");
+require_once("mod_room-reservation/functions.inc");
+require_once("mod_room-reservation/mod_roomReservationRoom.inc");
+require_once("mod_room-reservation/mod_roomReservationConfig.inc");
+
+/** Simple class for creating, editing and deleting rooms */
+class mod_roomReservationRoomsManager {
+  /** (mod_roomReservationConfig) Reference to the configuration */
+  protected $oCfg;
+  
+  /**
+   * Constructor
+   * @param $oCfg (reference to mod_roomReservationConfig) Reference to the
+   *  configuration object
+   * @return rmRoomsManager
+   */
+  public function __construct(mod_roomReservationConfig &$oCfg) {
+    $this->oCfg = $oCfg;
+  }
+  
+  /**
+   * Insert or update a room in the database
+   * param $or (rsRoom) Room to store in the database
+   * return (int) The UID of the booking, or <tt>-1</tt> in case of a failure.
+   * Call getLastError() to get more information about the error.
+   */
+/**  public function write(rsRoom $or) {
+    // Only administrators are allowed to create and alter rooms
+    if(!$this->oCfg->userIsAdmin()) {
+      // TODO throw exception
+      setLastError(RS_ERROR_ACCESS_DENIED);
+      return -1;
+    }
+
+    $strWhere = "";
+    $strLog = "";
+
+    // Update or insert?
+    if($or->getUid() == null) {
+      // No UID yet, insert new room
+      $strLog = sprintf("Raum „%s“ angelegt", $or->getName());
+    } else {
+      $strWhere = "rsr_uid = ".qp(intval($or->getUid()));
+      $strLog = sprintf("Raum „%s“ geändert", $or->getName());
+    }
+    
+    $aPut["rsr_name"] = $or->getName();
+    db_store("rooms", $aPut, $strWhere == "" ? null : $strWhere);
+    
+    $hQuery = db_query("SELECT currval('roomschedule_rooms_rsr_uid_seq') ".
+      "FROM roomschedule_rooms;");
+    $nNewUid = pg_fetch_result($hQuery, 0, "currval");
+    
+    rrInsertLog($strLog);
+    
+    // Return new UID
+    return $nNewUid;
+  }
+  */
+  /**
+   * Delete a room from the database
+   * param $nUid (int) Unique ID of the room
+   * return (bool) <tt>true</tt> on success, otherwise <tt>false</tt>.
+   *  Call getLastError() to get more information about the error.
+   */
+/*  public function delete($nUid) {
+    // Only administrators are allowed to delete rooms
+    if(!$this->oCfg->userIsAdmin()) {
+      // TODO throw exception
+      setLastError(RS_ERROR_ACCESS_DENIED);
+      return false;
+    }
+    // Delete it from the database
+    $strRoom = $this->getRoomName($nUid);
+    if(!db_query("DELETE FROM roomschedule_rooms WHERE rsr_uid = $1;",
+      intval($nUid))) {
+        // TODO throw exception
+      setLastError(RS_ERROR_SQL);
+      return false;
+    } else {
+      rsInsertLog(sprintf("Raum „%s“ gelöscht", $strRoom));
+      return true;
+    }
+  }
+*/
+
+  /**
+   * Get a room by its OID. Returns <tt>null</tt> if the room was not found.
+   * @param $nOid (integer) The OID of the room
+   * @return mod_roomReservationRoom
+   */
+  static function getRoomByOid($nOid) {
+    $o = null;
+    $h = db_query("SELECT * FROM rooms WHERE oid = $1;", $nOid);
+    if(pg_num_rows($h) > 0) {
+      $arResult = pg_fetch_array($h);
+      $o = new mod_roomReservationRoom($arResult["name"], 
+        $arResult["room_no"], $arResult["floor"], $arResult["building"],
+        $arResult["location"]);
+    }
+    return $o;
+  }
+  
+  /**
+   * Get a room by its name. Returns <tt>null</tt> if the room was not found.
+   * @param $sName (string) The name of the room
+   * @return mod_roomReservationRoom
+   */
+  static function getRoomByName($sName) {
+    $o = null;
+    $h = db_query("SELECT * FROM rooms WHERE name = $1;", $sName);
+    if(pg_num_rows($h) > 0) {
+      $arResult = pg_fetch_array($h);
+      $o = new mod_roomReservationRoom($arResult["name"], 
+        $arResult["room_no"], $arResult["floor"], $arResult["building"],
+        $arResult["location"]);
+    }
+    return $o;
+  }
+  
+  /**
+   * Get all rooms from the database
+   * @return array of mod_roomReservationRoom
+   */
+  static function getRooms() {
+    $aoReturn = array();
+    $hQuery = db_query("SELECT * FROM rooms ORDER BY name;");
+    while($arResult = pg_fetch_array($hQuery)) {
+      $aoReturn[] = new mod_roomReservationRoom($arResult["name"], 
+        $arResult["room_no"], $arResult["floor"], $arResult["building"],
+        $arResult["location"]);
+    }
+    return $aoReturn;
+  }
+}
+?>
diff --git a/inc/mod_roomReservationTimeslice.inc b/inc/mod_roomReservationTimeslice.inc
new file mode 100644 (file)
index 0000000..f6bd997
--- /dev/null
@@ -0,0 +1,102 @@
+<?php
+/**
+ * @file mod_roomReservationTimeslice.inc
+ * Representation of a timeslice
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)
+ * @date 03.02.2008
+ * 
+ * Copyright © 2007 Roland Hieber
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+/** Implementation of a simple timeslice with beginning and ending time */
+class mod_roomReservationTimeslice {
+  
+  /** (timestamp) Time when the timeslice begins */
+  protected $tsBegin = -1;
+  /** (timestamp) Time when the timeslice ends */
+  protected $tsEnd = 86400;
+  
+  /***************************************************************************/
+  /**
+   * @name Constructor
+   * @{
+   * Constructor
+   * @param $tsBegin (timestamp) Time when the timeslice begins. Only the
+   *  time part is used, the date part is ignored.
+   * @param $tsEnd (timestamp) Time when the timeslice ends. Only the time
+   *  part is used, the date part is ignored.
+   * @return mod_roomReservationTimeslice
+   */
+  public function __construct($tsBegin, $tsEnd) {
+    $this->setBegin($tsBegin);
+    $this->setEnd($tsEnd);
+  }
+
+  /***************************************************************************/
+  /**
+   * @}
+   * @name Access to attributes
+   * @{
+   */
+  
+  /**
+   * Set the beginning. Only the time part is used, the date part is ignored.
+   * If the timestamp is invalid, an Exception is thrown.
+   * @param $ts (timestamp)
+   * @throws Exception 
+   */
+  public function setBegin($ts) {
+    if(intval($ts) >= $this->getEnd()) {
+      throw new Exception(MOD_ROOM_RESERVATION_ERROR_END_BEFORE_BEGIN);
+    } else {
+      $this->tsBegin = (intval($ts) % 86400);
+    }
+  }
+
+  /**
+   * Set the ending. Only the time part is used, the date part is ignored.
+   * If the timestamp is invalid, an Exception is thrown.
+   * @param $ts (timestamp) 
+   * @throws Exception 
+   */
+  public function setEnd($ts) {
+    if($this->getBegin() >= intval($ts)) {
+      throw new Exception(MOD_ROOM_RESERVATION_ERROR_END_BEFORE_BEGIN);
+    } else {
+      $this->tsEnd = (intval($ts) % 86400);
+    }
+  }
+
+  /**
+   * Get the beginning.
+   * @return timestamp
+   */
+  public function getBegin() { return $this->tsBegin; }
+
+  /**
+   * Get the ending.
+   * @return timestamp
+   */
+  public function getEnd() { return $this->tsEnd; }
+  
+  /** @} */
+}
+?>
diff --git a/inc/mod_roomReservationTimesliceListBox.inc b/inc/mod_roomReservationTimesliceListBox.inc
new file mode 100644 (file)
index 0000000..6928a33
--- /dev/null
@@ -0,0 +1,264 @@
+<?php
+/**\r
+ * @file mod_roomReservationTimesliceListBox.inc\r
+ * A list box that allows the user to add and delete timeslices\r
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
+ * @date 23.06.2008\r
+ * \r
+ * Copyright © 2007 Roland Hieber\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included in\r
+ * all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+ * THE SOFTWARE.\r
+ */\r
+
+require_once("ctrl.inc");
+require_once("mod_room-reservation/mod_roomReservationControl.inc");
+require_once("mod_room-reservation/mod_roomReservationTimeslice.inc");
+
+/*****************************************************************************/
+/**
+ * @page timeslicelistbox_actions Actions of a 
+ * mod_roomReservationTimesliceListBox instance
+ * @{
+ * The following constants describe the actions that a
+ * mod_roomReservationTimesliceListBox instance can handle. They are used in
+ * processRequestVariables() to determine the action that should be done when
+ * the control is shown.
+ */
+/** Show the control (default action) */
+define("MOD_ROOM_RESERVATION_TLB_ACTION_SHOW", 0);
+/** Add a timeslice */
+define("MOD_ROOM_RESERVATION_TLB_ACTION_ADD", 1);
+/** Delete a timeslice */
+define("MOD_ROOM_RESERVATION_TLB_ACTION_DELETE", 2);
+/** @} */
+\r
+/** @todo document, add a delete confirmation */
+class mod_roomReservationTimesliceListBox  extends mod_roomReservationControl {
+  
+  /** 
+   * (constant) The action to be done (GET data).
+   * See @ref timeslicelistbox_actions.
+   */
+  protected $cAction;
+  /** (string) The beginning for a new timeslice (GET data) */
+  protected $sNewBegin;
+  /** (string) The ending for a new timeslice (GET data) */
+  protected $sNewEnd;
+  
+  /***************************************************************************/
+  /**
+   * @name Constructor
+   * @{
+   * Constructor
+   * @param $oCfg (reference to mod_roomReservationConfig) Reference to the
+   *  configuration
+   * @return mod_roomReservationTimesliceListBox
+   */
+  public function __construct(mod_roomReservationConfig &$oCfg) {
+    parent::__construct($oCfg);
+  }
+  /***************************************************************************/
+  /**
+   * @}
+   * @name Initialization
+   * @{
+   */
+
+  /**
+   * Process the REQUEST variables and preset the some variables
+   * @return void
+   */
+  protected function processRequestVariables() {
+    
+    if(isset($_GET["mod_roomReservationTimesliceListBox"])) {
+      // action
+      if(isset($_GET["mod_roomReservationTimesliceListBox"]["action"])) {
+        $ga = $_GET["mod_roomReservationTimesliceListBox"]["action"];
+        $this->setAction((($ga == "add") ? MOD_ROOM_RESERVATION_TLB_ACTION_ADD : 
+          (($ga == "delete") ? MOD_ROOM_RESERVATION_TLB_ACTION_DELETE :
+          MOD_ROOM_RESERVATION_TLB_ACTION_SHOW)));
+      }
+      
+      // new beginning and new ending
+      $this->setNewBegin(isset(
+        $_GET["mod_roomReservationTimesliceListBox"]["begin"]) ?
+        $_GET["mod_roomReservationTimesliceListBox"]["begin"] : "");
+      $this->setNewEnd(isset(
+        $_GET["mod_roomReservationTimesliceListBox"]["end"]) ?
+        $_GET["mod_roomReservationTimesliceListBox"]["end"] : "");
+    }
+    
+    // perform the requested action
+    if($this->getAction() == MOD_ROOM_RESERVATION_TLB_ACTION_ADD) {
+      // add a timeslice to the configuration file
+      
+      $bErrors = false;
+      
+      // Note: we want to handle the timestamps in GMT format, hence the "+0000"
+      if(strtotime($this->getNewBegin()." +0000") === false) {
+        $this->asMessages[] = _c("room-reservation:The beginning time is ".
+               "invalid.");
+        $bErrors = true;
+      }
+      if(strtotime($this->getNewEnd()." +0000") === false) {
+        $this->asMessages[] = _c("room-reservation:The ending time is ".
+               "invalid.");
+        $bErrors = true;
+      }
+      
+      if(!$bErrors) {
+        try {
+          $this->oCfg->addTimeslice(new mod_roomReservationTimeslice(
+            strtotime($this->getNewBegin()." +0000") % 86400, 
+            strtotime($this->getNewEnd()." +0000") % 86400));
+          $this->oCfg->writeConfig();
+          $this->setNewBegin("");
+          $this->setNewEnd("");
+        } catch(Exception $e) {
+          $this->asMessages[] = $e->getMessage();
+        }
+      }
+      
+    } elseif($this->getAction() == MOD_ROOM_RESERVATION_TLB_ACTION_DELETE) {
+      // delete a timeslice from the configuration file
+      if(isset($_POST["mod_roomReservationTimesliceListBox"])) {
+        if(isset($_POST["mod_roomReservationTimesliceListBox"]["l"])) {
+          $ao = $this->oCfg->getTimeslices();
+          foreach($_POST["mod_roomReservationTimesliceListBox"]["l"] as 
+            $n => $b) {
+            if($b) {
+              $this->oCfg->deleteTimeslice(new mod_roomReservationTimeslice(
+                $ao[$n]->getBegin(), $ao[$n]->getEnd()));
+            }
+          }
+          $this->oCfg->writeConfig();
+        }
+      }
+    }
+  }
+
+  /***************************************************************************/
+  /**
+   * @}
+   * @name Access to attributes
+   * @{
+   */
+  
+  /**
+   * Set the action to be done (GET data)
+   * @param $c (constant) Action. See @ref timeslicelistbox_actions.
+   */
+  protected function setAction($c) { $this->cAction = intval($c); }
+
+  /**
+   * Set the beginning for a new timeslice (GET data)
+   * @param $s (string)
+   */
+  protected function setNewBegin($s) { $this->sNewBegin = $s; }
+  
+  /**
+   * Set the beginning for a new timeslice (GET data)
+   * @param $s (string)
+   */
+  protected function setNewEnd($s) { $this->sNewEnd = $s; }
+  
+  /**
+   * Get the action to be done (GET data). See @ref timeslicelistbox_actions.
+   * @return constant
+   */
+  function getAction() { return $this->cAction; }
+  
+  /**
+   * Get the beginning for a new timeslice (GET data)
+   * @return string
+   */
+  public function getNewBegin() { return $this->sNewBegin; }
+  
+  /**
+   * Get the beginning for a new timeslice (GET data)
+   * @return string
+   */
+  public function getNewEnd() { return $this->sNewEnd; }
+  
+  /***************************************************************************/
+  /**
+   * @}
+   * @name Output
+   * @{
+   */
+  
+  /**
+   * Actually show the control
+   * @return void
+   */
+  public function doShow() {
+    TreeView(array(_c("room-reservation:Begin"), _c("room-reservation:End")));
+
+    // addition form
+    printf("<form method='get'>");
+    hidden("mod_roomReservationTimesliceListBox[action]", "add");
+    TreeViewTitle(_("Add"));
+    
+    $sMessages = $this->getMessages();
+    if(trim($sMessages) != "") {
+      TreeViewLine($sMessages);
+    }
+    
+    TreeViewLine(array(sprintf("<%s name='mod_roomReservationTimesliceListBox".
+       "[begin]' value='%s' size='8'/>", $GLOBALS["stdedt"], 
+      $this->getNewBegin()), sprintf("<%s name='".
+      "mod_roomReservationTimesliceListBox[end]' value='%s' size='8'/> <%s ".
+      "name='mod_roomReservationTimesliceListBox[submit]' value='%s' />", 
+      $GLOBALS["stdedt"], $this->getNewEnd(), $GLOBALS["stdbtn"], _("Add"))));
+    echo "</form>\n";
+    
+    // deletion form
+    TreeViewTitle(_c("room-reservation:Periods"));
+    $aoTs = $this->oCfg->getTimeslices();
+    if(count($aoTs) > 0) {
+      echo "<form action='?mod_roomReservationTimesliceListBox[action]=delete' ".
+       "method='post'>";
+      $i = 0;
+      foreach($aoTs as $oTs) {
+        $sBox = sprintf("<input type='hidden' ".
+               "name='mod_roomReservationTimesliceListBox[l][%d]' value='0' />".
+               "<%s name='mod_roomReservationTimesliceListBox[l][%d]' value='1' />",
+          $i, $GLOBALS["smlchk"], $i);
+        // Note: we have only GMT timestamps in the timeslice objects
+        TreeViewLine(array($sBox . gmstrftime(_("%#I:%M %p"), $oTs->getBegin()),
+          gmstrftime(_("%#I:%M %p"), $oTs->getEnd())));
+        $i++;
+      }
+      // toolbar
+      printf("<tr><td class='tbbtm' colspan='%d'>", $GLOBALS["treeview_cols"]);
+      CheckCombo();
+      printf("<%s name='mod_roomReservationTimesliceListBox[submit]' ".
+       "value='%s' />", $GLOBALS["stdbtn"], _("Delete"));
+      echo "</td></tr>\n";
+    } else {
+      TreeViewEmpty();
+    }
+    
+    echo "</form>\n";
+    _TreeView();
+  }
+  /** @} */
+}
+?>
\ No newline at end of file
diff --git a/includes/exceptions.inc b/includes/exceptions.inc
deleted file mode 100644 (file)
index 8d7c688..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-/**\r
- * @file exceptions.inc
- * Some custom exceptions\r
- * @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
- * @date 27.05.2008\r
- * \r
- * Copyright © 2007 Roland Hieber\r
- *\r
- * Permission is hereby granted, free of charge, to any person obtaining\r
- * copy of this software and associated documentation files (the "Software"),\r
- * to deal in the Software without restriction, including without limitation\r
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
- * and/or sell copies of the Software, and to permit persons to whom the\r
- * Software is furnished to do so, subject to the following conditions:\r
- * \r
- * The above copyright notice and this permission notice shall be included in\r
- * all copies or substantial portions of the Software.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
- * THE SOFTWARE.\r
- */\r
-
-/**
- * An exception while trying to do a SQL query.
- */
-class SQLException extends Exception {}
-
-/**
- * An exception while trying to access something 
- */
-class AccessException extends Exception {}
-
-/**
- * An exception while trying to write or read something 
- */
-class IOException extends Exception {}
-
-?>
\ No newline at end of file
diff --git a/includes/functions.inc b/includes/functions.inc
deleted file mode 100644 (file)
index 78e3690..0000000
+++ /dev/null
@@ -1,279 +0,0 @@
-<?php
-/**
- * @file functions.inc
- * additional functions for iserv-mod-room-reservation
- * @author Roland Hieber (roland.hieber@wilhelm-gym.net)
- * @date 22.12.2007
- * 
- * Copyright © 2007 Roland Hieber
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- * 
- * @todo move some functions into M Class Library
- */
-
-require_once("share.inc");
-require_once("db.inc");
-require_once("user.inc");
-require_once("sec/secure.inc");
-
-/**
- * @page errorcodes Error Codes
- * @{
- */
-/** Access denied. This can be due to missing access rights. */
-define("MOD_ROOM_RESERVATION_ERROR_ACCESS_DENIED", 
-  _c("room-reservation:Access denied."));
-/** Error while querying the database */
-define("MOD_ROOM_RESERVATION_ERROR_SQL", 
-  _c("room-reservation:Error while trying to query the database."));
-/** Error while trying to open a file */
-define("MOD_ROOM_RESERVATION_ERROR_OPEN_FILE",
-  _c("room-reservation:Could not open file."));
-/** Error while trying to write a file */
-define("MOD_ROOM_RESERVATION_ERROR_WRITE_FILE",
-  _c("room-reservation:Could not write to file."));
-/** Error while trying to lock a file */
-define("MOD_ROOM_RESERVATION_ERROR_LOCK_FILE",
-  _c("room-reservation:Could not lock file."));
-/** Error while trying to unlock a file */
-define("MOD_ROOM_RESERVATION_ERROR_UNLOCK_FILE",
-  _c("room-reservation:Could not unlock file."));
-/** The current booking overlaps with an existing booking */
-define("MOD_ROOM_RESERVATION_ERROR_BOOKING_OVERLAPS", _c("room-reservation:".
-  "The current booking overlaps with an existing booking."));
-/** The booking ends before it begins */
-define("MOD_ROOM_RESERVATION_ERROR_END_BEFORE_BEGIN", _c("room-reservation:".
-  "The ending of your booking cannot lie before the beginning."));
-define("MOD_ROOM_RESERVATION_ERROR_NO_REASON", _c("room-reservation:Please ".
- "give a reason."));
-/** A new timeslice overlaps with an existing timeslice */
-define("MOD_ROOM_RESERVATION_ERROR_CONFIG_OVERLAPPING_TIMESLICE",
-  _c("room-reservation:The period overlaps with an existing one."));
-/** There is no such timeslice */
-define("MOD_ROOM_RESERVATION_ERROR_CONFIG_NO_SUCH_TIMESLICE",
-  _c("room-reservation:The specified period does not exist."));
-/** There is no such account */
-define("MOD_ROOM_RESERVATION_ERROR_NO_SUCH_ACCOUNT", _c("room-reservation:".
-  "The specified account does not exist."));
-/** The room is not available for booking */
-define("MOD_ROOM_RESERVATION_ERROR_ROOM_NOT_WHITELISTED",
-  _c("room-reservation:This room is not available for booking."));
-/**
- * @}
- */
-
-/**
- * Determine if the specified user exists. Throws an SQLException if an error
- * occured.
- * @param $strAct (string) Account name of the user
- * @throws SQLException
- * @return (bool)
- */
-function isAct($strAct) {
-  $hQuery = db_query("SELECT * FROM users WHERE act = $1;", $strAct);
-  if(!is_resource($hQuery)) {
-    throw new SQLException(MOD_ROOM_RESERVATION_ERROR_SQL);
-    return null;
-  }
-  return (pg_num_rows($hQuery) > 0);
-}
-
-/**
- * Get the real user name for an account name
- * @param $strAct (string) Account name of the user to look up
- * @return (string) The real name of the user. If the function fails, it returns <tt>null</tt>.
- *  Call getLastError() to get more information about the error.
- */
-function getRealUserName($strAct) {
-  $hQuery = db_query("SELECT firstname, lastname FROM users WHERE act = $1;", $strAct);
-  if(!is_resource($hQuery)) {
-    // TODO throw exception
-    setLastError(RS_ERROR_SQL);
-    return null;
-  }
-  if(pg_num_rows($hQuery) == 0) {
-    return $strAct;     // User not found in database, return account name
-  }
-  $arResult = pg_fetch_array($hQuery);
-  return user_join_name($arResult);
-}
-
-/**
- * Determine if a specified group exists
- * @param $strAct (string) Account name of the group
- * @return  (bool / null) If the function fails, it returns <tt>null</tt>. Call getLastError() to
- *  get more information about the error.
- */
-function isGroup($strAct) {
-  $hQuery = db_query("SELECT * FROM groups WHERE act = $1;", $strAct);
-  if(!is_resource($hQuery)) {
-    // TODO throw exception
-    setLastError(RS_ERROR_SQL);
-    return null;
-  }
-  return (pg_num_rows($hQuery) > 0);
-}
-
-/**
- * Look up the name of a group
- * @param $strAct (string) Account name of the group
- * @return (string) The name of the group. If the function fails, it returns <tt>null</tt>.
- *  Call getLastError() to get more information about the error.
- */
-function getGroupName($strAct) {
-  $hQuery = db_query("SELECT * FROM groups WHERE act = $1;", $strAct);
-  if(!is_resource($hQuery)) {
-    // TODO throw exception
-    setLastError(RS_ERROR_SQL);
-    return null;
-  }
-  if(pg_num_rows($hQuery) == 0) {
-    return $strAct;     // Group not found in database, return account name
-  }
-  $arResult = pg_fetch_array($hQuery);
-  return $arResult["name"];
-}
-
-/**
- * Create a link to write a mail to the specified account name.
- * This function returns a link if the specified account exists, otherwise it returns the
- * account name.
- * @param $strAct (string) Account name
- * @param $strColor (string) Background color for icon()
- * @param $strParams (string) additional URL parameters
- * @return string
- */
-function mailToUserLink($strAct, $strColor = "bl", $strParams = "") {
-  if(!isAct($strAct)) {
-    return $strAct;
-  }
-  return popup(relroot("msg/write/?to=".user_mail_addr($strAct).$strParams),
-    600, 400, nobr(icon("mail-reply-usr", array("size" => 16, "bg" => 
-    $strColor)) . getRealUserName($strAct)));
-}
-
-/**
- * Determine if a specified string is a valid mail address
- * @param $strAddr string
- * @return string
- */
-function isMailAddress($strAddr) {
-  return ((preg_match("/([a-zA-Z0-9_\-\.]*(@[a-zA-Z0-9\-\.]*)?(\s*,\s*)?)+/", $strAddr) > 0)
-  and (preg_match("/(\s*,\s*)$/", $strAddr) == 0));
-}
-
-/**
- * Module-specific logging function.
- * Prefixes the log message with a module-specific string and writes it to the logs.
- * @param $strLog (string) Log message
- * @return void
- */
-function rrInsertLog($strLog) {
- log_insert($strLog, null, "Room Reservation Schedule");
-}
-
-/**
- * Get the SQL day number from a given timestamp.
- * @param $ts (timestamp)
- * @return (int) 0-6 for Sunday to Monday
- */
-function rrDateToSQLDayNumber($ts) {
-  $aDays = array("Sun" => 0, "Mon" => 1, "Tue" => 2,
-    "Wed" => 3, "Thu" => 4, "Fri" => 5, "Sat" => 6);
-  return $aDays[date("D", $ts)];
-}
-
-/**
- * Convert a UNIX timestamp to an SQL date string
- * @param $ts (timestamp)
- * @return string
- */
-function dateToSql($ts) { return date("Y\-m\-d", intval($ts)); }
-
-/**
- * Calculate the timestamp of the monday in the current week
- * @param $ts (timestamp) Calculate the value relative to this date
- * @return timestamp
- */
-function rrGetMonday($ts = null) {
-  if($ts === null) {
-    $ts = time();
-  }
-  if(date("D", $ts) == "Mon") {
-    // Today is monday
-    return strtotime("00:00", $ts);
-  } else {
-    return strtotime("last monday", $ts);
-  }
-}
-
-/** (array of strings) Additional CSS rules */
-$GLOBALS["rrLocalCss"] = array();
-
-/**
- * Add CSS rules to the page
- * @param $s (string)
- * @return void
- */
-function rrAddCss($s) {
-  rrDebug("rrAddCss: add \"$s\"");
-  $GLOBALS["rrLocalCss"][] = $s;
-}
-
-/**
- * Get CSS rules that have been added with rrAddCss()
- * @return string
- */
-function rrGetCss() {
-  rrDebug("rrGetCss: Local CSS is ".var_export($GLOBALS["rrLocalCss"], true));
-  return implode("\n", $GLOBALS["rrLocalCss"]);
-}
-
-function rrDebug($s, $bReturn = false) {
-  if(isset($_GET["debug"])) {
-    if(!$bReturn) {
-      echo "<!-- $s -->\n";
-    } else {
-      return $s;
-    }
-  }
-}
-
-/**
- * sprintf with support for ordinal numbers.
- * This version of sprintf replaces all substrings of the type <tt>/\\d+#/</tt>
- * (i.e. a decimal number with a hash sign appended) in the input string with
- * the corresponding english ordinal number prefices (st, nd, rd, th).
- * @param $str (string) Input string
- * @param $args (mixed) Additional parameters to be passed to sprintf()
- * @return (string)
- */
-function _sprintf_ord($str, $args /*leave this parameters for doxygen*/) {
-  $args = func_get_args();
-  if(preg_match_all("/%[bcdufosxX]/", $args[0], $temp) != func_num_args()-1) {
-    trigger_error("Too few arguments", E_USER_ERROR);
-    return false;
-  }
-  $str = call_user_func_array("sprintf", $args);
-  while(preg_match("/(.*)(\d+)#(.*)/", $str, $m))
-    $str = $m[1]._(append_ord_suffix($m[2])).$m[3];
-  return $str;
-}
-?>
diff --git a/includes/globals.inc b/includes/globals.inc
deleted file mode 100644 (file)
index eb2977e..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-/**
- * @file globals.inc 
- * Include all the stuff that we need
- * @author Roland Hieber (roland.hieber@wilhelm-gym.net)
- * @date 27.01.2008
- * 
- * Copyright © 2007 Roland Hieber
- * 
- * Permission is hereby granted, free of charge, to any person obtaining
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *  
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-require_once("mod_room-reservation/functions.inc");
-require_once("mod_room-reservation/exceptions.inc");
-require_once("mod_room-reservation/mod_roomReservationBookingsManager.inc");
-require_once("mod_room-reservation/mod_roomReservationRoomsManager.inc");
-require_once("mod_room-reservation/mod_roomReservationConfig.inc");
-
-/** A global instance of the mod_roomReservationConfig class */
-$g_rrCfg = new mod_roomReservationConfig();
-/** A global instance of the mod_roomReservationBookingsManager class */
-$g_rrBm = new mod_roomReservationBookingsManager($g_rrCfg);
-/** A global instance of the mod_roomReservationRoomsManager class */
-$g_rrRm = new mod_roomReservationRoomsManager($g_rrCfg);
-
-/**
- * @mainpage iserv-mod-room-reservation -- Simple reservation of rooms
- * The room reservation module allows the users of your IServ Portalserver
- * to reserve a room, e.g. for meetings, lessons etc.
- */
-?>
diff --git a/includes/mod_roomReservationBooking.inc b/includes/mod_roomReservationBooking.inc
deleted file mode 100644 (file)
index a6a1c8a..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-<?php
-/**
- * @file mod_roomReservationBooking.inc
- * Container class for the representation of a single booking
- * @author Roland Hieber (roland.hieber@wilhelm-gym.net)
- * @date 12.11.2007
- * 
- * Copyright © 2007 Roland Hieber
- * 
- * Permission is hereby granted, free of charge, to any person obtaining
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-/** @todo document */
-/**
- * Container class for the representation of a single booking
- */
-class mod_roomReservationBooking {
-  
-  /** (int / null) Unique ID in database */
-  protected $nUid;
-  /** (string) Name of the room */
-  protected $strRoom;
-  /** (timestamp) Date when the booking takes place */
-  protected $tsDate;
-  /** (int) Number of the first timeslice */
-  protected $nTsFirst;
-  /** (int) Number of the last timeslice (may be nBegin) */
-  protected $nTsLast;
-  /** (string) Account name of the owner */
-  protected $strAct;
-  /** (string) Reason for the booking */
-  protected $strReason;
-  /** (bool) Recurrence interval in weeks */
-  protected $nInterval;
-  
-  /***************************************************************************/
-  /**
-   * @name Constructor
-   * @{
-   */
-  /**
-   * Constructor.
-   * @param $strRoom (string) Name of the room
-   * @param $tsDate (timestamp) Date when the booking takes place
-   * @param $nTsFirst (int) Number of the first timeslice 
-   * @param $nTsLast (int) Number of the last timeslice (may be nBegin) 
-   * @param $strAct (string) Account name of the owner
-   * @param $strReason (string) Reason for the booking
-   * @param $nInterval (int) Recurrence interval, 0 for no recurrence
-   * @return mod_roomReservationBooking
-   */
-  public function __construct($strRoom, $tsDate, $nTsFirst, $nTsLast, $strAct,
-    $strReason, $nInterval = 0) {
-    $this->setUid(null);
-    $this->setRoom($strRoom);
-    $this->setDate($tsDate);
-    $this->setTsFirst($nTsFirst);
-    $this->setTsLast($nTsLast);
-    $this->setAct($strAct);
-    $this->setReason($strReason);
-    $this->setInterval($nInterval);
-  }
-  
-  /***************************************************************************/
-  /**
-   * @}
-   * @name Access to attributes
-   * @{
-   */
-  
-  /**
-   * Set the unique ID in database
-   * @param $n (int) Unique ID in database
-   * @return void
-   */
-  public function setUid($n) {
-    if(is_null($n)) {
-      $this->nUid = null;
-    } else {
-      $this->nUid = intval($n);
-    }
-  }
-  
-  /**
-   * Set the name of the room
-   * @param $str (string) Name of the room
-   * @return void
-   */
-  public function setRoom($str) { $this->strRoom = $str; }
-  
-  /**
-   * Set the date when the booking takes place
-   * @param $ts (timestamp) Date, only the date part is taken care of
-   * @return void
-   */
-  public function setDate($ts) {
-    // Only take the date part
-    $this->tsDate = intval(strtotime(date("Y\-m\-d", intval($ts))));  }
-
-  /**
-   * Set the first timeslice
-   * @param $n (int) Number of the first timeslice
-   * @return void
-   */
-  public function setTsFirst($n) { $this->nTsFirst = intval($n); }
-  
-  /**
-   * Set the end timeslice
-   * @param $n (int) Number of the last timeslice (may be the start timeslice) 
-   * @return void
-   */
-  public function setTsLast($n) { $this->nTsLast = intval($n); }
-  
-  /**
-   * Set the account name of the owner
-   * @param $str (string) Account name
-   * @return void
-   */
-  public function setAct($str) { $this->strAct = $str; }
-  
-  /**
-   * Set the reason for the booking
-   * @param $str (string) Reason
-   * @return void
-   */
-  public function setReason($str) { $this->strReason = $str; }
-  
-  /**
-   * Set the flag whether the booking repeates every week
-   * @param $n (int) interval in weeks, 0 for no recurrence
-   * @return void
-   */
-  public function setInterval($n) { $this->nInterval = intval(abs($n)); }
-
-  /**
-   * Get the unique ID in database
-   * @return int / null
-   */
-  public function getUid() { return intval($this->nUid); }
-  
-  /**
-   * Get the name of the room
-   * @return string
-   */
-  public function getRoom() { return $this->strRoom; }
-  
-  /**
-   * Get the date when the booking takes place
-   * @return timestamp
-   */
-  public function getDate() { return intval($this->tsDate); }
-  
-  /**
-   * Get the the number of the first timeslice
-   * @return int
-   */
-  public function getTsFirst() { return intval($this->nTsFirst); }
-  
-  /**
-   * Get the number of the last timeslice (may be the start timeslice)
-   * @return int
-   */
-  public function getTsLast() { return intval($this->nTsLast); }
-  
-  /**
-   * Get the account name of the owner
-   * @return string
-   */
-  public function getAct() { return $this->strAct; }
-  
-  /**
-   * Get the reason for the booking
-   * @return string
-   */
-  public function getReason() { return $this->strReason; }
-  
-  /**
-   * Get the recurrence interval
-   * @return int
-   */
-  public function getInterval() { return $this->nInterval; }
-
-  /**@}*/
-}
-?>
diff --git a/includes/mod_roomReservationBookingPage.inc b/includes/mod_roomReservationBookingPage.inc
deleted file mode 100644 (file)
index 219c7bd..0000000
+++ /dev/null
@@ -1,215 +0,0 @@
-<?php
-/**
- * @file mod_roomReservationBookingPage.inc
- * Page that shows the booking table
- * @author Roland Hieber (roland.hieber@wilhelm-gym.net)
- * @date 24.02.2008
- * 
- * Copyright © 2007 Roland Hieber
- * 
- * Permission is hereby granted, free of charge, to any person obtaining
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-require_once("share.inc");
-require_once("ctrl.inc");
-require_once("mod_room-reservation/mod_roomReservationPage.inc");
-require_once("mod_room-reservation/mod_roomReservationBookingTable.inc");
-require_once("mod_room-reservation/mod_roomReservationBookingsManager.inc");
-require_once("mod_room-reservation/mod_roomReservationConfig.inc");
-
-/**
- * Page that shows the booking table
- * @todo document, don't forget GET parameters 
- */
-class mod_roomReservationBookingPage extends mod_roomReservationPage {
-  
-       /** (mod_roomReservationConfig) Reference to the configuration object */
-  protected $oCfg;
-  /** 
-   * (mod_roomReservationRoomsManager) Reference to the rooms manager object 
-   */
-  protected $oRm;
-  /** 
-   * (mod_roomReservationBookingsManager) Reference to the bookings manager 
-   * object
-   */
-  protected $oBm;
-  /** (timestamp) Starting date of the booking table */
-  protected $tsStart;
-  /** (int) Name of the room to show in the booking table */
-  protected $strRoom;
-  
-  /** (mod_roomReservationBookingTable) The booking table */
-  protected $oBt;
-  
-  /***************************************************************************/
-  /**
-   * @name Constructor
-   * @{
-   * Constructor
-   * @param $oCfg (mod_roomReservationConfig) Reference to the configuration
-   *  object
-   * @param $oRm (mod_roomReservationRoomsManager) Reference to the rooms
-   *  manager object
-   * @param $oBm (mod_roomReservationBookingsManager) Reference to the
-   *  bookings manager object
-   * @return mod_roomReservationBookingPage
-   */
-  public function __construct(mod_roomReservationConfig &$oCfg, 
-    mod_roomReservationRoomsManager &$oRm,
-    mod_roomReservationBookingsManager &$oBm) {
-    $this->oCfg = $oCfg;
-    $this->oRm = $oRm;
-    $this->oBm = $oBm;
-
-    // create the booking table here, so the CSS is already added
-    /** @todo maybe move it into beforeAddCSS()... ? */
-    $this->oBt = new mod_roomReservationBookingsTable($this->oCfg, $this->oRm,
-      $this->oBm, "?bookingpage[action]=edit", "?bookingpage[action]=delete");
-
-    parent::__construct($oCfg);
-    $this->setTitle(_c("Room Reservation Schedule"));
-    $this->setIcon("mod_room-reservation_index");
-  }
-
-  /***************************************************************************/
-  /**
-   * @}
-   * @name Initialization
-   * @{
-   */
-
-  /**
-   * Process the REQUEST variables and preset the some variables
-   * @return void
-   */
-  protected function processRequestVariables() {
-    // take all settings from the booking table
-    $this->setRoom($this->oBt->getRoom());
-    $this->setStart($this->oBt->getDate());
-  }
-  
-  /***************************************************************************/
-  /**
-   * @}
-   * @name Access to attributes
-   * @{
-   */
-  
-  /**
-   * Set the starting date
-   * @param $ts (timestamp)
-   */
-  public function setStart($ts) { $this->tsStart = intval($ts); }
-
-  /**
-   * Set the room to show in the booking table
-   * @param $str (string) Name of the room
-   */
-  public function setRoom($str) { $this->strRoom = $str; }
-
-  /**
-   * Get the starting date
-   * @return int
-   */
-  public function getStart() { return intval($this->tsStart); }
-  
-  /**
-   * Get the name of the room to show in the booking table
-   * @return string
-   */
-  public function getRoom() { return $this->strRoom; }
-  
-  /***************************************************************************/
-  /**
-   * @}
-   * @name Output
-   * @{
-   */
-  
-  /**
-   * Show the page.
-   * @return void
-   */
-  public function doShow() {
-    // Protect access
-    if(!$this->oCfg->userCanView()) {
-      echo sprintf("<p class='err'>%s</p>", 
-        MOD_ROOM_RESERVATION_ERROR_ACCESS_DENIED);
-      _PageBlue();
-      die();
-    }
-    
-    Title(_c("room-reservation:Book rooms"));
-    
-    // Form for room selection
-    /** @todo checkbox for recurring booking */ 
-    echo sprintf("<form name='room' method='get' action='%s'>",
-      $_SERVER["PHP_SELF"]);
-    echo sprintf("<input type='hidden' name='mod_roomReservationBookingTable".
-      "[date]' value='%d' />\n", $this->getStart());
-    
-    // Show rooms only if it is whitelisted
-    try {
-      $aor = $this->oCfg->getWhitelistedRooms();
-    } catch(SQLException $e) {
-      trigger_error($e->getMessage());
-    }
-    if(count($aor) > 0) {
-      echo _c("room-reservation:Room:") . sprintf(" <select onchange=".
-        "'document.forms[\"room\"].submit()' width='250' ".
-       "name='mod_roomReservationBookingTable[room]'>\n", $this->getStart());
-      foreach($aor as $or) {
-        // note to myself: no qu() here, seems this is being done automagically
-        echo sprintf("<option value='%s'%s>%s</option>\n", $or->getName(),
-          ($or->getName() == $this->getRoom()) ? " selected='selected'" : "",
-          $or->getName());
-      }
-      echo sprintf("</select>&nbsp;<%s value='%s' /></form><p />\n",
-        $GLOBALS["stdbtn"], _("Change"));
-    } else {
-      printf("<p>%s</p>\n", _c("room-reservation:No rooms have been ".
-       "configured yet."));
-      return;
-    }
-        
-    // Print line with next 5 or so weeks
-    $strSep = "&nbsp;| ";
-    $strLink = sprintf("<a href='%s?mod_roomReservationBookingTable[date]=%%d".
-       "&mod_roomReservationBookingTable[room]=%%s'>%%s</a>",
-      $_SERVER["PHP_SELF"]);
-    echo "<p>".sprintf($strLink, time(), qu($this->getRoom()),
-      _c("room-reservation:Current Week")) . $strSep;
-    echo sprintf($strLink, strtotime("1 week ago", $this->getStart()),
-      qu($this->getRoom()), _c("room-reservation:&lt; Back")) . $strSep;
-    echo sprintf("<b>%s</b>", _sprintf_ord(_c("room-reservation:%d# week"), 
-      date("W", $this->getStart()))) . $strSep;
-    for($i = 1; $i <= 5; $i++) {
-      $nNextWeek = strtotime("$i week", $this->getStart());
-      echo sprintf($strLink, $nNextWeek, qu($this->getRoom()), _sprintf_ord(
-        _c("room-reservation:%d# week"), date("W", $nNextWeek)));
-      echo $strSep;
-    }
-    echo sprintf($strLink, strtotime("1 week", $this->getStart()), 
-      qu($this->getRoom()), _c("room-reservation:Next &gt;"))."</p>\n";
-    
-    $this->oBt->show();
-  }
-}
-?>
diff --git a/includes/mod_roomReservationBookingTable.inc b/includes/mod_roomReservationBookingTable.inc
deleted file mode 100644 (file)
index 8d017f5..0000000
+++ /dev/null
@@ -1,783 +0,0 @@
-<?php
-/**
- * @file mod_roomReservationBookingTable.inc
- * A timetable-like representation of bookings
- * @author Roland Hieber (roland.hieber@wilhelm-gym.net)
- * @date 03.02.2008
- *
- * Copyright © 2007 Roland Hieber
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-require_once("mod_room-reservation/mod_roomReservationConfig.inc");
-require_once("mod_room-reservation/mod_roomReservationBookingsManager.inc");
-require_once("mod_room-reservation/mod_roomReservationRoomsManager.inc");
-
-/*****************************************************************************/
-/**
- * @page bookingtable_actions Actions of a mod_roomReservationBookingTable
- *  instance
- * @{
- * The following constants describe the actions that a
- * mod_roomReservationBookingTable instance can handle. They are used in
- * processRequestVariables() to determine the action that should be done when
- * the table is shown.
- */
-/** Show the booking table (default action) */
-define("MOD_ROOM_RESERVATION_BT_ACTION_SHOW", 0);
-/** Show the form for a new booking */
-define("MOD_ROOM_RESERVATION_BT_ACTION_BOOK", 1);
-/** The booking form has been submitted, process the booking */
-define("MOD_ROOM_RESERVATION_BT_ACTION_SUBMIT", 2);
-/** Edit a booking */
-define("MOD_ROOM_RESERVATION_BT_ACTION_EDIT", 3);
-/** Show the deletion form */
-define("MOD_ROOM_RESERVATION_BT_ACTION_DELETE", 4);
-/** The deletion form has been submitted, delete the booking */
-define("MOD_ROOM_RESERVATION_BT_ACTION_SUBMITDELETE", 5);
-/** @} */
-
-/*****************************************************************************/
-/**
- * @page bookingtable_printbooking_flags Flags for
- *  mod_roomReservationBookingTable::printBooking
- * @{
- * The following constants describe the flags for the second parameter of
- * mod_roomReservationBookingTable::printBooking().
- */
-/** 
- * This booking is new. New bookings are printed with a different background
- * color.
- */
-define("MOD_ROOM_RESERVATION_BTPB_NEW", 2);
-/** This booking is requested for deletion. Show delete button. */
-define("MOD_ROOM_RESERVATION_BTPB_DELETE", 4);
-/** @} */
-
-/*****************************************************************************/
-/**
- * A timetable-like representation of bookings
- * @todo document
- */
-class mod_roomReservationBookingsTable /* extends mclWidget */ {
-
-  /** (mod_roomReservationConfig) Reference to the configuration object */
-  protected $oCfg;
-  /**
-   * (mod_roomReservationRoomsManager) Reference to the rooms manager object
-   */
-  protected $oRm;
-  /**
-   * (mod_roomReservationBookingsManager) Reference to the bookings manager
-   * object
-   */
-  protected $oBm;
-  /**
-   * (constant) The action to be performed.
-   * See @ref bookingtable_actions for a list of possible values.
-   */
-  protected $cAction;
-  /**
-        * (timestamp) The date of the requested booking or the date to show in the
-        * booking table
-        */
-  protected $tsDate;
-  /**
-   * (string) The name of the room of the requested booking or the room to be
-   * shown in the booking table
-   */
-  protected $strRoom;
-  /** (int) The starting timeslice of the requested booking */
-  protected $nTsFirst;
-  /** (int) The ending timeslice of the requested booking */
-  protected $nTsLast;
-  /** (string) The reason of the requested booking */
-  protected $strReason;
-  /** (int) UID of the booking to be deleted / edited */
-  protected $nDeleteUid;
-  /** (string) Value of the button that the user clicked */
-  protected $strSubmitButtonValue;
-  /** (string) Account of the owner, POST data */
-  protected $strPostAccount;
-  /** (int) recurrence interval, POST data */
-  protected $nPostInterval;
-  /** (string) Array of error messages */
-  protected $asErrors = array();
-  
-  /***************************************************************************/
-  /**
-   * @name Constructor
-   * @{
-   * Constructor
-   * @param $oCfg (reference to mod_roomReservationConfig) Reference to the
-   *  configuration
-   * @param $oRm (reference to mod_roomReservationRoomsManager) Reference to
-   *  the rooms manager object
-   * @param $oBm (reference to mod_roomReservationBookingsManager) Reference
-   *  to the bookings manager object
-   * @return mod_roomReservationBookingTable
-   */
-  public function __construct(mod_roomReservationConfig &$oCfg,
-    mod_roomReservationRoomsManager &$oRm,
-    mod_roomReservationBookingsManager &$oBm) {
-    $this->oCfg = $oCfg;
-    $this->oRm = $oRm;
-    $this->oBm = $oBm;
-   
-    try {
-      $this->processRequestVariables();
-    } catch(Exception $e) {
-      $this->asErrors[] = $e->getMessage();
-    }
-    $this->addCSS();
-  }
-
-  /***************************************************************************/
-  /**
-   * @}
-   * @name Initialization
-   * @{
-   */
-
-  /**
-   * Process the REQUEST variables and preset the some variables. Throws an
-   * exception if the room provided by the GET data is not allowed for booking
-   * @return void
-   * @throws Exception
-   */
-  protected function processRequestVariables() {
-    
-    // default values
-    $aoRooms = $this->oCfg->getWhitelistedRooms();
-    if(count($aoRooms) < 1) {
-      $this->setRoom("");
-    } else {
-      $this->setRoom($aoRooms[0]->getName());
-    }
-    // if weekends are not shown, show the next week already on saturday
-    if(!$this->oCfg->isShowWeekend() and date("w") == 6) {
-      $this->setDate(strtotime("monday"));
-    } else {
-      $this->setDate(time());
-    }
-    $this->setAction(MOD_ROOM_RESERVATION_BT_ACTION_SHOW);
-    $this->nPostInterval = 0;
-   
-    // handle GET parameters
-    if(isset($_GET["mod_roomReservationBookingTable"])) {
-      $ga = isset($_GET["mod_roomReservationBookingTable"]["action"]) ?
-        $_GET["mod_roomReservationBookingTable"]["action"] : "";
-      $this->setAction(($ga == "book") ?
-        MOD_ROOM_RESERVATION_BT_ACTION_BOOK : (($ga == "edit") ?
-        MOD_ROOM_RESERVATION_BT_ACTION_EDIT : (($ga == "delete") ?
-        MOD_ROOM_RESERVATION_BT_ACTION_DELETE : (($ga == "submit") ?
-        MOD_ROOM_RESERVATION_BT_ACTION_SUBMIT : (($ga == "submitdelete") ?
-        MOD_ROOM_RESERVATION_BT_ACTION_SUBMITDELETE :
-        MOD_ROOM_RESERVATION_BT_ACTION_SHOW)))));
-      $this->setDate(isset($_GET["mod_roomReservationBookingTable"]["date"]) ?
-        intval($_GET["mod_roomReservationBookingTable"]["date"]) : time());
-      if(isset($_GET["mod_roomReservationBookingTable"]["room"])) {
-        $this->setRoom($_GET["mod_roomReservationBookingTable"]["room"]);
-      }
-      $this->setTsFirst(
-        isset($_GET["mod_roomReservationBookingTable"]["tsfirst"]) ?
-        intval($_GET["mod_roomReservationBookingTable"]["tsfirst"]) : 0);
-      $this->setTsLast($this->getTsFirst());
-     
-      // if deletion form is requested, set the right date, room etc.
-      if($this->getAction() == MOD_ROOM_RESERVATION_BT_ACTION_DELETE) {
-        if(isset($_GET["mod_roomReservationBookingTable"]["uid"]) &&
-          $_GET["mod_roomReservationBookingTable"]["uid"] >= 0) {
-          $this->setUid(intval(
-            $_GET["mod_roomReservationBookingTable"]["uid"]));
-        } else {
-          trigger_error("The UID is invalid.", E_USER_ERROR);
-        }
-        $ob = mod_roomReservationBookingsManager::getBookingByUid(
-          $this->getUid());
-        $this->setRoom($ob->getRoom());
-        if($ob->getInterval() > 0) {
-          // don't show the first date when the booking was created, but the
-          // date of the page where the user clicked the delete button
-          $this->setDate(
-            isset($_GET["mod_roomReservationBookingTable"]["date"]) ?
-            intval($_GET["mod_roomReservationBookingTable"]["date"]) : time());
-        } else {
-          $this->setDate($ob->getDate());
-        }
-        $this->setTsFirst($ob->getTsFirst());
-      }
-    }
-   
-    if(isset($_POST["mod_roomReservationBookingTable"])) {
-      if(isset($_POST["mod_roomReservationBookingTable"]["submitbooking"])) {
-        // submission of the booking form
-        // let POST variables overwrite the variables
-        $this->setDate(
-          isset($_POST["mod_roomReservationBookingTable"]["date"]) ?
-          intval($_POST["mod_roomReservationBookingTable"]["date"]) : time());
-        $this->setRoom(
-          isset($_POST["mod_roomReservationBookingTable"]["room"]) ?
-          $_POST["mod_roomReservationBookingTable"]["room"] : "");
-        $this->setTsFirst(
-          isset($_POST["mod_roomReservationBookingTable"]["tsfirst"]) ?
-          intval($_POST["mod_roomReservationBookingTable"]["tsfirst"]) : 0);
-        $this->setTsLast(
-          isset($_POST["mod_roomReservationBookingTable"]["tslast"]) ?
-          intval($_POST["mod_roomReservationBookingTable"]["tslast"]) :
-          $this->getTsFirst());
-        $this->setReason(
-          isset($_POST["mod_roomReservationBookingTable"]["reason"]) ?
-          $_POST["mod_roomReservationBookingTable"]["reason"] : "");
-        $this->nPostInterval =
-          isset($_POST["mod_roomReservationBookingTable"]["interval"]) ?
-          intval($_POST["mod_roomReservationBookingTable"]["interval"]) : 0;
-        $this->strPostAccount =
-          isset($_POST["mod_roomReservationBookingTable"]["account"]) ?
-          $_POST["mod_roomReservationBookingTable"]["account"] : "";
-      }
-     
-      if(isset($_POST["mod_roomReservationBookingTable"]["submitdelete"])) {
-        // submission of the deletion form
-        if(isset($_POST["mod_roomReservationBookingTable"]["uid"]) &&
-          $_POST["mod_roomReservationBookingTable"]["uid"] >= 0) {
-          $this->setUid(
-            intval($_POST["mod_roomReservationBookingTable"]["uid"]));
-        } else {
-          trigger_error("The UID is invalid.", E_USER_ERROR);
-        }
-        // set the right date, room etc.
-        $ob = mod_roomReservationBookingsManager::getBookingByUid(
-          $this->getUid());
-        $this->setRoom($ob->getRoom());
-        $this->setDate($ob->getDate());
-        $this->setTsFirst($ob->getTsFirst());
-        $this->setSubmitButtonValue(isset(
-          $_POST["mod_roomReservationBookingTable"]["submitdelete"]) ?
-          $_POST["mod_roomReservationBookingTable"]["submitdelete"] : "");
-      }
-    }
-  }
-  /***************************************************************************/
-  /**
-   * @}
-   * @name Access to attributes
-   * @{
-   */
-
-  /**
-   * Set the action that should be done
-   * @param $c (constant) See @ref bookingtable_actions for possible values
-   */
-  protected function setAction($c) { $this->cAction = intval($c); }
-  /**
-   * Set the starting timeslice of the requested booking
-   * @param $n (int)
-   */
-  protected function setTsFirst($n) { $this->nTsFirst = intval($n); }
-
-  /**
-   * Set the ending timeslice of the requested booking
-   * @param $n (int)
-   */
-  protected function setTsLast($n) { $this->nTsLast = intval($n); }
-  /**
-   * Set the date of the requested booking or the date to be shown in the
-   * booking table
-   * @param $ts (timestamp)
-   */
-  public function setDate($ts) { $this->tsDate = intval($ts); }
-  /**
-   * Set the room of the requested booking or the room to be shown in the
-   * booking table. Throws an Exception if the room is not allowed for booking.
-   * @param $str (string)
-   * @throws Exception
-   */
-  protected function setRoom($str) {
-    // only allow whitelisted rooms
-    if($this->oCfg->isRoomWhitelisted($str)) {
-      $this->strRoom = $str;
-    } else {
-      throw new Exception(_c("room-reservation:This room is not available ".
-       "for booking."));
-    }
-  }
-  /**
-   * Set the reason of the requested booking
-   * @param $str (string)
-   */
-  protected function setReason($str) { $this->strReason = $str; }
-
-  /**
-   * Set the UID of the booking to be deleted / edited
-   * @param $n (int)
-   */
-  protected function setUid($n) { $this->nUid = intval($n); }
-  /**
-   * Set the value of the submit button that the user clicked
-   * @param $str (string)
-   */
-  protected function setSubmitButtonValue($str) {
-    $this->strSubmitButtonValue = $str;
-  }
-  /**
-   * Get the name of the room of the requested booking or the room to show in
-   * the booking table
-   * @return string
-   */
-  public function getRoom() { return $this->strRoom; }
-   
-  /**
-   * Get the action that should be done
-   * @return constant See @ref bookingtable_actions for possible values
-   */
-  public function getAction() { return $this->cAction; }
-  /**
-   * Get the the starting timeslice of the requested booking
-   * @return int
-   */
-  public function getTsFirst() { return $this->nTsFirst; }
-
-  /**
-   * Get the the ending timeslice of the requested booking
-   * @return int
-   */
-  public function getTsLast() { return $this->nTsLast; }
-
-  /**
-   * Get the the date of the requested booking or the date to be shown in the
-   * booking table
-   * @return timestamp
-   */
-  public function getDate() { return $this->tsDate; }
-  /**
-   * Get the the reason of the requested booking
-   * @return string
-   */
-  public function getReason() { return $this->strReason; }
-  /**
-   * Get the UID of the booking to be deleted / edited
-   * @return int
-   */
-  public function getUid() { return $this->nUid; }
-  /**
-   * Get the value of the submit button that the user clicked
-   * @return string
-   */
-  public function getSubmitButtonValue() {
-    return $this->strSubmitButtonValue;
-  }
-  /***************************************************************************/
-  /**
-   * @}
-   * @name Output
-   * @{
-   */
-  /**
-   * Add the CSS rules needed for this page
-   * @return void
-   */
-  protected function addCSS() {
-    $strCss = <<<CSS
-#mod_roomReservationBookingTable .msg { font-weight:800; }
-#mod_roomReservationBookingTable td {
-  vertical-align: middle;
-  height: 5em;
-  border: 1px solid white;
-  padding:0.4em;
-}
-#mod_roomReservationBookingTable td.booking { background-color:#5276AB; }
-#mod_roomReservationBookingTable td.new { background-color:#008015; }
-#mod_roomReservationBookingTable td.recurring { background-color:#1C4174; }
-#mod_roomReservationBookingTable td.recurringnew { background-color:#006010; }
-#mod_roomReservationBookingTable td.heading { font-weight:bold; height:3em; }
-#mod_roomReservationBookingTable td.lesson { width:9%; }
-#mod_roomReservationBookingTable td.today { font-style:italic; }
-#mod_roomReservationBookingTable {
-  border:1px solid white;
-  border-collapse:collapse;
-  text-align:center; width:100%;
-}
-CSS;
-    if($this->oCfg->isShowWeekend()) {
-      $strCss .= "#mod_roomReservationBookingTable td.cell { width:13%; }";
-    } else {
-      $strCss .= "#mod_roomReservationBookingTable td.cell { width:18.2%; }";
-    }
-    rrAddCss($strCss);
-  }
-  /**
-   * Show the timetable
-   * @return void
-   * @throws AccessException
-   * @todo increase the height of the cells a little
-   */
-  public function show() {
-    // Protect access
-    if(!$this->oCfg->userCanView()) {
-      throw new AccessException(MOD_ROOM_RESERVATION_ERROR_ACCESS_DENIED);
-      return;
-    }
-    
-    // print error messages and return if there are any
-    if(count($this->asErrors) > 0) {
-      printf("<p class='err'>%s</p>", join("<br />\n", $this->asErrors));
-      return;
-    }
-    
-    // Print the header with the days
-    $ncTs = sizeof($this->oCfg->getTimeslices());
-    $nDays = ($this->oCfg->isShowWeekend()) ? 7 : 5;
-   
-    echo "<table id='mod_roomReservationBookingTable'><tr>";
-
-    // Print header with day names
-    echo "<td class='heading' />";
-    for($ts = rrGetMonday($this->getDate()), $i=0; $i < $nDays;
-      $ts = strtotime("1 day", $ts), $i++) {
-      // Use a different color for the current day
-      $strClass = "heading";
-      $strTitle = strftime("%A<br />%x", $ts);
-      if(date("Ymd") === date("Ymd", $ts)) {
-        $strClass .= " today";
-        $strTitle .= " "._c("room-reservation:(today)");
-      }
-      echo sprintf("<td class='%s'>%s</td>", $strClass, $strTitle);
-    }
-    echo "</tr>\n";
-
-    // Print timetable
-    // To take care of bookings with more than one timeslice, we use an array
-    // that tells us which cell in the current column is the next to fill
-    $anNextRow = array_fill(0, $nDays, 0);
-    // Iterate over the timeslices
-    for($nTs = 0; $nTs < $ncTs; $nTs++) {
-      $strLessons = $this->oCfg->isShowLessons() ?_sprintf_ord(
-        _c("room-reservation:%s# lesson"), $nTs + 1) . "<br />" : "";
-      $oTs = $this->oCfg->getTimeslice($nTs);
-      $strTs = sprintf("%s - %s", gmstrftime(_("%#I:%M %p"), $oTs->getBegin()),
-        gmstrftime(_("%#I:%M %p"), $oTs->getEnd()));
-      // First column: Lesson
-      echo sprintf("<tr><td class='lesson'>%s</td>", $strLessons . $strTs);
-     
-      // Iterate over the days
-      for($ts = rrGetMonday($this->getDate()), $i = 0; $i <= $nDays;
-        $ts = strtotime("1 day", $ts), $i++) {
-        // Don't print if there is a spanning booking on the current cell
-        if(isset($anNextRow[$i]) && $anNextRow[$i] == $nTs) {
-          if(($ob = $this->oBm->getBookingByTimeslice($this->getRoom(), $ts,
-            $nTs)) !== null) {
-            // a booking exists here
-            // print booking or deletion form or handle the deletion form
-
-            // deletion form is requested:
-            if(($this->getAction() == MOD_ROOM_RESERVATION_BT_ACTION_DELETE) &&
-              (date("Ymd", $this->getDate()) == date("Ymd", $ts)) &&
-              ($this->getTsFirst() == $nTs) &&
-              ($this->getRoom() == $this->getRoom())) {
-              $anNextRow[$i] += $this->printBooking($nTs, $ts, $ob,
-                MOD_ROOM_RESERVATION_BTPB_DELETE);
-
-            // deletion form is submitted:
-            } else if(($this->getAction() == 
-              MOD_ROOM_RESERVATION_BT_ACTION_SUBMITDELETE) &&
-              (date("Ymd", $this->getDate()) == date("Ymd", $ts)) &&
-              ($this->getTsFirst() == $nTs) &&
-              ($this->getRoom() == $this->getRoom())) {
-              if($this->getSubmitButtonValue() == _("Delete")) {
-                // the user clicked the "delete" button
-                $bSuccess = false;
-                try {
-                  $bSuccess = $this->oBm->delete($this->getUid());
-                } catch(Exception $e) {
-                  $anNextRow[$i] += $this->printBooking($nTs, $ts, $ob, 0,
-                    array($e->getMessage()));
-                }
-                // print booking link and a success message
-                if($bSuccess) {
-                  $anNextRow[$i] += $this->printBookingLink($nTs, $ts,
-                    array(_c("room-reservation:The booking was deleted.")));
-                }
-              } else {
-                // the user cancelled the request
-                $anNextRow[$i] += $this->printBooking($nTs, $ts, $ob);
-              }
-           
-            // Something else -- print booking
-            } else {
-              $anNextRow[$i] += $this->printBooking($nTs, $ts, $ob);
-            }
-          } else {
-            // no booking is here
-            // print booking link, booking form or handle booking form
-            $asErrors = array();
-           
-            // booking form is requested:
-            if(($this->getAction() == MOD_ROOM_RESERVATION_BT_ACTION_BOOK) &&
-              (date("Ymd", $this->getDate()) == date("Ymd", $ts)) &&
-              ($this->getTsFirst() == $nTs) &&
-              ($this->getRoom() == $this->getRoom())) {
-              $anNextRow[$i] += $this->printBookingForm($nTs, $ts, $asErrors);
-             
-            // booking form is submitted:
-            } else if(($this->getAction() == 
-              MOD_ROOM_RESERVATION_BT_ACTION_SUBMIT) &&
-              // only handle the request if the form was in the current cell
-              (date("Ymd", $this->getDate()) == date("Ymd", $ts)) &&
-              ($this->getTsFirst() == $nTs) &&
-              ($this->getRoom() == $this->getRoom())) {
-             
-              // try writing the booking to the database
-              $nNewUid = -1;
-              $oNewBooking = new mod_roomReservationBooking($this->getRoom(),
-                $this->getDate(), $this->getTsFirst(), $this->getTsLast(),
-                (trim($this->strPostAccount) == "") ? $_SESSION["act"] : 
-                $this->strPostAccount, $this->getReason(), 
-                $this->nPostInterval);
-              try {
-                $nNewUid = $this->oBm->write($oNewBooking);
-              } catch(Exception $s) {
-                // print the booking form again with the user's input
-                // @todo check for overlapping bookings and print them
-                $asErrors[] = $s->getMessage();
-                $anNextRow[$i] += $this->printBookingForm($nTs, $ts,
-                  $asErrors);
-              }
-              if($nNewUid > 0) {
-                // print new booking and increment the "next row" variable by
-                // the current span
-                $oNewBooking->setUid($nNewUid);
-                $anNextRow[$i] += $this->printBooking($nTs, $ts, $oNewBooking,
-                  MOD_ROOM_RESERVATION_BTPB_NEW);
-              }
-
-            // Something else -- print booking link:
-            } else {
-              $anNextRow[$i] += $this->printBookingLink($nTs, $ts);
-            }
-          }
-        }
-      }
-      echo "</tr>\n";
-    }
-    echo "</table><br />";
-  }
-
-  /**
-   * Print a single booking in the booking table.
-   * @param $nTs (int) current timeslice
-   * @param $ts (timestamp) current date
-   * @param $ob (mod_roomReservationBooking) the booking
-   * @param $cFlags (constant) Flags,
-   *   See @ref bookingtable_printbooking_flags for more information.
-   * @param $asMsgs (array of strings) Additional messages to be printed
-   *  inside the cell, one array element per message
-   * @return (int) the span of the booking
-   */
-  protected function printBooking($nTs, $ts, mod_roomReservationBooking $ob,
-    $cFlags = 0, $asMsgs = array()) {
-    $strAfter = "";
-    $strBefore = "";
-
-    // messages
-    if(count($asMsgs) > 0) {
-      $strBefore .= "<p class='msg'>".nl2br(q(join("\n", $asMsgs)))."</p>\n";
-    }
-     
-    // calculate the timespan of the current booking
-    $nSpan = $ob->getTsLast() - $ob->getTsFirst() + 1;
-   
-    if(($cFlags & MOD_ROOM_RESERVATION_BTPB_DELETE) == 
-      MOD_ROOM_RESERVATION_BTPB_DELETE) {
-
-      // Restrict access
-      if(!($this->oBm->userIsOwner($ob->getUid()) or
-        $this->oCfg->userIsAdmin())) {
-        $strBefore .= "<p class='msg'>" . 
-          MOD_ROOM_RESERVATION_ERROR_ACCESS_DENIED . "</p>\n";
-        #return $nSpan;
-      } else {
-        // print delete form
-        $strWarning = sprintf("<div>%s%s</div>", icon("dlg-warn",
-          array("bg" =>"gb")), _c("room-reservation:<b>Attention:</b> This ".
-          "booking is a recurring booking. If you delete it, the period will ".
-          "be deallocated for <b>every week</b>, not just this single week!"));
-        $strAfter .= sprintf("<p name='form' id='form' style='".
-               "text-align:center'><form action='%s?".
-               "mod_roomReservationBookingTable[action]=submitdelete#form' ".
-          "method='post'>%s%s<br /><%s name='mod_roomReservationBookingTable".
-          "[submitdelete]' value='%s' /> <%s name='".
-          "mod_roomReservationBookingTable[submitdelete]' value='%s' />".
-          "<input type='hidden' name='mod_roomReservationBookingTable[uid]' ".
-          "value='%d' /></form></p>", $_SERVER["PHP_SELF"],
-          _c("room-reservation:Delete this booking?"),
-          ($ob->getInterval() > 0 ? $strWarning : ""), $GLOBALS["smlbtn"],
-          _("Delete"), $GLOBALS["smlbtn"], _("Cancel"), $ob->getUid(),
-          $this->getRoom(), $this->getDate());
-      }
-    } else {
-      // delete and edit links, show only if user is allowed to
-      if($this->oBm->userIsOwner($ob->getUid()) ||
-        $this->oCfg->userIsAdmin()) {
-        /** @todo edit form */
-        $strAfter .= sprintf("<br />(<!-- <a href='%s?".
-          "mod_roomReservationBookingTable[action]=edit&".
-          "mod_roomReservationBookingTable[uid]=%d&".
-          "mod_roomReservationBookingTable[date]=%d#form' title='%s'>%s</a>, -->".
-          "<a href='%s?mod_roomReservationBookingTable[action]=delete&".
-          "mod_roomReservationBookingTable[uid]=%d&".
-          "mod_roomReservationBookingTable[date]=%d#form' title='%s'>%s</a>)",
-          $_SERVER["PHP_SELF"], $ob->getUid(), $ts,
-          _c("room-reservation:Edit this booking"),
-          _c("room-reservation:edit"), $_SERVER["PHP_SELF"], $ob->getUid(),
-          $ts, _c("room-reservation:Delete this booking"),
-          _c("room-reservation:delete"));
-      }
-    }
-       
-    // test if booking is new and should be highlighted
-    $strClass = "cell booking".($ob->getInterval() > 0 ? " recurring" : "");
-    if(($cFlags & MOD_ROOM_RESERVATION_BTPB_NEW) ==
-      MOD_ROOM_RESERVATION_BTPB_NEW) {
-      $strClass .= " new";
-    }
-    // Use a different style for the current day
-    $strClass .= (date("Ymd", $ob->getDate()) == date("Ymd") ? " today" : "");
-    /** @todo: add ?subject=... to mailto link */
-    echo sprintf("<td rowspan='%d' class='%s'>%s<a %s>%s</a><br />%s%s</td>\n",
-      $nSpan, $strClass, $strBefore, mailto($ob->getAct()),
-      q(getRealUserName($ob->getAct())), q($ob->getReason()), $strAfter);
-     
-    return $nSpan;
-  }
-
-  /**
-   * Print the booking form.
-   * @param $nTs (int) current timeslice
-   * @param $ts (timestamp) current date
-   * @param $asErrors (array of strings) Additional error message to be printed
-   *  inside the cell, one array element per message
-   * @return (int) the span of the booking (i.e., 1)
-   */
-  protected function printBookingForm($nTs, $ts, $asErrors = array()) {
-    // Restrict access
-    if(!($this->oCfg->userCanBook() or $this->oCfg->userIsAdmin())) {
-      printf("<td class='err'>%s</td>\n", 
-        MOD_ROOM_RESERVATION_ERROR_ACCESS_DENIED);
-      return 1;
-    }
-
-    $strErrors = "<p class='err'>".nl2br(q(join("\n", $asErrors)))."</p>";
-
-    // form to allow fixed bookings for admins
-    $sWeeklyForm = "";
-    if($this->oCfg->userIsAdmin()) {
-      $sWeeklyForm = sprintf("<label for='interval'>%s</label> %s<br />".
-       "<label for='account'>%s</label> <%s name='".
-       "mod_roomReservationBookingTable[account]' id='account' value='%s' ".
-        "size='15' /><br />", _c("room-reservation:Repetition:"), 
-        select("mod_roomReservationBookingTable[interval]",
-        $this->nPostInterval, array(0 => _c("Select:None"), 1 =>
-        _c("room-reservation:every week")), array("add" => "id='interval'")),
-        _c("room-reservation:Account, if not yourself:"), $GLOBALS["stdedt"],
-                               $this->strPostAccount);
-    }
-    
-    echo sprintf("<td name='form' id='form' style='text-align:left'>%s".
-       "<form action='%s?mod_roomReservationBookingTable[action]=".
-       "submit#form' method='post'><label for='tslast'>%s</label> %s".
-       "<br /><label for='reason'>%s</label> <%s id='reason' size='15' ".
-       "value='%s' name='mod_roomReservationBookingTable[reason]' /><br />%s".
-       "<%s name='mod_roomReservationBookingTable[submitbooking]' value='%s' />".
-       "<input type='hidden' name='mod_roomReservationBookingTable[date]' ".
-       "value='%s' /><input type='hidden' name='".
-       "mod_roomReservationBookingTable[room]' value='%s' /><input ".
-       "type='hidden' name='mod_roomReservationBookingTable[tsfirst]' ".
-       "value='%s' /></form></td>\n", (count($asErrors) > 0) ? $strErrors : "",
-      $_SERVER["PHP_SELF"], _c("room-reservation:until:"),
-      select("mod_roomReservationBookingTable[tslast]", $this->getTsLast(),
-      $this->oCfg->getTimesliceEndings(true)), _c("room-reservation:Reason:"),
-      $GLOBALS["stdedt"], $this->getReason(), $sWeeklyForm, $GLOBALS["smlbtn"],
-      _c("room-reservation:Book"), $this->getDate(), $this->getRoom(),
-      $this->getTsFirst());
-      return 1;
-  }
-  /**
-   * Print the booking link
-   * @param $nTs (int) current timeslice
-   * @param $ts (timestamp) current date
-   * @param $asMsgs (array of strings) Additional messages to be printed
-   *  inside the cell, one array element per message
-   * @return (int) the span of the booking (i.e., 1)
-   */
-  protected function printBookingLink($nTs, $ts, $asMsgs = array()) {
-    
-    // Restrict access
-    if(!($this->oCfg->userCanBook() or $this->oCfg->userIsAdmin())) {
-      echo "<td />\n";
-      return 1;
-    }
-
-    // messages
-    $strBefore = "";
-    if(count($asMsgs) > 0) {
-      $strBefore .= "<p class='msg'>".join("<br />", $asMsgs)."</p>\n";
-    }
-   
-    // print link to booking if the timeslice is later than now
-    $oTs = $this->oCfg->getTimeslice($nTs);
-    // note: only the timeslices are in GMT!
-    $tsCur = strtotime(date("Y-m-d ", $ts) . gmdate(" G:i",
-      $oTs->getEnd()));
-    if($tsCur > time()) {
-      $strURL = $_SERVER["PHP_SELF"] .
-        sprintf("?mod_roomReservationBookingTable[action]=book&".
-        "mod_roomReservationBookingTable[date]=%d&".
-        "mod_roomReservationBookingTable[room]=%s&".
-        "mod_roomReservationBookingTable[tsfirst]=%d#form", $ts,
-        qu($this->getRoom()), $nTs);
-      echo sprintf("<td class='cell'>%s<a href='%s' title='%s'>%s</a></td>\n",
-        $strBefore, $strURL, _c("room-reservation:Book this room from here"),
-        _c("room-reservation:(Book from here)"));
-    } else {
-      // only print the messages
-      echo sprintf("<td name='form' id='form' class='cell'>%s</td>\n",
-        $strBefore);
-    }
-    return 1;
-  }
-  /** @} */
-}
-?>
diff --git a/includes/mod_roomReservationBookingsManager.inc b/includes/mod_roomReservationBookingsManager.inc
deleted file mode 100644 (file)
index 124068d..0000000
+++ /dev/null
@@ -1,274 +0,0 @@
-<?php
-/**
- * @file mod_roomReservationBookingsManager.inc
- * Class to manage a set of bookings
- * @author Roland Hieber (roland.hieber@wilhelm-gym.net)
- * @date 23.11.2007
- * 
- * Copyright © 2007 Roland Hieber
- * 
- * Permission is hereby granted, free of charge, to any person obtaining
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-require_once("sec/secure.inc");
-require_once("functions.inc");
-require_once("mod_room-reservation/mod_roomReservationConfig.inc");
-require_once("mod_room-reservation/mod_roomReservationBooking.inc");
-require_once("format.inc");
-
-db_query("SET DATESTYLE = ISO;");
-
-/**
- * Management of a set of bookings
- * @todo finish, document
- */
-class mod_roomReservationBookingsManager {
-
-  /** (mod_roomReservationConfig) Reference to the configuration object */
-  protected $oCfg;
-  
-  /***************************************************************************/
-  /**
-   * @name Constructor
-   * @{
-   * Constructor.
-   * @param $oCfg (mod_roomReservationConfig) Reference to the configuration
-   * @return mod_roomReservationBookingsManager
-   */
-  function __construct(mod_roomReservationConfig &$oCfg) {
-    $this->oCfg = $oCfg;
-  }
-  
-  /***************************************************************************/
-  /**
-   * @}
-   * @name Retrieving bookings
-   * @{
-   */
-
-  /**
-   * Fetch a booking with the given unique ID from the SQL table
-   * @param $nUid (int) Unique ID of the booking
-   * @return mod_roomReservationBooking
-   */
-  public static function getBookingByUid($nUid) {
-    $h = db_query("SELECT * FROM mod_roomreservation_bookings WHERE rrb_uid = $1;", $nUid);
-    $a = pg_fetch_array($h);
-    $o = new mod_roomReservationBooking($a["rrb_room"], strtotime($a["rrb_date"]),
-      intval($a["rrb_tsfirst"]), intval($a["rrb_tslast"]), $a["rrb_act"],
-      $a["rrb_reason"], intval($a["rrb_interval"]));
-    $o->setUid(intval($a["rrb_uid"]));
-    return $o;
-  }
-  
-  /**
-   * Test if there is a booking which takes place on the specified position at
-   * the specified date.
-   * @param $strRoom (string) Name of the room
-   * @param $tsDate (timestamp) The date
-   * @param $nTimeslice (int) The number of the timeslice
-   * @return mod_roomReservationBooking The booking which takes place on the
-   *  specified time or <tt>null</tt> if no booking could be found.
-   */
-  public static function getBookingByTimeslice($strRoom, $tsDate,
-    $nTimeslice) {
-    $a = mod_roomReservationBookingsManager::getOverlappingBookings(
-      new mod_roomReservationBooking($strRoom, $tsDate, $nTimeslice,
-      $nTimeslice, null, null));
-    return isset($a[0]) ? $a[0] : null;
-  }
-  
-  /**
-   * Get all bookings in database which overlap with the given booking.
-   * @param $ob (mod_roomReservationBooking) New booking that should be tested
-   *  if it overlaps
-   * @return array with elements of type mod_roomReservationBooking
-   */
-  public static function getOverlappingBookings(
-    mod_roomReservationBooking $ob) {
-    // TODO: Test for bookings that only take place every n.th week (modulo n)
-    
-    // Two bookings overlap, when they are on the same day and if
-    // old beginning < new ending  AND  old ending > new beginning
-    $hQuery = db_query("SELECT * FROM mod_roomreservation_bookings WHERE ".
-      "rrb_room = $1 AND ((rrb_interval > 0 AND EXTRACT(DOW FROM rrb_date) ".
-      "= $2) OR (rrb_interval = 0 AND rrb_date = $3)) AND rrb_tsfirst <= ".
-      "$4 AND rrb_tslast >= $5 ORDER BY rrb_tsfirst;", $ob->getRoom(),
-      date("w", $ob->getDate()), date("Y-m-d", $ob->getDate()),
-      intval($ob->getTsLast()), intval($ob->getTsFirst()));
-    $aoReturn = array();
-    while($aResult = pg_fetch_array($hQuery)) {
-      $aoReturn[] = mod_roomReservationBookingsManager::getBookingByUid(
-        $aResult["rrb_uid"]);
-    }
-    return $aoReturn;
-  }
-  
-  /***************************************************************************/
-  /**
-   * @}
-   * @name Management of bookings
-   * @{
-   */
-  
-  /**
-   * Insert or update a booking in the database.
-   * The function throws an AccessException if the user was not allowed to
-   * write the booking, or an SQLException if there was an error while trying
-   * to insert or update the booking into the database.
-   * @param $ob (mod_roomReservationBooking) Booking to write to the database
-   * @return (int) The UID of the written booking
-   * @throws SQLException, AccessException
-   * @todo document
-   */
-  function write(mod_roomReservationBooking $ob) {
-    // protect access
-    if(($ob->getUid() != null and !$this->oCfg->userIsAdmin() and
-      !$this->userIsOwner($ob->nUid)) or
-      ($ob->getUid() == null and !$this->oCfg->userCanBook())) {
-      throw new AccessException(MOD_ROOM_RESERVATION_ERROR_ACCESS_DENIED);
-    }
-    
-    // test if room is whitelisted
-    if(!$this->oCfg->isRoomWhitelisted($ob->getRoom())) {
-      throw new Exception(MOD_ROOM_RESERVATION_ERROR_ROOM_NOT_WHITELISTED);
-    }
-    
-    $strWhere = null;
-    $strLog = "";
-
-    // check if everything is right and throw exceptions
-    if(trim($ob->getAct()) == "") {
-      $ob->setAct($SESSION["act"]);
-    } elseif(!isAct($ob->getAct())) {
-      throw new Exception(MOD_ROOM_RESERVATION_ERROR_NO_SUCH_ACCOUNT);
-      return false;
-    }
-    if($ob->getTsFirst() > $ob->getTsLast()) {
-      throw new SQLException(MOD_ROOM_RESERVATION_ERROR_END_BEFORE_BEGIN);
-      return false;
-    }
-    if(trim($ob->getReason()) == "") {
-      throw new SQLException(MOD_ROOM_RESERVATION_ERROR_NO_REASON);
-      return false;
-    }
-    
-    // Test for overlapping bookings
-    if($this->getOverlappingBookings($ob) != array()) {
-      throw new SQLException(MOD_ROOM_RESERVATION_ERROR_BOOKING_OVERLAPS);
-      return false;
-    }    
-    
-    // Show real times in log, but don't use the user's locale!
-    $oTsB = $this->oCfg->getTimesliceBeginnings(false);
-    $oTsE = $this->oCfg->getTimesliceEndings(false);
-    
-    // Update or insert?
-    if($ob->getUid() == null) {
-      // No UID yet, insert new booking
-      // @todo write interval and user if interval > 0
-      $strLog = sprintf("Raum „%s“ am %s von %s bis %s gebucht ".
-       "(Begründung: %s)", $ob->getRoom(), date("d\.m\.Y", $ob->getDate()),
-        gmdate("G:i", $oTsB[$ob->getTsFirst()]), gmdate("G:i",
-        $oTsE[$ob->getTsLast()]), $ob->getReason());
-    } else {
-      // Update an existing booking
-      // @todo write old and new times into log
-      $strWhere = "rs_uid = ".qdb(intval($ob->getUid()));
-      $strLog = sprintf("Buchung im Raum „%s“ auf %s von %s bis %s ".
-        "geändert (Begründung: „%s“)", $ob->getRoom(), date("d\.m\.Y",
-        $ob->getDate()), gmdate("G:i", $oTsB[$ob->getTsFirst()]), gmdate("G:i",
-        $oTsE[$ob->getTsLast()]), $ob->getReason());
-    }
-    $aPut["rrb_room"] = $ob->getRoom();
-    $aPut["rrb_date"] = date("Y\-m\-d", $ob->getDate());
-    $aPut["rrb_tsfirst"] = intval($ob->getTsFirst());
-    $aPut["rrb_tslast"] = intval($ob->getTsLast());
-    $aPut["rrb_act"] = $ob->getAct();
-    $aPut["rrb_reason"] = $ob->getReason();
-    $aPut["rrb_interval"] = intval($ob->getInterval());
-    
-    // @todo test if the foreign keys are being violated and throw an error
-    // message if neccessary
-    db_store("mod_roomreservation_bookings", $aPut, $strWhere);
-    
-    $hQuery = db_query("SELECT currval('mod_roomreservation_bookings_rrb_uid_seq');");
-    $nNewUid = pg_fetch_result($hQuery, 0, "currval");
-    
-    rrInsertLog($strLog);
-    
-    // Return new UID
-    return $nNewUid;
-  }
-  
-  /**
-   * Delete a booking from the database
-   * @param $nUid (int) Unique ID of the booking
-   * @return (bool) <tt>true</tt> on success, otherwise <tt>false</tt>.
-   * @todo test
-   */
-  public function delete($nUid) {
-    // Only administrators and owners are allowed to delete bookings
-    if(!($this->oCfg->userIsAdmin() or $this->userIsOwner($nUid))) {
-      throw new AccessException(MOD_ROOM_RESERVATION_ERROR_ACCESS_DENIED);
-      return false;
-    }
-    
-    // Don't use the user's locale!
-    $oTsB = $this->oCfg->getTimesliceBeginnings(false);
-    $oTsE = $this->oCfg->getTimesliceEndings(false);
-    $ob = $this->getBookingByUid($nUid);
-    $strLog = sprintf("Buchung in Raum „%s“ am %s von %s bis %s ".
-      "gelöscht (Begründung war: %s)", $ob->getRoom(), date("d\.m\.Y",
-      $ob->getDate()), gmdate("G:i", $oTsB[$ob->getTsFirst()]), gmdate("G:i",
-      $oTsE[$ob->getTsLast()]), $ob->getReason());
-    // Delete it from the database
-    if(!db_query("DELETE FROM mod_roomreservation_bookings WHERE ".
-       "rrb_uid = $1;", $nUid)) {
-      throw new SQLException(MOD_ROOM_RESERVATION_ERROR_SQL);
-      return false;
-    } else {
-      rrInsertLog($strLog);
-      return true;
-    }
-  }
-  
-  /**
-   * Determine if the current user is the owner of a specified error report.
-   * If this function fails, call getLastError() to get more information.
-   * @param $nID (int) Unique ID of the error report
-   * @throws SQLException
-   * @return bool
-   */
-  public static function userIsOwner($nID) {
-    if(!isset($_SESSION["act"])) {
-      return false;   // user is not logged in
-    } else {
-      $hQuery = db_query("SELECT rrb_act FROM mod_roomreservation_bookings WHERE ".
-       "rrb_uid = $1;", intval($nID));
-      if(!is_resource($hQuery)) {
-        throw new SQLException(MOD_ROOM_RESERVATION_ERROR_SQL);
-        return false;
-      }
-      $arResult = pg_fetch_array($hQuery);
-      return ($arResult["rrb_act"] == $_SESSION["act"]);
-    }
-  }
-}
-?>
diff --git a/includes/mod_roomReservationConfig.inc b/includes/mod_roomReservationConfig.inc
deleted file mode 100644 (file)
index 72b630e..0000000
+++ /dev/null
@@ -1,454 +0,0 @@
-<?php
-/**
- * @file mod_roomReservationConfig.inc 
- * Handling of the configuration file
- * @author Roland Hieber (roland.hieber@wilhelm-gym.net)
- * @date 10.01.2008
- * 
- * Copyright © 2007 Roland Hieber
- * 
- * Permission is hereby granted, free of charge, to any person obtaining
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-require_once("sec/secure.inc");
-require_once("db.inc");
-require_once("mod_room-reservation/functions.inc");
-require_once("mod_room-reservation/mod_roomReservationTimeslice.inc");
-require_once("mod_room-reservation/mod_roomReservationRoomsManager.inc");
-
-/**
- * Determines if a privilege has been assigned
- * @param $sPriv (string) Privilege to test
- * @return bool
- */
-function rrPrivilegeAssigned($sPriv) {
-  $h = db_query("SELECT act FROM privileges_assign WHERE privilege = $1;",
-    $sPriv);
-  return pg_num_rows($h) > 0;
-}
-
-/**
- * Retrieve all groups that have a privilege assigned
- * @param $strPriv (string) Privilege to test
- * @return array
- */
-function rrPrivilegedGroups($strPriv) {
-  $aReturn = array();
-  $h = db_query("SELECT act FROM privileges_assign WHERE privilege = $1 ".
-    "ORDER BY act;", $strPriv);
-  if(pg_num_rows($h) > 0) {
-    while($a = pg_fetch_array($h)) {
-      $aReturn[] = $a["act"];
-    }
-  }
-  return $aReturn;
-}
-
-/**
- * User-defined compare function to compare timeslices
- * @param $oTs1 (mod_roomReservationTimeslice)
- * @param $oTs2 (mod_roomReservationTimeslice)
- * @return (int) <tt>-1</tt> if $oTs1 begins before $oTs2,
- *  <tt>0</tt> if the $oTs1 and $oTs2 have the same beginning,
- *  <tt>1</tt> if $oTs1 begins after $oTs2.
- */
-function rrConfigSortTimeslices(mod_roomReservationTimeslice $oTs1, 
-  mod_roomReservationTimeslice $oTs2) {
-  if($oTs1->getBegin() == $oTs2->getBegin()) {
-    return 0;
-  } else {
-    return ($oTs1->getBegin() > $oTs2->getBegin()) ? 1 : -1;
-  }
-}
-
-define("MOD_ROOM_RESERVATION_CONFIGFILE_HEADER", "<?php
-/**
- * configuration file for package iserv-mod-room-reservation
- * This file is written by the configuration script. Do not change it manually.
- */\n");
-
-/*****************************************************************************/
-/**
- * Handling of the configuration file
- * @todo document
- */
-class mod_roomReservationConfig {
-  
-  /** (array of rmTimeslice's) Timeslices */
-  protected $aoTimeslices;
-  /** (bool) Determine if the weekend is shown */
-  protected $bShowWeekend;
-  /** (bool) Determine if the strings "1. lesson", "2. lesson" etc are shown */
-  protected $bShowLessons;
-  /** (array of strings) error messages */
-  protected $asMessages;
-  
-  /***************************************************************************/
-  /**
-   * @name Constructor
-   * @{
-   * Constructor.
-   * @return mod_roomReservationConfig
-   */
-  public function __construct() {
-    $this->flushTimeslices();
-    $this->setShowWeekend(false);
-    $this->setShowLessons(true);
-    $this->asMessages = array();
-    
-    $this->readConfig();
-  }
-  
-  /**
-   * **************************************************************************
-   * @}
-   * @name Access to attributes
-   * @{
-   */
-  
-       /**
-   * Add a timeslice. A check is done that the timeslices do not overlap, and
-   * in this case, an Exception is thrown.
-   * @param $oTs (mod_roomReservationTimeslice)
-   * @throws Exception
-   * @return void
-   */
-  public function addTimeslice(mod_roomReservationTimeslice $oTs) {
-    // Check for overlapping timeslices
-    foreach($this->aoTimeslices as $oOldTs) {
-      if(($oOldTs->getBegin() < $oTs->getEnd() and 
-        $oOldTs->getEnd() > $oTs->getBegin())) {
-        throw new Exception(
-          MOD_ROOM_RESERVATION_ERROR_CONFIG_OVERLAPPING_TIMESLICE);
-      }
-    }
-    $this->aoTimeslices[] = $oTs;
-    usort($this->aoTimeslices, "rrConfigSortTimeslices");
-    return;
-  }
-  
-  /**
-   * Delete a timeslice
-   * @param $oTs (mod_roomReservationTimeslice) the timeslice to delete. If
-   *  the timeslice is not found, an Exception is thrown.
-   * @throws Exception
-   * @return void
-   */
-  public function deleteTimeslice(mod_roomReservationTimeslice $oTs) {
-    for($i = 0; $i < count($this->aoTimeslices); $i++) {
-      if($this->aoTimeslices[$i]->getBegin() == $oTs->getBegin() and
-        $this->aoTimeslices[$i]->getEnd() == $oTs->getEnd()) {
-        // use array_splice because it renumbers the keys
-        array_splice($this->aoTimeslices, $i, 1);
-        return;
-      }
-    }
-    throw new Exception(MOD_ROOM_RESERVATION_ERROR_CONFIG_NO_SUCH_TIMESLICE);
-  }
-  
-  /**
-   * Delete all timeslices.
-   * @return void
-   */
-  public function flushTimeslices() { $this->aoTimeslices = array(); }
-  
-  /**
-   * Add a room to the list of rooms who can be booked. Throws an SQLException
-   * in case of an error.
-   * @param $sRoom (string) The name of the room
-   * @throws SQLException, Exception
-   * @return void
-   */
-  public function whitelistRoom($sRoom) {
-    if(!$this->isRoomWhitelisted($sRoom)) {
-      $r = db_store("mod_roomreservation_roomswhitelist",
-        array("rrr_name" => $sRoom));
-      if(!$r) {
-        throw new SQLException(MOD_ROOM_RESERVATION_ERROR_SQL);
-      } else {
-        log_insert(sprintf("Raum „%s“ für Buchungen gesperrt", $sRoom));
-      }
-    }
-  }
-
-  /**
-   * Forbid bookings for a room. Throws an SQLException in case of an error.
-   * @param $sRoom The name of the room
-   * @throws SQLException
-   */
-  public function unWhitelistRoom($sRoom) {
-    $h = db_query("DELETE FROM mod_roomreservation_roomswhitelist WHERE ".
-       "rrr_name = $1;", $sRoom);
-    if(!$h) {
-      throw new SQLException(MOD_ROOM_RESERVATION_ERROR_SQL);
-    } else {
-      log_insert(sprintf("Raum „%s“ für Buchungen zur Verfügung gestellt",
-        $sRoom));
-    }
-  }
-  
-  /**
-   * Determine if a room is allowed for booking. Throws an SQLException
-   * in case of an error.
-   * @param $sRoom (string) The name of the room
-   * @return bool
-   * @throws SQLException
-   */
-  public function isRoomWhitelisted($sRoom) {
-    $h = db_query("SELECT * FROM mod_roomreservation_roomswhitelist WHERE ".
-       "rrr_name=$1;", $sRoom);
-    if(!$h) {
-      throw new SQLException(MOD_ROOM_RESERVATION_ERROR_SQL);
-    }
-    return (pg_num_rows($h) > 0);
-  }
-
-  /**
-   * Get all rooms that are allowed for booking. Throws an SQLException
-   * in case of an error. 
-   * @throws SQLException
-   * @return array of mod_roomReservationRoomsManager objects
-   */
-  public function getWhitelistedRooms() {
-    $aor = mod_roomReservationRoomsManager::getRooms();
-    $ar = array();
-    foreach($aor as $key => $or) {
-      if($this->isRoomWhitelisted($or->getName())) {
-        $ar[] = $or;
-      }
-    }
-    return $ar;
-  }
-
-  /**
-   * Show or hide the weekend
-   * @param $b (bool)
-   */
-  public function setShowWeekend($b) { $this->bShowWeekend = ($b == true); }
-  
-  /**
-   * Show or hide the lesson strings in the booking table
-   * @param $b (bool)
-   */
-  public function setShowLessons($b) { $this->bShowLessons = ($b == true); }
-  
-  /**
-   * Add a message to the internal array of (error) messages
-   * @param $sMessage (string)
-   */
-  public function addMessage($sMessage) {
-    array_merge($this->asMessages, array($sMessage));
-  }
-  
-       /**
-   * Get all timeslices in chronological order
-   * @return array of rmTimeslice
-   */
-  public function getTimeslices() { return $this->aoTimeslices; }
-
-  /**
-   * Return the starting times of every timeslice
-   * @param $bFormat (bool) <tt>true</tt>: Format the times according to the
-   *  current locale
-   *  <tt>false</tt>: return just the timestamps
-   * @return array
-   */
-  public function getTimesliceBeginnings($bFormat = false) {
-    $aot = $this->getTimeslices();
-    $aRet = array();
-    foreach($aot as $ao) {
-      $aRet[] = $bFormat ? gmstrftime(_("%#I:%M %p"), $ao->getBegin()) : 
-        $ao->getBegin();
-    }
-    return $aRet;
-  }
-  
-  /**
-   * Return the ending times of every timeslice
-   * @param $bFormat (bool) <tt>true</tt>: Format the times according to the
-   *  current locale
-   *  <tt>false</tt>: return just the timestamps
-   * @return array
-   */
-  public function getTimesliceEndings($bFormat = false) {
-    $aot = $this->getTimeslices();
-    $aRet = array();
-    foreach($aot as $ao) {
-      $aRet[] = $bFormat ? gmstrftime(_("%#I:%M %p"), $ao->getEnd()) :
-        $ao->getEnd();
-    }
-    return $aRet;
-  }
-  
-  /**
-   * Get a timeslice
-   * @param $n (int) index of the timeslice in the array
-   * @return rmTimeslice
-   */
-  public function getTimeslice($n) { return $this->aoTimeslices[$n]; }
-  
-  /**
-   * Determine if the weekend is shown
-   * @return bool
-   */
-  public function isShowWeekend() { return ($this->bShowWeekend == true); }
-
-  /**
-   * Determine if the lesson strings in the booking table are shown
-   * @return bool
-   */
-  public function isShowLessons() { return ($this->bShowLessons == true); }
-
-  /**
-   * Determine if the current user has admin rights. This function tests 
-   * if the user is in a group which has the privilege of admin rights.
-   * @todo test
-   * @return bool
-   */
-  public function userIsAdmin() {
-    return secure_privilege("mod_roomreservation_admin");
-  }
-  
-  /**
-   * Determine if the current user can book rooms. This function tests 
-   * if the user is in a group which has the privilege to book rooms.
-   * If no group has this privilege, all users can book.
-   * @todo test
-   * @return bool
-   */
-  public function userCanBook() {
-    if(!rrPrivilegeAssigned("mod_roomreservation_book")) {
-      // If the privilege is not assigned to any group, all users can book
-      return true;
-    } else {
-      // If user is admin, it makes sense that he can book rooms ;-)
-      return secure_privilege("mod_roomreservation_book") ||
-        secure_privilege("mod_roomreservation_admin");
-    }
-  }
-  
-  /**
-   * Determine if the current user can view bookings. This function tests 
-   * if the user is in a group which has been configured as a group who
-   * can view bookings. If no groups are configured, any user can view the
-   * bookings table.
-   * @todo test
-   * @return bool
-   */
-  public function userCanView() {
-    if(!rrPrivilegeAssigned("mod_roomreservation_view")) {
-      // If the privilege is not assigned to any group, all users can view
-      return true;
-    } else {
-      // If user is admin or can book, it makes sense that he can view bookings
-      return secure_privilege("mod_roomreservation_admin") ||
-        secure_privilege("mod_roomreservation_book") ||
-        secure_privilege("mod_roomreservation_view");
-    }
-  }
-  
-  /**
-   * Get the messages that have been produced
-   * @return string
-   */
-  public function getMessages() {
-    return join("\n", $this->asMessages);
-  }
-  
-  /***************************************************************************/
-  /**
-   * @}
-   * @name Operations
-   * @{
-   */
-  
-  /**
-   * Write the current state of this instance to the config file.
-   * @throws IOException
-   * @return bool
-   */
-  public function writeConfig() {
-    // Open config file
-    $hFile = fopen("mod_room-reservation/config.inc", "w", true);
-    if(!is_resource($hFile)) {
-      throw new IOException(MOD_ROOM_RESERVATION_ERROR_OPEN_FILE);
-      return false;
-    }
-    // Try to lock file repeatedly
-    for($n = 0; !flock($hFile, LOCK_EX); $n++) {
-      if($n > 10) {
-        throw new IOException(MOD_ROOM_RESERVATION_ERROR_OPEN_FILE);
-        return false; // Give up
-      } else {
-        sleep(0.2);   // Retry after 100 ms
-      }
-    }
-    
-    // Create text for config file
-    $strFile = MOD_ROOM_RESERVATION_CONFIGFILE_HEADER;
-    
-    // Timeslices
-    $strFile .= "\$this->flushTimeslices();\n";
-    foreach($this->getTimeslices() as $oTs) {
-      $strFile .= sprintf("\$this->addTimeslice(new ".
-        "mod_roomReservationTimeslice(%d, %d));\n", $oTs->getBegin(),
-        $oTs->getEnd());
-    }
-    
-    // Show weekend
-    $strFile .= sprintf("\$this->setShowWeekend(%s);\n",
-      $this->isShowWeekend() ? "true" : "false");
-
-    // Show lessons
-    $strFile .= sprintf("\$this->setShowLessons(%s);\n",
-      $this->isShowLessons() ? "true" : "false");
-
-    $strFile .= "?>";
-      
-    // Write to config file and unlock it
-    if(fwrite($hFile, $strFile) == false) {
-      throw new IOException(MOD_ROOM_RESERVATION_ERROR_WRITE_FILE);
-      return false;
-    }
-    if(!flock($hFile, LOCK_UN)) {
-      throw new IOException(MOD_ROOM_RESERVATION_ERROR_UNLOCK_FILE);
-      return false;
-    }
-    
-    rrInsertLog("Konfiguration verändert");
-    return true;
-  }
-  
-  /**
-   * Read configuration from file. Returns <tt>false</tt> if an error occured,
-   * in this case getMessages() contains error messages.
-   * @return bool
-   */
-  public function readConfig() {
-    global $g_rmCfg;
-    try {
-      require("mod_room-reservation/config.inc");
-    } catch(Exception $e) {
-      $this->addMessage($e->getMessage());
-    }
-  }
-
-  /** @} */
-}
-?>
diff --git a/includes/mod_roomReservationConfigPage.inc b/includes/mod_roomReservationConfigPage.inc
deleted file mode 100644 (file)
index 46ce45a..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-<?php
-/**\r
- * @file mod_roomReservationConfigPage.inc\r
- * The configuration page\r
- * @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
- * @date 24.06.2008\r
- * \r
- * Copyright © 2007 Roland Hieber\r
- *\r
- * Permission is hereby granted, free of charge, to any person obtaining\r
- * copy of this software and associated documentation files (the "Software"),\r
- * to deal in the Software without restriction, including without limitation\r
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
- * and/or sell copies of the Software, and to permit persons to whom the\r
- * Software is furnished to do so, subject to the following conditions:\r
- * \r
- * The above copyright notice and this permission notice shall be included in\r
- * all copies or substantial portions of the Software.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
- * THE SOFTWARE.\r
- */\r
-\r
-require_once("ctrl.inc");
-require_once("mod_room-reservation/mod_roomReservationPage.inc");
-require_once("mod_room-reservation/mod_roomReservationTimesliceListBox.inc");
-require_once("mod_room-reservation/mod_roomReservationRoomWhitelistListBox.inc");
-
-/** @todo document */
-class mod_roomReservationConfigPage extends mod_roomReservationPage {
-
-  protected $bPostShowWeekend;
-  protected $bPostShowLessons;
-  protected $asMessages = array();
-  protected $otlb;
-  protected $orwlb;
-  
-  public function __construct(mod_roomReservationConfig &$oCfg) {
-    parent::__construct($oCfg);
-    $this->otlb = new mod_roomReservationTimesliceListBox($this->oCfg);
-    $this->orwlb = new mod_roomReservationRoomWhitelistListBox($this->oCfg);
-    $this->setTitle(_c("room-reservation:Configuration"));
-    $this->setIcon("mod_room-reservation_config");
-  }
-
-  public function processRequestVariables() {
-    // default values
-    $this->bPostShowWeekend = $this->oCfg->isShowWeekend();
-    $this->bPostShowLessons = $this->oCfg->isShowLessons();
-    
-    if(isset($_POST["mod_roomReservationConfigPage"])) {
-      if(isset($_POST["mod_roomReservationConfigPage"]["showweekend"])) {
-        $this->bPostShowWeekend = 
-          ($_POST["mod_roomReservationConfigPage"]["showweekend"] == true);
-      }
-      
-      if(isset($_POST["mod_roomReservationConfigPage"]["showlessons"])) {
-        $this->bPostShowLessons = 
-          ($_POST["mod_roomReservationConfigPage"]["showlessons"] == true);
-      }
-      
-      // process the request
-      if(isset($_POST["mod_roomReservationConfigPage"]["submit"])) {
-        $this->oCfg->setShowWeekend($this->bPostShowWeekend);
-        $this->oCfg->setShowLessons($this->bPostShowLessons);
-        try {
-          $this->oCfg->writeConfig();
-        } catch(Exception $e) {
-          $this->asMessages[] = $e->getMessage();
-        }
-      }
-    }
-  }
-  
-  public function doShow() {
-    // error messages
-    if(count($this->asMessages) > 0) {
-      printf("<p>%s</p>", nl2br(q(join("\n", $this->asMessages))));
-    }
-    
-    // first column
-    echo "<table border='0' cellspacing='10' cellpadding='0'><tr>".
-       "<td style='width:50%;'>\n";
-    
-    GroupBox(_c("room-reservation:Available rooms"), "host");
-    printf("<p>%s</p>", _c("room-reservation:The following rooms are ".
-       "available for booking:"));
-    echo "<div style='margin:8px;'>";
-    $this->orwlb->show();
-    echo "</div>\n";
-    _GroupBox();
-    
-    GroupBox(_("Privileges"), "keys");
-    $asAdminGroups = rrPrivilegedGroups("mod_roomreservation_admin");
-    $asBookGroups = rrPrivilegedGroups("mod_roomreservation_book");
-    $asViewGroups = rrPrivilegedGroups("mod_roomreservation_view");
-    echo sprintf("<p>%s</p>\n<p>%s</p>\n<p>%s</p>", _c("room-reservation:This is ".
-      "a short summary of the privileges related to the room reservation ".
-      "schedulde and the groups which have them assigned."),
-      sprintf(_c("room-reservation:If one of these privileges is not assigned to ".
-      "any group, all users on this server are allowed to perform the specified ".
-      "action. Please use the %sgroup administration%s to assign and revoke ".
-      "privileges."), "<a href='/idesk/admin/act/groups.php'>", "</a>"),
-      _c("room-reservation:Please note that every group with the booking ".
-       "privilege can also implicitly view the booking table and every group with ".
-       "the administration privilege can also implicitly book and view the ".
-       "booking table."));
-    echo "<p><table style='width:100%'><tr>\n";
-    echo sprintf("<td>%s%s</td><td>%s</td>\n", icon("keys"),
-      _("View the booking table").":", $asViewGroups == array() ?
-      _c("room-reservation:all users") : icon("act-group") . join(", ", 
-      array_map("getGroupName", $asViewGroups)));
-    echo "</tr><tr>\n";
-    echo sprintf("<td>%s%s</td><td>%s</td>\n", icon("keys"),
-      _("Book rooms").":", $asBookGroups == array() ?
-      _c("room-reservation:all users") : icon("act-group") . join(", ",
-      array_map("getGroupName", $asBookGroups)));
-    echo "</tr><tr>\n";
-    echo sprintf("<td>%s%s</td><td>%s</td>\n", icon("keys"),
-      _("Administration of the room reservation schedule"),
-      $asAdminGroups == array() ? _c("room-reservation:all users") :
-      icon("act-group") . join(", ", array_map("getGroupName", $asAdminGroups)));
-    echo "</tr></table></p>\n";
-    _GroupBox();
-
-    // second column
-    echo "</td><td><!--second row-->\n";
-    
-    GroupBox(_c("room-reservation:Periods"), "mod_room-reservation_timeslice");
-    printf("<p>%s</p>", _c("room-reservation:Here you can fill in the ".
-       "periods where bookings can be undertaken. A booking period can ".
-       "e.&nbsp;g. correspond to a lesson."));
-    echo "<div style='margin:8px;'>";
-    $this->otlb->show();
-    echo "</div>\n";
-    _GroupBox();
-    
-    GroupBox(_c("room-reservation:Further options"), "manage");
-    printf("<div style='margin:8px;'><form action='%s' method='post'>".
-       "<table><tr>\n", $_SERVER["PHP_SELF"]);
-
-    printf("<td><input type='hidden' name='mod_roomReservationConfigPage".
-       "[showweekend]' value='0' /><%s name='mod_roomReservationConfigPage".
-       "[showweekend]' id='mod_roomReservationConfigPageShowWeekend' ".
-       "value='1' %s /></td><td><label for='".
-       "mod_roomReservationConfigPageShowWeekend'><b>%s</b></label><br />".
-       "<span class='mod_roomReservationConfigPageExplanation'>%s</span></p>",
-      $GLOBALS["smlchk"], $this->bPostShowWeekend ? "checked='checked' " : "",
-      _c("room-reservation:Show weekend"), _c("room-reservation:If ".
-      "selected, the weekdays saturday and sunday are also shown in the ".
-      "booking table."));
-
-    echo "</tr><tr>\n";
-    printf("<td><input type='hidden' name='mod_roomReservationConfigPage".
-       "[showlessons]' value='0' /><%s name='mod_roomReservationConfigPage".
-       "[showlessons]' id='mod_roomReservationConfigPageShowLessons' ".
-       "value='1'%s /></td><td><label for='".
-       "mod_roomReservationConfigPageShowLessons'><b>%s</b></label><br />".
-       "<span class='mod_roomReservationConfigPageExplanation'>%s</span></p>",
-      $GLOBALS["smlchk"], $this->bPostShowLessons ? "checked='checked' " : "",
-      _c("room-reservation:Show &bdquo;lesson&rdquo; texts"),
-      _c("room-reservation:Check this box to show texts like ".
-       "&bdquo;<i>n</i>th lesson&rdquo in the booking page. If this box is ".
-       "unchecked, none of these texts are shown."));
-      
-    printf("</tr><tr><td colspan='2'><%s name='mod_roomReservationConfigPage".
-       "[submit]' value='%s' /></td>", $GLOBALS["stdbtn"], _("OK"));
-    echo "</tr></table></form></div>\n";
-    _GroupBox();
-
-    echo "</td></tr></table>\n";
-  }
-}
-?>
\ No newline at end of file
diff --git a/includes/mod_roomReservationControl.inc b/includes/mod_roomReservationControl.inc
deleted file mode 100644 (file)
index 4d364c5..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-<?php
-/**\r
- * @file mod_roomReservationControl.inc\r
- * Class that represents an abstract control\r
- * @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
- * @date 25.07.2008\r
- * \r
- * Copyright © 2007 Roland Hieber\r
- *\r
- * Permission is hereby granted, free of charge, to any person obtaining\r
- * copy of this software and associated documentation files (the "Software"),\r
- * to deal in the Software without restriction, including without limitation\r
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
- * and/or sell copies of the Software, and to permit persons to whom the\r
- * Software is furnished to do so, subject to the following conditions:\r
- * \r
- * The above copyright notice and this permission notice shall be included in\r
- * all copies or substantial portions of the Software.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
- * THE SOFTWARE.\r
- */\r
-
-require_once("quote.inc");
-require_once("functions.inc");
-\r
-/** @todo document */
-abstract class mod_roomReservationControl {
-  /** (array of strings) Errors that occur while processing the form */ 
-  protected $asMessages;
-  /** (mod_roomReservationConfig) Reference to the configuration object */
-  protected $oCfg;
-  
-  /***************************************************************************/
-  /**
-   * @name Constructor
-   * @{
-   * Constructor
-   * @param $oCfg (reference to mod_roomReservationConfig) Reference to the
-   *  configuration
-   * @return mod_roomReservationBookingTable
-   */
-  public function __construct(mod_roomReservationConfig &$oCfg) {
-    rrAddCss(".blue .treeview .err { color:red !important; }");
-    $this->oCfg = $oCfg;
-    $this->processRequestVariables();
-  }
-  /***************************************************************************/
-  /**
-   * @}
-   * @name Initialization
-   * @{
-   */
-
-  /**
-   * Process the REQUEST variables and preset the some variables
-   * @return void
-   */
-  protected function processRequestVariables() { }
-  
-  /***************************************************************************/
-  /**
-   * @}
-   * @name Output
-   * @{
-   */
-
-  /**
-   * Get the messages that have been produced. Returns HTML.
-   * @return string
-   */
-  protected function getMessages() {
-    if(count($this->asMessages) > 0) {
-      return sprintf("<div class='err'>%s</p>\n",
-        nl2br(q(join("\n", $this->asMessages))));
-    }
-  }
-
-  /**
-   * Show the beginning of the control.
-   * @return void
-   */
-  protected function beginShow() { }
-  
-  /**
-   * Show the control. Override this function to print your HTML code.
-   * @return void
-   */
-  protected abstract function doShow();
-  
-  /**
-   * Show the end of the control.
-   * @return void
-   */
-  protected function endShow() { }
-
-  /**
-   * Show the full control. You don't need to override this function. Instead,
-   * override doShow(). 
-   * @return void
-   */
-  public function show() {
-    $this->beginShow();
-    $this->doShow();
-    $this->endShow();
-  }
-}
-?>
\ No newline at end of file
diff --git a/includes/mod_roomReservationPage.inc b/includes/mod_roomReservationPage.inc
deleted file mode 100644 (file)
index 6d0e018..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-<?php
-/**\r
- * @file mod_roomReservationPage.inc\r
- * A generic page class\r
- * @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
- * @date 24.06.2008\r
- * \r
- * Copyright © 2007 Roland Hieber\r
- *\r
- * Permission is hereby granted, free of charge, to any person obtaining\r
- * copy of this software and associated documentation files (the "Software"),\r
- * to deal in the Software without restriction, including without limitation\r
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
- * and/or sell copies of the Software, and to permit persons to whom the\r
- * Software is furnished to do so, subject to the following conditions:\r
- * \r
- * The above copyright notice and this permission notice shall be included in\r
- * all copies or substantial portions of the Software.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
- * THE SOFTWARE.\r
- */\r
-\r
-require_once("mod_room-reservation/mod_roomReservationConfig.inc");
-
-/** @todo document */
-abstract class mod_roomReservationPage {
-  /** (mod_roomReservationConfig) Reference to the configuration object */
-  protected $oCfg;
-  /** (string) Page title for PageBlue() */
-  protected $strTitle;
-  /** (string) Title icon for PageBlue() */
-  protected $strIcon;
-  
-  /***************************************************************************/
-  /**
-   * @name Constructor
-   * @{
-   * Constructor
-   * @param $oCfg (reference to mod_roomReservationConfig) Reference to the
-   *  configuration
-   * @return mod_roomReservationPage
-   */
-  function __construct(mod_roomReservationConfig &$oCfg) {
-    $this->oCfg = $oCfg;
-    
-    $this->processRequestVariables();
-  }
-
-  /***************************************************************************/
-  /**
-   * @}
-   * @name Initialization
-   * @{
-   */
-  
-  /**
-   * Process the REQUEST variables and preset the some variables. Override
-   * this function to process GET and POST parameters.
-   * @return void
-   */
-  protected function processRequestVariables() { }
-
-  /***************************************************************************/
-  /**
-   * @}
-   * @name Access to attributes
-   * @{
-   */
-  
-  /**
-   * Set the page title
-   * @param $str (string)
-   * @return void
-   */
-  public function setTitle($str) { $this->strTitle = $str; }
-  
-  /**
-   * Set the title icon
-   * @param $str (string)
-   * @return void
-   */
-  public function setIcon($str) { $this->strIcon = $str; }
-  
-  /**
-   * Get the page title
-   * @return string
-   */
-  public function getTitle() { return $this->strTitle; }
-
-  /**
-   * Get the title icon
-   * @return string
-   */
-  public function getIcon() { return $this->strIcon; }
-
-  /***************************************************************************/
-  /**
-   * @}
-   * @name Output
-   * @{
-   */
-
-  /**
-   * Show the beginning of the page.
-   * @return void
-   */
-  protected function beginShow() {
-    html_header("<style type='text/css'>\n".rrGetCss()."\n</style>\n");
-    PageBlue(q($this->getTitle()), $this->getIcon());
-    
-    // print error messages from the configuration
-    if($s = trim($this->oCfg->getMessages()) != "") {
-      printf("<p class='err'>%s</p>\n", nl2br(q($s)));
-    }
-  }
-  
-  /**
-   * Show the beginning of the page. Override this function to print your 
-   * HTML code.
-   * @return void
-   */
-  protected abstract function doShow();
-  
-  /**
-   * Show the end of the page.
-   * @return void
-   */
-  protected function endShow() {
-    _PageBlue();
-  }
-
-  /**
-   * Show the full page. You don't need to override this function. Instead,
-   * override doShow(). 
-   * @return void
-   */
-  public function show() {
-    $this->beginShow();
-    $this->doShow();
-    $this->endShow();
-  }
-
-}
-?>
\ No newline at end of file
diff --git a/includes/mod_roomReservationRoom.inc b/includes/mod_roomReservationRoom.inc
deleted file mode 100644 (file)
index 64ed6cb..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-<?php
-/**
- * @file mod_roomReservationRoom.inc 
- * Container class for the representation of a room
- * @author Roland Hieber (roland.hieber@wilhelm-gym.net)
- * @date 28.12.2007
- * 
- * Copyright © 2007 Roland Hieber
- * 
- * Permission is hereby granted, free of charge, to any person obtaining
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- * 
- * @todo move into M Class Library
- */
-
-/**
- * Container class for the representation of a room
- */
-class mod_roomReservationRoom {
-  
-  /** (string) Name of the room */
-  protected $strName;
-  /** (string) Room number */
-  protected $strRoomNo;
-  /** (string) Floor */
-  protected $strFloor;
-  /** (string) Building */
-  protected $strBuilding;
-  /** (string) Location */
-  protected $strLocation;
-  
-  /***************************************************************************/
-  /**
-   * @name Constructor
-   * @{
-   * Constructor.
-   * @param $strName (string) Name of the room
-   * @return rmRoom
-   */
-  public function __construct($strName, $strRoomNo = "", $strFloor = "",
-    $strBuilding = "", $strLocation = "") {
-    $this->setName($strName);
-    $this->setRoomNo($strRoomNo);
-    $this->setFloor($strFloor);
-    $this->setBuilding($strBuilding);
-    $this->setLocation($strLocation);
-  }
-
-  /***************************************************************************/
-  /**
-   * @}
-   * @name Access to attributes
-   * @{
-   */
-  
-  /**
-   * Set the name of the room
-   * @param $str (string) 
-   * @return void
-   */
-  public function setName($str) { $this->strName = $str; }
-  
-  /**
-   * Set the room number
-   * @param $str (string) 
-   * @return void
-   */
-  public function setRoomNo($str) { $this->strRoomNo = $str; }
-  
-  /**
-   * Set the floor
-   * @param $str (string) 
-   * @return void
-   */
-  public function setFloor($str) { $this->strFloor = $str; }
-  
-  /**
-   * Set the building
-   * @param $str (string) 
-   * @return void
-   */
-  public function setBuilding($str) { $this->strBuilding = $str; }
-  
-  /**
-   * Set the location
-   * @param $str (string) 
-   * @return void
-   */
-  public function setLocation($str) { $this->strLocation = $str; }
-  
-  /**
-   * Get the name of the room
-   * @return string
-   */
-  public function getName() { return $this->strName; }
-
-  /**
-   * Get the room number
-   * @return string
-   */
-  public function geRoomNo() { return $this->strRoomNo; }
-
-  /**
-   * Get the floor
-   * @return string
-   */
-  public function getFloor() { return $this->strFloor; }
-
-  /**
-   * Get the building
-   * @return string
-   */
-  public function getBuilding() { return $this->strBuilding; }
-
-  /**
-   * Get the location
-   * @return string
-   */
-  public function getLocation() { return $this->strLocation; }
-
-  /**
-   * Conversion to string
-   * @return string
-   */
-  public function __toString() { return $this->getName(); /* name is key */ }
-  /**@}*/
-}
-?>
diff --git a/includes/mod_roomReservationRoomWhitelistListBox.inc b/includes/mod_roomReservationRoomWhitelistListBox.inc
deleted file mode 100644 (file)
index 27bd6c2..0000000
+++ /dev/null
@@ -1,214 +0,0 @@
-<?php
-/**\r
- * @file mod_roomReservationRoomWhitelistListBox.inc\r
- * List box that shows the rooms who can be booked\r
- * @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
- * @date 24.07.2008\r
- * \r
- * Copyright © 2007 Roland Hieber\r
- *\r
- * Permission is hereby granted, free of charge, to any person obtaining\r
- * copy of this software and associated documentation files (the "Software"),\r
- * to deal in the Software without restriction, including without limitation\r
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
- * and/or sell copies of the Software, and to permit persons to whom the\r
- * Software is furnished to do so, subject to the following conditions:\r
- * \r
- * The above copyright notice and this permission notice shall be included in\r
- * all copies or substantial portions of the Software.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
- * THE SOFTWARE.\r
- */\r
-
-require_once("mod_roomReservationControl.inc");
-require_once("mod_roomReservationRoomsManager.inc");
-
-/*****************************************************************************/
-/**
- * @page roomwhitelistlistbox_actions Actions of a 
- * mod_roomReservationRoomWhitelistListBox instance
- * @{
- * The following constants describe the actions that a
- * mod_roomReservationRoomWhitelistListBox instance can handle. They are used
- * in processRequestVariables() to determine the action that should be done
- * when the control is shown.
- */
-/** Show the control (default action) */
-define("MOD_ROOM_RESERVATION_RWLB_ACTION_SHOW", 0);
-/** Show the addition form */
-define("MOD_ROOM_RESERVATION_RWLB_ACTION_ADD", 1);
-/** Process the addition form */
-define("MOD_ROOM_RESERVATION_RWLB_ACTION_SUBMITADD", 2);
-/** Show the deletion form */
-define("MOD_ROOM_RESERVATION_RWLB_ACTION_DELETE", 3);
-/** Process the deletion form */
-define("MOD_ROOM_RESERVATION_RWLB_ACTION_SUBMITDELETE", 4);
-/** @} */
-\r
-/** @todo document */
-class mod_roomReservationRoomWhitelistListBox 
-  extends mod_roomReservationControl {
-  /**
-   * (array of integers) OIDs of the rows in the rooms table that were 
-   * selected (POST data)
-   */
-  protected $anPostSelection = array();
-  /** (constant) Display mode, see @ref roomwhitelistlistbox_actions */
-  protected $cMode;
-  
-  protected function processRequestVariables() {
-    // default values
-    $this->cMode = MOD_ROOM_RESERVATION_RWLB_ACTION_SHOW;
-    
-    // POST data
-    if(isset($_POST["mod_roomReservationRoomWhitelistListBox"])) {
-      $aPost = $_POST["mod_roomReservationRoomWhitelistListBox"];
-      // mode
-      if(isset($aPost["action"])) {
-        if(isset($aPost["action"]["add"])) {
-          if($aPost["action"]["add"] == _("Add")) {
-            $this->cMode = MOD_ROOM_RESERVATION_RWLB_ACTION_ADD;
-          } elseif($aPost["action"]["add"] == _("OK")) {
-            $this->cMode = MOD_ROOM_RESERVATION_RWLB_ACTION_SUBMITADD;
-          }
-        } elseif(isset($aPost["action"]["delete"])) {
-          if($aPost["action"]["delete"] == _("Delete")) {
-            $this->cMode = MOD_ROOM_RESERVATION_RWLB_ACTION_DELETE;
-          } elseif($aPost["action"]["delete"] == _("OK")) {
-            $this->cMode = MOD_ROOM_RESERVATION_RWLB_ACTION_SUBMITDELETE;
-          }
-        }
-      }
-      // selection
-      if(isset($aPost["l"])) {
-        foreach($aPost["l"] as $nOid => $bChecked) {
-          if($bChecked) {
-            $this->anPostSelection[] = $nOid;
-          }
-        }
-      }
-    }
-    
-    // process the forms
-    if($this->cMode == MOD_ROOM_RESERVATION_RWLB_ACTION_SUBMITADD) {
-      $h = db_query("SELECT name FROM rooms WHERE oid IN ".
-        qdb_arr($this->anPostSelection));
-      while($a = pg_fetch_array($h)) {
-        $this->oCfg->whitelistRoom($a["name"]);
-      }
-    }
-
-    if($this->cMode == MOD_ROOM_RESERVATION_RWLB_ACTION_SUBMITDELETE) {
-      $h = db_query("SELECT name FROM rooms WHERE oid IN ".
-        qdb_arr($this->anPostSelection));
-      while($a = pg_fetch_array($h)) {
-        $this->oCfg->unWhitelistRoom($a["name"]);
-      }
-    }
-  }
-  
-  protected function doShow() {
-    echo "<form method='post'>";
-    TreeView(array(_("Room")));
-    switch($this->cMode) {
-      case MOD_ROOM_RESERVATION_RWLB_ACTION_DELETE:
-        $this->showDeleteForm();
-        break;
-      case MOD_ROOM_RESERVATION_RWLB_ACTION_ADD: $this->showAddForm(); break;
-      default:
-      case MOD_ROOM_RESERVATION_RWLB_ACTION_SHOW: $this->showForm(); break;
-    }
-    _TreeView();
-    echo "</form>\n";
-  }
-
-  /**
-   * Print the form if not delete nor add was requested
-   * @return void
-   */
-  protected function showForm() {
-    $aoRooms = $this->oCfg->getWhitelistedRooms();
-    // only show add button if there are still some unlisted rooms
-    if(count(mod_roomReservationRoomsManager::getRooms()) > count($aoRooms)) {
-      TreeViewLine(sprintf("<%s name='mod_roomReservationRoomWhitelistListBox".
-        "[action][add]' value='%s' /></form>", $GLOBALS["stdbtn"], _("Add")));
-    }
-    $this->showList($aoRooms);
-    // toolbar
-    printf("<tr><td class='tbbtm' colspan='%d'>", $GLOBALS["treeview_cols"]);
-    CheckCombo();
-    printf("<%s name='mod_roomReservationRoomWhitelistListBox[action]".
-       "[delete]' value='%s' />", $GLOBALS["stdbtn"], _("Delete"));
-    echo "</td></tr>\n";
-  }
-  
-  /**
-   * Print the addition form
-   * @return void
-   */
-  protected function showAddForm() {
-    // only list rooms that are not already whitelisted
-    $aoRooms = array_diff(mod_roomReservationRoomsManager::getRooms(),
-      $this->oCfg->getWhitelistedRooms());
-    TreeViewSubtitle(_("Add"));
-    $this->showList($aoRooms);
-    TreeViewLine(sprintf("<p><%s name='mod_roomReservationRoomWhitelistList".
-       "Box[action][add]' value='%s' /> <%s name='mod_roomReservationRoom".
-       "WhitelistListBox[action][add]' value='%s' /></p>", $GLOBALS["stdbtn"],
-       _("OK"), $GLOBALS["stdbtn"], _("Cancel")));
-  }
-  
-  /**
-   * Show the deletion form
-   * @return void
-   */
-  protected function showDeleteForm() {
-    // list rooms in selection
-    $aoRooms = array();
-    $h = db_query("SELECT name FROM rooms WHERE oid IN ".
-      qdb_arr($this->anPostSelection));
-    foreach($this->anPostSelection as $nOid) {
-      $aoRooms[] = mod_roomReservationRoomsManager::getRoomByOid($nOid);
-    }
-    TreeViewSubtitle(sprintf(_("Following %s will be deleted"),
-      _c("room-reservation:rooms")));
-    $this->showList($aoRooms, false);
-    TreeViewLine(sprintf("<p><%s name='mod_roomReservationRoomWhitelistList".
-       "Box[action][delete]' value='%s' /> <%s name='mod_roomReservationRoom".
-       "WhitelistListBox[action][delete]' value='%s' /></p>",
-       $GLOBALS["stdbtn"], _("OK"), $GLOBALS["stdbtn"], _("Cancel")));
-  }
-  
-  /**
-   * Show the list items
-   * @param $aoRooms (array of mod_roomReservationRoom objects) List items
-   * @param $bCheckboxes (bool) Whether to show checkboxes
-   */
-  protected function showList($aoRooms, $bCheckboxes = true) {
-    if(count($aoRooms) > 0) {
-      foreach($aoRooms as $o) {
-        // fetch oid from SQL table
-        $nOid = pg_fetch_result(db_query("SELECT oid FROM ".
-          "rooms WHERE name = $1", $o->getName()), 0, "oid");
-        $sBox = $bCheckboxes ? sprintf("<%s id='box%d' name='mod_room".
-               "ReservationRoomWhitelistListBox[l][%d]' value='1'%s /><label ".
-               "for='box%d'>%s%s</label>", $GLOBALS["smlchk"], $nOid, $nOid,
-          @$this->anPostSelection[$nOid] ? " checked='checked'" : "", $nOid,
-          icon("host"), $o->getName()) : 
-          sprintf("<input type='hidden' name='mod_roomReservationRoom".
-               "WhitelistListBox[l][%d]' value='1' />%s%s", $nOid, icon("host"),
-          $o->getName());
-        TreeViewLine($sBox);
-      }
-    } else {
-      TreeViewEmpty();
-    }
-  }
-}
-?>
\ No newline at end of file
diff --git a/includes/mod_roomReservationRoomsManager.inc b/includes/mod_roomReservationRoomsManager.inc
deleted file mode 100644 (file)
index edce221..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-<?php
-/**
- * @file mod_roomReservationRoomsManager.inc
- * Class for the management of rooms
- * @author Roland Hieber (roland.hieber@wilhelm-gym.net)
- * @date 28.12.2007
- * 
- * TODO: move into M Class Library
- * Copyright © 2007 Roland Hieber
- * 
- * Permission is hereby granted, free of charge, to any person obtaining
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-require_once("db.inc");
-require_once("mod_room-reservation/functions.inc");
-require_once("mod_room-reservation/mod_roomReservationRoom.inc");
-require_once("mod_room-reservation/mod_roomReservationConfig.inc");
-
-/** Simple class for creating, editing and deleting rooms */
-class mod_roomReservationRoomsManager {
-  /** (mod_roomReservationConfig) Reference to the configuration */
-  protected $oCfg;
-  
-  /**
-   * Constructor
-   * @param $oCfg (reference to mod_roomReservationConfig) Reference to the
-   *  configuration object
-   * @return rmRoomsManager
-   */
-  public function __construct(mod_roomReservationConfig &$oCfg) {
-    $this->oCfg = $oCfg;
-  }
-  
-  /**
-   * Insert or update a room in the database
-   * param $or (rsRoom) Room to store in the database
-   * return (int) The UID of the booking, or <tt>-1</tt> in case of a failure.
-   * Call getLastError() to get more information about the error.
-   */
-/**  public function write(rsRoom $or) {
-    // Only administrators are allowed to create and alter rooms
-    if(!$this->oCfg->userIsAdmin()) {
-      // TODO throw exception
-      setLastError(RS_ERROR_ACCESS_DENIED);
-      return -1;
-    }
-
-    $strWhere = "";
-    $strLog = "";
-
-    // Update or insert?
-    if($or->getUid() == null) {
-      // No UID yet, insert new room
-      $strLog = sprintf("Raum „%s“ angelegt", $or->getName());
-    } else {
-      $strWhere = "rsr_uid = ".qp(intval($or->getUid()));
-      $strLog = sprintf("Raum „%s“ geändert", $or->getName());
-    }
-    
-    $aPut["rsr_name"] = $or->getName();
-    db_store("rooms", $aPut, $strWhere == "" ? null : $strWhere);
-    
-    $hQuery = db_query("SELECT currval('roomschedule_rooms_rsr_uid_seq') ".
-      "FROM roomschedule_rooms;");
-    $nNewUid = pg_fetch_result($hQuery, 0, "currval");
-    
-    rrInsertLog($strLog);
-    
-    // Return new UID
-    return $nNewUid;
-  }
-  */
-  /**
-   * Delete a room from the database
-   * param $nUid (int) Unique ID of the room
-   * return (bool) <tt>true</tt> on success, otherwise <tt>false</tt>.
-   *  Call getLastError() to get more information about the error.
-   */
-/*  public function delete($nUid) {
-    // Only administrators are allowed to delete rooms
-    if(!$this->oCfg->userIsAdmin()) {
-      // TODO throw exception
-      setLastError(RS_ERROR_ACCESS_DENIED);
-      return false;
-    }
-    // Delete it from the database
-    $strRoom = $this->getRoomName($nUid);
-    if(!db_query("DELETE FROM roomschedule_rooms WHERE rsr_uid = $1;",
-      intval($nUid))) {
-        // TODO throw exception
-      setLastError(RS_ERROR_SQL);
-      return false;
-    } else {
-      rsInsertLog(sprintf("Raum „%s“ gelöscht", $strRoom));
-      return true;
-    }
-  }
-*/
-
-  /**
-   * Get a room by its OID. Returns <tt>null</tt> if the room was not found.
-   * @param $nOid (integer) The OID of the room
-   * @return mod_roomReservationRoom
-   */
-  static function getRoomByOid($nOid) {
-    $o = null;
-    $h = db_query("SELECT * FROM rooms WHERE oid = $1;", $nOid);
-    if(pg_num_rows($h) > 0) {
-      $arResult = pg_fetch_array($h);
-      $o = new mod_roomReservationRoom($arResult["name"], 
-        $arResult["room_no"], $arResult["floor"], $arResult["building"],
-        $arResult["location"]);
-    }
-    return $o;
-  }
-  
-  /**
-   * Get a room by its name. Returns <tt>null</tt> if the room was not found.
-   * @param $sName (string) The name of the room
-   * @return mod_roomReservationRoom
-   */
-  static function getRoomByName($sName) {
-    $o = null;
-    $h = db_query("SELECT * FROM rooms WHERE name = $1;", $sName);
-    if(pg_num_rows($h) > 0) {
-      $arResult = pg_fetch_array($h);
-      $o = new mod_roomReservationRoom($arResult["name"], 
-        $arResult["room_no"], $arResult["floor"], $arResult["building"],
-        $arResult["location"]);
-    }
-    return $o;
-  }
-  
-  /**
-   * Get all rooms from the database
-   * @return array of mod_roomReservationRoom
-   */
-  static function getRooms() {
-    $aoReturn = array();
-    $hQuery = db_query("SELECT * FROM rooms ORDER BY name;");
-    while($arResult = pg_fetch_array($hQuery)) {
-      $aoReturn[] = new mod_roomReservationRoom($arResult["name"], 
-        $arResult["room_no"], $arResult["floor"], $arResult["building"],
-        $arResult["location"]);
-    }
-    return $aoReturn;
-  }
-}
-?>
diff --git a/includes/mod_roomReservationTimeslice.inc b/includes/mod_roomReservationTimeslice.inc
deleted file mode 100644 (file)
index f6bd997..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-<?php
-/**
- * @file mod_roomReservationTimeslice.inc
- * Representation of a timeslice
- * @author Roland Hieber (roland.hieber@wilhelm-gym.net)
- * @date 03.02.2008
- * 
- * Copyright © 2007 Roland Hieber
- * 
- * Permission is hereby granted, free of charge, to any person obtaining
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-/** Implementation of a simple timeslice with beginning and ending time */
-class mod_roomReservationTimeslice {
-  
-  /** (timestamp) Time when the timeslice begins */
-  protected $tsBegin = -1;
-  /** (timestamp) Time when the timeslice ends */
-  protected $tsEnd = 86400;
-  
-  /***************************************************************************/
-  /**
-   * @name Constructor
-   * @{
-   * Constructor
-   * @param $tsBegin (timestamp) Time when the timeslice begins. Only the
-   *  time part is used, the date part is ignored.
-   * @param $tsEnd (timestamp) Time when the timeslice ends. Only the time
-   *  part is used, the date part is ignored.
-   * @return mod_roomReservationTimeslice
-   */
-  public function __construct($tsBegin, $tsEnd) {
-    $this->setBegin($tsBegin);
-    $this->setEnd($tsEnd);
-  }
-
-  /***************************************************************************/
-  /**
-   * @}
-   * @name Access to attributes
-   * @{
-   */
-  
-  /**
-   * Set the beginning. Only the time part is used, the date part is ignored.
-   * If the timestamp is invalid, an Exception is thrown.
-   * @param $ts (timestamp)
-   * @throws Exception 
-   */
-  public function setBegin($ts) {
-    if(intval($ts) >= $this->getEnd()) {
-      throw new Exception(MOD_ROOM_RESERVATION_ERROR_END_BEFORE_BEGIN);
-    } else {
-      $this->tsBegin = (intval($ts) % 86400);
-    }
-  }
-
-  /**
-   * Set the ending. Only the time part is used, the date part is ignored.
-   * If the timestamp is invalid, an Exception is thrown.
-   * @param $ts (timestamp) 
-   * @throws Exception 
-   */
-  public function setEnd($ts) {
-    if($this->getBegin() >= intval($ts)) {
-      throw new Exception(MOD_ROOM_RESERVATION_ERROR_END_BEFORE_BEGIN);
-    } else {
-      $this->tsEnd = (intval($ts) % 86400);
-    }
-  }
-
-  /**
-   * Get the beginning.
-   * @return timestamp
-   */
-  public function getBegin() { return $this->tsBegin; }
-
-  /**
-   * Get the ending.
-   * @return timestamp
-   */
-  public function getEnd() { return $this->tsEnd; }
-  
-  /** @} */
-}
-?>
diff --git a/includes/mod_roomReservationTimesliceListBox.inc b/includes/mod_roomReservationTimesliceListBox.inc
deleted file mode 100644 (file)
index 6928a33..0000000
+++ /dev/null
@@ -1,264 +0,0 @@
-<?php
-/**\r
- * @file mod_roomReservationTimesliceListBox.inc\r
- * A list box that allows the user to add and delete timeslices\r
- * @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
- * @date 23.06.2008\r
- * \r
- * Copyright © 2007 Roland Hieber\r
- *\r
- * Permission is hereby granted, free of charge, to any person obtaining\r
- * copy of this software and associated documentation files (the "Software"),\r
- * to deal in the Software without restriction, including without limitation\r
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
- * and/or sell copies of the Software, and to permit persons to whom the\r
- * Software is furnished to do so, subject to the following conditions:\r
- * \r
- * The above copyright notice and this permission notice shall be included in\r
- * all copies or substantial portions of the Software.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
- * THE SOFTWARE.\r
- */\r
-
-require_once("ctrl.inc");
-require_once("mod_room-reservation/mod_roomReservationControl.inc");
-require_once("mod_room-reservation/mod_roomReservationTimeslice.inc");
-
-/*****************************************************************************/
-/**
- * @page timeslicelistbox_actions Actions of a 
- * mod_roomReservationTimesliceListBox instance
- * @{
- * The following constants describe the actions that a
- * mod_roomReservationTimesliceListBox instance can handle. They are used in
- * processRequestVariables() to determine the action that should be done when
- * the control is shown.
- */
-/** Show the control (default action) */
-define("MOD_ROOM_RESERVATION_TLB_ACTION_SHOW", 0);
-/** Add a timeslice */
-define("MOD_ROOM_RESERVATION_TLB_ACTION_ADD", 1);
-/** Delete a timeslice */
-define("MOD_ROOM_RESERVATION_TLB_ACTION_DELETE", 2);
-/** @} */
-\r
-/** @todo document, add a delete confirmation */
-class mod_roomReservationTimesliceListBox  extends mod_roomReservationControl {
-  
-  /** 
-   * (constant) The action to be done (GET data).
-   * See @ref timeslicelistbox_actions.
-   */
-  protected $cAction;
-  /** (string) The beginning for a new timeslice (GET data) */
-  protected $sNewBegin;
-  /** (string) The ending for a new timeslice (GET data) */
-  protected $sNewEnd;
-  
-  /***************************************************************************/
-  /**
-   * @name Constructor
-   * @{
-   * Constructor
-   * @param $oCfg (reference to mod_roomReservationConfig) Reference to the
-   *  configuration
-   * @return mod_roomReservationTimesliceListBox
-   */
-  public function __construct(mod_roomReservationConfig &$oCfg) {
-    parent::__construct($oCfg);
-  }
-  /***************************************************************************/
-  /**
-   * @}
-   * @name Initialization
-   * @{
-   */
-
-  /**
-   * Process the REQUEST variables and preset the some variables
-   * @return void
-   */
-  protected function processRequestVariables() {
-    
-    if(isset($_GET["mod_roomReservationTimesliceListBox"])) {
-      // action
-      if(isset($_GET["mod_roomReservationTimesliceListBox"]["action"])) {
-        $ga = $_GET["mod_roomReservationTimesliceListBox"]["action"];
-        $this->setAction((($ga == "add") ? MOD_ROOM_RESERVATION_TLB_ACTION_ADD : 
-          (($ga == "delete") ? MOD_ROOM_RESERVATION_TLB_ACTION_DELETE :
-          MOD_ROOM_RESERVATION_TLB_ACTION_SHOW)));
-      }
-      
-      // new beginning and new ending
-      $this->setNewBegin(isset(
-        $_GET["mod_roomReservationTimesliceListBox"]["begin"]) ?
-        $_GET["mod_roomReservationTimesliceListBox"]["begin"] : "");
-      $this->setNewEnd(isset(
-        $_GET["mod_roomReservationTimesliceListBox"]["end"]) ?
-        $_GET["mod_roomReservationTimesliceListBox"]["end"] : "");
-    }
-    
-    // perform the requested action
-    if($this->getAction() == MOD_ROOM_RESERVATION_TLB_ACTION_ADD) {
-      // add a timeslice to the configuration file
-      
-      $bErrors = false;
-      
-      // Note: we want to handle the timestamps in GMT format, hence the "+0000"
-      if(strtotime($this->getNewBegin()." +0000") === false) {
-        $this->asMessages[] = _c("room-reservation:The beginning time is ".
-               "invalid.");
-        $bErrors = true;
-      }
-      if(strtotime($this->getNewEnd()." +0000") === false) {
-        $this->asMessages[] = _c("room-reservation:The ending time is ".
-               "invalid.");
-        $bErrors = true;
-      }
-      
-      if(!$bErrors) {
-        try {
-          $this->oCfg->addTimeslice(new mod_roomReservationTimeslice(
-            strtotime($this->getNewBegin()." +0000") % 86400, 
-            strtotime($this->getNewEnd()." +0000") % 86400));
-          $this->oCfg->writeConfig();
-          $this->setNewBegin("");
-          $this->setNewEnd("");
-        } catch(Exception $e) {
-          $this->asMessages[] = $e->getMessage();
-        }
-      }
-      
-    } elseif($this->getAction() == MOD_ROOM_RESERVATION_TLB_ACTION_DELETE) {
-      // delete a timeslice from the configuration file
-      if(isset($_POST["mod_roomReservationTimesliceListBox"])) {
-        if(isset($_POST["mod_roomReservationTimesliceListBox"]["l"])) {
-          $ao = $this->oCfg->getTimeslices();
-          foreach($_POST["mod_roomReservationTimesliceListBox"]["l"] as 
-            $n => $b) {
-            if($b) {
-              $this->oCfg->deleteTimeslice(new mod_roomReservationTimeslice(
-                $ao[$n]->getBegin(), $ao[$n]->getEnd()));
-            }
-          }
-          $this->oCfg->writeConfig();
-        }
-      }
-    }
-  }
-
-  /***************************************************************************/
-  /**
-   * @}
-   * @name Access to attributes
-   * @{
-   */
-  
-  /**
-   * Set the action to be done (GET data)
-   * @param $c (constant) Action. See @ref timeslicelistbox_actions.
-   */
-  protected function setAction($c) { $this->cAction = intval($c); }
-
-  /**
-   * Set the beginning for a new timeslice (GET data)
-   * @param $s (string)
-   */
-  protected function setNewBegin($s) { $this->sNewBegin = $s; }
-  
-  /**
-   * Set the beginning for a new timeslice (GET data)
-   * @param $s (string)
-   */
-  protected function setNewEnd($s) { $this->sNewEnd = $s; }
-  
-  /**
-   * Get the action to be done (GET data). See @ref timeslicelistbox_actions.
-   * @return constant
-   */
-  function getAction() { return $this->cAction; }
-  
-  /**
-   * Get the beginning for a new timeslice (GET data)
-   * @return string
-   */
-  public function getNewBegin() { return $this->sNewBegin; }
-  
-  /**
-   * Get the beginning for a new timeslice (GET data)
-   * @return string
-   */
-  public function getNewEnd() { return $this->sNewEnd; }
-  
-  /***************************************************************************/
-  /**
-   * @}
-   * @name Output
-   * @{
-   */
-  
-  /**
-   * Actually show the control
-   * @return void
-   */
-  public function doShow() {
-    TreeView(array(_c("room-reservation:Begin"), _c("room-reservation:End")));
-
-    // addition form
-    printf("<form method='get'>");
-    hidden("mod_roomReservationTimesliceListBox[action]", "add");
-    TreeViewTitle(_("Add"));
-    
-    $sMessages = $this->getMessages();
-    if(trim($sMessages) != "") {
-      TreeViewLine($sMessages);
-    }
-    
-    TreeViewLine(array(sprintf("<%s name='mod_roomReservationTimesliceListBox".
-       "[begin]' value='%s' size='8'/>", $GLOBALS["stdedt"], 
-      $this->getNewBegin()), sprintf("<%s name='".
-      "mod_roomReservationTimesliceListBox[end]' value='%s' size='8'/> <%s ".
-      "name='mod_roomReservationTimesliceListBox[submit]' value='%s' />", 
-      $GLOBALS["stdedt"], $this->getNewEnd(), $GLOBALS["stdbtn"], _("Add"))));
-    echo "</form>\n";
-    
-    // deletion form
-    TreeViewTitle(_c("room-reservation:Periods"));
-    $aoTs = $this->oCfg->getTimeslices();
-    if(count($aoTs) > 0) {
-      echo "<form action='?mod_roomReservationTimesliceListBox[action]=delete' ".
-       "method='post'>";
-      $i = 0;
-      foreach($aoTs as $oTs) {
-        $sBox = sprintf("<input type='hidden' ".
-               "name='mod_roomReservationTimesliceListBox[l][%d]' value='0' />".
-               "<%s name='mod_roomReservationTimesliceListBox[l][%d]' value='1' />",
-          $i, $GLOBALS["smlchk"], $i);
-        // Note: we have only GMT timestamps in the timeslice objects
-        TreeViewLine(array($sBox . gmstrftime(_("%#I:%M %p"), $oTs->getBegin()),
-          gmstrftime(_("%#I:%M %p"), $oTs->getEnd())));
-        $i++;
-      }
-      // toolbar
-      printf("<tr><td class='tbbtm' colspan='%d'>", $GLOBALS["treeview_cols"]);
-      CheckCombo();
-      printf("<%s name='mod_roomReservationTimesliceListBox[submit]' ".
-       "value='%s' />", $GLOBALS["stdbtn"], _("Delete"));
-      echo "</td></tr>\n";
-    } else {
-      TreeViewEmpty();
-    }
-    
-    echo "</form>\n";
-    _TreeView();
-  }
-  /** @} */
-}
-?>
\ No newline at end of file
index 5999605..a89370d 100644 (file)
@@ -200,6 +200,9 @@ msgstr "room-reservation:Hier die Zeitstunden der Buchungszeiträume eingeben. "
 msgid "room-reservation:all users"
 msgstr "room-reservation:alle Benutzer"
 
+msgid "room-reservation:no users"
+msgstr "room-reservation:keine Benutzer"
+
 msgid "room-reservation:Periods"
 msgstr "room-reservation:Zeitabschnitte"
 
index c0f219a..aa97f0c 100755 (executable)
@@ -208,7 +208,7 @@ print "importing old bookings...\n";
 IServ::DB::Exec "CREATE TABLE mod_roomreservation_bookings_old (id INT NOT NULL PRIMARY KEY, room TEXT NOT NULL, date DATE NOT NULL, timebegin TIME NOT NULL, timeend TIME NOT NULL, act TEXT REFERENCES users(Act) ON DELETE CASCADE ON UPDATE CASCADE NOT NULL, class TEXT, reason TEXT NOT NULL, fixed BOOL);";
 while(<IN>) {
   # rename the table
-  $_ =~ s/INSERT INTO rooms/INSERT INTO mod_roomreservation_bookings_old/;
+  $_ =~ s/INSERT INTO rooms /INSERT INTO mod_roomreservation_bookings_old /;
   IServ::DB::Exec($_);
 }
 
index 909891a..45a227a 100644 (file)
@@ -1,4 +1,4 @@
 <?
 TreeNode(_("Room Reservation Schedule"),
-  "mod_room-reservation/admin/", "mod_room-reservation_config");
+  "mod_room-reservation/config.php", "mod_room-reservation_index");
 ?>\r
diff --git a/src/admin/index.php b/src/admin/index.php
deleted file mode 100644 (file)
index f4ef22e..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-/**\r
- * @file index.php
- * Configuration page\r
- * @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
- * @date 20.05.2008\r
- * \r
- * Copyright © 2007 Roland Hieber\r
- *\r
- * Permission is hereby granted, free of charge, to any person obtaining\r
- * copy of this software and associated documentation files (the "Software"),\r
- * to deal in the Software without restriction, including without limitation\r
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
- * and/or sell copies of the Software, and to permit persons to whom the\r
- * Software is furnished to do so, subject to the following conditions:\r
- * \r
- * The above copyright notice and this permission notice shall be included in\r
- * all copies or substantial portions of the Software.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
- * THE SOFTWARE.\r
- */\r
-\r
-/** @todo document */\r
-
-require_once("sec/admsecure.inc");
-require_once("mod_room-reservation/globals.inc");\r
-require_once("mod_room-reservation/mod_roomReservationConfigPage.inc");
-
-$page = new mod_roomReservationConfigPage($g_rrCfg);
-$page->show();
-?>\r
diff --git a/src/config.php b/src/config.php
new file mode 100644 (file)
index 0000000..e53b70a
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+/**\r
+ * @file config.php
+ * Configuration page\r
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
+ * @date 20.05.2008\r
+ * \r
+ * Copyright © 2007 Roland Hieber\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included in\r
+ * all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+ * THE SOFTWARE.\r
+ */\r
+\r
+/** @todo document */\r
+
+require_once("sec/admsecure.inc");
+require_once("mod_room-reservation/globals.inc");\r
+require_once("mod_room-reservation/mod_roomReservationConfigPage.inc");
+
+$page = new mod_roomReservationConfigPage($g_rrCfg);
+$page->show();
+?>\r
This page took 0.320623 seconds and 4 git commands to generate.