Author: mcantelon
Date: Mon Jan 30 16:15:48 2012
New Revision: 10778

Log:
Fixed issue with rightsholder creation.

Modified:
   trunk/lib/task/import/csvImportTask.class.php

Modified: trunk/lib/task/import/csvImportTask.class.php
==============================================================================
--- trunk/lib/task/import/csvImportTask.class.php       Mon Jan 30 14:50:03 
2012        (r10777)
+++ trunk/lib/task/import/csvImportTask.class.php       Mon Jan 30 16:15:48 
2012        (r10778)
@@ -355,19 +355,28 @@
                 $rightsHolderId = FALSE;
                 if ($self->rowStatusVars['copyrightHolder'])
                 {
-                  $actor = 
$self->createOrFetchActor($self->rowStatusVars['copyrightHolder']);
-                  $rightsHolderId = $actor->id;
+                  $query = "SELECT object.id
+                    FROM object JOIN actor_i18n i18n
+                    ON object.id = i18n.id
+                    WHERE i18n.authorized_form_of_name = ?
+                    AND object.class_name = 'QubitRightsHolder';";
+
+                  $statement = $self->sqlQuery($query, 
array($self->rowStatusVars['copyrightHolder']));
 
-                  $query = "SELECT id FROM rights_holder WHERE id=?";
-                  $statement = $self->sqlQuery($query, array($rightsHolderId));
                   $result = $statement->fetch(PDO::FETCH_OBJ);
 
-                  // if actor isn't already a rightsholder, make it one
-                  if (!$result) {
-                    $query = "INSERT INTO rights_holder (id) VALUES (?)";
-                    $statement = $self->sqlQuery($query, 
array($rightsHolderId));
+                  if (!$result)
+                  {
+                    $rightsHolder = new QubitRightsHolder;
+                    $rightsHolder->authorizedFormOfName = 
$self->rowStatusVars['copyrightHolder'];
+                    $rightsHolder->save();
+
+                    $rightsHolderId = $rightsHolder->id;
+                  } else {
+                    $rightsHolderId = $result->id;
                   }
                 }
+
                 $rightAndRelation = array(
                   'restriction'       => 0,
                   'basisId'           => 170,
@@ -377,6 +386,7 @@
                     $self->getStatus('copyrightStatusTypes')
                   )
                 );
+
                 if ($rightsHolderId) $rightAndRelation['rightsHolderId'] = 
$rightsHolderId;
                 $self->createRightAndRelation($rightAndRelation);
                 break;

-- 
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.

Reply via email to