Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
BUG: refs #516. Can now use applet uploader for multi-file revision u…
Browse files Browse the repository at this point in the history
…pload
  • Loading branch information
zachmullen committed Oct 30, 2012
1 parent a8253ea commit 23e9831
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
35 changes: 29 additions & 6 deletions core/controllers/UploadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,28 @@ public function javarevisionsessionAction()
$this->disableLayout();
$this->disableView();

session_start();

$changes = $this->_getParam('changes');
$license = $this->_getParam('license');
$itemId = $this->_getParam('itemId');
$item = $this->Item->load($itemId);
if(!isset($itemId) || !$item)
{
throw new Zend_Exception('Invalid itemId', 404);
}
$rev = $this->Item->getLastRevision($item);
if($rev)
{
$revNumber = $rev->getRevision() + 1;
}
else
{
$revNumber = 1;
}

session_start();
$this->userSession->JavaUpload->changes = $changes;
$this->userSession->JavaUpload->license = $license;

$this->userSession->JavaUpload->revNumber = $revNumber;
session_write_close();
}

Expand Down Expand Up @@ -531,12 +546,20 @@ function processjavarevisionuploadAction()
{
$license = null;
}
if(isset($this->userSession->JavaUpload->revNumber))
{
$revNumber = $this->userSession->JavaUpload->revNumber;
}
else
{
$revNumber = 1;
}

try
{
$item = $this->Component->Upload->createNewRevision($this->userSession->Dao, $data['filename'],
$data['path'], $changes, $parentId, null,
$license, $data['md5'], (bool)$testingMode);
$this->Component->Upload->createNewRevision($this->userSession->Dao, $data['filename'],
$data['path'], $changes, $parentId, $revNumber,
$license, $data['md5'], (bool)$testingMode);
}
catch(Exception $e)
{
Expand Down
2 changes: 0 additions & 2 deletions core/controllers/components/UploadComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,6 @@ public function createNewRevision($userDao, $name, $path, $changes, $itemId, $it
throw new Zend_Exception('Parent permissions errors');
}


if($itemRevisionDao == null)
{
Zend_Loader::loadClass("ItemRevisionDao", BASE_PATH . '/core/models/dao');
Expand Down Expand Up @@ -380,7 +379,6 @@ public function createNewRevision($userDao, $name, $path, $changes, $itemId, $it
$itemRevisionModel->save($itemRevisionDao);
}


// Add bitstreams to the revision
Zend_Loader::loadClass('BitstreamDao', BASE_PATH . '/core/models/dao');
$bitstreamDao = new BitstreamDao;
Expand Down
3 changes: 2 additions & 1 deletion core/public/js/upload/upload.revision.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ midas.upload.revision = {};
midas.upload.revision.sendFormToJavaSession = function () {
$.post(json.global.webroot+'/upload/javarevisionsession', {
changes: $('textarea[name=revisionChanges]:last').val(),
license: $('select[name=licenseSelect]:last').val()
license: $('select[name=licenseSelect]:last').val(),
itemId: json.item.item_id
});
}

Expand Down

0 comments on commit 23e9831

Please sign in to comment.