Exemplo n.º 1
0
     if ($bookingData->option->courseid != 0) {
         foreach (array_keys($fromform->user, 1) as $selecteduserid) {
             booking_enrol_user($bookingData->option, $bookingData->booking, $selecteduserid);
         }
         redirect($url, get_string('userrssucesfullenroled', 'booking'), 5);
     } else {
         redirect($url, get_string('nocourse', 'booking'), 5);
     }
     die;
 } else {
     if (isset($fromform->sendpollurl) && has_capability('mod/booking:communicate', $context) && confirm_sesskey()) {
         $selectedusers = array_keys($fromform->user, 1);
         if (empty($selectedusers)) {
             redirect($url, get_string('selectatleastoneuser', 'booking', $bookingData->option->howmanyusers), 5);
         }
         booking_sendpollurl($selectedusers, $bookingData, $cm->id, $optionid);
         redirect($url, get_string('allmailssend', 'booking'), 5);
     } else {
         if (isset($fromform->sendcustommessage) && has_capability('mod/booking:communicate', $context) && confirm_sesskey()) {
             $selectedusers = array_keys($fromform->user, 1);
             if (empty($selectedusers)) {
                 redirect($url, get_string('selectatleastoneuser', 'booking', $bookingData->option->howmanyusers), 5);
             }
             $sendmessageurl = new moodle_url('/mod/booking/sendmessage.php', array('id' => $id, 'optionid' => $optionid, 'uids' => serialize($selectedusers)));
             redirect($sendmessageurl);
         } else {
             if (isset($fromform->activitycompletion) && (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);
                 }
     // subscription submitted
     if ($bookingData->option->courseid != 0) {
         foreach ($allSelectedUsers as $selecteduserid) {
             booking_enrol_user($bookingData->option, $bookingData->booking, $selecteduserid);
         }
         redirect($url, get_string('userrssucesfullenroled', 'booking'), 5);
     } else {
         redirect($url, get_string('nocourse', 'booking'), 5);
     }
     die;
 } else {
     if (isset($_POST['sendpollurl']) && has_capability('mod/booking:communicate', $context)) {
         if (empty($allSelectedUsers)) {
             redirect($url, get_string('selectatleastoneuser', 'booking', $bookingData->option->howmanyusers), 5);
         }
         booking_sendpollurl($allSelectedUsers, $bookingData, $cm->id, $optionid);
         redirect($url, get_string('allmailssend', 'booking'), 5);
     } else {
         if (isset($_POST['sendcustommessage']) && has_capability('mod/booking:communicate', $context)) {
             if (empty($allSelectedUsers)) {
                 redirect($url, get_string('selectatleastoneuser', 'booking', $bookingData->option->howmanyusers), 5);
             }
             $sendmessageurl = new moodle_url('/mod/booking/sendmessage.php', array('id' => $id, 'optionid' => $optionid, 'uids' => serialize($allSelectedUsers)));
             redirect($sendmessageurl);
         } else {
             if (isset($_POST['activitycompletion']) && (booking_check_if_teacher($bookingData->option, $USER) || has_capability('mod/booking:readresponses', $context))) {
                 if (empty($allSelectedUsers)) {
                     redirect($url, get_string('selectatleastoneuser', 'booking', $bookingData->option->howmanyusers), 5);
                 }
                 booking_activitycompletion($allSelectedUsers, $bookingData->booking, $cm->id, $optionid);
                 redirect($url, empty($bookingData->option->notificationtext) ? get_string('activitycompletionsuccess', 'booking') : $bookingData->option->notificationtext, 5);