mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-42605 portfolio_flickr: Photos can be added to a set on export
This commit is contained in:
parent
27199cfce8
commit
16dc4c13ae
@ -1113,7 +1113,9 @@ class phpFlickr {
|
||||
$args['content_type'] = isset($meta['content_type']) ? $meta['content_type'] : 1; // photo by default
|
||||
$args['hidden'] = isset($meta['hidden']) ? $meta['hidden'] : 2; // hide from public searches by default
|
||||
|
||||
$args['async'] = 1;
|
||||
// Do not enable the asynchronous more because then the query does not return a photo ID,
|
||||
// and we need a photo ID to add the photo to a set later on.
|
||||
// $args['async'] = 1;
|
||||
$args['api_key'] = $this->api_key;
|
||||
|
||||
if (!empty($this->email)) {
|
||||
@ -1144,8 +1146,17 @@ class phpFlickr {
|
||||
$args['photo'] = $photo; // $this->curl will process it correctly
|
||||
|
||||
if ($response = $this->curl->post($this->Upload, $args)) {
|
||||
$xml = simplexml_load_string($response);
|
||||
if ($xml['stat'] == 'fail') {
|
||||
$this->parsed_response = array('stat' => (string) $xml['stat'], 'code' => (int) $xml->err['code'],
|
||||
'message' => (string) $xml->err['msg']);
|
||||
} elseif ($xml['stat'] == 'ok') {
|
||||
$this->parsed_response = array('stat' => (string) $xml['stat'], 'photoid' => (int) $xml->photoid);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
$this->parsed_response = array('stat' => 'fail', 'code' => $this->curl->get_errno(),
|
||||
'message' => $this->curl->error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ class portfolio_plugin_flickr extends portfolio_plugin_push_base {
|
||||
'hidden' => $this->get_export_config('hidden')));
|
||||
if ($return) {
|
||||
// Attach photo to a set if requested
|
||||
if ($this->get_export_config('set')) {
|
||||
if ($this->get_export_config('set') && !empty($this->flickr->parsed_response['photoid'])) {
|
||||
$this->flickr->photosets_addPhoto($this->get_export_config('set'),
|
||||
$this->flickr->parsed_response['photoid']);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user