/** * Re-fetch a discussion's content based on its foreign url. * @param type $DiscussionID */ public function RefetchPageInfo($DiscussionID) { // Make sure we are posting back. if (!$this->Request->IsPostBack()) { throw PermissionException('Javascript'); } // Grab the discussion. $Discussion = $this->DiscussionModel->GetID($DiscussionID); if (!$Discussion) { throw NotFoundException('Discussion'); } // Make sure the user has permission to edit this discussion. $this->Permission('Vanilla.Discussions.Edit', TRUE, 'Category', $Discussion->PermissionCategoryID); $ForeignUrl = GetValueR('Attributes.ForeignUrl', $Discussion); if (!$ForeignUrl) { throw new Gdn_UserException(T("This discussion isn't associated with a url.")); } $Stub = $this->DiscussionModel->FetchPageInfo($ForeignUrl, TRUE); // Save the stub. $this->DiscussionModel->SetField($DiscussionID, (array) $Stub); // Send some of the stuff back. if (isset($Stub['Name'])) { $this->JsonTarget('.PageTitle h1', Gdn_Format::Text($Stub['Name'])); } if (isset($Stub['Body'])) { $this->JsonTarget("#Discussion_{$DiscussionID} .Message", Gdn_Format::To($Stub['Body'], $Stub['Format'])); } $this->InformMessage('The page was successfully fetched.'); $this->Render('Blank', 'Utility', 'Dashboard'); }