<?php
/**
 * Joomla! 1.5 component allarticleannounce
 *
 * @version $Id: controller.php 2009-10-18 20:32:30 svn $
 * @author David Han
 * @package Joomla
 * @subpackage allarticleannounce
 * @license GNU/GPL
 *
 * control component for plugin AllArticleAnnounce
 *
 * This component file was created using the Joomla Component Creator by Not Web Design
 * http://www.notwebdesign.com/joomla_component_creator/
 *
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.controller');

/**
 * allarticleannounce Component Controller
 */
class AllarticleannounceController extends JController {
	function __construct() {
        //Get View
        if(JRequest::getCmd('view') == '') {
            JRequest::setVar('view', 'allarticleannounce');
        }
        parent::__construct();
    }
	function on_switch()
	{
		JRequest::setVar('view', 'allarticleannounce');
		parent::display();
	}
	function update()
	{
		//JRequest::checkToken() or jexit( 'Invalid Token' );
		$db	=& JFactory::getDBO();
		$query="update `#__content_allarticleannounce_switch` set `facebook`='".$_GET['facebook']."',`twitter`='".$_GET['twitter']."',`content_type`='".$_GET['content_type']."'";
		$db->setQuery($query);
		if($db->query())
		{
			echo '1';
		}
		else
		{
			echo 'error';
		}
		return;
	}
	function get_url()
	{
		$url=JRoute::_('index.php?option=com_content&view=article&id='.$_GET['id']);
		if(strpos($url,'/')==0)
		{
			$url=substr($url,1);
		}
		echo $url;
	}
	function alltwitter()
	{
		require_once JPATH_ROOT.DS.'plugins'.DS.'editors-xtd'.DS.'alltwitter.php';
		allTwitterUpdate();
		return;
	}
}
?>