Author: david
Date: Wed Oct 26 15:34:10 2011
New Revision: 10202

Log:
Force a publication status when saving info object (Makes r10184 unnecessary)

Modified:
   trunk/lib/QubitXmlImport.class.php
   trunk/lib/model/QubitInformationObject.php

Modified: trunk/lib/QubitXmlImport.class.php
==============================================================================
--- trunk/lib/QubitXmlImport.class.php  Wed Oct 26 14:56:39 2011        (r10201)
+++ trunk/lib/QubitXmlImport.class.php  Wed Oct 26 15:34:10 2011        (r10202)
@@ -417,12 +417,6 @@
           }
         }
 
-        // make sure we have a publication status set before indexing
-        if ($currentObject instanceof QubitInformationObject && 
count($currentObject->statuss) == 0)
-        {
-          
$currentObject->setPublicationStatus(sfConfig::get('app_defaultPubStatus', 
QubitTerm::PUBLICATION_STATUS_DRAFT_ID));
-        }
-
         // save the object after it's fully-populated
         $currentObject->save();
 

Modified: trunk/lib/model/QubitInformationObject.php
==============================================================================
--- trunk/lib/model/QubitInformationObject.php  Wed Oct 26 14:56:39 2011        
(r10201)
+++ trunk/lib/model/QubitInformationObject.php  Wed Oct 26 15:34:10 2011        
(r10202)
@@ -205,8 +205,14 @@
     }
 
     // Save updated Status
+    $hasPubStatus = false;
     foreach ($this->statuss as $item)
     {
+      if (QubitTerm::STATUS_TYPE_PUBLICATION_ID == $item->typeId)
+      {
+        $hasPubStatus = true;
+      }
+
       $item->setIndexOnSave(false);
 
       // TODO Needed if $this is new, should be transparent
@@ -215,6 +221,18 @@
       $item->save($connection);
     }
 
+    // Force a publication status
+    if ($this->id != QubitInformationObject::ROOT_ID && !$hasPubStatus)
+    {
+      $status = new QubitStatus;
+      $status->objectId = $this->id;
+      $status->typeId = QubitTerm::STATUS_TYPE_PUBLICATION_ID;
+      $status->statusId = sfConfig::get('app_defaultPubStatus', 
QubitTerm::PUBLICATION_STATUS_DRAFT_ID);
+      $status->setIndexOnSave(false);
+
+      $status->save($connection);
+    }
+
     QubitSearch::updateInformationObject($this);
 
     return $this;

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