<?php
/*
+--------------------------------------------------------------------------
|   TanyaCMS - Question and Answer Sofware
|   -----------------------------------------------------------------------
|   by fbschool dev team
|   (c) 2011 - 2012 FBSCHOOL
|   http://www.fbschool.com/tanyacms
|   -----------------------------------------------------------------------
|   This is NOT a freeware, use is subject to license terms
|   Support: 13455n@gmail.com
+--------------------------------------------------------------------------
*/

define('IN_AJAX', TRUE);


if (!defined('IN_TANYACMS'))
{
	die;
}

class ajax extends ASK_CONTROLLER
{

	public function follow_people_action()
	{
		$action = null;
		$friend_uid = intval($_GET['uid']);
		
		if (! $friend_uid)
		{
			return false;
		}
		
		$follow = $this->model('follow');
		
		//First, determine whether there is concern
		if ($follow->user_follow_check($this->user_id, $friend_uid))
		{
			$action = "remove";
			
			$follow->user_follow_del($this->user_id, $friend_uid);
			
			H::ajax_json_output(ASK_APP::RSM(array(
				"type" => "remove"
			), "1", "Delete attention Success"));
		}
		else
		{
			$action = "add";
			
			$follow->user_follow_add($this->user_id, $friend_uid);
				
			$this->model('notify')->send($this->user_id, $friend_uid, notify_class::TYPE_PEOPLE_FOCUS, notify_class::CATEGORY_PEOPLE, $this->user_id, array(
				'from_uid' => $this->user_id
			));
				
			$this->model('email')->action_email(email_class::TYPE_FOLLOW_ME, $friend_uid, get_js_url('/people/' . $this->user_info['url_token']), array(
				'user_name' => $this->user_info['user_name'],
			));
				
			H::ajax_json_output(ASK_APP::RSM(array(
				"type" => "add"
			), "1", "Follow successfully added"));
		}
	}

}