### Eclipse Workspace Patch 1.0 #P facetoface Index: lib.php =================================================================== RCS file: /cvsroot/moodle/contrib/plugins/mod/facetoface/lib.php,v retrieving revision 1.42 diff -u -r1.42 lib.php --- lib.php 21 May 2009 05:56:44 -0000 1.42 +++ lib.php 27 Aug 2009 21:55:36 -0000 @@ -794,6 +794,9 @@ if ($bookedsession || ($status == get_string('bookingfull', 'facetoface'))) { $spanclass = ' class="dimmed_text"'; + if (facetoface_session_has_capacity($session, $context)) { + $options .= ''.get_string('signup', 'facetoface').''; + } } else { $options .= ''.get_string('signup', 'facetoface').''; } @@ -1831,8 +1834,9 @@ continue; } - $signupcount = facetoface_get_num_attendees($session->id); - if ($signupcount >= $session->capacity) continue; + if (!facetoface_session_has_capacity($session, $context)) { + continue; + } $multiday = ''; if ($session->datetimeknown) { @@ -2389,4 +2393,33 @@ return $result; } +/** + * Confirm that a user can be added to a session. + * + * @param class $session Record from the facetoface_sessions table + * @param object $context A context object (record from context table) + * @return bool True if user can be added to session + **/ +function facetoface_session_has_capacity($session, $context) { + + if(empty($session)) { + return false; + } + + $signupcount = facetoface_get_num_attendees($session->id); + if ($signupcount >= $session->capacity ) { + // if session is full, check if overbooking is allowed for this user + if (get_config(NULL,'facetoface_allowoverbooking') && + has_capability('mod/facetoface:overbook', $context) ) { + return true; + } else { + return false; + } + } else { + // session not full + return true; + } + +} + ?> Index: settings.php =================================================================== RCS file: /cvsroot/moodle/contrib/plugins/mod/facetoface/settings.php,v retrieving revision 1.1 diff -u -r1.1 settings.php --- settings.php 3 Nov 2008 05:30:22 -0000 1.1 +++ settings.php 27 Aug 2009 21:55:36 -0000 @@ -26,6 +26,8 @@ $settings->add(new admin_setting_configcheckbox('facetoface_disableicalcancel', get_string('setting:disableicalcancel_caption', 'facetoface'),get_string('setting:disableicalcancel', 'facetoface'), get_string('setting:disableicalcanceldefault', 'facetoface'), PARAM_BOOL)); + $settings->add(new admin_setting_configcheckbox('facetoface_allowoverbooking', get_string('setting:allowoverbooking_caption', 'facetoface'),get_string('setting:allowoverbooking', 'facetoface'), get_string('setting:allowoverbookingdefault', 'facetoface'), PARAM_BOOL)); + ?> Index: version.php =================================================================== RCS file: /cvsroot/moodle/contrib/plugins/mod/facetoface/version.php,v retrieving revision 1.7 diff -u -r1.7 version.php --- version.php 30 Oct 2008 23:59:43 -0000 1.7 +++ version.php 27 Aug 2009 21:55:36 -0000 @@ -5,7 +5,7 @@ // This fragment is called by /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2008100300; +$module->version = 2008100301; $module->requires = 2007021500; // Requires this Moodle version $module->cron = 60; Index: signup.php =================================================================== RCS file: /cvsroot/moodle/contrib/plugins/mod/facetoface/signup.php,v retrieving revision 1.16 diff -u -r1.16 signup.php --- signup.php 7 Aug 2009 02:51:23 -0000 1.16 +++ signup.php 27 Aug 2009 21:55:36 -0000 @@ -163,8 +163,7 @@ if ($confirm) { - $signupcount = facetoface_get_num_attendees($session->id); - if ($signupcount >= $session->capacity) { + if (!facetoface_session_has_capacity($session, $context)) { error(get_string('sessionisfull', 'facetoface'), $CFG->wwwroot.'/course/view.php?id='.$course->id); } elseif (facetoface_get_user_submissions($facetoface->id, $USER->id)) { @@ -260,8 +259,7 @@ echo '