MDL-33828 Portfolio: prevent notices while exporting to portfolios

This commit is contained in:
Frederic Massart 2012-06-26 17:28:03 +08:00
parent d71b79a406
commit c31dc0b695
3 changed files with 18 additions and 12 deletions

View File

@ -722,15 +722,18 @@ class portfolio_exporter {
if ($this->get('user')->id != $USER->id) { // make sure it belongs to the right user
throw new portfolio_exception('notyours', 'portfolio');
}
if (!$readonly && $this->get('instance') && !$this->get('instance')->allows_multiple_exports()
&& ($already = portfolio_existing_exports($this->get('user')->id, $this->get('instance')->get('plugin')))
&& array_shift(array_keys($already)) != $this->get('id')
) {
$a = (object)array(
'plugin' => $this->get('instance')->get('plugin'),
'link' => $CFG->wwwroot . '/user/portfoliologs.php',
);
throw new portfolio_exception('nomultipleexports', 'portfolio', '', $a);
if (!$readonly && $this->get('instance') && !$this->get('instance')->allows_multiple_exports()) {
$already = portfolio_existing_exports($this->get('user')->id, $this->get('instance')->get('plugin'));
$already = array_keys($already);
if (array_shift($already) != $this->get('id')) {
$a = (object)array(
'plugin' => $this->get('instance')->get('plugin'),
'link' => $CFG->wwwroot . '/user/portfoliologs.php',
);
throw new portfolio_exception('nomultipleexports', 'portfolio', '', $a);
}
}
if (!$this->caller->check_permissions()) { // recall the caller permission check
throw new portfolio_caller_exception('nopermissions', 'portfolio', $this->caller->get_return_url());

View File

@ -45,6 +45,9 @@ class assign_portfolio_caller extends portfolio_module_caller_base {
/** @var int callback arg - the id of submission we export */
protected $sid;
/** @var string component of the submission files we export*/
protected $component;
/** @var string callback arg - the area of submission files we export */
protected $area;
@ -60,7 +63,6 @@ class assign_portfolio_caller extends portfolio_module_caller_base {
/** @var string callback arg - the name of the editor field we export */
protected $editor;
/**
* callback arg for a single file export
*/

View File

@ -37,8 +37,9 @@ class portfolio_plugin_boxnet extends portfolio_plugin_push_base {
)
);
if (array_key_exists('status', $return) && $return['status'] == 'upload_ok'
&& array_key_exists('id', $return) && count($return['id']) == 1) {
$this->rename_file($return['id'][array_pop(array_keys($return['id']))], $file->get_filename());
&& array_key_exists('id', $return) && count($return['id']) == 1) {
$returnid = array_keys($return['id']);
$this->rename_file($return['id'][array_pop($returnid)], $file->get_filename());
// if this fails, the file was sent but not renamed - this triggers a warning but is not fatal.
}
}