public function afterSave() { if ($this->scenario == 'savecat') { $this->saveCategories(); if ($this->metroStations) { $this->setMetroStations($this->metroStations); } } if ($this->panoramaFile) { $panorama = new ApartmentPanorama(); $panorama->fileInstance = $this->panoramaFile; $panorama->apartment_id = $this->id; $panorama->save(); } if (issetModule('seo') && param('genFirendlyUrl')) { SeoFriendlyUrl::getAndCreateForModel($this); } if (issetModule('socialposting') && $this->active == self::STATUS_ACTIVE && ($this->owner_active = self::STATUS_ACTIVE)) { SocialpostingModel::preparePosting($this); } $sql = 'DELETE FROM {{apartment}} WHERE active=:draft AND date_created<DATE_SUB(NOW(),INTERVAL 1 DAY)'; Yii::app()->db->createCommand($sql)->execute(array(':draft' => self::STATUS_DRAFT)); return parent::afterSave(); }