mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
"MDL-16341, add upload function for flickrlib"
This commit is contained in:
parent
c1ded42472
commit
b3e6e8047b
@ -1079,5 +1079,55 @@ class phpFlickr {
|
||||
$this->request("flickr.urls.lookupUser", array("url"=>$url));
|
||||
return $this->parsed_response ? $this->parsed_response['user'] : false;
|
||||
}
|
||||
/**
|
||||
* upload a photo to flickr
|
||||
* @param string $photo must be the path of the file
|
||||
* @param string $title
|
||||
* @param string $description
|
||||
* @param string $tags
|
||||
* @param string $is_public
|
||||
* @param string $is_friend
|
||||
* @param string $is_family
|
||||
* @return boolean
|
||||
*/
|
||||
|
||||
function upload ($photo, $title = null, $description = null, $tags = null, $is_public = null, $is_friend = null, $is_family = null) {
|
||||
global $SESSION;
|
||||
$args = array("async" => 1, "api_key" => $this->api_key, "title" => $title, "description" => $description, "tags" => $tags, "is_public" => $is_public, "is_friend" => $is_friend, "is_family" => $is_family);
|
||||
if (!empty($this->email)) {
|
||||
$args = array_merge($args, array("email" => $this->email));
|
||||
}
|
||||
if (!empty($this->password)) {
|
||||
$args = array_merge($args, array("password" => $this->password));
|
||||
}
|
||||
// TODO:
|
||||
// should we request a token if it is not valid?
|
||||
if (!empty($this->token)) {
|
||||
$args = array_merge($args, array("auth_token" => $this->token));
|
||||
}
|
||||
|
||||
ksort($args);
|
||||
$auth_sig = "";
|
||||
foreach ($args as $key => $data) {
|
||||
if ($data !== null) {
|
||||
$auth_sig .= $key . $data;
|
||||
} else {
|
||||
unset($args[$key]);
|
||||
}
|
||||
}
|
||||
if (!empty($this->secret)) {
|
||||
$api_sig = md5($this->secret . $auth_sig);
|
||||
$args['api_sig'] = $api_sig;
|
||||
}
|
||||
|
||||
$photo = realpath($photo);
|
||||
$args['photo'] = '@'.$photo;
|
||||
|
||||
if ($response = $this->curl->post($this->Upload, $args)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -26,7 +26,7 @@ class portfolio_plugin_flickr extends portfolio_plugin_push_base {
|
||||
$filesize = $file->get_filesize();
|
||||
|
||||
if ($file->is_valid_image()) {
|
||||
$return = $this->flickr->request ('upload', array('photo' => $file,
|
||||
$return = $this->flickr->upload ('upload', array('photo' => $file,
|
||||
'title' => $this->get_export_config('title'),
|
||||
'description' => $this->get_export_config('description'),
|
||||
'tags' => $this->get_export_config('tags'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user