public function approve() { $this->Moderated = true; $this->IsApproved = true; $this->write(); $parent = $this->getParent(); //debug::show($parent->ClassName); if ($parent->GuestBookID) { $GuestBookPage = $parent->GuestBook(); $oBlogParent = $GuestBookPage->Level(1); //$GuestBookPageChildClass = $this->getGuestBookPageChildClass($GuestBook); $GuestBook = new BlogPost(); $GuestBook->Title = $this->Title; $GuestBook->AuthorNames = $this->Author; $GuestBook->Content = $this->Content; $GuestBook->PublishDate = SS_Datetime::now()->getValue(); $GuestBook->ParentID = $oBlogParent->ID; $GuestBook->FeaturedImageID = $this->ImageID; $GuestBook->doPublish(); $GuestBook->write(); $GuestBook->doRestoreToStage(); //$GuestBook->writeToStage("Stage", "Live"); $this->GuestBookLinkingID = $GuestBook->ID; $GuestBook->ShowInMenus = true; $GuestBook->doPublish(); $GuestBook->write(); $GuestBook->doRestoreToStage(); } $this->write(); return 'Submission published'; }