Skip to content

Commit

Permalink
MDL-42605 portfolio_flickr: Photos can be added to a set on export
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederic Massart authored and Damyon Wiese committed Nov 7, 2013
1 parent 27199cf commit 16dc4c1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion lib/flickrlib.php
Expand Up @@ -1113,7 +1113,9 @@ function upload(stored_file $photo, array $meta = array()) {
$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)) {
Expand Down Expand Up @@ -1144,8 +1146,17 @@ function upload(stored_file $photo, array $meta = array()) {
$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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion portfolio/flickr/lib.php
Expand Up @@ -64,7 +64,7 @@ public function send_package() {
'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']);
}
Expand Down

0 comments on commit 16dc4c1

Please sign in to comment.