Skip to content

Commit

Permalink
*8445* add support for file size, uploader, user group
Browse files Browse the repository at this point in the history
  • Loading branch information
jnugent committed Jan 13, 2014
1 parent af96269 commit d2700d5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Expand Up @@ -136,6 +136,28 @@ function handleRevisionElement($node, $stageId) {
}
}

$uploaderUsername = $node->getAttribute('uploader');
$uploaderUserGroup = $node->getAttribute('user_group_ref');

// Determine the user group based on the user_group_ref element.
$userGroupDao = DAORegistry::getDAO('UserGroupDAO');
$userGroups = $userGroupDao->getByContextId($context->getId());
while ($userGroup = $userGroups->next()) {
if (in_array($uploaderUserGroup, $userGroup->getName(null))) {
$submissionFile->setUserGroupId($userGroup->getId());
}
}

// Do the same for the user.
$userDao = DAORegistry::getDAO('UserDAO');
$user = $userDao->getByUsername($uploaderUsername);
if ($user) {
$submissionFile->setUploaderUserId($user->getId());
}

$fileSize = $node->getAttribute('filesize');
$submissionFile->setFileSize($fileSize);

$submissionFileDao->insertObject($submissionFile, $filename, false);
return $submissionFile;
}
Expand Down
Expand Up @@ -95,6 +95,7 @@ function createSubmissionFileNode($doc, $submissionFile) {
if ($submissionFile->getDirectSalesPrice() !== null) {
$revisionNode->setAttribute('direct_sales_price', $submissionFile->getDirectSalesPrice());
}
$revisionNode->setAttribute('filesize', $submissionFile->getFileSize());

$userGroupDao = DAORegistry::getDAO('UserGroupDAO');
$userGroup = $userGroupDao->getById($submissionFile->getUserGroupId());
Expand Down
1 change: 1 addition & 0 deletions plugins/importexport/native/pkp-native.xsd
Expand Up @@ -102,6 +102,7 @@
<attribute name="user_group_ref" type="pkp:user_group_ref" use="required" />
<attribute name="uploader" type="pkp:username" />
<attribute name="genre" type="normalizedString" use="required" />
<attribute name="filesize" type="int" use="required" />
</complexType>
</element>
</sequence>
Expand Down

0 comments on commit d2700d5

Please sign in to comment.