/** * Return filtered mentions * * @param $userId * * @return object Mention */ public function getRadarInfluencers($userId) { $conditions = new \Influencers_condition(); $conditions->get(); $cou = $conditions->count(); $blacklist = new \Influencers_blacklist(); $whitelist = new \Influencers_whitelist(); $blackIds = $blacklist->getByUser($userId); $whiteIds = $whitelist->getByUser($userId); $result = Mention::inst(); if (!empty($blackIds)) { $result->where_not_in('creator_id', $blackIds); } $i = 0; $result->group_start(); foreach ($this->socials as $social) { $relatedModel = 'mention_' . $social; $result->include_related($relatedModel); foreach ($conditions as $c) { $option = $c->option; $arC = explode('_', $option); if ($social == 'google') { $social = 'google+'; } if ($social == $arC[0]) { if ($i == 0) { $result->where_related($relatedModel, $this->fieldInfluencersOption[$option] . ' >=', (int) $c->value); } else { $result->or_where_related($relatedModel, $this->fieldInfluencersOption[$option] . ' >=', (int) $c->value); } $i++; if ($i == $cou) { if (!empty($whiteIds)) { $result->or_where_in('creator_id', array_keys($whiteIds)); } $result->group_end(); } } } } $result->getByFilters($this->getFilterParams(), $this->limit, $this->offset); return $result; }