public function allchanges()
    {
        // Check viewability of allchanges
        if (!Config::inst()->get(VersionFeed::class, 'allchanges_enabled')
            || !SiteConfig::current_site_config()->AllChangesEnabled
        ) {
            return $this->owner->httpError(404, 'Global history not viewable');
        }

        $limit = (int)Config::inst()->get(VersionFeed::class, 'allchanges_limit');
        $latestChanges = DB::query('
			SELECT * FROM "SiteTree_Versions"
			WHERE "WasPublished" = \'1\'
			AND "CanViewType" IN (\'Anyone\', \'Inherit\')
			AND "ShowInSearch" = 1
			AND ("PublicHistory" IS NULL OR "PublicHistory" = \'1\')
			ORDER BY "LastEdited" DESC LIMIT ' . $limit);
        $lastChange = $latestChanges->record();
        $latestChanges->rewind();

        if ($lastChange) {
            // Cache the diffs to remove DOS possibility.
            $key = 'allchanges'
                . preg_replace('#[^a-zA-Z0-9_]#', '', $lastChange['LastEdited'])
                . (Security::getCurrentUser() ? Security::getCurrentUser()->ID : 'public');
            $changeList = $this->filterContent($key, function () use ($latestChanges) {
                $changeList = new ArrayList();
                $canView = array();
                foreach ($latestChanges as $record) {
                    // Check if the page should be visible.
                    // WARNING: although we are providing historical details, we check the current configuration.
                    $id = $record['RecordID'];
                    if (!isset($canView[$id])) {
                        $page = DataObject::get_by_id(SiteTree::class, $id);
                        $canView[$id] = $page && $page->canView(Security::getCurrentUser());
                    }
                    if (!$canView[$id]) {
                        continue;
                    }

                    // Get the diff to the previous version.
                    $record['ID'] = $record['RecordID'];
                    $version = SiteTree::create($record);
                    if ($diff = $version->getDiff()) {
                        $changeList->push($diff);
                    }
                }

                return $changeList;
            });
        } else {
            $changeList = new ArrayList();
        }

        // Produce output
        $url = $this->owner->getRequest()->getURL();
        $rss = new RSSFeed(
            $changeList,
            $url,
            $this->linkToAllSitesRSSFeedTitle(),
            '',
            'Title',
            '',
            null
        );
        $rss->setTemplate('Page_allchanges_rss');
        return $rss->outputToBrowser();
    }
public function allchanges()
    {
        // Check viewability of allchanges
        if (!Config::inst()->get(VersionFeed::class, 'allchanges_enabled')
            || !SiteConfig::current_site_config()->AllChangesEnabled
        ) {
            return $this->owner->httpError(404, 'Global history not viewable');
        }

        $limit = (int)Config::inst()->get(VersionFeed::class, 'allchanges_limit');
        $latestChanges = DB::query('
			SELECT * FROM "SiteTree_Versions"
			WHERE "WasPublished" = \'1\'
			AND "CanViewType" IN (\'Anyone\', \'Inherit\')
			AND "ShowInSearch" = 1
			AND ("PublicHistory" IS NULL OR "PublicHistory" = \'1\')
			ORDER BY "LastEdited" DESC LIMIT ' . $limit);
        $lastChange = $latestChanges->record();
        $latestChanges->rewind();

        if ($lastChange) {
            // Cache the diffs to remove DOS possibility.
            $key = 'allchanges'
                . preg_replace('#[^a-zA-Z0-9_]#', '', $lastChange['LastEdited'])
                . (Security::getCurrentUser() ? Security::getCurrentUser()->ID : 'public');
            $changeList = $this->filterContent($key, function () use ($latestChanges) {
                $changeList = new ArrayList();
                $canView = array();
                foreach ($latestChanges as $record) {
                    // Check if the page should be visible.
                    // WARNING: although we are providing historical details, we check the current configuration.
                    $id = $record['RecordID'];
                    if (!isset($canView[$id])) {
                        $page = DataObject::get_by_id(SiteTree::class, $id);
                        $canView[$id] = $page && $page->canView(Security::getCurrentUser());
                    }
                    if (!$canView[$id]) {
                        continue;
                    }

                    // Get the diff to the previous version.
                    $record['ID'] = $record['RecordID'];
                    $version = SiteTree::create($record);
                    if ($diff = $version->getDiff()) {
                        $changeList->push($diff);
                    }
                }

                return $changeList;
            });
        } else {
            $changeList = new ArrayList();
        }

        // Produce output
        $url = $this->owner->getRequest()->getURL();
        $rss = new RSSFeed(
            $changeList,
            $url,
            $this->linkToAllSitesRSSFeedTitle(),
            '',
            'Title',
            '',
            null
        );
        $rss->setTemplate('Page_allchanges_rss');
        return $rss->outputToBrowser();
    }
public function allchanges ( ) { // Check viewability of allchanges if ( ! Config :: inst ( ) -> get ( VersionFeed :: class , 'allchanges_enabled' ) || ! SiteConfig :: current_site_config ( ) -> AllChangesEnabled ) { return $ this -> owner -> httpError ( 404 , 'Global history not viewable' ) ; } $ limit = ( int ) Config :: inst ( ) -> get ( VersionFeed :: class , 'allchanges_limit' ) ; $ latestChanges = DB :: query ( '
			SELECT * FROM "SiteTree_Versions"
			WHERE "WasPublished" = \'1\'
			AND "CanViewType" IN (\'Anyone\', \'Inherit\')
			AND "ShowInSearch" = 1
			AND ("PublicHistory" IS NULL OR "PublicHistory" = \'1\')
			ORDER BY "LastEdited" DESC LIMIT ' . $ limit ) ; $ lastChange = $ latestChanges -> record ( ) ; $ latestChanges -> rewind ( ) ; if ( $ lastChange ) { // Cache the diffs to remove DOS possibility. $ key = 'allchanges' . preg_replace ( '#[^a-zA-Z0-9_]#' , '' , $ lastChange [ 'LastEdited' ] ) . ( Security :: getCurrentUser ( ) ? Security :: getCurrentUser ( ) -> ID : 'public' ) ; $ changeList = $ this -> filterContent ( $ key , function ( ) use ( $ latestChanges ) { $ changeList = new ArrayList ( ) ; $ canView = array ( ) ; foreach ( $ latestChanges as $ record ) { // Check if the page should be visible. // WARNING: although we are providing historical details, we check the current configuration. $ id = $ record [ 'RecordID' ] ; if ( ! isset ( $ canView [ $ id ] ) ) { $ page = DataObject :: get_by_id ( SiteTree :: class , $ id ) ; $ canView [ $ id ] = $ page && $ page -> canView ( Security :: getCurrentUser ( ) ) ; } if ( ! $ canView [ $ id ] ) { continue ; } // Get the diff to the previous version. $ record [ 'ID' ] = $ record [ 'RecordID' ] ; $ version = SiteTree :: create ( $ record ) ; if ( $ diff = $ version -> getDiff ( ) ) { $ changeList -> push ( $ diff ) ; } } return $ changeList ; } ) ; } else { $ changeList = new ArrayList ( ) ; } // Produce output $ url = $ this -> owner -> getRequest ( ) -> getURL ( ) ; $ rss = new RSSFeed ( $ changeList , $ url , $ this -> linkToAllSitesRSSFeedTitle ( ) , '' , 'Title' , '' , null ) ; $ rss -> setTemplate ( 'Page_allchanges_rss' ) ; return $ rss -> outputToBrowser ( ) ; }
Get all changes from the site in a RSS feed.
Get all changes from the site in a RSS feed .