Browse Source

Refactor capabilities

Change name of enrol/apply:manage to enrol/apply:manageapplications to avoid confusion with reserved enrol/xxx:manage for manual enrolment status changes (see also allow_manage() method).
Remove unnecessary enrol/apply:enrol capability (plugin does not allow manual enrolment of other users)
Add description comments.
SABERES_37_STABLE
Johannes Burk 9 years ago
committed by test
parent
commit
0e5b8f8b8b
  1. 21
      db/access.php
  2. 2
      lang/ca/enrol_apply.php
  3. 2
      lang/de/enrol_apply.php
  4. 3
      lang/en/enrol_apply.php
  5. 2
      lang/en_us/en_us_enrol_apply.php
  6. 2
      lang/es/enrol_apply.php
  7. 2
      lang/it/enrol_apply.php
  8. 2
      lang/pt_br/enrol_apply.php
  9. 2
      lang/zh_cn/enrol_apply.php
  10. 2
      lib.php
  11. 4
      manage.php

21
db/access.php

@ -24,8 +24,8 @@ defined('MOODLE_INTERNAL') || die();
$capabilities = array( $capabilities = array(
/* Add, edit or remove manual enrol instance. */
'enrol/apply:config' => array( 'enrol/apply:config' => array(
'captype' => 'write', 'captype' => 'write',
'contextlevel' => CONTEXT_COURSE, 'contextlevel' => CONTEXT_COURSE,
'archetypes' => array( 'archetypes' => array(
@ -34,17 +34,12 @@ $capabilities = array(
) )
), ),
'enrol/apply:manage' => array( /**
* Enrolment approval.
'captype' => 'write', * If granted on CONTEXT_SYSTEM level it allows approval for all courses
'contextlevel' => CONTEXT_COURSE, * at Site Administration -> Courses -> Manage enrolment applications.
'archetypes' => array( */
'editingteacher' => CAP_ALLOW, 'enrol/apply:manageapplications' => array(
'manager' => CAP_ALLOW,
)
),
'enrol/apply:enrol' => array(
'captype' => 'write', 'captype' => 'write',
'contextlevel' => CONTEXT_COURSE, 'contextlevel' => CONTEXT_COURSE,
'archetypes' => array( 'archetypes' => array(
@ -53,6 +48,7 @@ $capabilities = array(
) )
), ),
/* Unenrol a user */
'enrol/apply:unenrol' => array( 'enrol/apply:unenrol' => array(
'captype' => 'write', 'captype' => 'write',
'contextlevel' => CONTEXT_COURSE, 'contextlevel' => CONTEXT_COURSE,
@ -62,6 +58,7 @@ $capabilities = array(
) )
), ),
/* Allow a user to unenrol himself */
'enrol/apply:unenrolself' => array( 'enrol/apply:unenrolself' => array(
'captype' => 'write', 'captype' => 'write',
'contextlevel' => CONTEXT_COURSE, 'contextlevel' => CONTEXT_COURSE,

2
lang/ca/enrol_apply.php

@ -35,7 +35,7 @@ $string['status'] = 'Permet inscripció prèvia aprovació';
$string['confirmenrol'] = 'Gestionar sol·licituds'; $string['confirmenrol'] = 'Gestionar sol·licituds';
$string['apply:config'] = 'Configurar instàncies d\'Inscripció prèvia aprovació'; // Needs more insight $string['apply:config'] = 'Configurar instàncies d\'Inscripció prèvia aprovació'; // Needs more insight
$string['apply:manage'] = 'Gestionar la Inscripció prèvia aprovació'; // Needs more insight $string['apply:manageapplications'] = 'Gestionar la Inscripció prèvia aprovació'; // Needs more insight
$string['apply:unenrol'] = 'Cancel·lar usuaris del curs'; // Needs more insight $string['apply:unenrol'] = 'Cancel·lar usuaris del curs'; // Needs more insight
$string['notification'] = '<b>Sol·licitud d\'inscripció enviada correctament</b>. <br/><br/>Rebràs una notificació per correu electrònic un cop estigui confirmada la inscripció.'; $string['notification'] = '<b>Sol·licitud d\'inscripció enviada correctament</b>. <br/><br/>Rebràs una notificació per correu electrònic un cop estigui confirmada la inscripció.';

2
lang/de/enrol_apply.php

@ -40,7 +40,7 @@ $string['status'] = 'Bestätigung der Kurseinschreibung erlauben';
$string['confirmenrol'] = 'Einschreibeanfragen bearbeiten'; $string['confirmenrol'] = 'Einschreibeanfragen bearbeiten';
$string['apply:config'] = 'Einschreibungsbelegstellen anlegen'; $string['apply:config'] = 'Einschreibungsbelegstellen anlegen';
$string['apply:manage'] = 'Einschreibungsanfragen verwalten'; $string['apply:manageapplications'] = 'Einschreibungsanfragen verwalten';
$string['apply:unenrol'] = 'Benutzer aus dem Kurs entfernen'; $string['apply:unenrol'] = 'Benutzer aus dem Kurs entfernen';
$string['notification'] = '<b>Einschreibungsantrag wurde erfolgreich gesendet.</b>. <br/><br/>Sie werden via Mail informiert, sobald Ihre Einschreibung bestätigt wurde.'; $string['notification'] = '<b>Einschreibungsantrag wurde erfolgreich gesendet.</b>. <br/><br/>Sie werden via Mail informiert, sobald Ihre Einschreibung bestätigt wurde.';

3
lang/en/enrol_apply.php

@ -56,8 +56,7 @@ $string['status'] = 'Allow Course enrol confirmation';
$string['confirmenrol'] = 'Manage application'; $string['confirmenrol'] = 'Manage application';
$string['apply:config'] = 'Configure apply enrol instances'; $string['apply:config'] = 'Configure apply enrol instances';
$string['apply:enrol'] = 'Enrol users'; $string['apply:manageapplications'] = 'Manage apply enrolment';
$string['apply:manage'] = 'Manage apply enrolment';
$string['apply:unenrol'] = 'Cancel users from the course'; $string['apply:unenrol'] = 'Cancel users from the course';
$string['apply:unenrolself'] = 'Cancel self from the course'; $string['apply:unenrolself'] = 'Cancel self from the course';

2
lang/en_us/en_us_enrol_apply.php

@ -35,7 +35,7 @@ $string['status'] = 'Allow course enroll confirmation';
$string['confirmenroll'] = 'Manage application'; $string['confirmenroll'] = 'Manage application';
$string['apply:config'] = 'Configure apply enroll instances'; $string['apply:config'] = 'Configure apply enroll instances';
$string['apply:manage'] = 'Manage apply enrollment'; $string['apply:manageapplications'] = 'Manage apply enrollment';
$string['apply:unenroll'] = 'Cancel users from the course'; $string['apply:unenroll'] = 'Cancel users from the course';
$string['apply:unenrollapply'] = 'Cancel self from the course'; $string['apply:unenrollapply'] = 'Cancel self from the course';

2
lang/es/enrol_apply.php

@ -35,7 +35,7 @@ $string['status'] = 'Aceptar matriculación tras aprobación';
$string['confirmenrol'] = 'Gestionar solicitudes'; $string['confirmenrol'] = 'Gestionar solicitudes';
$string['apply:config'] = 'Configurar instancias de matrículas solicitadas'; // Needs more insight $string['apply:config'] = 'Configurar instancias de matrículas solicitadas'; // Needs more insight
$string['apply:manage'] = 'Gestionar matrículas solicitadas'; // Needs more insight $string['apply:manageapplications'] = 'Gestionar matrículas solicitadas'; // Needs more insight
$string['apply:unenrol'] = 'Cancelar usuarios del curso'; // Needs more insight $string['apply:unenrol'] = 'Cancelar usuarios del curso'; // Needs more insight
$string['notification'] = '<b>Solicitud de matriculación enviada correctamente</b>. <br/><br/>Será notificado por correo electrónico en cuanto se confirme su matriculación.'; $string['notification'] = '<b>Solicitud de matriculación enviada correctamente</b>. <br/><br/>Será notificado por correo electrónico en cuanto se confirme su matriculación.';

2
lang/it/enrol_apply.php

@ -35,7 +35,7 @@ $string['status'] = 'Permetti la conferma di iscrizione al corso';
$string['confirmenrol'] = 'Gestisci l\'applicazione'; $string['confirmenrol'] = 'Gestisci l\'applicazione';
$string['apply:config'] = 'Configura le istanze del plugin'; $string['apply:config'] = 'Configura le istanze del plugin';
$string['apply:manage'] = 'Gestisci le richieste di iscrizione'; $string['apply:manageapplications'] = 'Gestisci le richieste di iscrizione';
$string['apply:unenrol'] = 'Cancella gli utenti dal corso'; $string['apply:unenrol'] = 'Cancella gli utenti dal corso';
$string['apply:unenrolself'] = 'Permetti all\'utente di disiscriversi dal corso'; $string['apply:unenrolself'] = 'Permetti all\'utente di disiscriversi dal corso';

2
lang/pt_br/enrol_apply.php

@ -35,7 +35,7 @@ $string['status'] = 'Aceitar matrícula após aprovação';
$string['confirmenrol'] = 'Gerenciar solicitações'; $string['confirmenrol'] = 'Gerenciar solicitações';
$string['apply:config'] = 'Configurar instâncias de matrículas solicitadas'; // Needs more insight $string['apply:config'] = 'Configurar instâncias de matrículas solicitadas'; // Needs more insight
$string['apply:manage'] = 'Gerenciar matrículas solicitadas'; // Needs more insight $string['apply:manageapplications'] = 'Gerenciar matrículas solicitadas'; // Needs more insight
$string['apply:unenrol'] = 'Cancelar usuários do curso'; // Needs more insight $string['apply:unenrol'] = 'Cancelar usuários do curso'; // Needs more insight
$string['notification'] = '<b>Solicitação de matrícula enviada com sucesso</b>. <br/><br/>Você será notificado por e-mail quando a sua matrícula for confirmada.'; $string['notification'] = '<b>Solicitação de matrícula enviada com sucesso</b>. <br/><br/>Você será notificado por e-mail quando a sua matrícula for confirmada.';

2
lang/zh_cn/enrol_apply.php

@ -35,7 +35,7 @@ $string['status'] = '允许选课确认';
$string['confirmenrol'] = '管理申请'; $string['confirmenrol'] = '管理申请';
$string['apply:config'] = '配置选课确认的实例'; $string['apply:config'] = '配置选课确认的实例';
$string['apply:manage'] = '管理选课申请'; $string['apply:manageapplications'] = '管理选课申请';
$string['apply:unenrol'] = '从课程中取消用户的选课'; $string['apply:unenrol'] = '从课程中取消用户的选课';
$string['apply:unenrolself'] = '从课程中取消自身的选课'; $string['apply:unenrolself'] = '从课程中取消自身的选课';

2
lib.php

@ -113,7 +113,7 @@ class enrol_apply_plugin extends enrol_plugin {
$icons[] = $OUTPUT->action_icon($editlink, new pix_icon('t/edit', get_string('edit'), 'core', array('class' => 'iconsmall'))); $icons[] = $OUTPUT->action_icon($editlink, new pix_icon('t/edit', get_string('edit'), 'core', array('class' => 'iconsmall')));
} }
if (has_capability('enrol/apply:manage', $context)) { if (has_capability('enrol/apply:manageapplications', $context)) {
$managelink = new moodle_url("/enrol/apply/manage.php", array('id'=>$instance->id)); $managelink = new moodle_url("/enrol/apply/manage.php", array('id'=>$instance->id));
$icons[] = $OUTPUT->action_icon($managelink, new pix_icon('i/users', get_string('confirmenrol', 'enrol_apply'), 'core', array('class'=>'iconsmall'))); $icons[] = $OUTPUT->action_icon($managelink, new pix_icon('i/users', get_string('confirmenrol', 'enrol_apply'), 'core', array('class'=>'iconsmall')));
} }

4
manage.php

@ -23,14 +23,14 @@ require_login();
$manageurlparams = array(); $manageurlparams = array();
if ($id == null) { if ($id == null) {
$context = context_system::instance(); $context = context_system::instance();
require_capability('enrol/apply:manage', $context); require_capability('enrol/apply:manageapplications', $context);
$pageheading = get_string('confirmusers', 'enrol_apply'); $pageheading = get_string('confirmusers', 'enrol_apply');
} else { } else {
$instance = $DB->get_record('enrol', array('id'=>$id, 'enrol'=>'apply'), '*', MUST_EXIST); $instance = $DB->get_record('enrol', array('id'=>$id, 'enrol'=>'apply'), '*', MUST_EXIST);
require_course_login($instance->courseid); require_course_login($instance->courseid);
$course = get_course($instance->courseid); $course = get_course($instance->courseid);
$context = context_course::instance($course->id, MUST_EXIST); $context = context_course::instance($course->id, MUST_EXIST);
require_capability('moodle/course:enrolreview', $context); require_capability('enrol/apply:manageapplications', $context);
$manageurlparams['id'] = $instance->id; $manageurlparams['id'] = $instance->id;
$pageheading = $course->fullname; $pageheading = $course->fullname;
} }

Loading…
Cancel
Save