public function onAfterPublish(&$original)
    {
        $member = Security::getCurrentUser();
        if (!$member || !$member->exists()) {
            return false;
        }

        $effectiveViewerGroups = '';
        if ($this->owner->CanViewType === 'OnlyTheseUsers') {
            $originalViewerGroups = $original ? $original->ViewerGroups()->column('Title') : [];
            $effectiveViewerGroups = implode(', ', $originalViewerGroups);
        }
        if (!$effectiveViewerGroups) {
            $effectiveViewerGroups = $this->owner->CanViewType;
        }

        $effectiveEditorGroups = '';
        if ($this->owner->CanEditType === 'OnlyTheseUsers') {
            $originalEditorGroups =  $original ? $original->EditorGroups()->column('Title') : [];
            $effectiveEditorGroups = implode(', ', $originalEditorGroups);
        }
        if (!$effectiveEditorGroups) {
            $effectiveEditorGroups = $this->owner->CanEditType;
        }

        $this->getAuditLogger()->info(sprintf(
            '"%s" (ID: %s) published %s "%s" (ID: %s, Version: %s, ClassName: %s, Effective ViewerGroups: %s, '
            . 'Effective EditorGroups: %s)',
            $member->Email ?: $member->Title,
            $member->ID,
            $this->owner->singular_name(),
            $this->owner->Title,
            $this->owner->ID,
            $this->owner->Version,
            $this->owner->ClassName,
            $effectiveViewerGroups,
            $effectiveEditorGroups
        ));
    }
public function onAfterPublish(&$original)
    {
        $member = Security::getCurrentUser();
        if (!$member || !$member->exists()) {
            return false;
        }

        $effectiveViewerGroups = '';
        if ($this->owner->CanViewType === 'OnlyTheseUsers') {
            $originalViewerGroups = $original ? $original->ViewerGroups()->column('Title') : [];
            $effectiveViewerGroups = implode(', ', $originalViewerGroups);
        }
        if (!$effectiveViewerGroups) {
            $effectiveViewerGroups = $this->owner->CanViewType;
        }

        $effectiveEditorGroups = '';
        if ($this->owner->CanEditType === 'OnlyTheseUsers') {
            $originalEditorGroups =  $original ? $original->EditorGroups()->column('Title') : [];
            $effectiveEditorGroups = implode(', ', $originalEditorGroups);
        }
        if (!$effectiveEditorGroups) {
            $effectiveEditorGroups = $this->owner->CanEditType;
        }

        $this->getAuditLogger()->info(sprintf(
            '"%s" (ID: %s) published %s "%s" (ID: %s, Version: %s, ClassName: %s, Effective ViewerGroups: %s, '
            . 'Effective EditorGroups: %s)',
            $member->Email ?: $member->Title,
            $member->ID,
            $this->owner->singular_name(),
            $this->owner->Title,
            $this->owner->ID,
            $this->owner->Version,
            $this->owner->ClassName,
            $effectiveViewerGroups,
            $effectiveEditorGroups
        ));
    }
public function onAfterPublish ( & $ original ) { $ member = Security :: getCurrentUser ( ) ; if ( ! $ member || ! $ member -> exists ( ) ) { return false ; } $ effectiveViewerGroups = '' ; if ( $ this -> owner -> CanViewType === 'OnlyTheseUsers' ) { $ originalViewerGroups = $ original ? $ original -> ViewerGroups ( ) -> column ( 'Title' ) : [ ] ; $ effectiveViewerGroups = implode ( ', ' , $ originalViewerGroups ) ; } if ( ! $ effectiveViewerGroups ) { $ effectiveViewerGroups = $ this -> owner -> CanViewType ; } $ effectiveEditorGroups = '' ; if ( $ this -> owner -> CanEditType === 'OnlyTheseUsers' ) { $ originalEditorGroups = $ original ? $ original -> EditorGroups ( ) -> column ( 'Title' ) : [ ] ; $ effectiveEditorGroups = implode ( ', ' , $ originalEditorGroups ) ; } if ( ! $ effectiveEditorGroups ) { $ effectiveEditorGroups = $ this -> owner -> CanEditType ; } $ this -> getAuditLogger ( ) -> info ( sprintf ( '"%s" (ID: %s) published %s "%s" (ID: %s, Version: %s, ClassName: %s, Effective ViewerGroups: %s, ' . 'Effective EditorGroups: %s)' , $ member -> Email ? : $ member -> Title , $ member -> ID , $ this -> owner -> singular_name ( ) , $ this -> owner -> Title , $ this -> owner -> ID , $ this -> owner -> Version , $ this -> owner -> ClassName , $ effectiveViewerGroups , $ effectiveEditorGroups ) ) ; }
Log a record being published.
Log a record being published .