Merge branch 'MDL-71491-311' of git://github.com/paulholden/moodle into MOODLE_311_STABLE

This commit is contained in:
Sara Arjona
2021-05-06 18:42:25 +02:00
+31 -7
View File
@@ -199,7 +199,7 @@ class repository_flickr extends repository {
$response = $this->flickr->call('photos.search', [
'user_id' => 'me',
'per_page' => 24,
'extras' => 'original_format,url_sq,url_o,date_upload,owner_name',
'extras' => 'original_format,url_sq,url_o,date_upload,last_update,owner_name,license',
'page' => $page,
'text' => $searchtext,
]);
@@ -210,7 +210,6 @@ class repository_flickr extends repository {
}
// Convert the response to the format expected by the filepicker.
$ret = [
'manage' => 'https://www.flickr.com/photos/organize',
'list' => [],
@@ -238,18 +237,23 @@ class repository_flickr extends repository {
$p->title .= $format;
}
// Perform a HEAD request to the image to obtain it's Content-Length.
$curl = new curl();
$curl->head($p->url_o);
$ret['list'][] = [
'title' => $p->title,
'source' => $p->id,
'id' => $p->id,
'thumbnail' => $p->url_sq,
'thumbnail_width' => $p->width_sq,
'thumbnail_height' => $p->height_sq,
'date' => $p->dateupload,
'datecreated' => $p->dateupload,
'datemodified' => $p->lastupdate,
'url' => $p->url_o,
'author' => $p->ownername,
'size' => null,
'license' => '',
'size' => (int)($curl->get_info()['download_content_length']),
'image_width' => $p->width_o,
'image_height' => $p->height_o,
'license' => $this->license4moodle((int) $p->license),
];
}
}
@@ -260,6 +264,26 @@ class repository_flickr extends repository {
return $ret;
}
/**
* Map Flickr license ID to those used internally by Moodle
*
* @param int $licenseid
* @return string
*/
public function license4moodle(int $licenseid): string {
$license = [
0 => 'allrightsreserved',
1 => 'cc-nc-sa',
2 => 'cc-nc',
3 => 'cc-nc-nd',
4 => 'cc',
5 => 'cc-sa',
6 => 'cc-nd',
7 => 'other'
];
return $license[$licenseid];
}
/**
*
* @param string $path