Merge branch 'MDL-83909-main' of https://github.com/sarjona/moodle

This commit is contained in:
Huong Nguyen 2025-02-05 10:36:44 +07:00 committed by Sara Arjona
commit fb211931cb
No known key found for this signature in database
36 changed files with 52 additions and 280 deletions

View file

@ -0,0 +1,10 @@
issueNumber: MDL-83909
notes:
core_badges:
- message: >-
The fields imageauthorname, imageauthoremail, and imageauthorurl have
been removed from badges due to confusion and their absence from the
official specification. These fields also do not appear in OBv3.0.
Additionally, the image_author_json.php file has been removed as it is
no longer needed.
type: removed

View file

@ -928,8 +928,7 @@ class backup_badges_structure_step extends backup_structure_step {
'timecreated', 'timemodified', 'usercreated', 'usermodified', 'issuername',
'issuerurl', 'issuercontact', 'expiredate', 'expireperiod', 'type', 'courseid',
'message', 'messagesubject', 'attachment', 'notification', 'status', 'nextcron',
'version', 'language', 'imageauthorname', 'imageauthoremail', 'imageauthorurl',
'imagecaption'));
'version', 'language', 'imagecaption'));
$criteria = new backup_nested_element('criteria');
$criterion = new backup_nested_element('criterion', array('id'), array('badgeid',

View file

@ -2789,9 +2789,6 @@ class restore_badges_structure_step extends restore_structure_step {
'nextcron' => $data->nextcron,
'version' => $data->version,
'language' => $data->language,
'imageauthorname' => $data->imageauthorname,
'imageauthoremail' => $data->imageauthoremail,
'imageauthorurl' => $data->imageauthorurl,
'imagecaption' => $data->imagecaption
);

View file

@ -47,23 +47,12 @@ if ($badge->status != BADGE_STATUS_INACTIVE) {
$json['name'] = $badge->name;
$json['description'] = $badge->description;
if ($badge->imageauthorname ||
$badge->imageauthoremail ||
$badge->imageauthorurl ||
$badge->imagecaption) {
$urlimage = moodle_url::make_pluginfile_url($context->id,
'badges', 'badgeimage', $badge->id, '/', 'f3')->out(false);
$json['image'] = array();
$json['image']['id'] = $urlimage;
if ($badge->imageauthorname || $badge->imageauthoremail || $badge->imageauthorurl) {
$authorimage = new moodle_url('/badges/image_author_json.php', array('id' => $badge->id));
$json['image']['author'] = $authorimage->out(false);
}
if ($badge->imagecaption) {
$json['image']['caption'] = $badge->imagecaption;
}
} else {
$json['image'] = $urlimage;
$urlimage = moodle_url::make_pluginfile_url($context->id,
'badges', 'badgeimage', $badge->id, '/', 'f3')->out(false);
$json['image'] = [];
$json['image']['id'] = $urlimage;
if ($badge->imagecaption) {
$json['image']['caption'] = $badge->imagecaption;
}
$params = ['id' => $badge->id];

View file

@ -360,10 +360,7 @@ class core_badges_assertion {
if ($alignments = $this->get_alignments()) {
$json['alignments'] = $alignments;
}
if ($this->_data->imageauthorname ||
$this->_data->imageauthoremail ||
$this->_data->imageauthorurl ||
$this->_data->imagecaption) {
if ($this->_data->imagecaption) {
$storage = get_file_storage();
$imagefile = $storage->get_file($context->id, 'badges', 'badgeimage', $this->_data->id, '/', 'f3.png');
if ($imagefile) {

View file

@ -106,15 +106,6 @@ class badge {
/** @var string What language is this badge written in. */
public $language;
/** @var string The author of the image for this badge. */
public $imageauthorname;
/** @var string The email of the author of the image for this badge. */
public $imageauthoremail;
/** @var string The url of the author of the image for this badge. */
public $imageauthorurl;
/** @var string The caption of the image for this badge. */
public $imagecaption;
@ -985,9 +976,6 @@ class badge {
$fordb->version = $data->version;
$fordb->language = $data->language;
$fordb->description = $data->description;
$fordb->imageauthorname = $data->imageauthorname;
$fordb->imageauthoremail = $data->imageauthoremail;
$fordb->imageauthorurl = $data->imageauthorurl;
$fordb->imagecaption = $data->imagecaption;
$fordb->timecreated = $now;
$fordb->timemodified = $now;
@ -1047,9 +1035,6 @@ class badge {
$this->version = trim($data->version);
$this->language = $data->language;
$this->description = $data->description;
$this->imageauthorname = $data->imageauthorname;
$this->imageauthoremail = $data->imageauthoremail;
$this->imageauthorurl = $data->imageauthorurl;
$this->imagecaption = $data->imagecaption;
$this->usermodified = $USER->id;
$this->issuername = $data->issuername;

View file

@ -206,24 +206,6 @@ class user_badge_exporter extends exporter {
'optional' => true,
'null' => NULL_ALLOWED,
],
'imageauthorname' => [
'type' => PARAM_TEXT,
'description' => 'Name of the image author',
'optional' => true,
'null' => NULL_ALLOWED,
],
'imageauthoremail' => [
'type' => PARAM_TEXT,
'description' => 'Email of the image author',
'optional' => true,
'null' => NULL_ALLOWED,
],
'imageauthorurl' => [
'type' => PARAM_URL,
'description' => 'URL of the image author',
'optional' => true,
'null' => NULL_ALLOWED,
],
'imagecaption' => [
'type' => PARAM_TEXT,
'description' => 'Caption of the image',

View file

@ -83,15 +83,6 @@ class badge extends moodleform {
$mform->insertElementBefore($currentimage, 'image');
}
$mform->addHelpButton('image', 'badgeimage', 'badges');
$mform->addElement('text', 'imageauthorname', get_string('imageauthorname', 'badges'), ['size' => '70']);
$mform->setType('imageauthorname', PARAM_TEXT);
$mform->addHelpButton('imageauthorname', 'imageauthorname', 'badges');
$mform->addElement('text', 'imageauthoremail', get_string('imageauthoremail', 'badges'), ['size' => '70']);
$mform->setType('imageauthoremail', PARAM_TEXT);
$mform->addHelpButton('imageauthoremail', 'imageauthoremail', 'badges');
$mform->addElement('text', 'imageauthorurl', get_string('imageauthorurl', 'badges'), ['size' => '70']);
$mform->setType('imageauthorurl', PARAM_URL);
$mform->addHelpButton('imageauthorurl', 'imageauthorurl', 'badges');
$mform->addElement('text', 'imagecaption', get_string('imagecaption', 'badges'), ['size' => '70']);
$mform->setType('imagecaption', PARAM_TEXT);
$mform->addHelpButton('imagecaption', 'imagecaption', 'badges');
@ -218,14 +209,6 @@ class badge extends moodleform {
$errors['expirydategr'] = get_string('error:invalidexpiredate', 'badges');
}
if ($data['imageauthoremail'] && !validate_email($data['imageauthoremail'])) {
$errors['imageauthoremail'] = get_string('invalidemail');
}
if ($data['imageauthorurl'] && !preg_match('@^https?://.+@', $data['imageauthorurl'])) {
$errors['imageauthorurl'] = get_string('invalidurl', 'badges');
}
return $errors;
}
}

View file

@ -119,18 +119,6 @@ class badgeclass implements renderable {
$data->hasotherfields = true;
$data->version = $this->badge->version;
}
if (!empty($this->badge->imageauthorname)) {
$data->hasotherfields = true;
$data->imageauthorname = $this->badge->imageauthorname;
}
if (!empty($this->badge->imageauthoremail)) {
$data->hasotherfields = true;
$data->imageauthoremail = obfuscate_mailto($this->badge->imageauthoremail, $this->badge->imageauthoremail);
}
if (!empty($this->badge->imageauthorurl)) {
$data->hasotherfields = true;
$data->imageauthorurl = $this->badge->imageauthorurl;
}
if (!empty($this->badge->imagecaption)) {
$data->hasotherfields = true;
$data->imagecaption = $this->badge->imagecaption;

View file

@ -125,10 +125,6 @@ class external_badge implements renderable {
}
$data->badgeimage = $this->issued->image;
if (is_object($data->badgeimage)) {
if (!empty($data->badgeimage->author)) {
$data->hasotherfields = true;
$data->imageauthorname = $data->badgeimage->author;
}
if (!empty($data->badgeimage->caption)) {
$data->hasotherfields = true;
$data->imagecaption = $data->badgeimage->caption;

View file

@ -175,18 +175,6 @@ class issued_badge implements renderable {
$data->hasotherfields = true;
$data->version = $badge->version;
}
if (!empty($badge->imageauthorname)) {
$data->hasotherfields = true;
$data->imageauthorname = $badge->imageauthorname;
}
if (!empty($badge->imageauthoremail)) {
$data->hasotherfields = true;
$data->imageauthoremail = obfuscate_mailto($badge->imageauthoremail, $badge->imageauthoremail);
}
if (!empty($badge->imageauthorurl)) {
$data->hasotherfields = true;
$data->imageauthorurl = $badge->imageauthorurl;
}
if (!empty($badge->imagecaption)) {
$data->hasotherfields = true;
$data->imagecaption = $badge->imagecaption;

View file

@ -454,9 +454,6 @@ class provider implements
'name' => $badge->name,
'version' => $badge->version,
'language' => $badge->language,
'imageauthorname' => $badge->imageauthorname,
'imageauthoremail' => $badge->imageauthoremail,
'imageauthorurl' => $badge->imageauthorurl,
'imagecaption' => $badge->imagecaption,
'issued' => null,
'manual_award' => null,

View file

@ -262,19 +262,6 @@ class badge extends base {
}
});
// Image author details.
foreach (['imageauthorname', 'imageauthoremail', 'imageauthorurl'] as $imageauthorfield) {
$columns[] = (new column(
$imageauthorfield,
new lang_string($imageauthorfield, 'core_badges'),
$this->get_entity_name()
))
->add_joins($this->get_joins())
->set_type(column::TYPE_TEXT)
->add_field("{$badgealias}.{$imageauthorfield}")
->set_is_sortable(true);
}
return $columns;
}

View file

@ -1,52 +0,0 @@
<?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/>.
/**
* Serve profile image author JSON for assertion.
*
* @package core
* @subpackage badges
* @copyright 2018 Tung Thai
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Tung Thai <Tung.ThaiDuc@nashtechglobal.com>
*/
define('AJAX_SCRIPT', true);
define('NO_MOODLE_COOKIES', true); // No need for a session here.
require_once(__DIR__ . '/../config.php');
require_once($CFG->libdir . '/badgeslib.php');
if (empty($CFG->enablebadges)) {
throw new \moodle_exception('badgesdisabled', 'badges');
}
$id = required_param('id', PARAM_INT); // Unique hash of badge assertion.
$badge = new badge($id);
$json = array();
$authorimage = new moodle_url('/badges/image_author_json.php', array('id' => $badge->id));
$json['id'] = $authorimage->out(false);
$json['type'] = OPEN_BADGES_V2_TYPE_AUTHOR;
if (!empty($badge->imageauthorname)) {
$json['name'] = $badge->imageauthorname;
}
if (!empty($badge->imageauthoremail)) {
$json['email'] = $badge->imageauthoremail;
}
if (!empty($badge->imageauthorurl)) {
$json['url'] = $badge->imageauthorurl;
}
echo $OUTPUT->header();
echo json_encode($json);

View file

@ -186,11 +186,6 @@ class core_badges_renderer extends plugin_renderer_base {
$dl[get_string('description', 'badges')] = $badge->description;
$dl[get_string('createdon', 'search')] = userdate($badge->timecreated);
$dl[get_string('badgeimage', 'badges')] = print_badge_image($badge, $context, 'large');
$dl[get_string('imageauthorname', 'badges')] = $badge->imageauthorname;
$dl[get_string('imageauthoremail', 'badges')] =
html_writer::tag('a', $badge->imageauthoremail, array('href' => 'mailto:' . $badge->imageauthoremail));
$dl[get_string('imageauthorurl', 'badges')] =
html_writer::link($badge->imageauthorurl, $badge->imageauthorurl, array('target' => '_blank'));
$dl[get_string('imagecaption', 'badges')] = $badge->imagecaption;
$tags = \core_tag_tag::get_item_tags('core_badges', 'badge', $badge->id);
$dl[get_string('tags', 'badges')] = $this->output->tag_list($tags, '');

View file

@ -37,9 +37,6 @@
* hasotherfields - Wheter the badge has other fields or not.
* language - Badge language [optional].
* version - Badge version [optional].
* imageauthorname - Badge image author name [optional].
* imageauthoremail - Badge image author email [optional].
* imageauthorurl - Badge image author URL [optional].
* imagecaption - Badge image caption [optional].
* endorsement - Badge endorsement data, with id, badgeid, issuername... [optional].
* hasrelatedbadges - Whether the badge has related badges or not.
@ -66,9 +63,6 @@
"hasotherfields": true,
"language": "English",
"version": "1.0beta",
"imageauthorname": "Judit Blanque",
"imageauthoremail": "<a href=\"mailto:xxx\">judit@moodle.invalid</a>",
"imageauthorurl": "http://juditblanque.cat",
"imagecaption": "This is a nice picture from my cat",
"endorsement": {
"id": "2",
@ -253,38 +247,6 @@
</dl>
{{/language}}
{{#imageauthorname}}
<dl>
<dt>
{{#str}}imageauthorname, core_badges{{/str}}
</dt>
<dd>
{{imageauthorname}}
</dd>
</dl>
{{/imageauthorname}}
{{#imageauthoremail}}
<dl>
<dt>
{{#str}}imageauthoremail, core_badges{{/str}}
</dt>
<dd>
{{{imageauthoremail}}}
</dd>
</dl>
{{/imageauthoremail}}
{{#imageauthorurl}}
<dl>
<dt>
{{#str}}imageauthorurl, core_badges{{/str}}
</dt>
<dd>
<a href="{{imageauthorurl}}" target="_blank">{{imageauthorurl}}</a>
</dd>
</dl>
{{/imageauthorurl}}
{{#imagecaption}}
<dl>
<dt>

View file

@ -288,9 +288,6 @@ final class badge_test extends \advanced_testcase {
'status' => BADGE_STATUS_ACTIVE_LOCKED,
'version' => OPEN_BADGES_V2,
'language' => 'en',
'imageauthorname' => 'Image author',
'imageauthoremail' => 'author@example.com',
'imageauthorurl' => 'http://image.example.com/',
'imagecaption' => 'Image caption',
'tags' => [],
];

View file

@ -65,9 +65,6 @@ final class badgeslib_test extends badges_testcase {
$this->assertEquals($badge->version, $clonedbadge->version);
$this->assertEquals($badge->language, $clonedbadge->language);
$this->assertEquals($badge->imagecaption, $clonedbadge->imagecaption);
$this->assertEquals($badge->imageauthorname, $clonedbadge->imageauthorname);
$this->assertEquals($badge->imageauthoremail, $clonedbadge->imageauthoremail);
$this->assertEquals($badge->imageauthorurl, $clonedbadge->imageauthorurl);
}
public function test_badge_status(): void {
@ -251,9 +248,6 @@ final class badgeslib_test extends badges_testcase {
$badge->version = "Version $i";
$badge->language = "en";
$badge->imagecaption = "Image caption $i";
$badge->imageauthorname = "Image author's name $i";
$badge->imageauthoremail = "author$i@example.com";
$badge->imageauthorname = "Image author's name $i";
$badgeid = $DB->insert_record('badge', $badge, true);
$badges[$badgeid] = new badge($badgeid);
@ -332,9 +326,6 @@ final class badgeslib_test extends badges_testcase {
$badge->version = "Version $i";
$badge->language = "en";
$badge->imagecaption = "Image caption";
$badge->imageauthorname = "Image author's name";
$badge->imageauthoremail = "author@example.com";
$badge->imageauthorname = "Image author's name";
$badgeid = $DB->insert_record('badge', $badge, true);
$badges[$badgeid] = new badge($badgeid);

View file

@ -32,7 +32,6 @@ Feature: Add badges to the system
| Version | v1 |
| Language | English |
| Description | Test badge description |
| Image author | http://author.example.com |
| Image caption | Test caption image |
| Tags | Math, Physics |
| Issuer contact | issuer@example.com |
@ -63,7 +62,6 @@ Feature: Add badges to the system
| Version | v1 |
| Language | French |
| Description | Test badge related description |
| Image author | http://author.example.com |
| Image caption | Test caption image |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
@ -74,7 +72,6 @@ Feature: Add badges to the system
| Version | v2 |
| Language | English |
| Description | Test badge description |
| Image author | http://author.example.com |
| Image caption | Test caption image |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
@ -96,7 +93,6 @@ Feature: Add badges to the system
| Version | v1 |
| Language | English |
| Description | Test badge description |
| Image author | http://author.example.com |
| Image caption | Test caption image |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
When I press "Create badge"
@ -120,7 +116,6 @@ Feature: Add badges to the system
| Version | v1 |
| Language | English |
| Description | Test badge description |
| Image author | http://author.example.com |
| Image caption | Test caption image |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
When I press "Create badge"
@ -153,7 +148,6 @@ Feature: Add badges to the system
| Version | v1 |
| Language | English |
| Description | Test badge description |
| Image author | http://author.example.com |
| Image caption | Test caption image |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
@ -180,7 +174,6 @@ Feature: Add badges to the system
| language | ca |
| description | Test badge description |
| image | badges/tests/behat/badge.png |
| imageauthorurl | http://imtheauthor.example.com |
| imagecaption | My caption image |
| issuercontact | testuser@example.com |
And the following "core_badges > Criterias" exist:
@ -195,7 +188,6 @@ Feature: Add badges to the system
| Version | secondversion |
| Language | English |
| Description | Modified test badge description |
| Image author | http://author.example.com |
| Image caption | Test caption image |
| Tags | Math, History |
| Issuer contact | issuer@invalid.cat |

View file

@ -43,7 +43,6 @@ Feature: Backpack badges
| language | en |
| description | Test badge description |
| image | badges/tests/behat/badge.png |
| imageauthorurl | http://author.example.com |
| imagecaption | Test caption image |
And the following "core_badges > Criteria" exists:
| badge | Test badge verify backpack |
@ -72,7 +71,6 @@ Feature: Backpack badges
| language | en |
| description | Test badge description |
| image | badges/tests/behat/badge.png |
| imageauthorurl | http://author.example.com |
| imagecaption | Test caption image |
And the following "core_badges > Criteria" exists:
| badge | Test badge verify backpack |

View file

@ -25,7 +25,6 @@ Feature: Test tertiary navigation as various users
| language | ca |
| description | Testing course badge description |
| image | badges/tests/behat/badge.png |
| imageauthorurl | http://author.example.com |
| imagecaption | Test caption image |
# Create a site badge.
And the following "core_badges > Badge" exists:
@ -35,7 +34,6 @@ Feature: Test tertiary navigation as various users
| language | ca |
| description | Testing site badge description |
| image | badges/tests/behat/badge.png |
| imageauthorurl | http://author.example.com |
| imagecaption | Test caption image |
And the following "core_badges > Criterias" exist:
| badge | role |

View file

@ -12,7 +12,6 @@ Feature: Manage badges
| language | en |
| description | Test badge description |
| image | badges/tests/behat/badge.png |
| imageauthorurl | http://author.example.com |
| imagecaption | Test caption image |
Scenario: Copy a badge
@ -154,7 +153,6 @@ Feature: Manage badges
| language | en |
| description | Test badge description |
| image | badges/tests/behat/badge.png |
| imageauthorurl | http://author.example.com |
| imagecaption | Test caption image |
And I log in as "admin"
And I navigate to "Badges > Add a new badge" in site administration

View file

@ -25,7 +25,6 @@ Feature: Badges not shown when there are no existing badges.
| Version | 1.1 |
| Language | Basque |
| Description | Testing course badge description |
| Image author | http://author.example.com |
| Image caption | Test caption image |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I click on "Create badge" "button"

View file

@ -16,7 +16,6 @@ Feature: Display badges
| language | ca |
| description | Testing system badge description |
| image | badges/tests/behat/badge.png |
| imageauthorurl | http://author.example.com |
| imagecaption | My caption image |
And the following "core_badges > Criterias" exist:
| badge | role |

View file

@ -85,9 +85,6 @@ abstract class badges_testcase extends \advanced_testcase {
$fordb->message = "Test message body";
$fordb->attachment = 1;
$fordb->notification = 0;
$fordb->imageauthorname = "Image Author 1";
$fordb->imageauthoremail = "author@example.com";
$fordb->imageauthorurl = "http://author-url.example.com";
$fordb->imagecaption = "Test caption image";
$fordb->status = BADGE_STATUS_INACTIVE;

View file

@ -98,9 +98,6 @@ final class external_test extends externallib_advanced_testcase {
$badge->status = BADGE_STATUS_ACTIVE;
$badge->version = '1';
$badge->language = 'en';
$badge->imageauthorname = 'Image author';
$badge->imageauthoremail = 'imageauthor@example.com';
$badge->imageauthorurl = 'http://image-author-url.domain.co.nz';
$badge->imagecaption = 'Caption';
$badgeid = $DB->insert_record('badge', $badge, true);

View file

@ -69,9 +69,6 @@ final class get_badge_test extends externallib_advanced_testcase {
$badge->status = BADGE_STATUS_ACTIVE;
$badge->version = '1';
$badge->language = 'en';
$badge->imageauthorname = 'Image author';
$badge->imageauthoremail = 'imageauthor@example.com';
$badge->imageauthorurl = 'http://image-author-url.domain.co.nz';
$badge->imagecaption = 'Caption';
$badgeid = $DB->insert_record('badge', $badge, true);

View file

@ -77,9 +77,6 @@ final class get_user_badge_by_hash_test extends externallib_advanced_testcase {
$badge->status = BADGE_STATUS_ACTIVE;
$badge->version = '1';
$badge->language = 'en';
$badge->imageauthorname = 'Image author';
$badge->imageauthoremail = 'imageauthor@example.com';
$badge->imageauthorurl = 'http://image-author-url.domain.co.nz';
$badge->imagecaption = 'Caption';
$badgeid = $DB->insert_record('badge', $badge, true);

View file

@ -69,9 +69,6 @@ class core_badges_generator extends component_generator_base {
'status' => BADGE_STATUS_ACTIVE,
'version' => OPEN_BADGES_V2,
'language' => 'en',
'imageauthorname' => 'Image author',
'imageauthoremail' => 'author@example.com',
'imageauthorurl' => 'http://image.example.com/',
'imagecaption' => 'Image caption'
], $record);

View file

@ -118,9 +118,6 @@ final class manage_badge_action_bar_test extends \advanced_testcase {
$badge->status = BADGE_STATUS_ACTIVE;
$badge->version = '1';
$badge->language = 'en';
$badge->imageauthorname = 'Image author';
$badge->imageauthoremail = 'imageauthor@example.com';
$badge->imageauthorurl = 'http://image-author-url.domain.co.nz';
$badge->imagecaption = 'Caption';
$coursebadgeid = $DB->insert_record('badge', $badge, true);
$badge = new \core_badges\badge($coursebadgeid);

View file

@ -342,9 +342,6 @@ final class provider_test extends provider_testcase {
$this->assertEquals($b1->name, $data->name);
$this->assertEquals($b1->version, $data->version);
$this->assertEquals($b1->language, $data->language);
$this->assertEquals($b1->imageauthorname, $data->imageauthorname);
$this->assertEquals($b1->imageauthoremail, $data->imageauthoremail);
$this->assertEquals($b1->imageauthorurl, $data->imageauthorurl);
$this->assertEquals($b1->imagecaption, $data->imagecaption);
$this->assertNotEmpty($data->issued);
$this->assertEmpty($data->manual_award);
@ -640,9 +637,6 @@ final class provider_test extends provider_testcase {
'status' => BADGE_STATUS_ACTIVE,
'version' => OPEN_BADGES_V2,
'language' => 'en',
'imageauthorname' => 'Image author',
'imageauthoremail' => 'author@example.com',
'imageauthorurl' => 'http://image.example.com/',
'imagecaption' => 'Image caption'
], $params);
$record->id = $DB->insert_record('badge', $record);

View file

@ -367,12 +367,6 @@ $string['hidden'] = 'Hidden';
$string['hiddenbadge'] = 'Unfortunately, the badge owner has not made this information available.';
$string['hostedurl'] = 'External URL';
$string['hostedurldescription'] = 'External URL where the badge is hosted';
$string['imageauthoremail'] = 'Image author\'s email';
$string['imageauthoremail_help'] = 'If specified, the email address of the badge image author is displayed on the badge page.';
$string['imageauthorname'] = 'Image author\'s name';
$string['imageauthorname_help'] = 'If specified, the name of the badge image author is displayed on the badge page.';
$string['imageauthorurl'] = 'Image author\'s URL';
$string['imageauthorurl_help'] = 'If specified, a link to the badge image author\'s website is displayed on the badge page. The URL should have a prefix http:// or https://.';
$string['invalidurl'] = 'Invalid URL';
$string['issuancedetails'] = 'Badge expiry';
$string['issuedbadge'] = 'Issued badge information';
@ -601,3 +595,11 @@ $string['backpackemail_help'] = 'The email address associated with your backpack
$string['error:cannotact'] = 'Cannot activate the badge. ';
$string['error:duplicatename'] = 'Badge with such name already exists in the system.';
$string['reviewbadge'] = 'Changes in badge access';
// Deprecated since Moodle 5.0.
$string['imageauthoremail'] = 'Image author\'s email';
$string['imageauthoremail_help'] = 'If specified, the email address of the badge image author is displayed on the badge page.';
$string['imageauthorname'] = 'Image author\'s name';
$string['imageauthorname_help'] = 'If specified, the name of the badge image author is displayed on the badge page.';
$string['imageauthorurl'] = 'Image author\'s URL';
$string['imageauthorurl_help'] = 'If specified, a link to the badge image author\'s website is displayed on the badge page. The URL should have a prefix http:// or https://.';

View file

@ -150,3 +150,9 @@ sitecommnews,core_hub
sitecommnews_help,core_hub
sitecommnewsyes,core_hub
cc_import_req_php5,core_imscc
imageauthoremail,core_badges
imageauthoremail_help,core_badges
imageauthorname,core_badges
imageauthorname_help,core_badges
imageauthorurl,core_badges
imageauthorurl_help,core_badges

View file

@ -124,7 +124,6 @@ define('OPEN_BADGES_V2_TYPE_ASSERTION', 'Assertion');
define('OPEN_BADGES_V2_TYPE_BADGE', 'BadgeClass');
define('OPEN_BADGES_V2_TYPE_ISSUER', 'Issuer');
define('OPEN_BADGES_V2_TYPE_ENDORSEMENT', 'Endorsement');
define('OPEN_BADGES_V2_TYPE_AUTHOR', 'Author');
define('BACKPACK_MOVE_UP', -1);
define('BACKPACK_MOVE_DOWN', 1);
@ -445,9 +444,6 @@ function badges_prepare_badge_for_external(stdClass $badge, stdClass $user): obj
'dateexpire' => $badge->dateexpire,
'version' => $badge->version,
'language' => $badge->language,
'imageauthorname' => $badge->imageauthorname,
'imageauthoremail' => $badge->imageauthoremail,
'imageauthorurl' => $badge->imageauthorurl,
'imagecaption' => $badge->imagecaption,
];
}

View file

@ -3192,9 +3192,6 @@
<FIELD NAME="nextcron" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="version" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="language" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="imageauthorname" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="imageauthoremail" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="imageauthorurl" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="imagecaption" TYPE="text" NOTNULL="false" SEQUENCE="false"/>
</FIELDS>
<KEYS>

View file

@ -1392,5 +1392,25 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2025012400.01);
}
if ($oldversion < 2025013100.01) {
// Remove imageauthorname, imageauthoremail and imageauthorurl fields for badges.
$table = new xmldb_table('badge');
$fields = [
'imageauthorname',
'imageauthoremail',
'imageauthorurl',
];
foreach ($fields as $field) {
$field = new xmldb_field($field);
if ($dbman->field_exists($table, $field)) {
$dbman->drop_field($table, $field);
}
}
// Main savepoint reached.
upgrade_main_savepoint(true, 2025013100.01);
}
return true;
}