Author: mcantelon
Date: Mon Feb 20 10:32:21 2012
New Revision: 10942
Log:
Added support for multiple rightsholders/expiry dates.
Modified:
trunk/lib/task/import/csvImportTask.class.php
Modified: trunk/lib/task/import/csvImportTask.class.php
==============================================================================
--- trunk/lib/task/import/csvImportTask.class.php Mon Feb 20 00:03:00
2012 (r10941)
+++ trunk/lib/task/import/csvImportTask.class.php Mon Feb 20 10:32:21
2012 (r10942)
@@ -397,39 +397,60 @@
case 'under copyright':
print "Adding rights for ". $self->object->title ."...\n";
$rightsHolderId = FALSE;
- $rightsHolderName = $self->rowStatusVars['copyrightHolder'];
- $rightsHolderName = ($rightsHolderName) ? $rightsHolderName :
'Unknown';
- $rightsHolder =
$self->createOrFetchRightsHolder($rightsHolderName);
- $rightsHolderId = $rightsHolder->id;
+ $rightsHolderNames = explode('|',
$self->rowStatusVars['copyrightHolder']);
- $rightsHolderName = trim(strtolower($rightsHolderName));
- if (
- $rightsHolderName == 'city of vancouver'
- || strpos($rightsHolderName, 'city of vancouver') === 0
- )
+ if ($self->rowStatusVars['copyrightExpires'])
{
- $restriction = 1;
- } else {
- $restriction = 0;
+ $endDates = explode('|',
$self->rowStatusVars['copyrightExpires']);
}
- $rightAndRelation = array(
- 'restriction' => $restriction,
- 'basisId' => 170,
- 'actId' => 305,
- 'copyrightStatusId' => array_search(
- 'Under copyright',
- $self->getStatus('copyrightStatusTypes')
+ foreach($rightsHolderNames as $index => $rightsHolderName)
+ {
+ $rightsHolderName = ($rightsHolderName) ? $rightsHolderName
: 'Unknown';
+ $rightsHolder =
$self->createOrFetchRightsHolder($rightsHolderName);
+ $rightsHolderId = $rightsHolder->id;
+
+ $rightsHolderName = trim(strtolower($rightsHolderName));
+ if (
+ $rightsHolderName == 'city of vancouver'
+ || strpos($rightsHolderName, 'city of vancouver') === 0
)
- );
+ {
+ $restriction = 1;
+ } else {
+ $restriction = 0;
+ }
+
+ $rightAndRelation = array(
+ 'restriction' => $restriction,
+ 'basisId' => 170,
+ 'actId' => 305,
+ 'copyrightStatusId' => array_search(
+ 'Under copyright',
+ $self->getStatus('copyrightStatusTypes')
+ )
+ );
+
+ if (isset($endDates))
+ {
+ // if rightsholder/expiry dates and paired, use
+ // corresponding date ...otherwise just use the
+ // first expiry date
+ $rightAndRelation['endDate']
+ = (count($endDates) == count($rightsHolderNames))
+ ? $endDates[$index]
+ : $endDates[0];
+
+ if (!is_numeric($rightAndRelation['endDate']))
+ {
+ throw new sfException('Copyright expiry '.
$rightAndRelation['endDate']
+ .' is invalid.');
+ }
+ }
- if ($self->rowStatusVars['copyrightExpires'])
- {
- $rightAndRelation['endDate'] =
$self->rowStatusVars['copyrightExpires'];
+ if ($rightsHolderId) $rightAndRelation['rightsHolderId'] =
$rightsHolderId;
+ $self->createRightAndRelation($rightAndRelation);
}
-
- if ($rightsHolderId) $rightAndRelation['rightsHolderId'] =
$rightsHolderId;
- $self->createRightAndRelation($rightAndRelation);
break;
case 'unknown':
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/qubit-commits?hl=en.