Пример #1
0
 public function render_course_enrolment_users_table(course_enrolment_users_table $table, moodleform $mform)
 {
     $table->initialise_javascript();
     // Added for the Bootstrap theme. Make this table responsive.
     $table->attributes['class'] .= ' table table-responsive';
     $buttons = $table->get_manual_enrol_buttons();
     $buttonhtml = '';
     if (count($buttons) > 0) {
         $buttonhtml .= html_writer::start_tag('div', array('class' => 'enrol_user_buttons'));
         foreach ($buttons as $button) {
             $buttonhtml .= $this->render($button);
         }
         $buttonhtml .= html_writer::end_tag('div');
     }
     $content = '';
     if (!empty($buttonhtml)) {
         $content .= $buttonhtml;
     }
     $content .= $mform->render();
     $content .= $this->output->render($table->get_paging_bar());
     // Check if the table has any bulk operations. If it does we want to wrap the table in a
     // form so that we can capture and perform any required bulk operations.
     if ($table->has_bulk_user_enrolment_operations()) {
         $content .= html_writer::start_tag('form', array('action' => new moodle_url('/enrol/bulkchange.php'), 'method' => 'post'));
         foreach ($table->get_combined_url_params() as $key => $value) {
             if ($key == 'action') {
                 continue;
             }
             $content .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $key, 'value' => $value));
         }
         $content .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'action', 'value' => 'bulkchange'));
         $content .= html_writer::table($table);
         $content .= html_writer::start_tag('div', array('class' => 'singleselect bulkuserop'));
         $content .= html_writer::start_tag('select', array('name' => 'bulkuserop'));
         $content .= html_writer::tag('option', get_string('withselectedusers', 'enrol'), array('value' => ''));
         $options = array('' => get_string('withselectedusers', 'enrol'));
         foreach ($table->get_bulk_user_enrolment_operations() as $operation) {
             $content .= html_writer::tag('option', $operation->get_title(), array('value' => $operation->get_identifier()));
         }
         $content .= html_writer::end_tag('select');
         $content .= html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('go')));
         $content .= html_writer::end_tag('div');
         $content .= html_writer::end_tag('form');
     } else {
         // Added for the Bootstrap theme, a no-overflow wrapper.
         $content .= html_writer::start_tag('div', array('class' => 'no-overflow'));
         $content .= html_writer::table($table);
         $content .= html_writer::end_tag('div');
     }
     $content .= $this->output->render($table->get_paging_bar());
     if (!empty($buttonhtml)) {
         $content .= $buttonhtml;
     }
     return $content;
 }
Пример #2
0
// course id
$bulkuserop = required_param('bulkuserop', PARAM_ALPHANUMEXT);
$userids = required_param_array('bulkuser', PARAM_INT);
$action = optional_param('action', '', PARAM_ACTION);
$filter = optional_param('ifilter', 0, PARAM_INT);
$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
$context = get_context_instance(CONTEXT_COURSE, $course->id, MUST_EXIST);
if ($course->id == SITEID) {
    redirect(new moodle_url('/'));
}
require_login($course);
require_capability('moodle/course:enrolreview', $context);
$PAGE->set_pagelayout('admin');
$manager = new course_enrolment_manager($PAGE, $course, $filter);
$table = new course_enrolment_users_table($manager, $PAGE);
$returnurl = new moodle_url('/enrol/users.php', $table->get_combined_url_params());
$actionurl = new moodle_url('/enrol/bulkchange.php', $table->get_combined_url_params() + array('bulkuserop' => $bulkuserop));
$PAGE->set_url($actionurl);
navigation_node::override_active_url(new moodle_url('/enrol/users.php', array('id' => $id)));
$ops = $table->get_bulk_user_enrolment_operations();
if (!array_key_exists($bulkuserop, $ops)) {
    throw new moodle_exception('invalidbulkenrolop');
}
$operation = $ops[$bulkuserop];
// Prepare the properties of the form
$users = $manager->get_users_enrolments($userids);
// Get the form for the bulk operation
$mform = $operation->get_form($actionurl, array('users' => $users));
// If the mform is false then attempt an immediate process. This may be an immediate action that
// doesn't require user input OR confirmation.... who know what but maybe one day
if ($mform === false) {