diff --git a/.travis.yml b/.travis.yml index abfe2d4..e115283 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,11 @@ language: php - -sudo: true - addons: - firefox: "47.0.1" - postgresql: "9.4" - mysql: "8.0.2" - apt: - packages: - - oracle-java9-installer - - oracle-java9-set-default + postgresql: "9.6" + +services: + - mysql + - postgresql + - docker cache: directories: @@ -17,66 +13,43 @@ cache: - $HOME/.npm php: -- 5.6 -- 7.1 -- 7.2 + - 7.1 + - 7.2 + - 7.3 + - 7.4 env: -- MOODLE_BRANCH=MOODLE_36_STABLE DB=pgsql -- MOODLE_BRANCH=MOODLE_36_STABLE DB=mysqli -- MOODLE_BRANCH=MOODLE_35_STABLE DB=pgsql -- MOODLE_BRANCH=MOODLE_35_STABLE DB=mysqli -- MOODLE_BRANCH=MOODLE_34_STABLE DB=pgsql -- MOODLE_BRANCH=MOODLE_34_STABLE DB=mysqli -- MOODLE_BRANCH=MOODLE_33_STABLE DB=pgsql -- MOODLE_BRANCH=MOODLE_33_STABLE DB=mysqli + matrix: + - MOODLE_BRANCH=MOODLE_310_STABLE DB=pgsql + - MOODLE_BRANCH=MOODLE_310_STABLE DB=mysqli + - MOODLE_BRANCH=MOODLE_311_STABLE DB=pgsql + - MOODLE_BRANCH=MOODLE_311_STABLE DB=mysqli matrix: exclude: - - php: 7.1 - env: MOODLE_BRANCH=MOODLE_33_STABLE DB=mysqli - - php: 7.1 - env: MOODLE_BRANCH=MOODLE_33_STABLE DB=pgsql - - php: 7.2 - env: MOODLE_BRANCH=MOODLE_33_STABLE DB=mysqli - - php: 7.2 - env: MOODLE_BRANCH=MOODLE_33_STABLE DB=pgsql - - php: 5.6 - env: MOODLE_BRANCH=MOODLE_34_STABLE DB=mysqli - - php: 5.6 - env: MOODLE_BRANCH=MOODLE_34_STABLE DB=pgsql - - php: 7.2 - env: MOODLE_BRANCH=MOODLE_34_STABLE DB=mysqli - - php: 7.2 - env: MOODLE_BRANCH=MOODLE_34_STABLE DB=pgsql - - php: 5.6 - env: MOODLE_BRANCH=MOODLE_35_STABLE DB=mysqli - - php: 5.6 - env: MOODLE_BRANCH=MOODLE_35_STABLE DB=pgsql - - php: 7.2 - env: MOODLE_BRANCH=MOODLE_35_STABLE DB=mysqli - - php: 7.2 - env: MOODLE_BRANCH=MOODLE_35_STABLE DB=pgsql - - php: 5.6 - env: MOODLE_BRANCH=MOODLE_36_STABLE DB=mysqli - - php: 5.6 - env: MOODLE_BRANCH=MOODLE_36_STABLE DB=pgsql - - php: 7.1 - env: MOODLE_BRANCH=MOODLE_36_STABLE DB=mysqli - - php: 7.1 - env: MOODLE_BRANCH=MOODLE_36_STABLE DB=pgsql + - php: 7.3 + env: MOODLE_BRANCH=MOODLE_310_STABLE DB=mysqli + - php: 7.3 + env: MOODLE_BRANCH=MOODLE_310_STABLE DB=pgsql + - php: 7.4 + env: MOODLE_BRANCH=MOODLE_310_STABLE DB=mysqli + - php: 7.4 + env: MOODLE_BRANCH=MOODLE_310_STABLE DB=pgsql + - php: 7.1 + env: MOODLE_BRANCH=MOODLE_311_STABLE DB=mysqli + - php: 7.1 + env: MOODLE_BRANCH=MOODLE_311_STABLE DB=pgsql + - php: 7.2 + env: MOODLE_BRANCH=MOODLE_311_STABLE DB=mysqli + - php: 7.2 + env: MOODLE_BRANCH=MOODLE_311_STABLE DB=pgsql before_install: - phpenv config-rm xdebug.ini - - nvm install node - - nvm install 8.9 - - nvm use 8.9 - cd ../.. - - composer selfupdate - - composer create-project -n --no-dev --prefer-dist moodlerooms/moodle-plugin-ci ci ^2 + - composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3 - export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH" - install: - moodle-plugin-ci install @@ -89,5 +62,6 @@ script: - moodle-plugin-ci savepoints - moodle-plugin-ci mustache - moodle-plugin-ci grunt +# - moodle-plugin-ci phpdoc - moodle-plugin-ci phpunit - moodle-plugin-ci behat diff --git a/CHANGES.md b/CHANGES.md new file mode 100644 index 0000000..9545a65 --- /dev/null +++ b/CHANGES.md @@ -0,0 +1,6 @@ +Release Notes + +Release 3.11.0 (Build 2020111801) +Updated subplugin declaration file to new subplugins.json structure. + +(see CHANGES.TXT in release 3.8 for earlier changes.) \ No newline at end of file diff --git a/CHANGES.txt b/CHANGES.txt deleted file mode 100644 index ed98c34..0000000 --- a/CHANGES.txt +++ /dev/null @@ -1,11 +0,0 @@ -Release Notes - -Release 3.6.0 (Build 2018120300) -First stable release. Compatibile with 3.6, 3.5, 3.4 and 3.3. - -Release BETA3.3.4 (Build 2018062800) -GHISSUE-1 - Added hooks to module form to include metadata form elements in the module settings page. -GHISSUE-10 - Implemented Privacy API for GDPR compliance. - -Version BETA3.3.3 (Build 2018052200) -Added Behat tests to verify 3.4 and 3.5 compatibility. \ No newline at end of file diff --git a/backup/moodle2/backup_local_metadata_plugin.class.php b/backup/moodle2/backup_local_metadata_plugin.class.php new file mode 100644 index 0000000..e0e4053 --- /dev/null +++ b/backup/moodle2/backup_local_metadata_plugin.class.php @@ -0,0 +1,51 @@ +. + +/** + * @package local_metadata + * @version 1.0 + * @copyright © 2020 Kurvin Hendricks khendricks@2u.com + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + + +defined('MOODLE_INTERNAL') || die(); + + +class backup_local_metadata_plugin extends backup_local_plugin { + /** + * Define (add) particular settings this activity can have + */ + protected function define_my_settings() { + // No particular settings for this activity. + } + protected function define_course_plugin_structure() { + + $plugin = $this->get_plugin_element(null, null, null); + $pluginwrapper = new backup_nested_element( + $this->get_recommended_name(), + array('id'), + array('instanceid', 'fieldid', 'data', 'dataformat') + ); + // Connect the visible container ASAP. + $plugin->add_child($pluginwrapper); + + // Set source to populate the data. + $pluginwrapper->set_source_sql("SELECT id, instanceid, fieldid, data, dataformat FROM {local_metadata}", array()); + + return $plugin; + } +} diff --git a/backup/moodle2/restore_local_metadata_plugin.class.php b/backup/moodle2/restore_local_metadata_plugin.class.php new file mode 100644 index 0000000..a10e8a7 --- /dev/null +++ b/backup/moodle2/restore_local_metadata_plugin.class.php @@ -0,0 +1,76 @@ +. + +/** + * Grid Information + * @package local_metadata + * @version 1.0 + * @copyright © 2020 Kurvin Hendricks khendricks@2u.com + * @license http://www.gnu.org/copyleft/gpl.html GNU Public License + */ +defined('MOODLE_INTERNAL') || die(); + +/** + * Restore plugin class that provides the necessary information + * needed to restore metadata + */ + +class restore_local_metadata_plugin extends restore_local_plugin { + + /** + * Returns the paths to be handled by the plugin at course level. + */ + protected function define_course_plugin_structure() { + + $paths = array(); + + $elename = 'plugin_local_metatdata_course'; // This defines the postfix of 'process_*' below. + $elepath = $this->get_pathfor('/'); + $paths[] = new restore_path_element($elename, $elepath); + return $paths; // And we return the interesting paths. + } + + + /** + * Process the metadata element. + */ + public function process_plugin_local_metatdata_course($data) { + global $DB, $COURSE; + + $data = (object)$data; + $oldid = $data->id; + unset($data->id); + + $data->instanceid = $this->task->get_courseid(); + + if ($data->instanceid) { + $sql = 'SELECT * FROM {local_metadata} WHERE instanceid = ?'; + $params = array('instanceid' => $data->instanceid); + try { + if (!$DB->record_exists_sql($sql, $params)) { + try { + $DB->insert_record('local_metadata', $data); + } catch (Exception $e){ + error_log($e->getMessage(), 0); + } + } + } catch(Exception $e) { + error_log($e->getMessage(), 0); + } + + } + } +} diff --git a/context/category/tests/metadatacontext_category_event_test.php b/context/category/tests/metadatacontext_category_event_test.php index 982ec21..e5bb09f 100644 --- a/context/category/tests/metadatacontext_category_event_test.php +++ b/context/category/tests/metadatacontext_category_event_test.php @@ -43,7 +43,7 @@ class metadatacontext_category_event_testcase extends advanced_testcase { /** * Setup tasks. */ - public function setUp() { + public function setUp(): void { $this->generator = $this->getDataGenerator()->get_plugin_generator('local_metadata'); $this->category = []; $this->category[] = $this->getDataGenerator()->create_category(); diff --git a/context/cohort/tests/metadatacontext_cohort_event_test.php b/context/cohort/tests/metadatacontext_cohort_event_test.php index 10320dc..ef99b7c 100644 --- a/context/cohort/tests/metadatacontext_cohort_event_test.php +++ b/context/cohort/tests/metadatacontext_cohort_event_test.php @@ -43,7 +43,7 @@ class metadatacontext_cohort_event_testcase extends advanced_testcase { /** * Setup tasks. */ - public function setUp() { + public function setUp(): void { $this->generator = $this->getDataGenerator()->get_plugin_generator('local_metadata'); $this->cohort = []; $this->cohort[] = $this->getDataGenerator()->create_cohort(); diff --git a/context/course/classes/context_handler.php b/context/course/classes/context_handler.php index 700f993..011f885 100644 --- a/context/course/classes/context_handler.php +++ b/context/course/classes/context_handler.php @@ -108,7 +108,7 @@ public function get_redirect() { */ public function require_access() { require_login($this->instance); - require_capability('moodle/course:create', $this->context); + require_capability('moodle/course:update', $this->context); return true; } @@ -138,4 +138,4 @@ public function extend_navigation_course($parentnode, $course, $context) { $parentnode->add_node($metadatanode); } } -} \ No newline at end of file +} diff --git a/context/course/tests/metadatacontext_course_event_test.php b/context/course/tests/metadatacontext_course_event_test.php index ac80d53..d842b00 100644 --- a/context/course/tests/metadatacontext_course_event_test.php +++ b/context/course/tests/metadatacontext_course_event_test.php @@ -43,7 +43,7 @@ class metadatacontext_course_event_testcase extends advanced_testcase { /** * Setup tasks. */ - public function setUp() { + public function setUp(): void { $this->generator = $this->getDataGenerator()->get_plugin_generator('local_metadata'); $this->course = []; $this->course[] = $this->getDataGenerator()->create_course(); diff --git a/context/group/tests/metadatacontext_group_event_test.php b/context/group/tests/metadatacontext_group_event_test.php index c040d47..4a64463 100644 --- a/context/group/tests/metadatacontext_group_event_test.php +++ b/context/group/tests/metadatacontext_group_event_test.php @@ -43,7 +43,7 @@ class metadatacontext_group_event_testcase extends advanced_testcase { /** * Setup tasks. */ - public function setUp() { + public function setUp(): void { $this->generator = $this->getDataGenerator()->get_plugin_generator('local_metadata'); $this->course = []; $this->course[] = $this->getDataGenerator()->create_course(); diff --git a/context/module/tests/metadatacontext_module_event_test.php b/context/module/tests/metadatacontext_module_event_test.php index b10ad60..4496ac5 100644 --- a/context/module/tests/metadatacontext_module_event_test.php +++ b/context/module/tests/metadatacontext_module_event_test.php @@ -43,7 +43,7 @@ class metadatacontext_module_event_testcase extends advanced_testcase { /** * Setup tasks. */ - public function setUp() { + public function setUp(): void { $this->generator = $this->getDataGenerator()->get_plugin_generator('local_metadata'); $this->course = []; $this->course[] = $this->getDataGenerator()->create_course(); diff --git a/context/user/tests/metadatacontext_user_event_test.php b/context/user/tests/metadatacontext_user_event_test.php index 2c4fc63..51ac88c 100644 --- a/context/user/tests/metadatacontext_user_event_test.php +++ b/context/user/tests/metadatacontext_user_event_test.php @@ -43,7 +43,7 @@ class metadatacontext_user_event_testcase extends advanced_testcase { /** * Setup tasks. */ - public function setUp() { + public function setUp(): void { $this->generator = $this->getDataGenerator()->get_plugin_generator('local_metadata'); $this->user = []; $this->user[] = $this->getDataGenerator()->create_user(); diff --git a/db/subplugins.json b/db/subplugins.json new file mode 100644 index 0000000..e2aa598 --- /dev/null +++ b/db/subplugins.json @@ -0,0 +1,6 @@ +{ + "plugintypes": { + "metadatafieldtype": "local\/metadata\/fieldtype", + "metadatacontext": "local\/metadata\/context" + } +} \ No newline at end of file diff --git a/db/subplugins.php b/db/subplugins.php deleted file mode 100644 index 0919c2f..0000000 --- a/db/subplugins.php +++ /dev/null @@ -1,31 +0,0 @@ -. - -/** - * Metadata local subplugin types declaration. - * - * @package local_metadata - * @author Mike Churchward - * @copyright 2017 onwards Mike Churchward (mike.churchward@poetopensource.org) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die; - -$subplugins = [ - 'metadatafieldtype' => 'local/metadata/fieldtype', - 'metadatacontext' => 'local/metadata/context', -]; \ No newline at end of file diff --git a/tests/metadata_test.php b/tests/metadata_test.php index e66be54..077d43c 100644 --- a/tests/metadata_test.php +++ b/tests/metadata_test.php @@ -41,7 +41,7 @@ class local_metadata_testcase extends advanced_testcase { /** * Sets up the test cases. */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->metadata = new local_metadata\fieldtype\metadata(); } diff --git a/version.php b/version.php index 97b563f..e6d7860 100644 --- a/version.php +++ b/version.php @@ -22,8 +22,8 @@ */ defined('MOODLE_INTERNAL') || die; -$plugin->version = 2018120104; +$plugin->version = 2021062300; $plugin->release = '3.6.0 (Build 2018120300)'; $plugin->maturity = MATURITY_STABLE; $plugin->requires = 2016052300; // Moodle 3.1 release and upwards. -$plugin->component = 'local_metadata'; \ No newline at end of file +$plugin->component = 'local_metadata';