Merge branch 'MDL-66954-master' of git://github.com/aanabit/moodle

This commit is contained in:
Eloy Lafuente (stronk7)
2019-10-21 23:31:37 +02:00
6 changed files with 37 additions and 32 deletions
@@ -15,19 +15,19 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Privacy Subsystem implementation for filter_h5p.
* Privacy Subsystem implementation for filter_displayh5p.
*
* @package filter_h5p
* @package filter_displayh5p
* @copyright 2019 Victor Deniz <victor@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace filter_h5p\privacy;
namespace filter_displayh5p\privacy;
defined('MOODLE_INTERNAL') || die;
/**
* Privacy Subsystem for filter_h5p implementing null_provider.
* Privacy Subsystem for filter_displayh5p implementing null_provider.
*
* @copyright 2019 Victor Deniz <victor@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@@ -14,9 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* H5P filter
* Display H5P filter
*
* @package filter_h5p
* @package filter_displayh5p
* @copyright 2019 Victor Deniz <victor@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -24,15 +24,15 @@
defined('MOODLE_INTERNAL') || die;
/**
* H5P filter
* Display H5P filter
*
* This filter will replace any occurrence of H5P URLs with the corresponding H5P content embed code
*
* @package filter_h5p
* @package filter_displayh5p
* @copyright 2019 Victor Deniz <victor@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class filter_h5p extends moodle_text_filter {
class filter_displayh5p extends moodle_text_filter {
/**
* @var boolean $loadresizerjs This is whether to request the resize.js script.
@@ -57,7 +57,7 @@ class filter_h5p extends moodle_text_filter {
return $text;
}
$allowedsources = get_config('filter_h5p', 'allowedsources');
$allowedsources = get_config('filter_displayh5p', 'allowedsources');
$allowedsources = array_filter(array_map('trim', explode("\n", $allowedsources)));
if (empty($allowedsources)) {
return $text;
@@ -15,9 +15,9 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for filter_h5p
* Strings for filter_displayh5p
*
* @package filter_h5p
* @package filter_displayh5p
* @copyright 2019 Victor Deniz <victor@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -30,5 +30,5 @@ $string['allowedsourceslistdesc'] = 'List of sources from which users can embed
<b>[id]</b> is a placeholder for the H5P content id in the external source.
<b>*</b> wildcard is supported. For example, *.example.com will embed H5P content from any subdomain of example.com, but not from the example.com domain.';
$string['filtername'] = 'H5P';
$string['filtername'] = 'Display H5P';
$string['privacy:metadata'] = 'This H5P filter does not store any personal data.';
@@ -15,9 +15,9 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* H5P filter settings
* Display H5P filter settings
*
* @package filter_h5p
* @package filter_displayh5p
* @copyright 2019 Victor Deniz <victor@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -25,7 +25,10 @@
defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {
$settings->add(new admin_setting_configtextarea('filter_h5p/allowedsources', get_string('allowedsourceslist', 'filter_h5p'),
get_string('allowedsourceslistdesc', 'filter_h5p'),
$settings->add(new admin_setting_configtextarea(
'filter_displayh5p/allowedsources',
get_string('allowedsourceslist',
'filter_displayh5p'),
get_string('allowedsourceslistdesc', 'filter_displayh5p'),
"https://h5p.org/h5p/embed/[id]\nhttps://*.h5p.com/content/[id]/embed\nhttps://*.h5p.com/content/[id]"));
}
@@ -15,9 +15,9 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for the filter_h5p
* Unit tests for the filter_displayh5p
*
* @package filter_h5p
* @package filter_displayh5p
* @category test
* @copyright 2019 Victor Deniz <victor@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@@ -26,38 +26,40 @@
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot.'/filter/h5p/filter.php');
require_once($CFG->dirroot.'/filter/displayh5p/filter.php');
/**
* Unit tests for the H5P filter.
* Unit tests for the display H5P filter.
*
* @copyright 2019 Victor Deniz <victor@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class filter_h5p_testcase extends advanced_testcase {
class filter_displayh5p_testcase extends advanced_testcase {
public function setUp() {
parent::setUp();
$this->resetAfterTest(true);
set_config('allowedsources', "https://h5p.org/h5p/embed/[id]\nhttps://*.h5p.com/content/[id]/embed\nhttps://*.h5p.com/content/[id]
\nhttps://generic.wordpress.soton.ac.uk/altc/wp-admin/admin-ajax.php?action=h5p_embed&id=[id]", 'filter_h5p');
// Enable h5p filter at top level.
filter_set_global_state('h5p', TEXTFILTER_ON);
set_config('allowedsources',
"https://h5p.org/h5p/embed/[id]\nhttps://*.h5p.com/content/[id]/embed\nhttps://*.h5p.com/content/[id]
\nhttps://generic.wordpress.soton.ac.uk/altc/wp-admin/admin-ajax.php?action=h5p_embed&id=[id]",
'filter_displayh5p');
// Enable display h5p filter at top level.
filter_set_global_state('displayh5p', TEXTFILTER_ON);
}
/**
* Check that h5p tags with urls from allowed domains are filtered.
*
* @param string $text Original text
* @param string $filteredtextpattern Text pattern after H5P filter
* @param string $filteredtextpattern Text pattern after display H5P filter
*
* @dataProvider texts_provider
*/
public function test_filter_urls($text, $filteredtextpattern) {
$filterplugin = new filter_h5p(null, array());
$filterplugin = new filter_displayh5p(null, array());
$filteredtext = $filterplugin->filter($text);
$this->assertRegExp($filteredtextpattern, $filteredtext);
@@ -15,15 +15,15 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Version of filter_h5p.
* Version of filter_displayh5p.
*
* @package filter_h5p
* @package filter_displayh5p
* @copyright 2019 Victor Deniz <victor@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
$plugin->version = 2019092000;
$plugin->version = 2019101800;
$plugin->requires = 2019092000;
$plugin->component = 'filter_h5p';
$plugin->component = 'filter_displayh5p';