示例#1
0
 /**
  * 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));
     }
 }
示例#2
0
 /**
  * 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;
 }