public function onBeforeWrite() {
		parent::onBeforeWrite();
		
		// dummy initial date
		if (!$this->OriginalPublishedDate) {
			// @TODO Fix this to be correctly localized!!
			$this->OriginalPublishedDate = date('Y-m-d 12:00:00');
		}
		
		$parent = $this->Parent();

		// just in case we've been moved, update our section
		$section = $this->findSection();
		$this->NewsSectionID = $section->ID;

		$newlyCreated = $section->ID == $parent->ID;
		$changedPublishDate = $this->isChanged('OriginalPublishedDate', 2);

		if (($changedPublishDate || $newlyCreated) && ($section->AutoFiling || $section->FilingMode)) {
			if (!$this->Created) {
				$this->Created = date('Y-m-d H:i:s');
			}
			$pp = $this->PartitionParent();
			if ($pp->ID != $this->ParentID) {
				$this->ParentID = $pp->ID;
			}
		}

	}
public function onBeforeWrite() {
		parent::onBeforeWrite();
		
		// dummy initial date
		if (!$this->OriginalPublishedDate) {
			// @TODO Fix this to be correctly localized!!
			$this->OriginalPublishedDate = date('Y-m-d 12:00:00');
		}
		
		$parent = $this->Parent();

		// just in case we've been moved, update our section
		$section = $this->findSection();
		$this->NewsSectionID = $section->ID;

		$newlyCreated = $section->ID == $parent->ID;
		$changedPublishDate = $this->isChanged('OriginalPublishedDate', 2);

		if (($changedPublishDate || $newlyCreated) && ($section->AutoFiling || $section->FilingMode)) {
			if (!$this->Created) {
				$this->Created = date('Y-m-d H:i:s');
			}
			$pp = $this->PartitionParent();
			if ($pp->ID != $this->ParentID) {
				$this->ParentID = $pp->ID;
			}
		}

	}
public function onBeforeWrite ( ) { parent :: onBeforeWrite ( ) ; // dummy initial date if ( ! $ this -> OriginalPublishedDate ) { // @TODO Fix this to be correctly localized!! $ this -> OriginalPublishedDate = date ( 'Y-m-d 12:00:00' ) ; } $ parent = $ this -> Parent ( ) ; // just in case we've been moved, update our section $ section = $ this -> findSection ( ) ; $ this -> NewsSectionID = $ section -> ID ; $ newlyCreated = $ section -> ID == $ parent -> ID ; $ changedPublishDate = $ this -> isChanged ( 'OriginalPublishedDate' , 2 ) ; if ( ( $ changedPublishDate || $ newlyCreated ) && ( $ section -> AutoFiling || $ section -> FilingMode ) ) { if ( ! $ this -> Created ) { $ this -> Created = date ( 'Y-m-d H:i:s' ) ; } $ pp = $ this -> PartitionParent ( ) ; if ( $ pp -> ID != $ this -> ParentID ) { $ this -> ParentID = $ pp -> ID ; } } }
When the article is saved, and this article's section dictates that it
needs to be filed, then do so
When the article is saved and this article s section dictates that it needs to be filed then do so