DiscussionModel::setField PHP Method

setField() public method

An event firing wrapper for Gdn_Model::setField().
public setField ( integer $RowID, string $Property, mixed $Value = false )
$RowID integer
$Property string
$Value mixed
    public function setField($RowID, $Property, $Value = false)
    {
        if (!is_array($Property)) {
            $Property = [$Property => $Value];
        }
        $this->EventArguments['DiscussionID'] = $RowID;
        if (!is_array($Property)) {
            $this->EventArguments['SetField'] = [$Property => $Value];
        } else {
            $this->EventArguments['SetField'] = $Property;
        }
        parent::setField($RowID, $Property, $Value);
        $this->fireEvent('AfterSetField');
    }

Usage Example

コード例 #1
0
 /**
  * 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->isAuthenticatedPostBack(true)) {
         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 = valr('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');
 }
All Usage Examples Of DiscussionModel::setField