Skip to content

Commit

Permalink
MDL-33828 Portfolio: prevent notices while exporting to portfolios
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederic Massart committed Jul 3, 2012
1 parent d71b79a commit c31dc0b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
21 changes: 12 additions & 9 deletions lib/portfolio/exporter.php
Expand Up @@ -722,15 +722,18 @@ public function verify_rewaken($readonly=false) {
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());
Expand Down
4 changes: 3 additions & 1 deletion mod/assign/portfolio_callback.php
Expand Up @@ -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;

Expand All @@ -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
*/
Expand Down
5 changes: 3 additions & 2 deletions portfolio/boxnet/lib.php
Expand Up @@ -37,8 +37,9 @@ public function send_package() {
)
);
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.
}
}
Expand Down

0 comments on commit c31dc0b

Please sign in to comment.