DiscussionModel::setProperty PHP Method

setProperty() public method

By default, this toggles the specified between '1' and '0'. If $ForceValue is provided, the field is set to this value instead. An example use is announcing and unannouncing a discussion.
public setProperty ( integer $DiscussionID, string $Property, mixed $ForceValue = null ) : mixed
$DiscussionID integer Unique ID of discussion being updated.
$Property string Name of field to be updated.
$ForceValue mixed If set, overrides toggle behavior with this value.
return mixed Value that was ultimately set for the field.
    public function setProperty($DiscussionID, $Property, $ForceValue = null)
    {
        if ($ForceValue !== null) {
            $Value = $ForceValue;
        } else {
            $Discussion = $this->getID($DiscussionID);
            $Value = $Discussion->{$Property} == '1' ? '0' : '1';
        }
        $this->SQL->update('Discussion')->set($Property, $Value)->where('DiscussionID', $DiscussionID)->put();
        return $Value;
    }