FOF30\Model\DataModel::unlock PHP Method

unlock() public method

Unlock a record by resetting its locked_on and/or locked_by columns
public unlock ( )
    public function unlock()
    {
        if (!$this->getId()) {
            throw new RecordNotLoaded("Can't unlock a not loaded DataModel");
        }
        if (!$this->hasField('locked_on') && !$this->hasField('locked_by')) {
            return $this;
        }
        $this->triggerEvent('onBeforeUnlock', array());
        $db = $this->getDbo();
        if ($this->hasField('locked_on')) {
            $locked_on = $this->getFieldAlias('locked_on');
            $this->{$locked_on} = $db->getNullDate();
        }
        if ($this->hasField('locked_by')) {
            $locked_by = $this->getFieldAlias('locked_by');
            $this->{$locked_by} = 0;
        }
        $this->save();
        $this->triggerEvent('onAfterUnlock');
        return $this;
    }