<?php
/*
 * Copyright (c) 2010, webvariants GbR, http://www.webvariants.de
 *
 * This file is released under the terms of the MIT license. You can find the
 * complete text in the attached LICENSE file or online at:
 *
 * http://www.opensource.org/licenses/mit-license.php
 */

class WV_Filter_Article_CategoryID extends WV_Filter_Or implements WV_IFilter {
	public function __construct($id, $operation = '=', $recursive = false) {
		if ($recursive) {
			parent::__construct(
				new WV_Filter_Article_Column('article.re_id', $id, $operation),
				new WV_Filter_Article_Column('article.id', $id, $operation),
				new WV_Filter_Article_Column('article.path', "%|$id|%", 'LIKE')
			);
		}
		else {
			parent::__construct(
				new WV_Filter_Article_Column('article.re_id', $id, $operation),
				new WV_Filter_Article_Column('article.id', $id, $operation)
			);
		}
	}

	public function useSeparateJoins($flag = true) {
		if ($flag) throw new WV_Exception_Filter('This filter cannot be joined separately (because it would be stupid).');
		parent::useSeparateJoins($flag);
	}
}
