Exemple #1
0
$PAGE->set_url($url);
$PAGE->set_pagelayout('standard');
//Capabilities
//Validates capabilities of the user for him to see the content
//In this case only the admin of the module can access.
if (!has_capability('local/bookingrooms:blocking', $context)) {
    print_error(get_string('INVALID_ACCESS', 'booking_room'));
}
//Migas de pan
$PAGE->navbar->add(get_string('roomsreserve', 'local_bookingrooms'));
$PAGE->navbar->add(get_string('users', 'local_bookingrooms'));
$PAGE->navbar->add(get_string('unblockstudent', 'local_bookingrooms'));
//$PAGE->set_title('UAI Webcursos');
//$PAGE->set_heading('UAI Webcursos');
//Form to unblock a student
$unblockform = new UnblockStudentForm();
if ($fromform = $unblcokform->get_data()) {
    //if the form is sent, the student exists and it is blocked, then it will be unblocked.
    //else it will show a mesage according to the error.
    if ($user = $DB->get_record('user', array('username' => $fromform->user))) {
        $datenow = date('Y-m-d');
        if ($block = $DB->get_record('bookingrooms_blocked', array('student_id' => $user->id, 'status' => 1))) {
            //('reservasalas_bloqueados', array('alumno_id'=>$user->id));
            $record = new stdClass();
            $record->id = $block->id;
            $record->id_booking = $block->id_booking;
            $record->comments = $fromform->comment;
            $record->status = 0;
            $DB->update_record('bookingrooms_blocked', $record);
            $unblock = true;
        } else {
//context_system::instance();
$PAGE->set_context($context);
$PAGE->set_url($url);
$PAGE->set_pagelayout('standard');
//Capabilities
//Validates capabilities of the user for him to see the content
//In this case only the admin of the module can access.
if (!has_capability('local/bookingrooms:blocking', $context)) {
    print_error(get_string('invalidaccess', 'local_bookingrooms'));
}
//Migas de pan
$PAGE->navbar->add(get_string('roomsreserve', 'local_bookingrooms'));
$PAGE->navbar->add(get_string('users', 'local_bookingrooms'));
$PAGE->navbar->add(get_string('unblockstudent', 'local_bookingrooms'));
//Form to unblock a student
$unblockform = new UnblockStudentForm();
if ($fromform = $unblockform->get_data()) {
    //if the form is sent, the student exists and it is blocked, then it will be unblocked.
    //else it will show a mesage according to the error.
    if ($user = $DB->get_record('user', array('email' => $fromform->email))) {
        $datenow = date('Y-m-d');
        if ($block = $DB->get_record('bookingrooms_blocked', array('student_id' => $user->id, 'status' => 1))) {
            $record = new stdClass();
            $record->id = $block->id;
            $record->id_reserve = $block->id_reserve;
            $record->comments = $fromform->commentary;
            $record->status = 0;
            $DB->update_record('bookingrooms_blocked', $record);
            $unblock = true;
        }
    }