diff --git a/index.php b/index.php index 99d50a7..aad2d46 100644 --- a/index.php +++ b/index.php @@ -516,10 +516,13 @@ echo ''; echo ''; echo ''; -print ''; +print ''; echo $OUTPUT->box_end(); echo $OUTPUT->footer(); diff --git a/lang/en/report_ilbenrol.php b/lang/en/report_ilbenrol.php index 324bd81..d484d7b 100644 --- a/lang/en/report_ilbenrol.php +++ b/lang/en/report_ilbenrol.php @@ -33,6 +33,9 @@ $string['confirmed'] = 'Role to confirmed enrollment'; $string['confirmeddescription'] = 'Role to confirmed enrollments'; $string['revoked'] = 'Role to revoked enrollment'; $string['revokeddescription'] = 'Role to revoked enrollment'; +$string['suspendrevoked'] = 'Suspend all revoked enrollments'; +$string['suspendsuccess'] = 'All revoked enrols are successfull suspended'; +$string['suspenderror'] = 'ERROR: A database error occurs and no revoked enrols are suspended'; $string['changeduser'] = 'User {$a->user} changed from role {$a->from} to {$a->to}'; $string['return'] = 'Return'; $string['total'] = 'Totals'; diff --git a/lang/pt_br/report_ilbenrol.php b/lang/pt_br/report_ilbenrol.php index 2db79f6..927e8fe 100644 --- a/lang/pt_br/report_ilbenrol.php +++ b/lang/pt_br/report_ilbenrol.php @@ -33,6 +33,9 @@ $string['confirmed'] = 'Função para matrícula confirmada'; $string['confirmeddescription'] = 'Função para matrícula confirmada'; $string['revoked'] = 'Função para matrícula revogada'; $string['revokeddescription'] = 'Função para matrícula revogada'; +$string['suspendrevoked'] = 'Suspender todas as inscrições revogadas - PROCESSO IRREVERSÍVEL'; +$string['suspendsuccess'] = 'Todas as pré-inscrições revogadas foram suspendidas com sucesso.'; +$string['suspenderror'] = 'ERRO: Um erro de banco de dados ocorreu e nenhuma pré-inscrição revogada foi suspensa.'; $string['changeduser'] = 'Usuário {$a->user} alterado da função {$a->from} para {$a->to}'; $string['return'] = 'Voltar'; $string['total'] = 'Totais'; diff --git a/suspend.php b/suspend.php new file mode 100644 index 0000000..d711e84 --- /dev/null +++ b/suspend.php @@ -0,0 +1,83 @@ +. + +/** + * Wrapper script redirecting user operations to correct destination. + * + * @copyright 1999 Martin Dougiamas http://dougiamas.com + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package user + */ + +require_once("../../config.php"); +require("{$CFG->dirroot}/enrol/locallib.php"); + +$id = required_param('course', PARAM_INT); + +if (!confirm_sesskey()) { + print_error('confirmsesskeybad'); +} + +$role_revoked = get_config(null, 'report_ilbenrol_revoked'); + +if (!$role_revoked) { + print_error('invalidargorconf'); +} + +$course = $DB->get_record('course',array('id'=>$id)); + +if (!$course) { + print_error('invalidcourseid'); +} + +$context = context_course::instance($course->id); +$manager = new course_enrolment_manager($PAGE, $course, null, $role_revoked); +$instances = $manager->get_enrolment_instances(); +$contextids = $context->get_parent_context_ids(true); + +// Prepare select +list($in_instances, $param_instances) = $DB->get_in_or_equal(array_keys($instances), SQL_PARAMS_NAMED); +list($in_contexts, $param_contexts) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED); +$params = $param_instances + $param_contexts; + +$sql = "UPDATE {user_enrolments} SET status = 1 WHERE id in ( +SELECT DISTINCT ue.id +FROM {user} u + JOIN {user_enrolments} ue ON (ue.userid = u.id AND ue.enrolid {$in_instances}) + JOIN {role_assignments} ra ON (ra.userid = u.id AND ra.contextid {$in_contexts}) +WHERE ra.roleid = {$role_revoked})"; + +$PAGE->set_heading($course->fullname); +$PAGE->set_url('/user/action.php', array('action'=>$action,'id'=>$id)); +$PAGE->set_pagelayout('report'); +$PAGE->set_title(get_string('title','report_ilbenrol')); +$PAGE->set_heading($course->fullname); + +require_login($course); +require_capability('report/ilbenrol:view',$context); + +echo $OUTPUT->header(); + +if ($DB->execute($sql, $params)) { + echo $OUTPUT->box(get_string('suspendsuccess', 'report_ilbenrol')); +} else { + echo $OUTPUT->container(get_string('suspenderror', 'report_ilbenrol'), 'errorbox errorboxcontent'); +} + +echo ''.get_string('return', 'report_ilbenrol').''; +echo $OUTPUT->footer(); +