示例#1
0
 public function set_values($user_id, $profile_id, $post)
 {
     $where = array('user_id' => $user_id, 'profile_id' => $profile_id);
     if (isset($post['from'])) {
         $where['date >='] = $post['from'];
     }
     if (isset($post['to'])) {
         $where['date <='] = $post['to'];
     }
     if (isset($post['type'])) {
         $where['type'] = $post['type'];
     }
     $all_data = $this->where($where)->order_by('date')->get()->all_to_array();
     $values = array('facebook' => array(), 'twitter' => array(), 'linkedin' => array(), 'google' => array(), 'likes_count' => 0, 'followers_count' => 0, 'conns_count' => 0, 'friends_count' => 0);
     foreach ($all_data as $_data) {
         //$_data['type'] == 'facebook' ? $values['likes_count'] += (int)$_data['value'] : $values['followers_count'] += (int)$_data['value'];
         $values[$_data['type']][$_data['date']] = (int) $_data['value'];
     }
     $values['followers_count'] = end($values['twitter']);
     $values['likes_count'] = end($values['facebook']);
     $values['conns_count'] = end($values['linkedin']);
     $values['friends_count'] = end($values['google']);
     $values['facebook'] = count($values['facebook']) > 0 ? $values['facebook'] : array('' => 0);
     $values['twitter'] = count($values['twitter']) > 0 ? $values['twitter'] : array('' => 0);
     $values['linkedin'] = count($values['linkedin']) > 0 ? $values['linkedin'] : array('' => 0);
     $values['google'] = count($values['google']) > 0 ? $values['google'] : array('' => 0);
     self::$_user_values = $values;
 }
示例#2
0
 /**
  * Collect data for current user
  * For selected period (default - for 1 month)
  *
  * @access public
  * @return void
  */
 public function get_chart_data()
 {
     $social_values = Social_value::inst();
     $post = $this->input->post();
     $post['from'] = isset($post['from']) ? date($this->date_format, strtotime($post['from'])) : $this->dates['from'];
     $post['to'] = isset($post['to']) ? date($this->date_format, strtotime($post['to'])) : $this->dates['to'];
     $social_values->set_values($this->c_user->id, $this->profile->id, $post);
     $data = $social_values->get_data();
     echo json_encode($data);
 }
