'y', 'bought' => 'y']; protected function _getFromColumns() { $columns = parent::_getFromColumns(); $columns['days'] = new Zend_Db_Expr("DATEDIFF(`Classified`.`expirationDate`, CURDATE())"); return $columns; } protected function _filter(Zend_Db_Select $select) { if (!$this->hasFilter()) { return $this; } $filterFields = $this->getFilterFields(); if (!empty($filterFields) && array_key_exists('query', $this->_filter)) { Qs_Db_Filter::where($select, $filterFields, $this->_filter['query']); } if(!empty($this->_filter) && array_key_exists('type', $this->_filter)) { unset($this->_filter['type']); } $filter = $this->_getCleanedFilter($this->_filter); Qs_Db::filter($select, $filter, $this->_getTableAlias()); $this->_filterByUser($select); return $this; } protected function _filterByUser(Zend_Db_Select $select) { $doc = Zend_Registry::get('doc'); $select->where('`Classified`.`submitterUserId` = ?', (int)$doc->getUserId()); return $this; } protected function _getFromDbSelect($primaryKey) { $select = $this->_db->select(); $select->from($this->_getPair(), $this->_getFromDbColumns()); $select->join( $this->_getPair('ClassifiedType'), '`Classified`.`type` = `ClassifiedType`.`id`', array('typeTitle' => 'title') ); $select->where($this->_getTable()->prepareWhere((array)$primaryKey, $this->_getTableAlias())); return $select; } public function initFromForm(array $data) { if (!array_key_exists('id', $data) || empty($data['id'])) { if (empty($data['type'])) { $data['type'] = $this->_getType(); } $data['submitterUserId'] = Auth::getInstance()->getData('id'); $data['enabled'] = 'n'; if ($this->isFreePurchase()) { $data['bought'] = 'y'; } } $this->initFromFormDateRange($data); $this->_arrayParseUrl2Tag($data); $this->_prepareNullableFields($data); $this->_prepareRawData($data); $this->_data = $data; return $this; } }