<?php
/*
* @package LabCMS
* @copyright (c) 2006 Alexander Levin aka Loki (loki_angel@mail.ru)
* @support http://labcms.ru
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/

class lc_pm_ignore_list
{
	function __construct($boxowner=null)
	{
		$this->boxowner=($boxowner)?$boxowner:User::i();
	}
	
	public function addToIgnore($user)
	{
		Db::i()->query(
			"INSERT IGNORE INTO ?_lc_pm_ignore (user_id, ignore_id)
			VALUES(?, ?)", $this->boxowner->id, $user->id
		);
	}
	
	public function removeFromIgnore($user)
	{
		Db::i()->query(
			"DELETE FROM ?_lc_pm_ignore
			WHERE user_id=? AND ignore_id=?", $this->boxowner->id, $user->id
		);
	}
	
	public function getIgnoreList()
	{
		$users=Db::i()->selectCol(
			"SELECT ignore_id
			FROM ?_lc_pm_ignore i
			WHERE i.user_id=?", $this->boxowner->id
		);
		if ($users) $users=User::i()->getUsersByIds($users);
		return $users;
	}
}