MDL-53167 search: Add ability to limit courses searched
This commit is contained in:
+16
-1
@@ -54,6 +54,11 @@ class MoodleQuickForm_course extends MoodleQuickForm_autocomplete {
|
||||
*/
|
||||
protected $requiredcapabilities = array();
|
||||
|
||||
/**
|
||||
* @var bool $limittoenrolled Only allow enrolled courses.
|
||||
*/
|
||||
protected $limittoenrolled = false;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@@ -78,15 +83,25 @@ class MoodleQuickForm_course extends MoodleQuickForm_autocomplete {
|
||||
if (isset($options['requiredcapabilities'])) {
|
||||
$this->requiredcapabilities = $options['requiredcapabilities'];
|
||||
}
|
||||
if (isset($options['limittoenrolled'])) {
|
||||
$this->limittoenrolled = $options['limittoenrolled'];
|
||||
}
|
||||
|
||||
$validattributes = array(
|
||||
'ajax' => 'core/form-course-selector',
|
||||
'data-requiredcapabilities' => implode(',', $this->requiredcapabilities),
|
||||
'data-exclude' => implode(',', $this->exclude)
|
||||
'data-exclude' => implode(',', $this->exclude),
|
||||
'data-limittoenrolled' => (int)$this->limittoenrolled
|
||||
);
|
||||
if ($this->multiple) {
|
||||
$validattributes['multiple'] = 'multiple';
|
||||
}
|
||||
if (isset($options['noselectionstring'])) {
|
||||
$validattributes['noselectionstring'] = $options['noselectionstring'];
|
||||
}
|
||||
if (isset($options['placeholder'])) {
|
||||
$validattributes['placeholder'] = $options['placeholder'];
|
||||
}
|
||||
|
||||
parent::__construct($elementname, $elementlabel, array(), $validattributes);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user