### 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 26 Aug 2009 22:44:17 -0000 @@ -417,7 +417,7 @@ timecancelled = 0"); if ($signedupusers and count($signedupusers) > 0) { foreach ($signedupusers as $user) { - if (facetoface_user_cancel($session, $user->userid)) { + if (facetoface_user_cancel($session, $user->userid, true)) { facetoface_send_cancellation_notice($facetoface, $session, $user->userid); } else { @@ -1275,19 +1275,33 @@ * * @param class $session record from the facetoface_sessions table * @param integer $userid ID of the user to remove from the session + * @param bool $forcecancel Forces cancellation of sessions that have already occurred + * @param string $errorstr Passed by reference. For setting error string in calling function */ -function facetoface_user_cancel($session, $userid=false) { +function facetoface_user_cancel($session, $userid=false, $forcecancel=false, &$errorstr=null) { if (!$userid) { global $USER; $userid = $USER->id; } + // if $forcecancel is set, cancel session even if already occurred + // used by facetotoface_delete_session() + if (!$forcecancel) { + $timenow = time(); + // don't allow user to cancel a session that has already occurred + if (facetoface_has_session_started($session, $timenow)) { + $errorstr = get_string('error:eventoccurred', 'facetoface'); + return false; + } + } + if (facetoface_user_cancel_submission($session->id, $userid)) { facetoface_remove_bookings_from_user_calendar($session, $userid); return true; } + $errorstr = get_string('error:cancelbooking', 'facetoface'); return false; } @@ -1776,6 +1790,13 @@ } + // don't include the link to cancel a session if it has already occurred + if (!facetoface_has_session_started($session, $timenow)) { + $cancellink = ''.get_string('cancelbooking', 'facetoface').''; + } else { + $cancellink = ''; + } + $table = '' .'' .'' @@ -1791,9 +1812,7 @@ .'' .'' .'' - .'' - .'' - .'' + .$cancellink .'' .'' .'' 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 26 Aug 2009 22:44:18 -0000 @@ -82,7 +82,7 @@ } else if ($cancelbooking) { - if (facetoface_user_cancel($session)) { + if (facetoface_user_cancel($session, false, false, $errorstr)) { add_to_log($course->id, 'facetoface', 'cancel booking', "signup.php?id=$cm->id", $facetoface->id, $cm->id); @@ -114,9 +114,16 @@ redirect($url, $message, $timemessage); } else { - add_to_log($course->id, 'facetoface', 'cancel booking (FAILED)', "signup.php?id=$cm->id", $facetoface->id, $cm->id); - - $errorstr = get_string('error:cancelbooking', 'facetoface'); + // $errorstr now set by reference in facetoface_user_cancel() + //$errorstr = get_string('error:cancelbooking', 'facetoface'); + + if ($errorstr === get_string('error:eventoccurred', 'facetoface')) { + $reason='Too late to cancel'; + } else { + $reason='FAILED'; + } + add_to_log($course->id, 'facetoface', "cancel booking ($reason)", "signup.php?id=$cm->id", $facetoface->id, $cm->id); + } } elseif (!empty($addmanager)) { Index: signup.html =================================================================== RCS file: /cvsroot/moodle/contrib/plugins/mod/facetoface/signup.html,v retrieving revision 1.8 diff -u -r1.8 signup.html --- signup.html 21 May 2009 05:53:53 -0000 1.8 +++ signup.html 26 Aug 2009 22:44:18 -0000 @@ -151,8 +151,17 @@ + + +
'.get_string('bookingstatus', 'facetoface').':
'.get_string('seeattendees', 'facetoface').'
'.get_string('cancelbooking', 'facetoface').'
'.get_string('viewallsessions', 'facetoface').'
: +
-