Author: mcantelon
Date: Fri May 4 23:48:39 2012
New Revision: 11647
Log:
Re-added copyright column handling logic to import.
Modified:
trunk/lib/task/import/csvImportTask.class.php
Modified: trunk/lib/task/import/csvImportTask.class.php
==============================================================================
--- trunk/lib/task/import/csvImportTask.class.php Fri May 4 18:11:22
2012 (r11646)
+++ trunk/lib/task/import/csvImportTask.class.php Fri May 4 23:48:39
2012 (r11647)
@@ -551,6 +551,131 @@
);
}
+ // add copyright info
+ // TODO: handle this via a separate import
+ if (isset($self->rowStatusVars['copyrightStatus']) &&
$self->rowStatusVars['copyrightStatus'])
+ {
+ switch (strtolower($self->rowStatusVars['copyrightStatus']))
+ {
+ case 'under copyright':
+ print "Adding rights for ". $self->object->title ."...\n";
+ $rightsHolderId = FALSE;
+ $rightsHolderNames = explode('|',
$self->rowStatusVars['copyrightHolder']);
+
+ if ($self->rowStatusVars['copyrightExpires'])
+ {
+ $endDates = explode('|',
$self->rowStatusVars['copyrightExpires']);
+ }
+
+ 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' => QubitTerm::RIGHT_BASIS_COPYRIGHT_ID,
+ 'actId' => array_search(
+ 'Replicate',
+ $self->getStatus('copyrightActTypes')
+ ),
+ '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 ($rightsHolderId) $rightAndRelation['rightsHolderId'] =
$rightsHolderId;
+ $self->createRightAndRelation($rightAndRelation);
+ }
+ break;
+
+ case 'unknown':
+ $rightsHolder = $self->createOrFetchRightsHolder('Unknown');
+ $rightsHolderId = $rightsHolder->id;
+
+ $rightAndRelation = array(
+ 'rightsHolderId' => $rightsHolderId,
+ 'restriction' => 0,
+ 'basisId' => QubitTerm::RIGHT_BASIS_COPYRIGHT_ID,
+ 'actId' => array_search(
+ 'Replicate',
+ $self->getStatus('copyrightActTypes')
+ ),
+ 'copyrightStatusId' => array_search(
+ 'Unknown',
+ $self->getStatus('copyrightStatusTypes')
+ )
+ );
+
+ if ($self->rowStatusVars['copyrightExpires'])
+ {
+ $rightAndRelation['endDate'] =
$self->rowStatusVars['copyrightExpires'];
+ }
+
+ $self->createRightAndRelation($rightAndRelation);
+ break;
+
+ case 'public domain':
+
+ $rightAndRelation = array(
+ 'restriction' => 1,
+ 'basisId' => QubitTerm::RIGHT_BASIS_COPYRIGHT_ID,
+ 'actId' => array_search(
+ 'Replicate',
+ $self->getStatus('copyrightActTypes')
+ ),
+ 'copyrightStatusId' => array_search(
+ 'Public domain',
+ $self->getStatus('copyrightStatusTypes')
+ )
+ );
+
+ if ($self->rowStatusVars['copyrightExpires'])
+ {
+ $rightAndRelation['endDate'] =
$self->rowStatusVars['copyrightExpires'];
+ }
+
+ $self->createRightAndRelation($rightAndRelation);
+ break;
+
+ default:
+ throw new sfException('Copyright status "'
+ . $self->rowStatusVars['copyrightStatus']
+ .'" not handled: adjust script or import data');
+ break;
+ }
+ }
+
// add creators and create events
$createEvents = array();
if (isset($self->rowStatusVars['creators'])
--
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.