Exemplo n.º 1
0
function booking_send_notification($optionid, $subject)
{
    global $DB, $USER, $CFG;
    require_once "{$CFG->dirroot}/mod/booking/locallib.php";
    $returnVal = true;
    $option = $DB->get_record('booking_options', array('id' => $optionid));
    $booking = $DB->get_record('booking', array('id' => $option->bookingid));
    $cm = get_coursemodule_from_instance('booking', $booking->id);
    $bookingData = new booking_option($cm->id, $option->id);
    $bookingData->apply_tags();
    if (isset($bookingData->usersOnList)) {
        $allusers = $bookingData->usersOnList;
        foreach ($allusers as $record) {
            $ruser = $DB->get_record('user', array('id' => $record->id));
            $params = booking_generate_email_params($bookingData->booking, $bookingData->option, $ruser, $cm->id);
            $pollurlmessage = booking_get_email_body($bookingData->booking, 'notificationtext', 'notificationtextmessage', $params);
            $eventdata = new stdClass();
            $eventdata->modulename = 'booking';
            $eventdata->userfrom = $USER;
            $eventdata->userto = $ruser;
            $eventdata->subject = $subject;
            $eventdata->fullmessage = strip_tags(preg_replace('#<br\\s*?/?>#i', "\n", $pollurlmessage));
            $eventdata->fullmessageformat = FORMAT_HTML;
            $eventdata->fullmessagehtml = $pollurlmessage;
            $eventdata->smallmessage = '';
            $eventdata->component = 'mod_booking';
            $eventdata->name = 'bookingconfirmation';
            $returnVal = message_send($eventdata);
        }
        return $returnVal;
    } else {
        return FALSE;
    }
}
Exemplo n.º 2
0
echo $OUTPUT->header();
// check if custom user profile fields are required and redirect to complete them if necessary
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();
}
if ($mform->is_cancelled()) {
    $redirecturl = new moodle_url('view.php', array('id' => $cm->id));
    redirect($redirecturl, '', 0);
} else {
    if ($fromform = $mform->get_data()) {
        //validated data.
        if (confirm_sesskey() && has_capability('mod/booking:updatebooking', $context)) {
            if (!isset($fromform->limitanswers)) {
                $fromform->limitanswers = 0;
            }
            if (!isset($fromform->daystonotify)) {
                $fromform->daystonotify = 0;
            }
            $nBooking = booking_update_options($fromform);
            $bookingData = new booking_option($cm->id, $nBooking);
            $bookingData->sync_waiting_list();
            if (isset($fromform->submittandaddnew)) {
                $redirecturl = new moodle_url('editoptions.php', array('id' => $cm->id, 'optionid' => 'add'));
                redirect($redirecturl, get_string('changessaved'), 0);
            } else {
                $redirecturl = new moodle_url('report.php', array('id' => $cm->id, 'optionid' => $nBooking));
                redirect($redirecturl, get_string('changessaved'), 0);
            }
        }
    } else {
        $PAGE->set_title(format_string($booking->name));
        $PAGE->set_heading($course->fullname);
        echo $OUTPUT->header();
        // this branch is executed if the form is submitted but the data doesn't validate and the form should be redisplayed
        // or on the first display of the form.
Exemplo n.º 4
0
             }
             $studentid = !empty($user->idnumber) ? $user->idnumber : " ";
             $ug2 = '';
             if ($usergrps = groups_get_all_groups($course->id, $user->id)) {
                 foreach ($usergrps as $ug) {
                     $ug2 = $ug2 . $ug->name;
                 }
             }
             $row++;
             $pos = 4;
         }
     }
 } else {
     // get list of one specified booking option: $action is $optionid
     foreach ($bookingData->get_all_users() as $usernumber => $user) {
         $bookingData = new booking_option($cm->id, $optionid);
         $bookingData->apply_tags();
         $option_text = $bookingData->option->text;
         if ($user->waitinglist) {
             $cellform = $cellformat1;
         } else {
             $cellform = $cellformat;
         }
         if (isset($option_text)) {
             $myxls->write_string($row, 0, format_string($option_text, true));
         }
         $myxls->write_string($row, 1, $user->id, $cellform);
         $myxls->write_string($row, 2, $user->firstname, $cellform);
         $myxls->write_string($row, 3, $user->lastname, $cellform);
         $myxls->write_string($row, 4, $user->email, $cellform);
         $i = 5;
Exemplo n.º 5
0
 * @package mod/booking
 */
require_once dirname(dirname(dirname(__FILE__))) . '/config.php';
require_once $CFG->dirroot . '/mod/booking/locallib.php';
$id = required_param('id', PARAM_INT);
// course_module ID
$optionid = required_param('optionid', PARAM_INT);
//
$subscribe = optional_param('subscribe', false, PARAM_BOOL);
$unsubscribe = optional_param('unsubscribe', false, PARAM_BOOL);
$agree = optional_param('agree', false, PARAM_BOOL);
$cm = get_coursemodule_from_id('booking', $id, 0, false, MUST_EXIST);
$course = get_course($cm->course);
(bool) ($subscribesuccess = false);
(bool) ($unsubscribesuccess = false);
$bookingoption = new booking_option($id, $optionid);
$bookingoption->apply_tags();
require_login($course, true, $cm);
/// Print the page header
$context = context_module::instance($cm->id);
$PAGE->set_context($context);
require_capability('mod/booking:subscribeusers', $context);
$url = new moodle_url('/mod/booking/subscribeusers.php', array('id' => $id, 'optionid' => $optionid));
$errorurl = new moodle_url('/mod/booking/view.php', array('id' => $id));
$PAGE->set_url($url);
$PAGE->set_title(get_string('modulename', 'booking'));
$PAGE->set_heading($COURSE->fullname);
$PAGE->navbar->add(get_string('booking:subscribeusers', 'booking'), $url);
if (!$agree && !empty($bookingoption->booking->bookingpolicy)) {
    echo $OUTPUT->header();
    $alright = false;