Browse Source

Rotina para suspender acesso de alunos não selecionados

master
Sesostris Vieira 11 years ago
parent
commit
ccdd60cdea
  1. 9
      index.php
  2. 3
      lang/en/report_ilbenrol.php
  3. 3
      lang/pt_br/report_ilbenrol.php
  4. 83
      suspend.php

9
index.php

@ -516,10 +516,13 @@ echo '</noscript>';
echo '</div>'; echo '</div>';
echo '</form>'; echo '</form>';
print '<ul class="progress-actions"><li><a href="index.php?course='.$course->id. print '<ul class="progress-actions">
'&amp;format=csv">'.get_string('csvdownload','completion').'</a></li> <li><a href="index.php?course='.$course->id.'&amp;format=csv">'.
get_string('csvdownload','completion').'</a></li>
<li><a href="index.php?course='.$course->id.'&amp;format=excelcsv">'. <li><a href="index.php?course='.$course->id.'&amp;format=excelcsv">'.
get_string('excelcsvdownload','completion').'</a></li></ul>'; get_string('excelcsvdownload','completion').'</a></li>
<li><a href="suspend.php?course='.$course->id.'&amp;sesskey='.sesskey().'">'.
get_string('suspendrevoked', 'report_ilbenrol').'</a></li></ul>';
echo $OUTPUT->box_end(); echo $OUTPUT->box_end();
echo $OUTPUT->footer(); echo $OUTPUT->footer();

3
lang/en/report_ilbenrol.php

@ -33,6 +33,9 @@ $string['confirmed'] = 'Role to confirmed enrollment';
$string['confirmeddescription'] = 'Role to confirmed enrollments'; $string['confirmeddescription'] = 'Role to confirmed enrollments';
$string['revoked'] = 'Role to revoked enrollment'; $string['revoked'] = 'Role to revoked enrollment';
$string['revokeddescription'] = '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 <strong>{$a->user}</strong> changed from role <strong>{$a->from}</strong> to <strong>{$a->to}</strong>'; $string['changeduser'] = 'User <strong>{$a->user}</strong> changed from role <strong>{$a->from}</strong> to <strong>{$a->to}</strong>';
$string['return'] = 'Return'; $string['return'] = 'Return';
$string['total'] = 'Totals'; $string['total'] = 'Totals';

3
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['confirmeddescription'] = 'Função para matrícula confirmada';
$string['revoked'] = 'Função para matrícula revogada'; $string['revoked'] = 'Função para matrícula revogada';
$string['revokeddescription'] = '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 <strong>{$a->user}</strong> alterado da função <strong>{$a->from}</strong> para <strong>{$a->to}</strong>'; $string['changeduser'] = 'Usuário <strong>{$a->user}</strong> alterado da função <strong>{$a->from}</strong> para <strong>{$a->to}</strong>';
$string['return'] = 'Voltar'; $string['return'] = 'Voltar';
$string['total'] = 'Totais'; $string['total'] = 'Totais';

83
suspend.php

@ -0,0 +1,83 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* 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 '<a href="index.php?course='.$course->id.'">'.get_string('return', 'report_ilbenrol').'</a>';
echo $OUTPUT->footer();
Loading…
Cancel
Save