/** * Add user to influencer */ public function add() { if ($post = $this->input->post()) { $blist = new Influencers_blacklist(); $blist->remove($this->c_user->id, $post['creator_id'], $post['social']); $wlist = new Influencers_whitelist(); $result = $wlist->add($this->c_user->id, $post['creator_id'], $post['social']); echo json_encode(array('success' => $result)); } }
public function getFeedHtmlData($activities) { $htmlData = ''; if ($activities->exists()) { $this->load->library('Socializer/socializer'); /* @var Socializer_Facebook $facebook */ $facebook = Socializer::factory('Facebook', $this->c_user->id); $fbUserImage = $facebook->get_profile_picture(); $wlist = Influencers_whitelist::create()->getByUser($this->c_user->id); foreach ($activities as $activity) { $social = $activity->social; $radar = $this->get('core.radar'); if ($social == 'facebook') { $activity->creator_image_url = $facebook->get_profile_picture($activity->creator_id); $activity->user_image = $fbUserImage; } $activity->actions = in_array($social, $this->activeSocials); $activity->influencer = array_key_exists($activity->creator_id, $wlist) && $wlist[$activity->creator_id] == $mention->social; $activity->created_at = $radar->formatRadarDate($activity->created_at); $activity->profileUrl = $radar->getProfileUrl($activity->social); $content = $this->template->block('_content', '/social/webradar/blocks/' . $activity->social, array('mention' => $activity)); $blockData = array('mention' => $activity, 'content' => $content); $htmlData .= $this->load->view('social/webradar/blocks/_feed', $blockData, true); } } return $htmlData; }
/** * 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; }