示例#3
0
 public function index()
 {
     if ($this->c_user->isTrialPlanEnds()) {
         $this->addFlash(lang('subscription_ends_error', [site_url('subscript/plans')]), 'error');
     }
     // UNCOMMENT TO USE
     // get average google rank for all keywords for chart in range
     $keyword_rank = Keyword::average_for_range($this->c_user->id, '-30 days', 'today');
     // average result for all the range
     $keywords_trending = Keyword::average_for_range($this->c_user->id, '-30 days', 'today', FALSE);
     // average for each day in range
     // analytics data
     $google_access_token = Access_token::getByTypeAndUserId('googlea', $this->c_user->id);
     list($ga_visits_chart, $ga_visits_count) = $google_access_token->google_analytics_dashboard_visits();
     $review = new Review();
     $last_reviews_count = $review->last_period_count($this->c_user->id, $this->profile->id);
     $review->clear();
     $social_values = Social_value::inst();
     $social_values->set_values($this->c_user->id, $this->profile->id, array('from' => date('Y-m-d', strtotime('-30 days')), 'to' => date('Y-m-d', time())));
     $all_socials_data = $social_values->get_data();
     $monthly_trending = array('reviews' => $review->last_month_trending($this->c_user->id, $this->profile->id), 'traffic' => $ga_visits_chart, 'keywords' => $keywords_trending, 'twitter_followers' => $all_socials_data['twitter'], 'facebook_likes' => $all_socials_data['facebook']);
     $keywordsForHighlight = Mention_keyword::inst()->get_for_highlight($this->c_user->id, 0);
     CssJs::getInst()->add_js('www.google.com/jsapi', 'external', 'footer');
     CssJs::getInst()->add_js(array('libs/lodash.compat.js', 'libs/highcharts/highcharts.js'))->c_js();
     $opportunities = $this->getOpportunities();
     if (!empty($opportunities['web_radar'])) {
         CssJs::getInst()->add_js('controller/webradar/index.js');
     }
     JsSettings::instance()->add(array('monthly_trending' => $monthly_trending, 'dashboard' => true, 'keywords' => $keywordsForHighlight, 'opportunities' => $opportunities));
     $summary = array('reviews' => (int) $last_reviews_count, 'fb_likes' => (int) $all_socials_data['likes_count'], 'twiter_followers' => (int) $all_socials_data['followers_count'], 'web_traffic' => (int) $ga_visits_count, 'google_rank' => (int) round($keyword_rank, 3));
     $this->isSupportScheduledPosts = $this->getAAC()->isGrantedPlan('scheduled_posts');
     $this->load->helper('my_url_helper');
     $this->template->set('isSupportScheduledPosts', $this->isSupportScheduledPosts);
     $this->template->set('socials', Social_post::getActiveSocials($this->profile->id));
     $this->is_user_set_timezone = User_timezone::is_user_set_timezone($this->c_user->id);
     JsSettings::instance()->add(array('twitterLimits' => array('maxLength' => 140, 'midLength' => 117, 'lowLength' => 94), 'twitterLimitsText' => lang('twitter_error'), 'linkedinLimits' => array('maxLength' => 400), 'linkedinLimitsText' => lang('linkedin_error')));
     CssJs::getInst()->add_css(array('custom/pick-a-color-1.css'));
     CssJs::getInst()->add_js(array('libs/jq.file-uploader/jquery.iframe-transport.js', 'libs/jq.file-uploader/jquery.fileupload.js', 'libs/fabric/fabric.min.js', 'libs/fabric/StackBlur.js', 'libs/color/tinycolor-0.9.15.min.js', 'libs/color/pick-a-color-1.2.3.min.js'));
     CssJs::getInst()->c_js('social/create', 'post_update');
     CssJs::getInst()->c_js('social/create', 'post_cron');
     CssJs::getInst()->c_js('social/create', 'post_attachment');
     CssJs::getInst()->c_js('social/create', 'social_limiter');
     CssJs::getInst()->c_js('social/create', 'schedule_block');
     CssJs::getInst()->c_js('social/create', 'bulk_upload');
     $this->template->set('is_user_set_timezone', User_timezone::is_user_set_timezone($this->c_user->id));
     $user_posts = Social_post::inst()->get_user_scheduled_posts($this->c_user->id, $this->profile->id, 1, 3, 'all');
     $this->template->set('posts', $user_posts);
     $this->load->helper('Image_designer_helper');
     $this->template->set('imageDesignerImages', Image_designer::getImages());
     $this->template->set('summary', $summary);
     $this->template->set('opportunities', $opportunities);
     $this->template->set('need_welcome_notification', User_notification::needShowNotification($this->c_user->id, User_notification::WELCOME));
     $this->template->render();
 }
 /**
  * Insert data into 'Social Values' table
  *
  * @access private
  *
  * @param $user_id
  * @param $profile_id
  * @param $count
  * @param $type
  */
 private function _save_values($user_id, $profile_id, $count, $type)
 {
     $social_value = Social_value::inst();
     $where = array('user_id' => $user_id, 'profile_id' => $profile_id, 'date' => date('Y-m-d'), 'type' => $type);
     $social_value = $social_value->where($where)->get();
     $social_value->user_id = (int) $user_id;
     $social_value->profile_id = (int) $profile_id;
     $social_value->date = date('Y-m-d');
     $social_value->value = $count;
     $social_value->type = $type;
     $social_value->save();
 }
