Author: peter
Date: 2008-11-10 12:27:18 -0800 (Mon, 10 Nov 2008)
New Revision: 1544

Modified:
   
trunk/qubit/apps/qubit/modules/informationobject/actions/updateAction.class.php
Log:
refactor information object update action to work with new Event create/edit 
options

Modified: 
trunk/qubit/apps/qubit/modules/informationobject/actions/updateAction.class.php
===================================================================
--- 
trunk/qubit/apps/qubit/modules/informationobject/actions/updateAction.class.php 
    2008-11-10 19:21:37 UTC (rev 1543)
+++ 
trunk/qubit/apps/qubit/modules/informationobject/actions/updateAction.class.php 
    2008-11-10 20:27:18 UTC (rev 1544)
@@ -399,24 +399,24 @@
 
   public function updateActorEvents($informationObject)
   {
-    // Get an array of creation events (even if there's only one)
-    if (!is_array($newCreationEvents = 
$this->getRequestParameter('newCreationEvents')))
+    // Get an array of Actor Events (even if there's only one)
+    if (!is_array($newActorEvents = 
$this->getRequestParameter('newActorEvents')))
     {
-      $newCreationEvents = 
array($this->getRequestParameter('newCreationEvent'));
+      $newActorEvents = array($this->getRequestParameter('newActorEvent'));
     }
 
-    // Loop thru new creation events
-    foreach ($newCreationEvents as $thisEvent)
+    // Loop thru new Actor Events
+    foreach ($newActorEvents as $thisEvent)
     {
-      $newCreationEvent = new QubitEvent;
+      $newActorEvent = new QubitEvent;
 
-      //add creator
+      // add actor
       if ($thisEvent['actorId'])
       {
-        $newCreationEvent->setActorId($thisEvent['actorId']);
-        $newCreationEvent->setInformationObjectId($informationObject->getId());
-        $newCreationEvent->setActorRoleId(QubitTerm::CREATOR_ID);
-        $newCreationEvent->save();
+        $newActorEvent->setActorId($thisEvent['actorId']);
+        $newActorEvent->setInformationObjectId($informationObject->getId());
+        $newActorEvent->setTypeId($thisEvent['eventTypeId']);
+        $newActorEvent->save();
         $this->foreignKeyUpdate = true;
       }
       else if ($thisEvent['newActorAuthorizedName'])
@@ -424,38 +424,49 @@
         $actor = new QubitActor;
         $actor->setAuthorizedFormOfName($thisEvent['newActorAuthorizedName']);
         $actor->save();
-        $newCreationEvent->setActorId($actor->getId());
-        $newCreationEvent->setInformationObjectId($informationObject->getId());
-        $newCreationEvent->setActorRoleId(QubitTerm::CREATOR_ID);
-        $newCreationEvent->save();
+        $newActorEvent->setActorId($actor->getId());
+        $newActorEvent->setInformationObjectId($informationObject->getId());
+        $newActorEvent->setTypeId($thisEvent['eventTypeId']);
+        $newActorEvent->setDescription($thisEvent['description']);
+        $newActorEvent->save();
         $this->foreignKeyUpdate = true;
       }
 
-      //add creation event date/date range
-      if (($thisEvent['creationYear']) || ($thisEvent['creationDateNote']))
+      // add actor event date/date range
+      if (($thisEvent['year']) || ($thisEvent['endYear']))
       {
-        $newCreationEvent->setTypeId(QubitTerm::CREATION_ID);
-        $newCreationEvent->setInformationObjectId($informationObject->getId());
-        $newCreationEvent->setStartDate($thisEvent['creationYear'].'-01-01');
-        $newCreationEvent->setEndDate($thisEvent['endYear'].'-01-01');
+        $newActorEvent->setTypeId($thisEvent['eventTypeId']);
+        $newActorEvent->setInformationObjectId($informationObject->getId());
+        $newActorEvent->setStartDate($thisEvent['year'].'-01-01');
+        $newActorEvent->setEndDate($thisEvent['endYear'].'-01-01');
 
         if ($thisEvent['dateDisplay'])
         {
-          $newCreationEvent->setDateDisplay($thisEvent['dateDisplay']);
+          $newActorEvent->setDateDisplay($thisEvent['dateDisplay']);
         }
         else
         {
-          $dateString = $thisEvent['creationYear'];
+          $dateString = $thisEvent['year'];
           if ($thisEvent['endYear'])
           {
             $dateString .= ' - '.$thisEvent['endYear'];
           }
-          $newCreationEvent->setDateDisplay($dateString);
+          $newActorEvent->setDateDisplay($dateString);
         }
 
-        $newCreationEvent->save();
+        $newActorEvent->setDescription($thisEvent['description']);
+        $newActorEvent->save();
         $this->foreignKeyUpdate = true;
       }
+
+      // add place
+      if ($newActorEvent->getId() & ($thisEvent['placeId']))
+      {
+        $place = new QubitObjectTermRelation;
+        $place->setObjectId($newActorEvent->getId());
+        $place->setTermId($thisEvent['placeId']);
+        $place->save();
+      }
     }
 
     if ($name_ids = $this->getRequestParameter('name_id'))


--~--~---------~--~----~------------~-------~--~----~
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.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to