mirror of
https://github.com/moodle/moodle.git
synced 2025-08-03 08:09:47 +02:00
MDL-16341 Almost finished portfolio flickr plugin. Modified phpflickr->request method so it can upload files, but having permission issue (only read)
This commit is contained in:
parent
a5131d8154
commit
a55d94d4ac
4 changed files with 192 additions and 14 deletions
|
@ -70,6 +70,11 @@ class phpFlickr {
|
|||
|
||||
function request ($command, $args = array())
|
||||
{
|
||||
if ($command == 'upload') {
|
||||
$filecontent = $args['photo'];
|
||||
unset($args['photo']);
|
||||
}
|
||||
|
||||
//Sends a request to Flickr's REST endpoint via POST.
|
||||
if (substr($command,0,7) != "flickr.") {
|
||||
$command = "flickr." . $command;
|
||||
|
@ -77,23 +82,32 @@ class phpFlickr {
|
|||
|
||||
//Process arguments, including method and login data.
|
||||
$args = array_merge(array("method" => $command, "format" => "php_serial", "api_key" => $this->api_key), $args);
|
||||
|
||||
if (!empty($this->token)) {
|
||||
$args = array_merge($args, array("auth_token" => $this->token));
|
||||
} elseif (!empty($this->token)) {
|
||||
$args = array_merge($args, array("auth_token" => $this->token));
|
||||
}
|
||||
|
||||
ksort($args);
|
||||
$auth_sig = "";
|
||||
foreach ($args as $key => $data) {
|
||||
$auth_sig .= $key . $data;
|
||||
if ($key != 'photo') {
|
||||
$auth_sig .= $key . $data;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($this->secret)) {
|
||||
$api_sig = md5($this->secret . $auth_sig);
|
||||
$args['api_sig'] = $api_sig;
|
||||
}
|
||||
|
||||
//$this->req->addHeader("Connection", "Keep-Alive");
|
||||
$ret = $this->curl->post($this->REST, $args);
|
||||
if ($command != 'flickr.upload') {
|
||||
$ret = $this->curl->post($this->REST, $args);
|
||||
} else {
|
||||
$ret = $this->curl->post($this->Upload, $args);
|
||||
print_object($ret);die();
|
||||
}
|
||||
|
||||
$this->parsed_response = $this->clean_text_nodes(unserialize($ret));
|
||||
if ($this->parsed_response['stat'] == 'fail') {
|
||||
if ($this->die_on_error) die("The Flickr API returned the following error: #{$this->parsed_response['code']} - {$this->parsed_response['message']}");
|
||||
|
|
|
@ -37,32 +37,32 @@
|
|||
abstract class portfolio_plugin_base {
|
||||
|
||||
/**
|
||||
* boolean
|
||||
* whether this object needs writing out to the database
|
||||
* @var boolean $dirty
|
||||
*/
|
||||
protected $dirty;
|
||||
|
||||
/**
|
||||
* integer
|
||||
* id of instance
|
||||
* @var integer $id
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* string
|
||||
* name of instance
|
||||
* @var string $name
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* string
|
||||
* plugin this instance belongs to
|
||||
* @var string $plugin
|
||||
*/
|
||||
protected $plugin;
|
||||
|
||||
/**
|
||||
* boolean
|
||||
* whether this instance is visible or not
|
||||
* @var boolean $visible
|
||||
*/
|
||||
protected $visible;
|
||||
|
||||
|
@ -239,7 +239,7 @@ abstract class portfolio_plugin_base {
|
|||
foreach ($config as $key => $value) {
|
||||
if (!in_array($key, $allowed)) {
|
||||
$a = (object)array('property' => $key, 'class' => get_class($this));
|
||||
throw new portfolio_export_exception($this->get('exporter'), 'invalidexportproperty', 'portfolio', $this->get_return_url(), $a);
|
||||
throw new portfolio_export_exception($this->get('exporter'), 'invalidexportproperty', 'portfolio', null, $a);
|
||||
}
|
||||
$this->exportconfig[$key] = $value;
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ abstract class portfolio_plugin_base {
|
|||
);
|
||||
if (!in_array($key, $allowed)) {
|
||||
$a = (object)array('property' => $key, 'class' => get_class($this));
|
||||
throw new portfolio_export_exception($this->get('exporter'), 'invalidexportproperty', 'portfolio', $this->get_return_url(), $a);
|
||||
throw new portfolio_export_exception($this->get('exporter'), 'invalidexportproperty', 'portfolio', null, $a);
|
||||
}
|
||||
if (!array_key_exists($key, $this->exportconfig)) {
|
||||
return null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue