protected function beforeInsert() { if (empty($this->_data['created'])) { $this->_data['created'] = date('Y-m-d H:i:s', cot::$sys['now']); } return parent::beforeInsert(); }
protected function beforeUpdate() { $this->_data['updated'] = date('Y-m-d H:i:s', cot::$sys['now']); $this->_data['updated_by'] = cot::$usr['id']; return parent::beforeUpdate(); }
protected function beforeDelete() { // Удалить всех подписчиков $items = subscribe_model_Subscriber::find(array(array('subscribe', $this->_data['id']))); if (!empty($items)) { foreach ($items as $itemRow) { $itemRow->delete(); } } return parent::beforeDelete(); }
protected function afterDelete() { // Обновить структуру // Наверное не учитываем состояние объявления, а считаем все. $count = advboard_model_Advert::count(array(array('category', $this->_data['category']))); static::$_db->update(cot::$db->structure, array('structure_count' => $count), "structure_area='advboard' AND structure_code = ?", $this->_data['category']); // Сбросим кеш структуры и главной страницы if (!empty(cot::$cache)) { cot::$cache->db->remove('structure', 'system'); if (cot::$cfg['cache_index']) { cot::$cache->page->clear('index'); } } return parent::afterDelete(); }