Skip to content

Commit

Permalink
Refactorig code.
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-milette committed Oct 14, 2024
1 parent e4d1889 commit d026ed5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
All notable changes to this project will be documented in this file.

## [2.2.2] - 2024-10-13
- Added option to automatically add instance to new courses.
### Updated
- Fixed support for plain text tag called {$a->userfullname}.
- Fixed deprecation notice running on PHP 8.3.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ Michael Milette - Author and Lead Developer

Big thank you to the following contributors. (Please let me know if I forgot to include you in the list):

* Phillip Fickl (phillipfickl) - Add instance to new coures by default. (2023)
* MSVermet - Case insensitive comparison between invitation email and user email. (2023)
* [Jerome Mouneyrac](http://www.moodleitandme.com) for his work on the original [invitation enrollment plug-in](https://github.com/mouneyrac/moodle-enrol_invitation) in which this one is based upon.
* The staff, faculty, and students at the University of California, Los Angeles (UCLA) that were involved in creating the additional use cases, development, and refinement to this tool.
Expand Down
37 changes: 23 additions & 14 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,26 +114,35 @@ public function add_instance($course, ?array $fields = null) {
return parent::add_instance($course, $fields);
}

/**
* Returns defaults for new instances.
*
* @return array
*/
public function get_instance_defaults() {
$fields = [];
$fields['status'] = $this->get_config('status');
$fields['name'] = '';
$fields['customint1'] = 0;
$fields['customint2'] = 3;
$fields['customint3'] = 0;
$fields['customint4'] = 0;
$fields['customint5'] = 0;
$fields['customint6'] = 0;
$fields['customchar1'] = get_string('default_subject', 'enrol_invitation', getcoursesubject($course));
$fields['customtext1'] = '';

return $fields;
}

/**
* Add new instance of enrol plugin with default settings.
*
* @param stdClass $course
* @return int id of new instance
*/
public function add_default_instance($course)
{
$fields = [
'status' => $this->get_config('status'),
'name' => '',
'customint1' => 0,
'customint2' => 3,
'customint3' => 0,
'customint4' => 0,
'customint5' => 0,
'customint6' => 0,
'customchar1' => get_string('default_subject', 'enrol_invitation', getcoursesubject($course)),
'customtext1' => '',
];
public function add_default_instance($course) {
$fields = $this->get_instance_defaults();

return $this->add_instance($course, $fields);
}
Expand Down

0 comments on commit d026ed5

Please sign in to comment.