| Línea 112... |
Línea 112... |
| 112 |
$icons = array();
|
112 |
$icons = array();
|
| 113 |
if (has_capability('enrol/manual:enrol', $context) or has_capability('enrol/manual:unenrol', $context)) {
|
113 |
if (has_capability('enrol/manual:enrol', $context) or has_capability('enrol/manual:unenrol', $context)) {
|
| 114 |
$managelink = new moodle_url("/enrol/manual/manage.php", array('enrolid'=>$instance->id));
|
114 |
$managelink = new moodle_url("/enrol/manual/manage.php", array('enrolid'=>$instance->id));
|
| 115 |
$icons[] = $OUTPUT->action_icon($managelink, new pix_icon('t/enrolusers', get_string('enrolusers', 'enrol_manual'), 'core', array('class'=>'iconsmall')));
|
115 |
$icons[] = $OUTPUT->action_icon($managelink, new pix_icon('t/enrolusers', get_string('enrolusers', 'enrol_manual'), 'core', array('class'=>'iconsmall')));
|
| 116 |
}
|
116 |
}
|
| - |
|
117 |
|
| - |
|
118 |
if (has_any_capability(['enrol/manual:config', 'moodle/course:editcoursewelcomemessage'], $context)) {
|
| - |
|
119 |
$linkparams = [
|
| - |
|
120 |
'courseid' => $instance->courseid,
|
| - |
|
121 |
'id' => $instance->id,
|
| - |
|
122 |
'type' => $instance->enrol,
|
| - |
|
123 |
];
|
| 117 |
$parenticons = parent::get_action_icons($instance);
|
124 |
$editlink = new moodle_url('/enrol/editinstance.php', $linkparams);
|
| - |
|
125 |
$icon = new pix_icon('t/edit', get_string('edit'), 'core', ['class' => 'iconsmall']);
|
| 118 |
$icons = array_merge($icons, $parenticons);
|
126 |
$icons[] = $OUTPUT->action_icon($editlink, $icon);
|
| - |
|
127 |
}
|
| Línea 119... |
Línea 128... |
| 119 |
|
128 |
|
| 120 |
return $icons;
|
129 |
return $icons;
|
| Línea 121... |
Línea 130... |
| 121 |
}
|
130 |
}
|
| Línea 144... |
Línea 153... |
| 144 |
* Add new instance of enrol plugin.
|
153 |
* Add new instance of enrol plugin.
|
| 145 |
* @param stdClass $course
|
154 |
* @param stdClass $course
|
| 146 |
* @param array instance fields
|
155 |
* @param array instance fields
|
| 147 |
* @return int id of new instance, null if can not be created
|
156 |
* @return int id of new instance, null if can not be created
|
| 148 |
*/
|
157 |
*/
|
| 149 |
public function add_instance($course, array $fields = NULL) {
|
158 |
public function add_instance($course, ?array $fields = NULL) {
|
| 150 |
global $DB;
|
159 |
global $DB;
|
| Línea 151... |
Línea 160... |
| 151 |
|
160 |
|
| 152 |
if ($DB->record_exists('enrol', array('courseid'=>$course->id, 'enrol'=>'manual'))) {
|
161 |
if ($DB->record_exists('enrol', array('courseid'=>$course->id, 'enrol'=>'manual'))) {
|
| 153 |
// only one instance allowed, sorry
|
162 |
// only one instance allowed, sorry
|
| Línea 173... |
Línea 182... |
| 173 |
$this->delete_instance($anotherinstance);
|
182 |
$this->delete_instance($anotherinstance);
|
| 174 |
}
|
183 |
}
|
| 175 |
}
|
184 |
}
|
| 176 |
}
|
185 |
}
|
| Línea -... |
Línea 186... |
| - |
|
186 |
|
| - |
|
187 |
// This method is used when configuring the enrolment method, and when only updating the welcome message.
|
| - |
|
188 |
// The 'expirynotify' property won't be set when updating the welcome message.
|
| 177 |
|
189 |
if (isset($data->expirynotify)) {
|
| - |
|
190 |
$data->notifyall = $data->expirynotify == 2 ? 1 : 0;
|
| Línea 178... |
Línea 191... |
| 178 |
$data->notifyall = $data->expirynotify == 2 ? 1 : 0;
|
191 |
}
|
| 179 |
|
192 |
|
| Línea 180... |
Línea 193... |
| 180 |
return parent::update_instance($instance, $data);
|
193 |
return parent::update_instance($instance, $data);
|
| Línea 580... |
Línea 593... |
| 580 |
* @param context $context
|
593 |
* @param context $context
|
| 581 |
* @return bool
|
594 |
* @return bool
|
| 582 |
*/
|
595 |
*/
|
| 583 |
public function edit_instance_form($instance, MoodleQuickForm $mform, $context) {
|
596 |
public function edit_instance_form($instance, MoodleQuickForm $mform, $context) {
|
| Línea -... |
Línea 597... |
| - |
|
597 |
|
| - |
|
598 |
// Main fields.
|
| 584 |
|
599 |
if (has_capability('enrol/manual:config', $context)) {
|
| 585 |
$options = $this->get_status_options();
|
600 |
$options = $this->get_status_options();
|
| 586 |
$mform->addElement('select', 'status', get_string('status', 'enrol_manual'), $options);
|
601 |
$mform->addElement('select', 'status', get_string('status', 'enrol_manual'), $options);
|
| 587 |
$mform->addHelpButton('status', 'status', 'enrol_manual');
|
602 |
$mform->addHelpButton('status', 'status', 'enrol_manual');
|
| 588 |
$mform->setDefault('status', $this->get_config('status'));
|
603 |
$mform->setDefault('status', $this->get_config('status'));
|
| 589 |
|
604 |
|
| 590 |
$roles = $this->get_roleid_options($instance, $context);
|
605 |
$roles = $this->get_roleid_options($instance, $context);
|
| 591 |
$mform->addElement('select', 'roleid', get_string('defaultrole', 'role'), $roles);
|
606 |
$mform->addElement('select', 'roleid', get_string('defaultrole', 'role'), $roles);
|
| 592 |
$mform->setDefault('roleid', $this->get_config('roleid'));
|
607 |
$mform->setDefault('roleid', $this->get_config('roleid'));
|
| 593 |
|
608 |
|
| 594 |
$options = array('optional' => true, 'defaultunit' => 86400);
|
609 |
$options = ['optional' => true, 'defaultunit' => 86400];
|
| 595 |
$mform->addElement('duration', 'enrolperiod', get_string('defaultperiod', 'enrol_manual'), $options);
|
610 |
$mform->addElement('duration', 'enrolperiod', get_string('defaultperiod', 'enrol_manual'), $options);
|
| 596 |
$mform->setDefault('enrolperiod', $this->get_config('enrolperiod'));
|
611 |
$mform->setDefault('enrolperiod', $this->get_config('enrolperiod'));
|
| 597 |
$mform->addHelpButton('enrolperiod', 'defaultperiod', 'enrol_manual');
|
612 |
$mform->addHelpButton('enrolperiod', 'defaultperiod', 'enrol_manual');
|
| 598 |
|
613 |
|
| 599 |
$options = $this->get_expirynotify_options();
|
614 |
$options = $this->get_expirynotify_options();
|
| 600 |
$mform->addElement('select', 'expirynotify', get_string('expirynotify', 'core_enrol'), $options);
|
615 |
$mform->addElement('select', 'expirynotify', get_string('expirynotify', 'core_enrol'), $options);
|
| 601 |
$mform->addHelpButton('expirynotify', 'expirynotify', 'core_enrol');
|
616 |
$mform->addHelpButton('expirynotify', 'expirynotify', 'core_enrol');
|
| 602 |
|
617 |
|
| 603 |
$options = array('optional' => false, 'defaultunit' => 86400);
|
618 |
$options = ['optional' => false, 'defaultunit' => 86400];
|
| 604 |
$mform->addElement('duration', 'expirythreshold', get_string('expirythreshold', 'core_enrol'), $options);
|
619 |
$mform->addElement('duration', 'expirythreshold', get_string('expirythreshold', 'core_enrol'), $options);
|
| 605 |
$mform->addHelpButton('expirythreshold', 'expirythreshold', 'core_enrol');
|
620 |
$mform->addHelpButton('expirythreshold', 'expirythreshold', 'core_enrol');
|
| - |
|
621 |
$mform->disabledIf('expirythreshold', 'expirynotify', 'eq', 0);
|
| Línea 606... |
Línea 622... |
| 606 |
$mform->disabledIf('expirythreshold', 'expirynotify', 'eq', 0);
|
622 |
}
|
| - |
|
623 |
|
| 607 |
|
624 |
// Course welcome message.
|
| 608 |
// Course welcome message.
|
625 |
if (has_any_capability(['enrol/manual:config', 'moodle/course:editcoursewelcomemessage'], $context)) {
|
| 609 |
$mform->addElement(
|
626 |
$mform->addElement(
|
| 610 |
'select',
|
627 |
'select',
|
| - |
|
628 |
'customint1',
|
| - |
|
629 |
get_string(
|
| - |
|
630 |
identifier: 'sendcoursewelcomemessage',
|
| - |
|
631 |
component: 'core_enrol',
|
| - |
|
632 |
),
|
| - |
|
633 |
enrol_send_welcome_email_options(),
|
| - |
|
634 |
);
|
| 611 |
'customint1',
|
635 |
$mform->addHelpButton(
|
| 612 |
get_string(
|
636 |
elementname: 'customint1',
|
| 613 |
identifier: 'sendcoursewelcomemessage',
|
637 |
identifier: 'sendcoursewelcomemessage',
|
| 614 |
component: 'core_enrol',
|
- |
|
| 615 |
),
|
- |
|
| 616 |
enrol_send_welcome_email_options(),
|
- |
|
| 617 |
);
|
- |
|
| 618 |
$mform->addHelpButton(
|
- |
|
| 619 |
elementname: 'customint1',
|
- |
|
| 620 |
identifier: 'sendcoursewelcomemessage',
|
- |
|
| 621 |
component: 'core_enrol',
|
- |
|
| 622 |
);
|
- |
|
| 623 |
|
- |
|
| 624 |
$options = [
|
- |
|
| 625 |
'cols' => '60',
|
- |
|
| 626 |
'rows' => '8',
|
- |
|
| 627 |
];
|
- |
|
| 628 |
$mform->addElement(
|
- |
|
| 629 |
'textarea',
|
- |
|
| 630 |
'customtext1',
|
- |
|
| 631 |
get_string(
|
- |
|
| 632 |
identifier: 'customwelcomemessage',
|
- |
|
| 633 |
component: 'core_enrol',
|
- |
|
| 634 |
),
|
- |
|
| 635 |
$options,
|
- |
|
| 636 |
);
|
- |
|
| 637 |
$mform->setDefault('customtext1', get_string('customwelcomemessageplaceholder', 'core_enrol'));
|
- |
|
| 638 |
$mform->hideIf(
|
- |
|
| 639 |
elementname: 'customtext1',
|
- |
|
| 640 |
dependenton: 'customint1',
|
- |
|
| 641 |
condition: 'eq',
|
- |
|
| Línea -... |
Línea 638... |
| - |
|
638 |
component: 'core_enrol',
|
| - |
|
639 |
);
|
| - |
|
640 |
|
| - |
|
641 |
$options = [
|
| - |
|
642 |
'cols' => '60',
|
| - |
|
643 |
'rows' => '8',
|
| - |
|
644 |
];
|
| - |
|
645 |
$mform->addElement(
|
| - |
|
646 |
'textarea',
|
| - |
|
647 |
'customtext1',
|
| - |
|
648 |
get_string(
|
| - |
|
649 |
identifier: 'customwelcomemessage',
|
| - |
|
650 |
component: 'core_enrol',
|
| - |
|
651 |
),
|
| - |
|
652 |
$options,
|
| - |
|
653 |
);
|
| - |
|
654 |
$mform->setDefault('customtext1', get_string('customwelcomemessageplaceholder', 'core_enrol'));
|
| - |
|
655 |
$mform->hideIf(
|
| - |
|
656 |
elementname: 'customtext1',
|
| - |
|
657 |
dependenton: 'customint1',
|
| - |
|
658 |
condition: 'eq',
|
| 642 |
value: ENROL_DO_NOT_SEND_EMAIL,
|
659 |
value: ENROL_DO_NOT_SEND_EMAIL,
|
| 643 |
);
|
660 |
);
|
| 644 |
|
661 |
|
| 645 |
// Static form elements cannot be hidden by hideIf() so we need to add a dummy group.
|
662 |
// Static form elements cannot be hidden by hideIf() so we need to add a dummy group.
|
| 646 |
// See: https://tracker.moodle.org/browse/MDL-66251.
|
663 |
// See: https://tracker.moodle.org/browse/MDL-66251.
|
| 647 |
$group[] = $mform->createElement(
|
664 |
$group[] = $mform->createElement(
|
| 648 |
'static',
|
665 |
'static',
|
| 649 |
'customwelcomemessage_extra_help',
|
666 |
'customwelcomemessage_extra_help',
|
| 650 |
null,
|
667 |
null,
|
| 651 |
get_string(
|
668 |
get_string(
|
| 652 |
identifier: 'customwelcomemessage_help',
|
669 |
identifier: 'customwelcomemessage_help',
|
| 653 |
component: 'core_enrol',
|
670 |
component: 'core_enrol',
|
| 654 |
),
|
671 |
),
|
| 655 |
);
|
672 |
);
|
| 656 |
$mform->addGroup($group, 'group_customwelcomemessage_extra_help', '', ' ', false);
|
673 |
$mform->addGroup($group, 'group_customwelcomemessage_extra_help', '', ' ', false);
|
| 657 |
$mform->hideIf(
|
674 |
$mform->hideIf(
|
| 658 |
elementname: 'group_customwelcomemessage_extra_help',
|
675 |
elementname: 'group_customwelcomemessage_extra_help',
|
| - |
|
676 |
dependenton: 'customint1',
|
| 659 |
dependenton: 'customint1',
|
677 |
condition: 'eq',
|
| Línea -... |
Línea 678... |
| - |
|
678 |
value: ENROL_DO_NOT_SEND_EMAIL,
|
| 660 |
condition: 'eq',
|
679 |
);
|
| 661 |
value: ENROL_DO_NOT_SEND_EMAIL,
|
680 |
}
|
| 662 |
);
|
681 |
|
| 663 |
|
682 |
// Enrolment changes warning.
|
| 664 |
if (enrol_accessing_via_instance($instance)) {
|
683 |
if (has_capability('enrol/manual:config', $context) && enrol_accessing_via_instance($instance)) {
|
| Línea 679... |
Línea 698... |
| 679 |
* @return void
|
698 |
* @return void
|
| 680 |
*/
|
699 |
*/
|
| 681 |
public function edit_instance_validation($data, $files, $instance, $context) {
|
700 |
public function edit_instance_validation($data, $files, $instance, $context) {
|
| 682 |
$errors = array();
|
701 |
$errors = array();
|
| Línea -... |
Línea 702... |
| - |
|
702 |
|
| - |
|
703 |
// This method is used when configuring the enrolment method, and when only updating the welcome message.
|
| 683 |
|
704 |
// The 'expirynotify' key won't be set when updating the welcome message.
|
| 684 |
if ($data['expirynotify'] > 0 and $data['expirythreshold'] < 86400) {
|
705 |
if (isset($data['expirynotify']) && $data['expirynotify'] > 0 && $data['expirythreshold'] < DAYSECS) {
|
| 685 |
$errors['expirythreshold'] = get_string('errorthresholdlow', 'core_enrol');
|
706 |
$errors['expirythreshold'] = get_string('errorthresholdlow', 'core_enrol');
|
| Línea 686... |
Línea 707... |
| 686 |
}
|
707 |
}
|
| 687 |
|
708 |
|