From 864a15db8e04b0ba0e46303a539a0d6d851359c1 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 13 Apr 2010 02:17:11 +0000 Subject: [PATCH] MINOR redirector link tracking is more intelligent (from r96461) (from r98139) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102611 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/SiteTree.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/core/model/SiteTree.php b/core/model/SiteTree.php index 734ad8b81..373021f2d 100755 --- a/core/model/SiteTree.php +++ b/core/model/SiteTree.php @@ -1435,11 +1435,20 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } else { $virtualPages = DataObject::get('VirtualPage', "SiteTree$suffix.ID = SiteTree$suffix.ID AND CopyContentFromID = {$this->ID}"); } + if(class_exists('Subsite')) { + $redirectorPages = Subsite::get_from_all_subsites('RedirectorPage', "SiteTree$suffix.ID = SiteTree$suffix.ID AND LinkToID = {$this->ID}"); + } else { + $redirectorPages = DataObject::get('RedirectorPage', "SiteTree$suffix.ID = SiteTree$suffix.ID AND LinkToID = {$this->ID}"); + } if($virtualPages) foreach($virtualPages as $page) { // $page->write() calls syncLinkTracking, which does all the hard work for us. $page->write(); } + if($redirectorPages) foreach($redirectorPages as $page) { + // $page->write() calls syncLinkTracking, which does all the hard work for us. + $page->write(); + } parent::onAfterDelete(); } @@ -2022,6 +2031,18 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } if ($virtualPages) foreach($virtualPages as $vp) $vp->doUnpublish(); + $suffix = Versioned::current_stage() == 'Live' ? '_Live' : ''; + if(class_exists('Subsite')) { + $redirectorPages = Subsite::get_from_all_subsites('RedirectorPage', "SiteTree$suffix.ID = SiteTree$suffix.ID AND LinkToID = {$this->ID}"); + } else { + $redirectorPages = DataObject::get('RedirectorPage', "SiteTree$suffix.ID = SiteTree$suffix.ID AND LinkToID = {$this->ID}"); + } + + if($redirectorPages) foreach($redirectorPages as $page) { + // $page->write() calls syncLinkTracking, which does all the hard work for us. + $page->write(); + } + $this->extend('onAfterUnpublish'); }