Skip to content

Commit a16934d

Browse files
committed
MDL-83909 core_badges: Remove author name, email and url fields
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.
1 parent 07881a5 commit a16934d

37 files changed

+53
-281
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
issueNumber: MDL-83909
2+
notes:
3+
core_badges:
4+
- message: >-
5+
The fields imageauthorname, imageauthoremail, and imageauthorurl have
6+
been removed from badges due to confusion and their absence from the
7+
official specification. These fields also do not appear in OBv3.0.
8+
Additionally, the image_author_json.php file has been removed as it is
9+
no longer needed.
10+
type: removed

backup/moodle2/backup_stepslib.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -928,8 +928,7 @@ protected function define_structure() {
928928
'timecreated', 'timemodified', 'usercreated', 'usermodified', 'issuername',
929929
'issuerurl', 'issuercontact', 'expiredate', 'expireperiod', 'type', 'courseid',
930930
'message', 'messagesubject', 'attachment', 'notification', 'status', 'nextcron',
931-
'version', 'language', 'imageauthorname', 'imageauthoremail', 'imageauthorurl',
932-
'imagecaption'));
931+
'version', 'language', 'imagecaption'));
933932

934933
$criteria = new backup_nested_element('criteria');
935934
$criterion = new backup_nested_element('criterion', array('id'), array('badgeid',

backup/moodle2/restore_stepslib.php

-3
Original file line numberDiff line numberDiff line change
@@ -2789,9 +2789,6 @@ public function process_badge($data) {
27892789
'nextcron' => $data->nextcron,
27902790
'version' => $data->version,
27912791
'language' => $data->language,
2792-
'imageauthorname' => $data->imageauthorname,
2793-
'imageauthoremail' => $data->imageauthoremail,
2794-
'imageauthorurl' => $data->imageauthorurl,
27952792
'imagecaption' => $data->imagecaption
27962793
);
27972794

badges/badge_json.php

+6-17
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,12 @@
4747

4848
$json['name'] = $badge->name;
4949
$json['description'] = $badge->description;
50-
if ($badge->imageauthorname ||
51-
$badge->imageauthoremail ||
52-
$badge->imageauthorurl ||
53-
$badge->imagecaption) {
54-
$urlimage = moodle_url::make_pluginfile_url($context->id,
55-
'badges', 'badgeimage', $badge->id, '/', 'f3')->out(false);
56-
$json['image'] = array();
57-
$json['image']['id'] = $urlimage;
58-
if ($badge->imageauthorname || $badge->imageauthoremail || $badge->imageauthorurl) {
59-
$authorimage = new moodle_url('/badges/image_author_json.php', array('id' => $badge->id));
60-
$json['image']['author'] = $authorimage->out(false);
61-
}
62-
if ($badge->imagecaption) {
63-
$json['image']['caption'] = $badge->imagecaption;
64-
}
65-
} else {
66-
$json['image'] = $urlimage;
50+
$urlimage = moodle_url::make_pluginfile_url($context->id,
51+
'badges', 'badgeimage', $badge->id, '/', 'f3')->out(false);
52+
$json['image'] = [];
53+
$json['image']['id'] = $urlimage;
54+
if ($badge->imagecaption) {
55+
$json['image']['caption'] = $badge->imagecaption;
6756
}
6857

6958
$params = ['id' => $badge->id];

badges/classes/assertion.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,7 @@ protected function embed_data_badge_version2(&$json, $type = OPEN_BADGES_V2_TYPE
360360
if ($alignments = $this->get_alignments()) {
361361
$json['alignments'] = $alignments;
362362
}
363-
if ($this->_data->imageauthorname ||
364-
$this->_data->imageauthoremail ||
365-
$this->_data->imageauthorurl ||
366-
$this->_data->imagecaption) {
363+
if ($this->_data->imagecaption) {
367364
$storage = get_file_storage();
368365
$imagefile = $storage->get_file($context->id, 'badges', 'badgeimage', $this->_data->id, '/', 'f3.png');
369366
if ($imagefile) {

badges/classes/badge.php

-15
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,6 @@ class badge {
106106
/** @var string What language is this badge written in. */
107107
public $language;
108108

109-
/** @var string The author of the image for this badge. */
110-
public $imageauthorname;
111-
112-
/** @var string The email of the author of the image for this badge. */
113-
public $imageauthoremail;
114-
115-
/** @var string The url of the author of the image for this badge. */
116-
public $imageauthorurl;
117-
118109
/** @var string The caption of the image for this badge. */
119110
public $imagecaption;
120111

@@ -985,9 +976,6 @@ public static function create_badge(stdClass $data, ?int $courseid = null): badg
985976
$fordb->version = $data->version;
986977
$fordb->language = $data->language;
987978
$fordb->description = $data->description;
988-
$fordb->imageauthorname = $data->imageauthorname;
989-
$fordb->imageauthoremail = $data->imageauthoremail;
990-
$fordb->imageauthorurl = $data->imageauthorurl;
991979
$fordb->imagecaption = $data->imagecaption;
992980
$fordb->timecreated = $now;
993981
$fordb->timemodified = $now;
@@ -1047,9 +1035,6 @@ public function update(stdClass $data): bool {
10471035
$this->version = trim($data->version);
10481036
$this->language = $data->language;
10491037
$this->description = $data->description;
1050-
$this->imageauthorname = $data->imageauthorname;
1051-
$this->imageauthoremail = $data->imageauthoremail;
1052-
$this->imageauthorurl = $data->imageauthorurl;
10531038
$this->imagecaption = $data->imagecaption;
10541039
$this->usermodified = $USER->id;
10551040
$this->issuername = $data->issuername;

badges/classes/external/user_badge_exporter.php

-18
Original file line numberDiff line numberDiff line change
@@ -206,24 +206,6 @@ protected static function define_properties() {
206206
'optional' => true,
207207
'null' => NULL_ALLOWED,
208208
],
209-
'imageauthorname' => [
210-
'type' => PARAM_TEXT,
211-
'description' => 'Name of the image author',
212-
'optional' => true,
213-
'null' => NULL_ALLOWED,
214-
],
215-
'imageauthoremail' => [
216-
'type' => PARAM_TEXT,
217-
'description' => 'Email of the image author',
218-
'optional' => true,
219-
'null' => NULL_ALLOWED,
220-
],
221-
'imageauthorurl' => [
222-
'type' => PARAM_URL,
223-
'description' => 'URL of the image author',
224-
'optional' => true,
225-
'null' => NULL_ALLOWED,
226-
],
227209
'imagecaption' => [
228210
'type' => PARAM_TEXT,
229211
'description' => 'Caption of the image',

badges/classes/form/badge.php

-17
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,6 @@ public function definition() {
8383
$mform->insertElementBefore($currentimage, 'image');
8484
}
8585
$mform->addHelpButton('image', 'badgeimage', 'badges');
86-
$mform->addElement('text', 'imageauthorname', get_string('imageauthorname', 'badges'), ['size' => '70']);
87-
$mform->setType('imageauthorname', PARAM_TEXT);
88-
$mform->addHelpButton('imageauthorname', 'imageauthorname', 'badges');
89-
$mform->addElement('text', 'imageauthoremail', get_string('imageauthoremail', 'badges'), ['size' => '70']);
90-
$mform->setType('imageauthoremail', PARAM_TEXT);
91-
$mform->addHelpButton('imageauthoremail', 'imageauthoremail', 'badges');
92-
$mform->addElement('text', 'imageauthorurl', get_string('imageauthorurl', 'badges'), ['size' => '70']);
93-
$mform->setType('imageauthorurl', PARAM_URL);
94-
$mform->addHelpButton('imageauthorurl', 'imageauthorurl', 'badges');
9586
$mform->addElement('text', 'imagecaption', get_string('imagecaption', 'badges'), ['size' => '70']);
9687
$mform->setType('imagecaption', PARAM_TEXT);
9788
$mform->addHelpButton('imagecaption', 'imagecaption', 'badges');
@@ -218,14 +209,6 @@ public function validation($data, $files) {
218209
$errors['expirydategr'] = get_string('error:invalidexpiredate', 'badges');
219210
}
220211

221-
if ($data['imageauthoremail'] && !validate_email($data['imageauthoremail'])) {
222-
$errors['imageauthoremail'] = get_string('invalidemail');
223-
}
224-
225-
if ($data['imageauthorurl'] && !preg_match('@^https?://.+@', $data['imageauthorurl'])) {
226-
$errors['imageauthorurl'] = get_string('invalidurl', 'badges');
227-
}
228-
229212
return $errors;
230213
}
231214
}

badges/classes/output/badgeclass.php

-12
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,6 @@ public function export_for_template(renderer_base $output): stdClass {
119119
$data->hasotherfields = true;
120120
$data->version = $this->badge->version;
121121
}
122-
if (!empty($this->badge->imageauthorname)) {
123-
$data->hasotherfields = true;
124-
$data->imageauthorname = $this->badge->imageauthorname;
125-
}
126-
if (!empty($this->badge->imageauthoremail)) {
127-
$data->hasotherfields = true;
128-
$data->imageauthoremail = obfuscate_mailto($this->badge->imageauthoremail, $this->badge->imageauthoremail);
129-
}
130-
if (!empty($this->badge->imageauthorurl)) {
131-
$data->hasotherfields = true;
132-
$data->imageauthorurl = $this->badge->imageauthorurl;
133-
}
134122
if (!empty($this->badge->imagecaption)) {
135123
$data->hasotherfields = true;
136124
$data->imagecaption = $this->badge->imagecaption;

badges/classes/output/external_badge.php

-4
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,6 @@ public function export_for_template(renderer_base $output): stdClass {
125125
}
126126
$data->badgeimage = $this->issued->image;
127127
if (is_object($data->badgeimage)) {
128-
if (!empty($data->badgeimage->author)) {
129-
$data->hasotherfields = true;
130-
$data->imageauthorname = $data->badgeimage->author;
131-
}
132128
if (!empty($data->badgeimage->caption)) {
133129
$data->hasotherfields = true;
134130
$data->imagecaption = $data->badgeimage->caption;

badges/classes/output/issued_badge.php

-12
Original file line numberDiff line numberDiff line change
@@ -175,18 +175,6 @@ public function export_for_template(renderer_base $output): stdClass {
175175
$data->hasotherfields = true;
176176
$data->version = $badge->version;
177177
}
178-
if (!empty($badge->imageauthorname)) {
179-
$data->hasotherfields = true;
180-
$data->imageauthorname = $badge->imageauthorname;
181-
}
182-
if (!empty($badge->imageauthoremail)) {
183-
$data->hasotherfields = true;
184-
$data->imageauthoremail = obfuscate_mailto($badge->imageauthoremail, $badge->imageauthoremail);
185-
}
186-
if (!empty($badge->imageauthorurl)) {
187-
$data->hasotherfields = true;
188-
$data->imageauthorurl = $badge->imageauthorurl;
189-
}
190178
if (!empty($badge->imagecaption)) {
191179
$data->hasotherfields = true;
192180
$data->imagecaption = $badge->imagecaption;

badges/classes/privacy/provider.php

-3
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,6 @@ public static function export_user_data(approved_contextlist $contextlist) {
454454
'name' => $badge->name,
455455
'version' => $badge->version,
456456
'language' => $badge->language,
457-
'imageauthorname' => $badge->imageauthorname,
458-
'imageauthoremail' => $badge->imageauthoremail,
459-
'imageauthorurl' => $badge->imageauthorurl,
460457
'imagecaption' => $badge->imagecaption,
461458
'issued' => null,
462459
'manual_award' => null,

badges/classes/reportbuilder/local/entities/badge.php

-13
Original file line numberDiff line numberDiff line change
@@ -262,19 +262,6 @@ protected function get_all_columns(): array {
262262
}
263263
});
264264

265-
// Image author details.
266-
foreach (['imageauthorname', 'imageauthoremail', 'imageauthorurl'] as $imageauthorfield) {
267-
$columns[] = (new column(
268-
$imageauthorfield,
269-
new lang_string($imageauthorfield, 'core_badges'),
270-
$this->get_entity_name()
271-
))
272-
->add_joins($this->get_joins())
273-
->set_type(column::TYPE_TEXT)
274-
->add_field("{$badgealias}.{$imageauthorfield}")
275-
->set_is_sortable(true);
276-
}
277-
278265
return $columns;
279266
}
280267

badges/image_author_json.php

-52
This file was deleted.

badges/renderer.php

-5
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,6 @@ public function print_badge_overview($badge, $context) {
186186
$dl[get_string('description', 'badges')] = $badge->description;
187187
$dl[get_string('createdon', 'search')] = userdate($badge->timecreated);
188188
$dl[get_string('badgeimage', 'badges')] = print_badge_image($badge, $context, 'large');
189-
$dl[get_string('imageauthorname', 'badges')] = $badge->imageauthorname;
190-
$dl[get_string('imageauthoremail', 'badges')] =
191-
html_writer::tag('a', $badge->imageauthoremail, array('href' => 'mailto:' . $badge->imageauthoremail));
192-
$dl[get_string('imageauthorurl', 'badges')] =
193-
html_writer::link($badge->imageauthorurl, $badge->imageauthorurl, array('target' => '_blank'));
194189
$dl[get_string('imagecaption', 'badges')] = $badge->imagecaption;
195190
$tags = \core_tag_tag::get_item_tags('core_badges', 'badge', $badge->id);
196191
$dl[get_string('tags', 'badges')] = $this->output->tag_list($tags, '');

badges/templates/issued_badge.mustache

-38
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@
3737
* hasotherfields - Wheter the badge has other fields or not.
3838
* language - Badge language [optional].
3939
* version - Badge version [optional].
40-
* imageauthorname - Badge image author name [optional].
41-
* imageauthoremail - Badge image author email [optional].
42-
* imageauthorurl - Badge image author URL [optional].
4340
* imagecaption - Badge image caption [optional].
4441
* endorsement - Badge endorsement data, with id, badgeid, issuername... [optional].
4542
* hasrelatedbadges - Whether the badge has related badges or not.
@@ -66,9 +63,6 @@
6663
"hasotherfields": true,
6764
"language": "English",
6865
"version": "1.0beta",
69-
"imageauthorname": "Judit Blanque",
70-
"imageauthoremail": "<a href=\"mailto:xxx\">judit@moodle.invalid</a>",
71-
"imageauthorurl": "http://juditblanque.cat",
7266
"imagecaption": "This is a nice picture from my cat",
7367
"endorsement": {
7468
"id": "2",
@@ -253,38 +247,6 @@
253247
</dl>
254248
{{/language}}
255249

256-
{{#imageauthorname}}
257-
<dl>
258-
<dt>
259-
{{#str}}imageauthorname, core_badges{{/str}}
260-
</dt>
261-
<dd>
262-
{{imageauthorname}}
263-
</dd>
264-
</dl>
265-
{{/imageauthorname}}
266-
267-
{{#imageauthoremail}}
268-
<dl>
269-
<dt>
270-
{{#str}}imageauthoremail, core_badges{{/str}}
271-
</dt>
272-
<dd>
273-
{{{imageauthoremail}}}
274-
</dd>
275-
</dl>
276-
{{/imageauthoremail}}
277-
278-
{{#imageauthorurl}}
279-
<dl>
280-
<dt>
281-
{{#str}}imageauthorurl, core_badges{{/str}}
282-
</dt>
283-
<dd>
284-
<a href="{{imageauthorurl}}" target="_blank">{{imageauthorurl}}</a>
285-
</dd>
286-
</dl>
287-
{{/imageauthorurl}}
288250
{{#imagecaption}}
289251
<dl>
290252
<dt>

badges/tests/badge_test.php

-3
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,6 @@ private function get_badge(): array {
288288
'status' => BADGE_STATUS_ACTIVE_LOCKED,
289289
'version' => OPEN_BADGES_V2,
290290
'language' => 'en',
291-
'imageauthorname' => 'Image author',
292-
'imageauthoremail' => 'author@example.com',
293-
'imageauthorurl' => 'http://image.example.com/',
294291
'imagecaption' => 'Image caption',
295292
'tags' => [],
296293
];

0 commit comments

Comments
 (0)