mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-70910 contentbank: fix for using contentid not validated
This commit is contained in:
parent
4652b66ee4
commit
52627c5f0f
1 changed files with 5 additions and 5 deletions
10
contentbank/classes/external/rename_content.php
vendored
10
contentbank/classes/external/rename_content.php
vendored
|
@ -81,13 +81,13 @@ class rename_content extends external_api {
|
||||||
// If name is empty don't try to rename and return a more detailed message.
|
// If name is empty don't try to rename and return a more detailed message.
|
||||||
if (empty(trim($params['name']))) {
|
if (empty(trim($params['name']))) {
|
||||||
$warnings[] = [
|
$warnings[] = [
|
||||||
'item' => $contentid,
|
'item' => $params['contentid'],
|
||||||
'warningcode' => 'emptynamenotallowed',
|
'warningcode' => 'emptynamenotallowed',
|
||||||
'message' => get_string('emptynamenotallowed', 'core_contentbank')
|
'message' => get_string('emptynamenotallowed', 'core_contentbank')
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
$record = $DB->get_record('contentbank_content', ['id' => $contentid], '*', MUST_EXIST);
|
$record = $DB->get_record('contentbank_content', ['id' => $params['contentid']], '*', MUST_EXIST);
|
||||||
$cb = new contentbank();
|
$cb = new contentbank();
|
||||||
$content = $cb->get_content_from_id($record->id);
|
$content = $cb->get_content_from_id($record->id);
|
||||||
$contenttype = $content->get_content_type_instance();
|
$contenttype = $content->get_content_type_instance();
|
||||||
|
@ -100,7 +100,7 @@ class rename_content extends external_api {
|
||||||
$result = true;
|
$result = true;
|
||||||
} else {
|
} else {
|
||||||
$warnings[] = [
|
$warnings[] = [
|
||||||
'item' => $contentid,
|
'item' => $params['contentid'],
|
||||||
'warningcode' => 'contentnotrenamed',
|
'warningcode' => 'contentnotrenamed',
|
||||||
'message' => get_string('contentnotrenamed', 'core_contentbank')
|
'message' => get_string('contentnotrenamed', 'core_contentbank')
|
||||||
];
|
];
|
||||||
|
@ -108,7 +108,7 @@ class rename_content extends external_api {
|
||||||
} else {
|
} else {
|
||||||
// The user has no permission to manage this content.
|
// The user has no permission to manage this content.
|
||||||
$warnings[] = [
|
$warnings[] = [
|
||||||
'item' => $contentid,
|
'item' => $params['contentid'],
|
||||||
'warningcode' => 'nopermissiontomanage',
|
'warningcode' => 'nopermissiontomanage',
|
||||||
'message' => get_string('nopermissiontomanage', 'core_contentbank')
|
'message' => get_string('nopermissiontomanage', 'core_contentbank')
|
||||||
];
|
];
|
||||||
|
@ -116,7 +116,7 @@ class rename_content extends external_api {
|
||||||
} catch (\moodle_exception $e) {
|
} catch (\moodle_exception $e) {
|
||||||
// The content or the context don't exist.
|
// The content or the context don't exist.
|
||||||
$warnings[] = [
|
$warnings[] = [
|
||||||
'item' => $contentid,
|
'item' => $params['contentid'],
|
||||||
'warningcode' => 'exception',
|
'warningcode' => 'exception',
|
||||||
'message' => $e->getMessage()
|
'message' => $e->getMessage()
|
||||||
];
|
];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue