MDL-69166 enrol_fee: An enrolment plugin that supports payments
This commit is contained in:
@@ -0,0 +1,413 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Fee enrolment plugin.
|
||||
*
|
||||
* This plugin allows you to set up paid courses.
|
||||
*
|
||||
* @package enrol_fee
|
||||
* @copyright 2019 Shamim Rezaie <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fee enrolment plugin implementation.
|
||||
*
|
||||
* @copyright 2019 Shamim Rezaie <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class enrol_fee_plugin extends enrol_plugin {
|
||||
|
||||
/**
|
||||
* Returns the list of currencies that the payment subsystem supports and therefore we can work with.
|
||||
*
|
||||
* @return array[currencycode => currencyname]
|
||||
*/
|
||||
public function get_possible_currencies(): array {
|
||||
$codes = \core_payment\helper::get_supported_currencies();
|
||||
|
||||
$currencies = [];
|
||||
foreach ($codes as $c) {
|
||||
$currencies[$c] = new lang_string($c, 'core_currencies');
|
||||
}
|
||||
|
||||
return $currencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns optional enrolment information icons.
|
||||
*
|
||||
* This is used in course list for quick overview of enrolment options.
|
||||
*
|
||||
* We are not using single instance parameter because sometimes
|
||||
* we might want to prevent icon repetition when multiple instances
|
||||
* of one type exist. One instance may also produce several icons.
|
||||
*
|
||||
* @param array $instances all enrol instances of this type in one course
|
||||
* @return array of pix_icon
|
||||
*/
|
||||
public function get_info_icons(array $instances) {
|
||||
$found = false;
|
||||
foreach ($instances as $instance) {
|
||||
if ($instance->enrolstartdate != 0 && $instance->enrolstartdate > time()) {
|
||||
continue;
|
||||
}
|
||||
if ($instance->enrolenddate != 0 && $instance->enrolenddate < time()) {
|
||||
continue;
|
||||
}
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
if ($found) {
|
||||
return array(new pix_icon('icon', get_string('pluginname', 'enrol_fee'), 'enrol_fee'));
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
public function roles_protected() {
|
||||
// Users with role assign cap may tweak the roles later.
|
||||
return false;
|
||||
}
|
||||
|
||||
public function allow_unenrol(stdClass $instance) {
|
||||
// Users with unenrol cap may unenrol other users manually - requires enrol/fee:unenrol.
|
||||
return true;
|
||||
}
|
||||
|
||||
public function allow_manage(stdClass $instance) {
|
||||
// Users with manage cap may tweak period and status - requires enrol/fee:manage.
|
||||
return true;
|
||||
}
|
||||
|
||||
public function show_enrolme_link(stdClass $instance) {
|
||||
return ($instance->status == ENROL_INSTANCE_ENABLED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the user can add a new instance in this course.
|
||||
* @param int $courseid
|
||||
* @return boolean
|
||||
*/
|
||||
public function can_add_instance($courseid) {
|
||||
$context = context_course::instance($courseid, MUST_EXIST);
|
||||
|
||||
if (!has_capability('moodle/course:enrolconfig', $context) or !has_capability('enrol/fee:config', $context)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Multiple instances supported - different cost for different roles.
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* We are a good plugin and don't invent our own UI/validation code path.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function use_standard_editing_ui() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new instance of enrol plugin.
|
||||
* @param object $course
|
||||
* @param array $fields instance fields
|
||||
* @return int id of new instance, null if can not be created
|
||||
*/
|
||||
public function add_instance($course, array $fields = null) {
|
||||
if ($fields && !empty($fields['cost'])) {
|
||||
$fields['cost'] = unformat_float($fields['cost']);
|
||||
}
|
||||
return parent::add_instance($course, $fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update instance of enrol plugin.
|
||||
* @param stdClass $instance
|
||||
* @param stdClass $data modified instance fields
|
||||
* @return boolean
|
||||
*/
|
||||
public function update_instance($instance, $data) {
|
||||
if ($data) {
|
||||
$data->cost = unformat_float($data->cost);
|
||||
}
|
||||
return parent::update_instance($instance, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates course enrol form, checks if form submitted
|
||||
* and enrols user if necessary. It can also redirect.
|
||||
*
|
||||
* @param stdClass $instance
|
||||
* @return string html text, usually a form in a text box
|
||||
*/
|
||||
public function enrol_page_hook(stdClass $instance) {
|
||||
global $CFG, $USER, $OUTPUT, $PAGE, $DB;
|
||||
|
||||
ob_start();
|
||||
|
||||
if ($DB->record_exists('user_enrolments', array('userid' => $USER->id, 'enrolid' => $instance->id))) {
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
if ($instance->enrolstartdate != 0 && $instance->enrolstartdate > time()) {
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
if ($instance->enrolenddate != 0 && $instance->enrolenddate < time()) {
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
$course = $DB->get_record('course', array('id' => $instance->courseid));
|
||||
$context = context_course::instance($course->id);
|
||||
|
||||
$shortname = format_string($course->shortname, true, array('context' => $context));
|
||||
$strloginto = get_string("loginto", "", $shortname);
|
||||
$strcourses = get_string("courses");
|
||||
|
||||
// Pass $view=true to filter hidden caps if the user cannot see them.
|
||||
if ($users = get_users_by_capability($context, 'moodle/course:update', 'u.*', 'u.id ASC',
|
||||
'', '', '', '', false, true)) {
|
||||
$users = sort_by_roleassignment_authority($users, $context);
|
||||
$teacher = array_shift($users);
|
||||
} else {
|
||||
$teacher = false;
|
||||
}
|
||||
|
||||
if ( (float) $instance->cost <= 0 ) {
|
||||
$cost = (float) $this->get_config('cost');
|
||||
} else {
|
||||
$cost = (float) $instance->cost;
|
||||
}
|
||||
|
||||
if (abs($cost) < 0.01) { // No cost, other enrolment methods (instances) should be used.
|
||||
echo '<p>'.get_string('nocost', 'enrol_fee').'</p>';
|
||||
} else {
|
||||
$localisedcost = format_float($cost, -1, true);
|
||||
|
||||
if (isguestuser()) { // Force login only for guest user, not real users with guest role.
|
||||
$wwwroot = $CFG->wwwroot;
|
||||
echo '<div class="mdl-align"><p>'.get_string('paymentrequired').'</p>';
|
||||
echo '<p><b>'.get_string('cost').": $instance->currency $localisedcost".'</b></p>';
|
||||
echo '<p><a href="'.$wwwroot.'/login/">'.get_string('loginsite').'</a></p>';
|
||||
echo '</div>';
|
||||
} else {
|
||||
echo '<div align="center"><input type="submit" value="' . get_string("sendpaymentbutton", "enrol_paypal") . '" /></div>';
|
||||
$PAGE->requires->js_call_amd('profilefield_conditional/conditionconfig', 'init', array('#id_param1',
|
||||
'#profilefield_conditional_conditionconfiguration', '#id_conditionconfigbutton', $fieldid));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $OUTPUT->box(ob_get_clean());
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore instance and map settings.
|
||||
*
|
||||
* @param restore_enrolments_structure_step $step
|
||||
* @param stdClass $data
|
||||
* @param stdClass $course
|
||||
* @param int $oldid
|
||||
*/
|
||||
public function restore_instance(restore_enrolments_structure_step $step, stdClass $data, $course, $oldid) {
|
||||
global $DB;
|
||||
if ($step->get_task()->get_target() == backup::TARGET_NEW_COURSE) {
|
||||
$merge = false;
|
||||
} else {
|
||||
$merge = array(
|
||||
'courseid' => $data->courseid,
|
||||
'enrol' => $this->get_name(),
|
||||
'roleid' => $data->roleid,
|
||||
'cost' => $data->cost,
|
||||
'currency' => $data->currency,
|
||||
);
|
||||
}
|
||||
if ($merge and $instances = $DB->get_records('enrol', $merge, 'id')) {
|
||||
$instance = reset($instances);
|
||||
$instanceid = $instance->id;
|
||||
} else {
|
||||
$instanceid = $this->add_instance($course, (array) $data);
|
||||
}
|
||||
$step->set_mapping('enrol', $oldid, $instanceid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore user enrolment.
|
||||
*
|
||||
* @param restore_enrolments_structure_step $step
|
||||
* @param stdClass $data
|
||||
* @param stdClass $instance
|
||||
* @param int $oldinstancestatus
|
||||
* @param int $userid
|
||||
*/
|
||||
public function restore_user_enrolment(restore_enrolments_structure_step $step, $data, $instance, $userid, $oldinstancestatus) {
|
||||
$this->enrol_user($instance, $userid, null, $data->timestart, $data->timeend, $data->status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of valid options for the status.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_status_options() {
|
||||
$options = array(ENROL_INSTANCE_ENABLED => get_string('yes'),
|
||||
ENROL_INSTANCE_DISABLED => get_string('no'));
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of valid options for the roleid.
|
||||
*
|
||||
* @param stdClass $instance
|
||||
* @param context $context
|
||||
* @return array
|
||||
*/
|
||||
protected function get_roleid_options($instance, $context) {
|
||||
if ($instance->id) {
|
||||
$roles = get_default_enrol_roles($context, $instance->roleid);
|
||||
} else {
|
||||
$roles = get_default_enrol_roles($context, $this->get_config('roleid'));
|
||||
}
|
||||
return $roles;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add elements to the edit instance form.
|
||||
*
|
||||
* @param stdClass $instance
|
||||
* @param MoodleQuickForm $mform
|
||||
* @param context $context
|
||||
* @return bool
|
||||
*/
|
||||
public function edit_instance_form($instance, MoodleQuickForm $mform, $context) {
|
||||
|
||||
$mform->addElement('text', 'name', get_string('custominstancename', 'enrol'));
|
||||
$mform->setType('name', PARAM_TEXT);
|
||||
|
||||
$options = $this->get_status_options();
|
||||
$mform->addElement('select', 'status', get_string('status', 'enrol_fee'), $options);
|
||||
$mform->setDefault('status', $this->get_config('status'));
|
||||
|
||||
$mform->addElement('text', 'cost', get_string('cost', 'enrol_fee'), array('size' => 4));
|
||||
$mform->setType('cost', PARAM_RAW);
|
||||
$mform->setDefault('cost', format_float($this->get_config('cost'), 2, true));
|
||||
|
||||
$supportedcurrencies = $this->get_possible_currencies();
|
||||
$mform->addElement('select', 'currency', get_string('currency', 'enrol_fee'), $supportedcurrencies);
|
||||
$mform->setDefault('currency', $this->get_config('currency'));
|
||||
|
||||
$roles = $this->get_roleid_options($instance, $context);
|
||||
$mform->addElement('select', 'roleid', get_string('assignrole', 'enrol_fee'), $roles);
|
||||
$mform->setDefault('roleid', $this->get_config('roleid'));
|
||||
|
||||
$options = array('optional' => true, 'defaultunit' => 86400);
|
||||
$mform->addElement('duration', 'enrolperiod', get_string('enrolperiod', 'enrol_fee'), $options);
|
||||
$mform->setDefault('enrolperiod', $this->get_config('enrolperiod'));
|
||||
$mform->addHelpButton('enrolperiod', 'enrolperiod', 'enrol_fee');
|
||||
|
||||
$options = array('optional' => true);
|
||||
$mform->addElement('date_time_selector', 'enrolstartdate', get_string('enrolstartdate', 'enrol_fee'), $options);
|
||||
$mform->setDefault('enrolstartdate', 0);
|
||||
$mform->addHelpButton('enrolstartdate', 'enrolstartdate', 'enrol_fee');
|
||||
|
||||
$options = array('optional' => true);
|
||||
$mform->addElement('date_time_selector', 'enrolenddate', get_string('enrolenddate', 'enrol_fee'), $options);
|
||||
$mform->setDefault('enrolenddate', 0);
|
||||
$mform->addHelpButton('enrolenddate', 'enrolenddate', 'enrol_fee');
|
||||
|
||||
if (enrol_accessing_via_instance($instance)) {
|
||||
$warningtext = get_string('instanceeditselfwarningtext', 'core_enrol');
|
||||
$mform->addElement('static', 'selfwarn', get_string('instanceeditselfwarning', 'core_enrol'), $warningtext);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform custom validation of the data used to edit the instance.
|
||||
*
|
||||
* @param array $data array of ("fieldname"=>value) of submitted data
|
||||
* @param array $files array of uploaded files "element_name"=>tmp_file_path
|
||||
* @param object $instance The instance loaded from the DB
|
||||
* @param context $context The context of the instance we are editing
|
||||
* @return array of "element_name"=>"error_description" if there are errors,
|
||||
* or an empty array if everything is OK.
|
||||
* @return void
|
||||
*/
|
||||
public function edit_instance_validation($data, $files, $instance, $context) {
|
||||
$errors = array();
|
||||
|
||||
if (!empty($data['enrolenddate']) and $data['enrolenddate'] < $data['enrolstartdate']) {
|
||||
$errors['enrolenddate'] = get_string('enrolenddaterror', 'enrol_fee');
|
||||
}
|
||||
|
||||
$cost = str_replace(get_string('decsep', 'langconfig'), '.', $data['cost']);
|
||||
if (!is_numeric($cost)) {
|
||||
$errors['cost'] = get_string('costerror', 'enrol_fee');
|
||||
}
|
||||
|
||||
$validstatus = array_keys($this->get_status_options());
|
||||
$validcurrency = array_keys($this->get_possible_currencies());
|
||||
$validroles = array_keys($this->get_roleid_options($instance, $context));
|
||||
$tovalidate = array(
|
||||
'name' => PARAM_TEXT,
|
||||
'status' => $validstatus,
|
||||
'currency' => $validcurrency,
|
||||
'roleid' => $validroles,
|
||||
'enrolperiod' => PARAM_INT,
|
||||
'enrolstartdate' => PARAM_INT,
|
||||
'enrolenddate' => PARAM_INT
|
||||
);
|
||||
|
||||
$typeerrors = $this->validate_param_types($data, $tovalidate);
|
||||
$errors = array_merge($errors, $typeerrors);
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute synchronisation.
|
||||
* @param progress_trace $trace
|
||||
* @return int exit code, 0 means ok
|
||||
*/
|
||||
public function sync(progress_trace $trace) {
|
||||
$this->process_expirations($trace);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is it possible to delete enrol instance via standard UI?
|
||||
*
|
||||
* @param stdClass $instance
|
||||
* @return bool
|
||||
*/
|
||||
public function can_delete_instance($instance) {
|
||||
$context = context_course::instance($instance->courseid);
|
||||
return has_capability('enrol/fee:config', $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is it possible to hide/show enrol instance via standard UI?
|
||||
*
|
||||
* @param stdClass $instance
|
||||
* @return bool
|
||||
*/
|
||||
public function can_hide_show_instance($instance) {
|
||||
$context = context_course::instance($instance->courseid);
|
||||
return has_capability('enrol/fee:config', $context);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Capabilities for fee enrolment plugin.
|
||||
*
|
||||
* @package enrol_fee
|
||||
* @copyright 2019 Shamim Rezaie <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$capabilities = array(
|
||||
|
||||
'enrol/fee:config' => array(
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'archetypes' => array(
|
||||
'manager' => CAP_ALLOW,
|
||||
)
|
||||
),
|
||||
|
||||
'enrol/fee:manage' => array(
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'archetypes' => array(
|
||||
'manager' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
)
|
||||
),
|
||||
|
||||
'enrol/fee:unenrol' => array(
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'archetypes' => array(
|
||||
'manager' => CAP_ALLOW,
|
||||
)
|
||||
),
|
||||
|
||||
'enrol/fee:unenrolself' => array(
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'archetypes' => array(
|
||||
)
|
||||
),
|
||||
|
||||
);
|
||||
@@ -0,0 +1,50 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Strings for component 'enrol_fee', language 'en'
|
||||
*
|
||||
* @package enrol_fee
|
||||
* @copyright 2019 Shamim Rezaie <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['assignrole'] = 'Assign role';
|
||||
$string['cost'] = 'Enrolment fee';
|
||||
$string['costerror'] = 'The enrolment fee must be a number.';
|
||||
$string['currency'] = 'Currency';
|
||||
$string['defaultrole'] = 'Default role assignment';
|
||||
$string['defaultrole_desc'] = 'Select the role to assign to users after making a payment.';
|
||||
$string['enrolenddate'] = 'End date';
|
||||
$string['enrolenddate_help'] = 'If enabled, users can be enrolled until this date only.';
|
||||
$string['enrolenddaterror'] = 'The enrolment end date cannot be earlier than the start date.';
|
||||
$string['enrolperiod'] = 'Enrolment duration';
|
||||
$string['enrolperiod_desc'] = 'Default length of time that the enrolment is valid. If set to zero, the enrolment duration will be unlimited by default.';
|
||||
$string['enrolperiod_help'] = 'Length of time that the enrolment is valid, starting with the moment the user is enrolled. If disabled, the enrolment duration will be unlimited.';
|
||||
$string['enrolstartdate'] = 'Start date';
|
||||
$string['enrolstartdate_help'] = 'If enabled, users can only be enrolled from this date onwards.';
|
||||
$string['expiredaction'] = 'Enrolment expiry action';
|
||||
$string['expiredaction_help'] = 'Select the action to be performed when a user\'s enrolment expires. Please note that some user data and settings are deleted when a user is unenrolled.';
|
||||
$string['fee:config'] = 'Configure enrolment on payment enrol instances';
|
||||
$string['fee:manage'] = 'Manage enrolled users';
|
||||
$string['fee:unenrol'] = 'Unenrol users from course';
|
||||
$string['fee:unenrolself'] = 'Unenrol self from course';
|
||||
$string['nocost'] = 'There is no cost to enrol in this course!';
|
||||
$string['pluginname'] = 'Enrolment on payment';
|
||||
$string['pluginname_desc'] = 'The enrolment on payment enrolment method allows you to set up courses requiring a payment. If the fee for any course is set to zero, then students are not asked to pay for entry. There is a site-wide fee that you set here as a default for the whole site and then a course setting that you can set for each course individually. The course fee overrides the site fee.';
|
||||
$string['sendpaymentbutton'] = 'Select payment type';
|
||||
$string['status'] = 'Allow enrolment on payment enrolments';
|
||||
$string['status_desc'] = 'Allow users to make a payment to enrol into a course by default.';
|
||||
@@ -0,0 +1,25 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Fee enrolment plugin.
|
||||
*
|
||||
* This plugin allows you to set up paid courses.
|
||||
*
|
||||
* @package enrol_fee
|
||||
* @copyright 2019 Shamim Rezaie <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 32.001 32.001" style="enable-background:new 0 0 32.001 32.001;" xml:space="preserve">
|
||||
<g>
|
||||
<g id="banknote">
|
||||
<path style="fill:#010002;" d="M31.415,10.586l-10-10C20.919,0.09,20.2-0.109,19.519,0.059c-0.359,0.088-0.68,0.273-0.934,0.527
|
||||
c-0.227,0.227-0.398,0.508-0.496,0.822c-0.453,1.469-1.236,2.746-2.395,3.904C14.146,6.859,12.13,8.031,9.997,9.27
|
||||
c-2.264,1.312-4.603,2.672-6.52,4.588c-1.629,1.631-2.738,3.445-3.388,5.551c-0.219,0.711-0.028,1.48,0.496,2.006l10,10
|
||||
c0.496,0.496,1.215,0.695,1.896,0.527c0.359-0.09,0.68-0.273,0.934-0.527c0.227-0.227,0.398-0.508,0.496-0.824
|
||||
c0.454-1.469,1.237-2.746,2.397-3.904c1.547-1.547,3.562-2.717,5.697-3.955c2.262-1.314,4.602-2.674,6.518-4.59
|
||||
c1.629-1.629,2.738-3.445,3.389-5.551C32.13,11.881,31.938,11.109,31.415,10.586z M12,30c-3.312-3.312-6.688-6.689-10-10
|
||||
c2.842-9.201,15.16-8.799,18-18c3.312,3.311,6.689,6.688,10.002,10C27.159,21.199,14.841,20.799,12,30z"/>
|
||||
<path style="fill:#010002;" d="M19.562,14.9c-0.326-0.273-0.654-0.459-0.984-0.551c-0.328-0.092-0.656-0.129-0.988-0.105
|
||||
c-0.328,0.025-0.664,0.1-1,0.229c-0.336,0.131-0.674,0.273-1.014,0.438c-0.537-0.617-1.074-1.227-1.611-1.793
|
||||
c0.242-0.219,0.477-0.33,0.703-0.338c0.227-0.01,0.445,0.014,0.652,0.066c0.211,0.053,0.404,0.098,0.582,0.133
|
||||
c0.18,0.035,0.336-0.004,0.473-0.119c0.145-0.125,0.225-0.287,0.236-0.482c0.01-0.197-0.064-0.389-0.229-0.576
|
||||
c-0.211-0.242-0.465-0.389-0.77-0.443c-0.301-0.053-0.609-0.049-0.93,0.021c-0.316,0.072-0.617,0.191-0.902,0.359
|
||||
s-0.514,0.34-0.684,0.508c-0.065-0.062-0.13-0.123-0.195-0.184c-0.072-0.066-0.162-0.102-0.27-0.1
|
||||
c-0.109,0-0.199,0.047-0.273,0.133c-0.072,0.084-0.105,0.182-0.092,0.285c0.01,0.107,0.053,0.189,0.127,0.252
|
||||
c0.065,0.055,0.13,0.109,0.195,0.166c-0.256,0.309-0.467,0.65-0.633,1.01c-0.168,0.361-0.268,0.719-0.305,1.066
|
||||
c-0.039,0.35-0.002,0.67,0.105,0.967c0.107,0.299,0.305,0.553,0.594,0.793c0.471,0.391,1.025,0.557,1.668,0.52
|
||||
c0.641-0.039,1.332-0.23,2.075-0.629c0.59,0.682,1.182,1.359,1.773,1.988c-0.25,0.211-0.469,0.332-0.662,0.371
|
||||
c-0.193,0.041-0.365,0.037-0.521-0.01c-0.156-0.049-0.301-0.119-0.434-0.209c-0.133-0.092-0.264-0.17-0.395-0.234
|
||||
c-0.129-0.064-0.262-0.1-0.398-0.102s-0.281,0.064-0.441,0.201c-0.164,0.143-0.246,0.309-0.246,0.496
|
||||
c0,0.186,0.086,0.375,0.254,0.566c0.17,0.191,0.391,0.352,0.658,0.479s0.569,0.207,0.901,0.229
|
||||
c0.332,0.023,0.682-0.027,1.051-0.164c0.371-0.135,0.738-0.379,1.1-0.742c0.174,0.17,0.35,0.332,0.525,0.488
|
||||
c0.074,0.064,0.164,0.096,0.273,0.088c0.105-0.004,0.197-0.053,0.27-0.141c0.074-0.09,0.105-0.189,0.094-0.293
|
||||
c-0.01-0.105-0.053-0.186-0.125-0.244c-0.176-0.141-0.352-0.289-0.527-0.445c0.299-0.367,0.539-0.754,0.717-1.137
|
||||
c0.178-0.385,0.283-0.756,0.318-1.1c0.035-0.346-0.006-0.658-0.119-0.941C20.046,15.383,19.847,15.137,19.562,14.9z
|
||||
M13.971,15.578c-0.283,0.012-0.53-0.082-0.746-0.291c-0.092-0.088-0.156-0.195-0.195-0.322c-0.041-0.127-0.055-0.266-0.039-0.418
|
||||
c0.014-0.15,0.059-0.307,0.137-0.465c0.074-0.158,0.184-0.316,0.324-0.469c0.507,0.504,1.013,1.057,1.52,1.629
|
||||
C14.588,15.453,14.254,15.566,13.971,15.578z M18.688,17.58c-0.09,0.166-0.193,0.314-0.314,0.443
|
||||
c-0.561-0.566-1.121-1.188-1.68-1.826c0.143-0.064,0.293-0.131,0.455-0.199s0.324-0.113,0.486-0.141
|
||||
c0.166-0.025,0.33-0.018,0.494,0.021c0.162,0.041,0.316,0.129,0.459,0.268c0.141,0.141,0.23,0.287,0.266,0.445
|
||||
c0.039,0.16,0.041,0.322,0.014,0.488C18.839,17.246,18.78,17.412,18.688,17.58z"/>
|
||||
<path style="fill:#010002;" d="M14.717,22.18h-0.002c-0.625,0.48-1.235,0.986-1.8,1.553c-0.543,0.543-1.034,1.115-1.461,1.699
|
||||
l-0.684,0.934l0.002,0.002c-0.125,0.195-0.104,0.457,0.066,0.627c0.195,0.195,0.514,0.195,0.71,0
|
||||
c0.03-0.031,0.054-0.064,0.074-0.1l0.639-0.875c0.396-0.541,0.854-1.074,1.361-1.58c0.561-0.561,1.081-0.994,1.714-1.475
|
||||
l-0.002-0.002c0.018-0.014,0.035-0.025,0.051-0.041c0.196-0.195,0.196-0.514,0-0.709C15.204,22.029,14.914,22.021,14.717,22.18z"
|
||||
/>
|
||||
<path style="fill:#010002;" d="M18.378,7.715c-0.523,0.523-1.09,0.994-1.678,1.443c-0.041,0.023-0.082,0.049-0.117,0.086
|
||||
c-0.197,0.197-0.197,0.518,0,0.715c0.191,0.193,0.5,0.197,0.699,0.014l0.004,0.002c0.625-0.48,1.234-0.988,1.799-1.553
|
||||
c0.543-0.543,1.033-1.113,1.461-1.697l0.684-0.938l-0.002-0.002c0.17-0.199,0.162-0.496-0.025-0.684
|
||||
c-0.197-0.197-0.516-0.197-0.713,0c-0.037,0.037-0.064,0.08-0.088,0.123l-0.664,0.91C19.341,6.678,18.884,7.209,18.378,7.715z"/>
|
||||
</g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.7 KiB |
@@ -0,0 +1,68 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Settings for the Fee enrolment plugin
|
||||
*
|
||||
* @package enrol_fee
|
||||
* @copyright 2019 Shamim Rezaie <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
if ($ADMIN->fulltree) {
|
||||
|
||||
$settings->add(new admin_setting_heading('enrol_fee_settings', '', get_string('pluginname_desc', 'enrol_fee')));
|
||||
|
||||
// Note: let's reuse the ext sync constants and strings here, internally it is very similar,
|
||||
// it describes what should happen when users are not supposed to be enrolled any more.
|
||||
$options = array(
|
||||
ENROL_EXT_REMOVED_KEEP => get_string('extremovedkeep', 'enrol'),
|
||||
ENROL_EXT_REMOVED_SUSPENDNOROLES => get_string('extremovedsuspendnoroles', 'enrol'),
|
||||
ENROL_EXT_REMOVED_UNENROL => get_string('extremovedunenrol', 'enrol'),
|
||||
);
|
||||
$settings->add(new admin_setting_configselect(
|
||||
'enrol_fee/expiredaction',
|
||||
get_string('expiredaction', 'enrol_fee'),
|
||||
get_string('expiredaction_help', 'enrol_fee'),
|
||||
ENROL_EXT_REMOVED_SUSPENDNOROLES,
|
||||
$options));
|
||||
|
||||
$settings->add(new admin_setting_heading('enrol_fee_defaults',
|
||||
get_string('enrolinstancedefaults', 'admin'), get_string('enrolinstancedefaults_desc', 'admin')));
|
||||
|
||||
$options = array(ENROL_INSTANCE_ENABLED => get_string('yes'),
|
||||
ENROL_INSTANCE_DISABLED => get_string('no'));
|
||||
$settings->add(new admin_setting_configselect('enrol_fee/status',
|
||||
get_string('status', 'enrol_fee'), get_string('status_desc', 'enrol_fee'), ENROL_INSTANCE_DISABLED, $options));
|
||||
|
||||
$settings->add(new admin_setting_configtext('enrol_fee/cost', get_string('cost', 'enrol_fee'), '', 0, PARAM_FLOAT, 4));
|
||||
|
||||
$currencies = enrol_get_plugin('fee')->get_possible_currencies();
|
||||
$settings->add(new admin_setting_configselect('enrol_fee/currency', get_string('currency', 'enrol_fee'), '', '', $currencies));
|
||||
|
||||
if (!during_initial_install()) {
|
||||
$options = get_default_enrol_roles(context_system::instance());
|
||||
$student = get_archetype_roles('student');
|
||||
$student = reset($student);
|
||||
$settings->add(new admin_setting_configselect('enrol_fee/roleid',
|
||||
get_string('defaultrole', 'enrol_fee'), get_string('defaultrole_desc', 'enrol_fee'), $student->id, $options));
|
||||
}
|
||||
|
||||
$settings->add(new admin_setting_configduration('enrol_fee/enrolperiod',
|
||||
get_string('enrolperiod', 'enrol_fee'), get_string('enrolperiod_desc', 'enrol_fee'), 0));
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Fee enrolment plugin version specification.
|
||||
*
|
||||
* @package enrol_fee
|
||||
* @copyright 2019 Shamim Rezaie <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2020102700; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2020060900; // Requires this Moodle version.
|
||||
$plugin->component = 'enrol_fee'; // Full name of the plugin (used for diagnostics).
|
||||
@@ -1853,7 +1853,7 @@ class core_plugin_manager {
|
||||
'enrol' => array(
|
||||
'category', 'cohort', 'database', 'flatfile',
|
||||
'guest', 'imsenterprise', 'ldap', 'lti', 'manual', 'meta', 'mnet',
|
||||
'paypal', 'self'
|
||||
'paypal', 'self', 'fee',
|
||||
),
|
||||
|
||||
'filter' => array(
|
||||
|
||||
Reference in New Issue
Block a user