MDL-23502 improved new instance function name

This commit is contained in:
Petr Skoda 2010-07-31 20:02:56 +00:00
parent 42761bc637
commit e25f24669b
14 changed files with 14 additions and 14 deletions

View File

@ -53,7 +53,7 @@ class enrol_category_plugin extends enrol_plugin {
* @param int $courseid
* @return moodle_url page url
*/
public function get_candidate_link($courseid) {
public function get_newinstance_link($courseid) {
// instances are added automatically as necessary
return NULL;
}

View File

@ -46,7 +46,7 @@ if ($courseadmin && $courseadmin->get('users') && $courseadmin->get('users')->ge
$enrol = enrol_get_plugin('cohort');
if (!$enrol->get_candidate_link($course->id)) {
if (!$enrol->get_newinstance_link($course->id)) {
redirect(new moodle_url('/enrol/instances.php', array('id'=>$course->id)));
}

View File

@ -62,7 +62,7 @@ class enrol_cohort_plugin extends enrol_plugin {
* @param int $courseid
* @return moodle_url page url
*/
public function get_candidate_link($courseid) {
public function get_newinstance_link($courseid) {
global $DB;
$coursecontext = get_context_instance(CONTEXT_COURSE, $courseid);

View File

@ -36,7 +36,7 @@ require_sesskey();
$enrol = enrol_get_plugin('guest');
if ($enrol->get_candidate_link($course->id)) {
if ($enrol->get_newinstance_link($course->id)) {
$enrol->add_default_instance($course);
}

View File

@ -66,7 +66,7 @@ class enrol_guest_plugin extends enrol_plugin {
* @param int $courseid
* @return moodle_url page url
*/
public function get_candidate_link($courseid) {
public function get_newinstance_link($courseid) {
global $DB;
if (!has_capability('moodle/course:enrolconfig', get_context_instance(CONTEXT_COURSE, $courseid, MUST_EXIST))) {

View File

@ -222,7 +222,7 @@ echo html_writer::table($table);
// access security is in each plugin
$candidates = array();
foreach (enrol_get_plugins(true) as $name=>$plugin) {
if (!$link = $plugin->get_candidate_link($course->id)) {
if (!$link = $plugin->get_newinstance_link($course->id)) {
continue;
}
$candidates[$link->out(false)] = get_string('pluginname', 'enrol_'.$name);

View File

@ -126,7 +126,7 @@ class enrol_manual_plugin extends enrol_plugin {
* @param int $courseid
* @return moodle_url page url
*/
public function get_candidate_link($courseid) {
public function get_newinstance_link($courseid) {
global $DB;
$context = get_context_instance(CONTEXT_COURSE, $courseid, MUST_EXIST);

View File

@ -36,7 +36,7 @@ require_login($course);
require_capability('moodle/course:enrolconfig', $context);
$enrol = enrol_get_plugin('meta');
if (!$enrol->get_candidate_link($course->id)) {
if (!$enrol->get_newinstance_link($course->id)) {
redirect(new moodle_url('/enrol/instances.php', array('id'=>$course->id)));
}

View File

@ -57,7 +57,7 @@ class enrol_meta_plugin extends enrol_plugin {
* @param int $courseid
* @return moodle_url page url
*/
public function get_candidate_link($courseid) {
public function get_newinstance_link($courseid) {
if (!has_capability('moodle/course:enrolconfig', get_context_instance(CONTEXT_COURSE, $courseid, MUST_EXIST))) {
return NULL;
}

View File

@ -47,7 +47,7 @@ if ($courseadmin && $courseadmin->get('users') && $courseadmin->get('users')->ge
$enrol = enrol_get_plugin('mnet');
// make sure we were allowed to get here form the Enrolment methods page
if (!$enrol->get_candidate_link($course->id)) {
if (!$enrol->get_newinstance_link($course->id)) {
redirect(new moodle_url('/enrol/instances.php', array('id'=>$course->id)));
}
$service = mnetservice_enrol::get_instance();

View File

@ -71,7 +71,7 @@ class enrol_mnet_plugin extends enrol_plugin {
* @param int $courseid id of the course to add the instance to
* @return moodle_url|null page url or null if instance can not be created
*/
public function get_candidate_link($courseid) {
public function get_newinstance_link($courseid) {
global $CFG, $DB;
require_once($CFG->dirroot.'/mnet/service/enrol/locallib.php');

View File

@ -100,7 +100,7 @@ class enrol_paypal_plugin extends enrol_plugin {
* @param int $courseid
* @return moodle_url page url
*/
public function get_candidate_link($courseid) {
public function get_newinstance_link($courseid) {
$context = get_context_instance(CONTEXT_COURSE, $courseid, MUST_EXIST);
if (!has_capability('moodle/course:enrolconfig', $context) or !has_capability('enrol/paypal:config', $context)) {

View File

@ -118,7 +118,7 @@ class enrol_self_plugin extends enrol_plugin {
* @param int $courseid
* @return moodle_url page url
*/
public function get_candidate_link($courseid) {
public function get_newinstance_link($courseid) {
$context = get_context_instance(CONTEXT_COURSE, $courseid, MUST_EXIST);
if (!has_capability('moodle/course:enrolconfig', $context) or !has_capability('enrol/manual:config', $context)) {

View File

@ -1055,7 +1055,7 @@ abstract class enrol_plugin {
* @param int $courseid
* @return moodle_url page url
*/
public function get_candidate_link($courseid) {
public function get_newinstance_link($courseid) {
// override for most plugins, check if instance already exists in cases only one instance is supported
return NULL;
}