MidCOM svn: r15280 - in branches/MidCOM_2_8/org.routamc.gallery: config midcom

rambo midcom-commits at lists.midgard-project.org
Thu Feb 28 09:20:07 CET 2008


Author: rambo
Date: Thu Feb 28 09:20:07 2008
New Revision: 15280
URL: http://trac.midgard-project.org/software/changeset/15280

Log:
backport r13417

Modified:
   branches/MidCOM_2_8/org.routamc.gallery/config/manifest.inc
   branches/MidCOM_2_8/org.routamc.gallery/midcom/interfaces.php

Modified: branches/MidCOM_2_8/org.routamc.gallery/config/manifest.inc
==============================================================================
--- branches/MidCOM_2_8/org.routamc.gallery/config/manifest.inc	(original)
+++ branches/MidCOM_2_8/org.routamc.gallery/config/manifest.inc	Thu Feb 28 09:20:07 2008
@@ -48,6 +48,14 @@
         'midcom' => array(),
     ),
 ),
+'watches' => array
+(
+    array
+    (
+        'classes' => array('org_routamc_photostream_photo_dba'),
+        'operations' => MIDCOM_OPERATION_DBA_DELETE,
+    ),
+),
 'customdata' => array
 (
     'midcom.services.cron' => array

Modified: branches/MidCOM_2_8/org.routamc.gallery/midcom/interfaces.php
==============================================================================
--- branches/MidCOM_2_8/org.routamc.gallery/midcom/interfaces.php	(original)
+++ branches/MidCOM_2_8/org.routamc.gallery/midcom/interfaces.php	Thu Feb 28 09:20:07 2008
@@ -50,5 +50,47 @@
         return true;
     }
 
+
+    function _on_watched_operation($operation, &$object)
+    {
+        // In the future we might want to trap creates etc as well, thus we do this flexibly from the start
+        switch(true)
+        {
+            case (   $operation === MIDCOM_OPERATION_DBA_DELETE
+                  && is_a($object, 'org_routamc_photostream_photo_dba')):
+                $this->remove_photo_links($object->id);
+                break;
+            default:
+                return;
+        }
+    }
+
+    /**
+     * Removes photolink objects that link to given photo id
+     *
+     * @param int $photoid local id of photo object
+     */
+    function remove_photo_links($photoid)
+    {
+        debug_push_class(__CLASS__, __FUNCTION__);
+        debug_add("Clearing photo links for photo #{$photoid}", MIDCOM_LOG_INFO);
+        $qb = org_routamc_gallery_photolink_dba::new_query_builder();
+        $qb->add_constraint('photo', '=', $photoid);
+        $links = $qb->execute();
+        if (empty($links))
+        {
+            debug_add('No links found');
+            debug_pop();
+            return;
+        }
+        foreach($links as $link)
+        {
+            debug_add("Removing link #{$link->id} (node #{$link->node})");
+            $link->delete();
+        }
+        $cnt = count($links);
+        debug_add("Removed {$cnt} links for photo #{$photoid}", MIDCOM_LOG_INFO);
+        debug_pop();
+    }
 }
 ?>
\ No newline at end of file


More information about the midcom-commits mailing list