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

/**
 * OSB OAuth Model
 *
 * @package    OAuth
 * @category   Models
 * @author     Deon George
 * @copyright  (c) 2009-2013 Open Source Billing
 * @license    http://dev.osbill.net/license.html
 */
class Model_Oauth extends ORM_OSB {
	// Relationships
	protected $_has_many = array(
		'account_oauth' => array('far_key'=>'id'),
	);

	/**
	 * Return the object of the OAuth plugin
	 */
	public function plugin($type='') {
		$c = 'OAuth_Plugin_'.ucfirst($this->name);

		if (! $this->name OR ! class_exists($c))
			return NULL;

		$o = new $c($this);

		return $type ? $o->$type : $o;
	}
}
?>
