Exemplo n.º 1
0
                             redirect($url, get_string('activitycompletionsuccess', 'booking'), 5);
                         } else {
                             if (isset($fromform->booktootherbooking) && (booking_check_if_teacher($bookingData->option, $USER) || has_capability('mod/booking:readresponses', $context)) && confirm_sesskey()) {
                                 $selectedusers = array_keys($fromform->user, 1);
                                 if (empty($selectedusers)) {
                                     redirect($url, get_string('selectatleastoneuser', 'booking', $bookingData->option->howmanyusers), 5);
                                 }
                                 if (count($selectedusers) > $bookingData->canBookToOtherBooking) {
                                     redirect($url, get_string('toomuchusersbooked', 'booking', $bookingData->canBookToOtherBooking), 5);
                                 }
                                 $tmpcmid = $DB->get_record_sql("SELECT cm.id FROM {course_modules} cm JOIN {modules} md ON md.id = cm.module JOIN {booking} m ON m.id = cm.instance WHERE md.name = 'booking' AND cm.instance = ?", array($bookingData->booking->conectedbooking));
                                 $tmpBooking = new booking_option($tmpcmid->id, $bookingData->option->conectedoption);
                                 foreach ($selectedusers as $value) {
                                     $user = new stdClass();
                                     $user->id = $value;
                                     $tmpBooking->user_submit_response($user);
                                 }
                                 redirect($url, get_string('userssucesfullybooked', 'booking', $bookingData->canBookToOtherBooking), 5);
                             }
                         }
                     }
                 }
             }
         }
     } else {
         echo $OUTPUT->header();
     }
 }
 echo $OUTPUT->heading($bookingData->option->text, 4, '', '');
 $urlParamsODS = $urlParams;
 $urlParamsXLS = $urlParams;
Exemplo n.º 2
0
if (has_capability('moodle/user:editownprofile', $context, NULL, false) and booking_check_user_profile_fields($USER->id) and !has_capability('moodle/site:config', $context)) {
    $contents = get_string('mustfilloutuserinfobeforebooking', 'booking');
    $contents .= $OUTPUT->single_button(new moodle_url("edituserprofile.php", array('cmid' => $cm->id, 'courseid' => $course->id)), get_string('continue'), 'get');
    echo $OUTPUT->box($contents, 'box generalbox', 'notice');
    echo $OUTPUT->footer();
    die;
}
/// Submit any new data if there is any
if ($form = data_submitted() && has_capability('mod/booking:choose', $context)) {
    $timenow = time();
    $url = new moodle_url("view.php", array('id' => $cm->id));
    $url->set_anchor("option" . $booking->options[$answer]->id);
    if (!empty($answer)) {
        $bookingData = new booking_option($cm->id, $answer);
        $bookingData->apply_tags();
        if ($bookingData->user_submit_response($USER)) {
            $contents = get_string('bookingsaved', 'booking');
            if ($booking->booking->sendmail) {
                $contents .= "<br />" . get_string('mailconfirmationsent', 'booking') . ".";
            }
            $contents .= $OUTPUT->single_button($url, get_string('continue'), 'get');
            echo $OUTPUT->box($contents, 'box generalbox', 'notice');
            echo $OUTPUT->footer();
            die;
        } elseif (is_int($answer)) {
            $contents = get_string('bookingmeanwhilefull', 'booking') . " " . $booking->option[$answer]->text;
            $contents .= $OUTPUT->single_button($url, 'get');
            echo $OUTPUT->box($contents, 'box generalbox', 'notice');
            echo $OUTPUT->footer();
            die;
        }
Exemplo n.º 3
0
 }
 if ($subscribe) {
     $users = $subscriberselector->get_selected_users();
     if ($currentgroup and !has_capability('moodle/site:accessallgroups', $context)) {
         $usersofgroup = array_intersect_key($users, $groupmembers);
         $usersallowed = count($users) === count($usersofgroup);
     } else {
         $usersallowed = true;
     }
     // compare if selected users are members of the currentgroup if person has not the
     // right to access all groups
     $subscribesuccess = true;
     $subscribedusers = array();
     if ($usersallowed and (groups_is_member($currentgroup, $USER->id) or has_capability('moodle/site:accessallgroups', $context))) {
         foreach ($users as $user) {
             if (!$bookingoption->user_submit_response($user)) {
                 $subscribesuccess = false;
                 print_error('bookingmeanwhilefull', 'booking', $errorurl->out(), $user->id);
             }
             $subscribedusers[] = $user->id;
         }
     } else {
         print_error('invalidaction');
     }
 } else {
     if ($unsubscribe && has_capability('mod/booking:deleteresponses', $context)) {
         $users = $existingselector->get_selected_users();
         $unsubscribesuccess = true;
         foreach ($users as $user) {
             if (!$bookingoption->user_delete_response($user->id)) {
                 $unsubscribesuccess = false;