<?php

/**
* A mysql connection plug-in
* @package Joomla
* @subpackage Fabrik
* @author Rob Clayburn
* @copyright (C) Rob Clayburn
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die();

//require the abstract plugin class
require_once(COM_FABRIK_FRONTEND.DS.'models'.DS.'plugin.php');
require_once(COM_FABRIK_FRONTEND.DS.'helpers'.DS.'html.php');
require_once(COM_FABRIK_FRONTEND.DS.'libs'.DS.'twitter'.DS.'class.twitter.php');


class FabrikModelCnntwitter extends fabrikModelPlugin {
  
  function __construct()
  {
    $this->api = new twitter();
    parent::__construct();
  }

  function testConnection()
  {
    $params =& $this->getParams();
    $this->api->password = $params->get('password');
    $this->api->username = $params->get('user');
    
    $res = $this->api->friendsTimeline( $params->get('user'));
    return (empty($res)) ? false : true;
  }
  
	/**
	 * write out the admin form for customising the plugin
	 *
	 * @param object $row
	 */

	function renderAdminSettings()
	{
		/* can be overwritten by action plugin */
		$params =& $this->getParams();
		
		$params->loadObject($this->_element);
		?>
<div id="page-<?php echo $this->_name;?>" class="pluginSettings"
	style="display: none">
<table>
<?php echo $params->render('details');?>
</table>
</div>
<?php
	}

}
?>