forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'MDL-73483-master' of https://github.com/dmitriim/moodle
- Loading branch information
Showing
8 changed files
with
461 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?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/>. | ||
|
||
namespace core_course\hook; | ||
|
||
use core\hook\described_hook; | ||
use course_edit_form; | ||
use MoodleQuickForm; | ||
|
||
/** | ||
* Allows plugins to extend course form definition and add/remove/update form elements. | ||
* | ||
* @see course_edit_form::definition() | ||
* | ||
* @package core | ||
* @copyright 2023 Dmitrii Metelkin <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class after_form_definition implements described_hook { | ||
|
||
/** | ||
* Course form wrapper. | ||
* | ||
* @var course_edit_form | ||
*/ | ||
protected $formwrapper; | ||
|
||
/** | ||
* Form to be extended. | ||
* | ||
* @var \MoodleQuickForm | ||
*/ | ||
protected $mform; | ||
|
||
/** | ||
* Creates new hook. | ||
* | ||
* @param course_edit_form $formwrapper Course form wrapper. | ||
* @param MoodleQuickForm $mform Form to be extended. | ||
*/ | ||
public function __construct(course_edit_form $formwrapper, MoodleQuickForm $mform) { | ||
$this->formwrapper = $formwrapper; | ||
$this->mform = $mform; | ||
} | ||
|
||
/** | ||
* Returns form. | ||
* | ||
* @return MoodleQuickForm | ||
*/ | ||
public function get_mform(): MoodleQuickForm { | ||
return $this->mform; | ||
} | ||
|
||
/** | ||
* Returns form wrapper instance. | ||
* | ||
* @return course_edit_form | ||
*/ | ||
public function get_formwrapper(): course_edit_form { | ||
return $this->formwrapper; | ||
} | ||
|
||
/** | ||
* Describes the hook purpose. | ||
* | ||
* @return string | ||
*/ | ||
public static function get_hook_description(): string { | ||
return 'Allows plugins to extend course editing form'; | ||
} | ||
|
||
/** | ||
* List of tags that describe this hook. | ||
* | ||
* @return string[] | ||
*/ | ||
public static function get_hook_tags(): array { | ||
return ['course']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?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/>. | ||
|
||
namespace core_course\hook; | ||
|
||
use core\hook\described_hook; | ||
use course_edit_form; | ||
use MoodleQuickForm; | ||
|
||
/** | ||
* Allows plugins to extend course form after data is set. | ||
* | ||
* @see course_edit_form::definition_after_data() | ||
* | ||
* @package core | ||
* @copyright 2023 Dmitrii Metelkin <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class after_form_definition_after_data implements described_hook { | ||
|
||
/** | ||
* Course form wrapper. | ||
* | ||
* @var course_edit_form | ||
*/ | ||
protected $formwrapper; | ||
|
||
/** | ||
* Form to be extended. | ||
* | ||
* @var \MoodleQuickForm | ||
*/ | ||
protected $mform; | ||
|
||
/** | ||
* Creates new hook. | ||
* | ||
* @param course_edit_form $formwrapper Course form wrapper.. | ||
* @param MoodleQuickForm $mform Form to be extended. | ||
*/ | ||
public function __construct(course_edit_form $formwrapper, MoodleQuickForm $mform) { | ||
$this->formwrapper = $formwrapper; | ||
$this->mform = $mform; | ||
} | ||
|
||
/** | ||
* Returns form. | ||
* | ||
* @return MoodleQuickForm | ||
*/ | ||
public function get_mform(): MoodleQuickForm { | ||
return $this->mform; | ||
} | ||
|
||
/** | ||
* Returns form wrapper instance. | ||
* | ||
* @return course_edit_form | ||
*/ | ||
public function get_formwrapper(): course_edit_form { | ||
return $this->formwrapper; | ||
} | ||
|
||
/** | ||
* Describes the hook purpose. | ||
* | ||
* @return string | ||
*/ | ||
public static function get_hook_description(): string { | ||
return 'Allows plugins to extend course editing form after data is set'; | ||
} | ||
|
||
/** | ||
* List of tags that describe this hook. | ||
* | ||
* @return string[] | ||
*/ | ||
public static function get_hook_tags(): array { | ||
return ['course']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?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/>. | ||
|
||
namespace core_course\hook; | ||
|
||
use core\hook\described_hook; | ||
use stdClass; | ||
|
||
/** | ||
* Allows plugins to extend course form submission. | ||
* | ||
* @see create_course() | ||
* @see update_course() | ||
* | ||
* @package core | ||
* @copyright 2023 Dmitrii Metelkin <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class after_form_submission implements described_hook { | ||
|
||
/** | ||
* Submitted data. | ||
* | ||
* @var stdClass | ||
*/ | ||
protected $data; | ||
|
||
/** | ||
* Is it a new course ? | ||
* | ||
* @var bool | ||
*/ | ||
protected $isnewcourse = false; | ||
|
||
/** | ||
* Creates new hook. | ||
* | ||
* @param stdClass $data Submitted data. | ||
* @param bool $isnewcourse Is it a new course? | ||
*/ | ||
public function __construct(stdClass $data, bool $isnewcourse = false) { | ||
$this->data = $data; | ||
$this->isnewcourse = $isnewcourse; | ||
} | ||
|
||
/** | ||
* Returns submitted data. | ||
* | ||
* @return stdClass | ||
*/ | ||
public function get_data(): stdClass { | ||
return $this->data; | ||
} | ||
|
||
/** | ||
* Informs callbacks if a hook called for a new course. | ||
* | ||
* @return bool | ||
*/ | ||
public function is_new_course(): bool { | ||
return $this->isnewcourse; | ||
} | ||
|
||
/** | ||
* Describes the hook purpose. | ||
* | ||
* @return string | ||
*/ | ||
public static function get_hook_description(): string { | ||
return 'Allows plugins to extend saving of the course editing form'; | ||
} | ||
|
||
/** | ||
* List of tags that describe this hook. | ||
* | ||
* @return string[] | ||
*/ | ||
public static function get_hook_tags(): array { | ||
return ['course']; | ||
} | ||
} |
Oops, something went wrong.