public static function getDataForListings($userId)
{
$criteria = new CDbCriteria;
$criteria->addCondition('t.active = ' . Apartment::STATUS_ACTIVE . ' AND deleted = 0');
if (param('useUserads'))
$criteria->addCondition('t.owner_active = ' . Apartment::STATUS_ACTIVE);
$criteria->addInCondition('t.type', HApartment::availableApTypesIds());
//$criteria->addInCondition('t.price_type', array_keys(HApartment::getPriceArray(Apartment::PRICE_SALE, true)));
$criteria->addCondition('(t.price_type IN (' . implode(',', array_keys(HApartment::getPriceArray(Apartment::PRICE_SALE, true))) . ') OR t.is_price_poa = 1)');
$userName = '';
$userModel = User::model()->findByPk($userId);
if (!empty($userModel)) {
$userName = $userModel->getNameForType();
}
if ($userModel->type == User::TYPE_AGENCY) {
$userName = $userModel->getTypeName() . ' "' . $userName . '"';
$sql = "SELECT id FROM {{users}} WHERE agency_user_id = :user_id AND agent_status=:status";
$agentsId = Yii::app()->db->createCommand($sql)->queryColumn(array(':user_id' => $userModel->id, ':status' => User::AGENT_STATUS_CONFIRMED));
$agentsId[] = $userModel->id;
$criteria->compare('t.owner_id', $agentsId, false);
} else {
$criteria->compare('t.owner_id', $userModel->id);
}
return array(
'criteria' => $criteria,
'userName' => $userName,
);
}
Users browsing this forum: No registered users and 10 guests