示例#5
0
 public function delete($user_id = NULL)
 {
     $user = $this->prepare_user($user_id);
     if ($this->ion_auth->is_admin($user_id)) {
         $url = 'manage_admins';
     } elseif ($this->ion_auth->is_manager($user_id)) {
         $url = 'manage_accounts';
     } else {
         $url = 'admin_users';
     }
     if ($this->ion_auth->is_collaborator($user_id)) {
         $this->c_user->delete($user);
     }
     $user_deleted = $this->ion_auth->delete_user($user->id);
     if (!$user_deleted) {
         $this->addFlash(lang('delete_error', [$this->ion_auth->errors()]));
         redirect('admin/admin_users');
     }
     $sender = $this->get('core.mail.sender');
     $sender->sendUserDeleteMail(array('user' => $user));
     $access_token = new Access_token();
     $access_token->where('user_id', $user->id)->get()->delete_all();
     $directory_user = new Directory_User();
     $directory_user->where('user_id', $user->id)->get()->delete_all();
     $facebook_fanpage = new Facebook_Fanpage();
     $facebook_fanpage->where('user_id', $user->id)->get()->delete_all();
     $keyword = new Keyword();
     $keyword->where('user_id', $user->id)->get();
     foreach ($keyword as $k) {
         $keyword_rank = new Keyword_rank();
         $keyword_rank->where('keyword_id', $k->id)->get()->delete_all();
     }
     $keyword->delete_all();
     $media = new Media();
     $media->where('user_id', $user->id)->get()->delete_all();
     $post = new Post();
     $post->where('user_id', $user->id)->get();
     foreach ($post as $p) {
         $post_social = new Post_social();
         $post_social->where('post_id', $p->id)->get()->delete_all();
     }
     $post->delete_all();
     $review = new Review();
     $review->where('user_id', $user->id)->get()->delete_all();
     $reviews_notification = new Reviews_notification();
     $reviews_notification->where('user_id', $user->id)->get()->delete_all();
     $rss_feeds_users = new Rss_feeds_users();
     $rss_feeds_users->where('user_id', $user->id)->get()->delete_all();
     $social_post = new Social_post();
     $social_post->where('user_id', $user->id)->get()->delete_all();
     $social_value = new Social_value();
     $social_value->where('user_id', $user->id)->get()->delete_all();
     $user_additional = new User_additional();
     $user_additional->where('user_id', $user->id)->get()->delete_all();
     $user_feed = new User_feed();
     $user_feed->where('user_id', $user->id)->get()->delete_all();
     $user_timezone = new User_timezone();
     $user_timezone->where('user_id', $user->id)->get()->delete_all();
     $this->addFlash(lang('delete_success'), 'success');
     redirect('admin/' . $url);
 }
示例#6
0
 public function get_analytics_data()
 {
     if ($this->template->is_ajax()) {
         $id = $this->input->post('access_token_id');
         $period = $this->input->post('period');
         $to = new DateTime('UTC');
         $from = new DateTime('UTC');
         $from->modify('-' . $period);
         $token = Access_token::inst($id);
         $data = $token->social_analytics->get_by_period($from->format('Y-m-d'), $to->format('Y-m-d'))->all_to_array();
         $answer = [Social_analytics::RETWEETS_ANALYTICS_TYPE => [], Social_analytics::FAVOURITES_ANALYTICS_TYPE => [], Social_analytics::NEW_FOLLOWING_ANALYTICS_TYPE => [], Social_analytics::NEW_UNFOLLOWERS_ANALYTICS_TYPE => [], Social_analytics::NEW_FOLLOWING_BY_SEARCH_ANALYTICS_TYPE => [], Social_analytics::NEW_UNFOLLOWING_ANALYTICS_TYPE => []];
         foreach ($data as $el) {
             $answer[$el['type']][$el['date']] = $el['value'];
         }
         $social_values = Social_value::inst();
         $social_values->set_values($this->c_user->id, $this->profile->id, array('from' => $from->format('Y-m-d'), 'to' => $to->format('Y-m-d'), 'type' => 'twitter'));
         $answer['followers'] = $social_values->get_data()['twitter'];
         unset($answer['followers']['']);
         echo json_encode($answer);
     }
 }