<?php

namespace FSPoster\App\Controller\Popups;


use FSPoster\App\Providers\DB;
use FSPoster\App\Providers\Helper;
use FSPoster\App\Providers\Request;

trait SocialAccounts
{

	public function add_fb_account()
	{
		Helper::modalView('fb.add_account');
	}

	public function add_twitter_account()
	{
		Helper::modalView('twitter.add_account');
	}

	public function add_linkedin_account()
	{
		Helper::modalView('linkedin.add_account');
	}

	public function add_ok_account()
	{
		Helper::modalView('ok.add_account');
	}

	public function add_pinterest_account_case()
	{
		Helper::modalView('pinterest.add_account_case');
	}

	public function add_pinterest_account()
	{
		Helper::modalView('pinterest.add_account');
	}

	public function add_pinterest_account_cookies_method()
	{
		Helper::modalView('pinterest.add_account_cookies_method');
	}

	public function add_reddit_account()
	{
		Helper::modalView('reddit.add_account');
	}

	public function add_tumblr_account()
	{
		Helper::modalView('tumblr.add_account');
	}

	public function reddit_add_subreddit()
	{
		Helper::modalView('reddit.add_subreddit');
	}

	public function add_vk_account()
	{
		Helper::modalView('vk.add_account');
	}

	public function add_instagram_account()
	{
		Helper::modalView('instagram.add_account');
	}

	public function add_instagram_account_case()
	{
		Helper::modalView('instagram.add_account_case');
	}

	public function add_instagram_account_cookies_method()
	{
		Helper::modalView('instagram.add_account_cookies_method');
	}

	public function activate_with_condition()
	{
		$id = Request::post('id' , '0' , 'num');
		$type = Request::post('type' , '' , 'string');

		if( $type == 'node' )
		{
			$ajaxUrl    = 'settings_node_activity_change';
			$tableName  = 'account_node_status';
			$fieldName  = 'node_id';
		}
		else
		{
			$ajaxUrl    = 'account_activity_change';
			$tableName  = 'account_status';
			$fieldName  = 'account_id';
		}
		$info           = DB::fetch( $tableName, [ $fieldName => $id ] );
		$filter_type    = $info ? $info['filter_type'] : 'in';
		$categories     = $info ? explode(',', $info['categories']) : [];

		Helper::modalView('other.activate_with_condition' , [
			'id'            =>  $id ,
			'ajaxUrl'       =>  $ajaxUrl,
			'filter_type'   =>  $filter_type,
			'categories'    =>  $categories
		]);
	}

	public function add_google_b_account()
	{
		Helper::modalView('google.add_account' , []);
	}

	public function add_telegram_bot()
	{
		Helper::modalView('telegram.add_bot' , []);
	}

	public function show_telegram_chats()
	{
		Helper::modalView('telegram.show_chats', []);
	}

	public function telegram_add_chat()
	{
		Helper::modalView('telegram.add_chat', []);
	}

	public function add_medium_account()
	{
		Helper::modalView('medium.add_account', []);
	}

	public function add_wordpress_site()
	{
		Helper::modalView('wordpress.add_site', []);
	}

	public function add_node_to_list()
	{
		$fn_prefix = Request::post('fn_prefix', '', 'int');

		Helper::modalView('other.add_node_to_list', [
			'fn_name'   =>  'addNodeToList' . $fn_prefix
		]);
	}

}
