<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
$db=&JFactory::getDBO();
$query="CREATE TABLE IF NOT EXISTS `#__content_allarticleannounce` (`content_id` int(11) NOT NULL,`published_f` tinyint(1) NOT NULL default '0',`published_t` tinyint(1) NOT NULL default '0',`published_f_date` date default NULL,`published_t_date` date default NULL,`published_f_text` text,`published_t_text` text,`twitter_on` tinyint(1) NOT NULL default '0',`facebook_on` tinyint(1) NOT NULL default '0')";
$db->setQuery($query);
$db->query();
$query="CREATE TABLE IF NOT EXISTS `#__content_allarticleannounce_switch` (`switch_id` int(11) NOT NULL auto_increment,`facebook` tinyint(1) NOT NULL default '1',`twitter` tinyint(1) NOT NULL default '1',`content_type` tinyint(1) NOT NULL default '0',PRIMARY KEY  (`switch_id`))";
$db->setQuery($query);
$db->query();
$query="INSERT INTO `#__content_allarticleannounce_switch` (`switch_id`, `facebook`, `twitter`, `content_type`) VALUES(0, 1, 1, 0);";
$db->setQuery($query);
$db->query();
$query="CREATE TABLE IF NOT EXISTS `#__content_allarticleannounce_config` (`publish_facebook` tinyint(1) default '1',`username_f` varchar(50) default NULL,`ps_f` varchar(50) default NULL,`page_type` tinyint(1) default '1',`page_id` varchar(50) default NULL,`publish_twitter` tinyint(1) default '1',`username_t` varchar(50) default NULL,`ps_t` varchar(50) default NULL,`all_categories_f` tinyint(1) default '0',`category_option_f` text,`all_categories_t` tinyint(1) NOT NULL default '0',`category_option_t` text,`update_message` tinyint(1) default '1',`content_type` tinyint(1) NOT NULL default '0',`content_detail` tinyint(1) NOT NULL default '0',`timeout` int(11) default '2')";
$db->setQuery($query);
$db->query();
$query="INSERT INTO `#__content_allarticleannounce_config` (`publish_facebook`, `username_f`, `ps_f`, `page_type`, `page_id`, `publish_twitter`, `username_t`, `ps_t`, `all_categories_f`, `category_option_f`, `all_categories_t`, `category_option_t`, `update_message`, `content_type`, `content_detail`, `timeout`) VALUES(1, NULL, NULL, 1, NULL, 1, NULL, NULL, 0, NULL, 0, NULL, 1, 0,0,2)";
$db->setQuery($query);
$db->query();
?>
<script type='text/javascript'>
var xmlhttp
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}
function set_date()
{
	xmlhttp=GetXmlHttpObject();
	
	if (xmlhttp==null)
	{
	  alert ("Your browser does not support AJAX!");
	  return;
	}
	date=document.getElementById('set_date').value;
	url="index.php?task=set_date&format=raw&option=com_allarticleannounce";
	url=url+"&date="+date;
	xmlhttp.onreadystatechange=set_date_change;
	xmlhttp.open("POST",url,true);
	xmlhttp.send(null);
}
function set_date_change()
{
	if (xmlhttp.readyState==4)
	{
		response=xmlhttp.responseText;
		document.getElementById('set_date').disabled = true;
		document.getElementById('update_button').disabled = true;
		alert(response);
	}
}

</script>
<img src='../administrator/components/com_allarticleannounce/image/logo.png'/>
<p>
Thank you for installing allArticleAnnounce from <a href='http://www.joomtraders.com/'>Joomtraders</a>. 
</p>
<p>
Please remember that there are three pieces to this extension and all three must be installed for it to run correctly.
</p>
<p>
If you require assistance with the installation or use of this product:
</p>
<ul>
<li>Visit our forums,</li>
<li>Send an email to our support desk,</li>
<li>Log a ticket to our help desk,</li>
<li>Revisit the allArticleAnnounce documents.</li>
</ul>
<p>
To use allArticleAnnounce, please remember to enable/publish the two plugins. 
</p>
<h3> Starting Date Set </h3>
<p>
	I do not want to publish the articles before <input id='set_date' value='<?php echo date('Y-m-d');?>'/> <input id='update_button' type='button' value='Update' onclick='set_date();'/>
</p>
