<?php defined('SYSPATH') or die('No direct access allowed.');

/**
 * Enahance Kohanas Auth driver.
 *
 * @package    OSB
 * @category   Classes
 * @author     Deon George
 * @copyright  (c) 2009-2013 Open Source Billing
 * @license    http://dev.osbill.net/license.html
 */
class Auth_ORM extends lnAuth_Auth_ORM {
	/**
	 * Determine if a user is authorised to view an account
	 *
	 * @param Model_Account Account Ojbect to validate if the current user has access
	 * @return boolean TRUE if authorised, FALSE if not.
	 */
	public function authorised(Model_Account $ao) {
		return (($uo = $this->get_user()) AND $uo->loaded() AND ($uo == $ao OR in_array($ao->id,$uo->RTM->customers($uo->RTM))));
	}
}
?>