<?php
	
	/**
	* @copyright		(C)2013 DM Digital S.r.l
	* @author 			DM Digital <support@dmjoomlaextensions.com>
	* @link				http://www.dmjoomlaextensions.com
	* @license 			GNU/LGPL http://www.gnu.org/copyleft/gpl.html
	**/
	
	defined('_JEXEC') or die('Restricted access');

	class com_dmfrontendusermanagerInstallerScript {
		
		public function install($parent) {

            $db = JFactory::getDBO();
            $myQuery = 	"
				CREATE TABLE IF NOT EXISTS `#__dmfrontendusermanager_group_permissions` (
				  `id_mastergroup` int(11) NOT NULL,
				  `id_slavegroup` int(11) NOT NULL,
				  `action_view` tinyint(1) NOT NULL,
				  `action_add` tinyint(1) NOT NULL,
				  `action_edit` tinyint(1) NOT NULL,
				  `action_del` tinyint(1) NOT NULL,
				  PRIMARY KEY (`id_mastergroup`, `id_slavegroup`)
				);";
            $db->setQuery($myQuery);
            $db->query();

            $myQuery = 	"
				CREATE TABLE IF NOT EXISTS `#__dmfrontendusermanager_log` (
				  `log_id` int(11) NOT NULL AUTO_INCREMENT,
				  `action_user_id` varchar(128) NOT NULL,
				  `user_id` varchar(128) NOT NULL,
				  `action` varchar(16) NOT NULL,
				  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
				  PRIMARY KEY (`log_id`)
				);
			";
            $db->setQuery($myQuery);
            $db->query();

			$parent->getParent()->setRedirectURL('index.php?option=com_dmfrontendusermanager');
     
		}

		public function uninstall($parent) {
		}
		
		public function update($parent) {

            $parent->getParent()->setRedirectURL('index.php?option=com_dmfrontendusermanager');

		}
		
		public function preflight($type, $parent) {
		}
		
		public function postflight($type, $parent) {
		}
		
	}
	
?>
