_filterFields) { $filterFields = $this->getConfig('filterFields'); $filterFields = ($filterFields) ? $filterFields->toArray() : []; $mode = $this->getConfig('mode'); $this->_filterFields = Qs_Array::get($filterFields, (string) $mode, []); } return $this->_filterFields; } protected function _getReorderSelect() { $select = parent::_getReorderSelect(); $select->join( $this->_getPair('LeadershipGroup'), '`LeadershipGroup`.`id` = `User`.`leadershipGroupId`', [ 'category' => 'IFNULL(`LeadershipGroup`.`name`, " --- ")', 'categoryEnabled' => 'IFNULL(`LeadershipGroup`.`enabled`, "y")', 'leadershipGroupName' => 'name', ] ); return $select; } protected function _filter(\Zend_Db_Select $select) { $select->where('`' . $this->_tableAlias . '`.`bought` = "y"'); if (self::NO_STATUS === $this->getFilter('status')) { $select->where($this->_quoteField('status') . ' IS NULL'); unset($this->_filter['status']); } return parent::_filter($select); } protected function _getFromColumns() { $columns = parent::_getFromColumns(); $columns['reorderLeadershipTitle'] = Model::getFullNameWithPositionDbExpr(); return $columns; } protected function _insertDependency() { parent::_insertDependency(); return $this; } protected function _deleteDependency() { parent::_deleteDependency(); return $this; } protected function _insertAddresses() { if ($this->isAssociationMode()) { $this->_insertAddress(Entity::ADDRESS_HOME); } else { parent::_insertAddresses(); } return $this; } protected function _deleteAddresses() { if ($this->isAssociationMode()) { $this->_deleteAddress(Entity::ADDRESS_HOME); } else { parent::_deleteAddresses(); } return $this; } protected function _getSimpleExportColumns() { return $this->getConfig('export')->fields->{Module::MODE_SIMPLE}->toArray(); } protected function _getAssociationExportColumns() { $columns = $this->getConfig('export')->fields->{Module::MODE_ASSOCIATION}->toArray(); $dynamicColumns = []; $splitColumn = $this->getConfig('export')->dynamicFieldsAfter; if (false !== ($splitPos = Qs_Array::keyPos($splitColumn, $columns))) { $splitPos++; $after = array_slice($columns, 0, $splitPos, true); $before = array_slice($columns, $splitPos, null, true); $columns = $after + $dynamicColumns + $before; } else { $columns += $dynamicColumns; } return $columns; } public function getExportColumns() { if ($this->isAssociationMode()) { $columns = $this->_getAssociationExportColumns(); } else { $columns = $this->_getSimpleExportColumns(); } foreach ($columns as $key => $title) { if ('' == $title) { if (strtolower($key) === $key) { $title = ucfirst($key); } else { $title = ucfirst(Qs_String::decamelize($key)); } $columns[$key] = $title; } } return $columns; } public function getList4ExportStatement() { $select = $this->_db->select(); $select->from($this->_getPair()); if ($this->isAssociationMode()) { $select->joinLeft( $this->_getPair('MembershipType', 'mt'), '`mt`.`id` = `User`.`membershipTypeId`', ['membershipType' => 'title'] ); $select->joinLeft( $this->_getPair('LeadershipGroup', 'lg'), '`lg`.`id` = `User`.`leadershipGroupId`', ['leadershipGroup' => 'name'] ); } $select->joinLeft( $this->_getPair($this->_tableAlias . 'Status', 's'), '`s`.`id` = `User`.`status`', ['status' => 'title'] ); $select->where('`User`.`bought` = "y"'); $this->_filter($select); $this->_applySelectOptions($select, $this->_selectOptions); return $select->query(); } public function prepareExportRow(array &$data) { $this->_prepareBio($data['bio']); // prepare addresses $this->_addAddressesFromDb($data); if (array_key_exists(Entity::ADDRESS_SHIPPING, $data) && 'y' == Qs_Array::get($data[Entity::ADDRESS_SHIPPING], 'asBilling') ) { $data[Entity::ADDRESS_SHIPPING] = array_merge( $data[Entity::ADDRESS_SHIPPING], $data[Entity::ADDRESS_BILLING] ); } else { $data[Entity::ADDRESS_SHIPPING]['asBilling'] = 'n'; } foreach ([Entity::ADDRESS_BILLING, Entity::ADDRESS_SHIPPING, Entity::ADDRESS_HOME] as $type) { if (array_key_exists($type, $data)) { foreach ($data[$type] as $key => $val) { $index = $type . ucfirst($key); $data[$index] = $val; } } } // prepare photo link if (!empty($data['photo'])) { $data['photo'] = BASE_URL . '/' . Qs_ImageFs::get($data['photo']); } return $this; } protected function _prepareBio(&$bio) { $bio = strip_tags($bio); $bio = preg_replace("/[\n\r]+/", "\n", $bio); $bio = preg_replace("/\s+/", " ", $bio); return $this; } }