Exemplo n.º 1
0
// 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();
            die;
Exemplo n.º 2
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.º 3
0
 */
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;
    $message = "<p><b>" . get_string('agreetobookingpolicy', 'booking') . ":</b></p>";