### 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('bookingstatus', 'facetoface').': | ' @@ -1791,9 +1812,7 @@ .'|||
'.get_string('seeattendees', 'facetoface').' | ' .'|||
'.get_string('cancelbooking', 'facetoface').' | ' - .'|||
'.get_string('viewallsessions', 'facetoface').' | ' .': |
+
- |
+
+
+