skeeks\cms\models\CmsUserEmail::beforeSaveEvent PHP Method

beforeSaveEvent() public method

public beforeSaveEvent ( $event )
$event
    public function beforeSaveEvent($event)
    {
        if ($this->def == Cms::BOOL_N) {
            if ($this->user_id) {
                if (!static::find()->where(['def' => Cms::BOOL_Y])->andWhere(['!=', 'id', $this->id])->andWhere(['user_id' => $this->user_id])->count()) {
                    $this->def = Cms::BOOL_Y;
                }
            }
        } else {
            if ($this->def == Cms::BOOL_Y) {
                if ($this->user_id) {
                    static::updateAll(['def' => Cms::BOOL_N], ['and', ['user_id' => $this->user_id], ['!=', 'id', $this->id]]);
                }
            }
        }
    }