Author: david
Date: Tue Nov 22 11:22:51 2011
New Revision: 10349

Log:
Check for existing actor key (name)

Modified:
   trunk/lib/QubitCsvImport.class.php

Modified: trunk/lib/QubitCsvImport.class.php
==============================================================================
--- trunk/lib/QubitCsvImport.class.php  Tue Nov 22 08:47:39 2011        (r10348)
+++ trunk/lib/QubitCsvImport.class.php  Tue Nov 22 11:22:51 2011        (r10349)
@@ -373,6 +373,7 @@
 
     // name access points
     $n = 0;
+    $this->getActors();
     foreach (explode('|', $parameters['nameAccessPoints']) as 
$new_nameAccessPoint)
     {
       if (0 == strlen(trim($new_nameAccessPoint)))
@@ -381,7 +382,7 @@
       }
 
       // if the name does not exist, create it
-      if (!in_array($new_nameAccessPoint, $this->getActors()) && 
!empty($new_nameAccessPoint))
+      if (!isset($this->actors[$new_nameAccessPoint]))
       {
         $name = new QubitActor();
         $name->authorizedFormOfName = $new_nameAccessPoint;
@@ -417,11 +418,12 @@
     }
 
     // Creators
+    $this->getActors();
     foreach (explode('|', $parameters['creators']) as $creator)
     {
       if (0 < strlen($creator))
       {
-        if (!in_array($creator, $this->getActors()))
+        if (!isset($this->actors[$creator]))
         {
           $actor = new QubitActor;
           $actor->authorizedFormOfName = $creator;
@@ -515,23 +517,26 @@
 
     // name access points
     $n = 0;
+    $this->getActors();
     foreach (explode('|', $parameters['creators']) as $creator)
     {
-      if (0 < strlen($creator))
+      if (0 == strlen(trim($creator)))
       {
-        // if the name does not exist, create it
-        if (!in_array($new_creator, $this->getActors()))
-        {
-          $name = new QubitActor();
-          $name->authorizedFormOfName = $creator;
-          $name->save();
+        continue;
+      }
 
-          $this->actors[$name->__toString()] = $name;
-        }
+      // if the name does not exist, create it
+      if (!isset($this->actors[$creator]))
+      {
+        $name = new QubitActor();
+        $name->authorizedFormOfName = $creator;
+        $name->save();
 
-        $new_creators['new'.$n] = $this->context->routing->generate(null, 
array($this->actors[$new_creator], 'module' => 'actor'));
-        $n++;
+        $this->actors[$name->__toString()] = $name;
       }
+
+      $new_creators['new'.$n] = $this->context->routing->generate(null, 
array($this->actors[$creator], 'module' => 'actor'));
+      $n++;
     }
     $parameters['creators'] = $new_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.

Reply via email to