Author: peter
Date: Sat Sep 19 00:52:34 2009
New Revision: 3427

Log:
update descendants if publicationStatus is changed. fixes issue #955

Modified:
   trunk/apps/qubit/modules/informationobject/actions/editAction.class.php
   trunk/lib/model/QubitInformationObject.php
   trunk/lib/model/QubitObject.php

Modified: 
trunk/apps/qubit/modules/informationobject/actions/editAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/editAction.class.php     
Sat Sep 19 00:02:49 2009        (r3426)
+++ trunk/apps/qubit/modules/informationobject/actions/editAction.class.php     
Sat Sep 19 00:52:34 2009        (r3427)
@@ -530,7 +530,11 @@
     else
     {
       $params = 
$this->context->routing->parse(preg_replace('/.*'.preg_quote($this->request->getPathInfoPrefix(),
 '/').'/', null, $this->getRequestParameter('publicationStatus')));
-      $this->informationObject->setStatus($options = array('typeId' => 
QubitTerm::STATUS_TYPE_PUBLICATION_ID, 'statusId' => $params['id']));
+      // only update publicationStatus if its value has changed because it 
triggers a resource-intensive update of all its descendants
+      if ($params['id'] !== $this->informationObject->getStatus($options = 
array('typeId' => QubitTerm::STATUS_TYPE_PUBLICATION_ID))->statusId)
+      {
+        $this->informationObject->setStatus($options = array('typeId' => 
QubitTerm::STATUS_TYPE_PUBLICATION_ID, 'statusId' => $params['id']));
+      }
     }
   }
 }

Modified: trunk/lib/model/QubitInformationObject.php
==============================================================================
--- trunk/lib/model/QubitInformationObject.php  Sat Sep 19 00:02:49 2009        
(r3426)
+++ trunk/lib/model/QubitInformationObject.php  Sat Sep 19 00:52:34 2009        
(r3427)
@@ -172,6 +172,33 @@
       }
     }
 
+    // Save updated Status
+    if (0 < count($this->statuss->transient))
+    {
+      $publicationStatusUpdate = false;
+      foreach ($this->statuss->transient as $status)
+      {
+        $status->setIndexOnSave(false);
+        $status->setObject($this);
+        $status->save();
+        if ($status->typeId == QubitTerm::STATUS_TYPE_PUBLICATION_ID)
+        {
+          $publicationStatusUpdate = true;
+        }
+      }
+      if ($publicationStatusUpdate)
+      {
+        // if publication status has changed, set the status of all its 
descendants to null
+        // so that they inherit the newly changed status, and update their 
search index
+        // document so that the changed status is reflected in search and list 
browse results
+        foreach ($this->descendants as $descendant)
+        {
+          $descendant->setStatus($options = array('typeId' => 
QubitTerm::STATUS_TYPE_PUBLICATION_ID, 'statusId' => null));
+          $descendant->save();
+        }
+      }
+    }
+
     SearchIndex::updateTranslatedLanguages($this);
 
     return $this;

Modified: trunk/lib/model/QubitObject.php
==============================================================================
--- trunk/lib/model/QubitObject.php     Sat Sep 19 00:02:49 2009        (r3426)
+++ trunk/lib/model/QubitObject.php     Sat Sep 19 00:52:34 2009        (r3427)
@@ -67,17 +67,6 @@
       }
     }
 
-    // Save updated Status
-    if (0 < count($this->statuss->transient))
-    {
-      foreach ($this->statuss->transient as $status)
-      {
-        $status->setIndexOnSave(false);
-        $status->setObject($this);
-        $status->save();
-      }
-    }
-
     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.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to