<?php
/**
* @package ccNewsletter
* @version 1.0.9
* @author  Chill Creations <info@chillcreations.com>
* @link    http://www.chillcreations.com
* @copyright Copyright (C) 2008 - 2010 Chill Creations-All rights reserved
* @license GNU/GPL, see LICENSE.php for full license.
* See COPYRIGHT.php for more copyright notices and details.

This file is part of ccNewsletter.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
**/

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

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

// extend the JView class for our specific view
class ccNewsletterViewremove extends JView
{
	function display($tpl = null)
	{
		$db=& JFactory::getDBO();
		$params = &JComponentHelper::getParams( 'com_ccnewsletter' );
		$document =& JFactory::getDocument();

		$email_id=JRequest::getVar('email_id','', 'post', 'string');
		$session =& JFactory::getSession();
		if(isset($_GET['id']))
		{
			$removeID=JRequest::getVar('id','', 'get', 'string');
			$session->set('act_id', $removeID);
		}
		elseif(isset($_POST['id']))
		{
			$removeID=JRequest::getVar('id','', 'post', 'string');
			$removeID= md5($removeID);
			$session->set('act_id', $removeID);
		}
		else
		{
			$removeID = $session->get('act_id');
		}

		$name=JRequest::getVar('name','', 'post', 'string');

		if($params->get('show_page_title'))
		{
			$page_title = $params->get( 'page_title' );
		}
		else
		{
			$page_title = JText::_( 'CC_NEWSLETTER_UNSUBSCRIPTION' );
		}


		$query = "SELECT * FROM #__ccnewsletter_subscribers WHERE email='".$email_id."' LIMIT 1";
		$db->setQuery($query);
		$rows=$db->loadObject();
		$subcriberid = @$rows->id;

		$document->setTitle( $page_title );
		// get the operation status (set in the controller)
		$operationStatus = JRequest::getVar('operationStatus','');

		if(isset($_GET['id']))
		{
			$status_de_un=JRequest::getVar('status_de_un','', 'get', 'string');
		}
		else
		{
			$status_de_un=JRequest::getVar('status_de_un','', 'post', 'string');
		}

		// assign the operaton status to a variable for use in the view
		$this->assignRef( 'operationStatus',	$operationStatus );
		$this->assignRef( 'status_de_un',	$status_de_un );
		$this->assignRef( 'pageTitle',	$page_title );
		$this->assignRef( 'email_id',	$email_id );
		$this->assignRef( 'name',	$name );
		$this->assignRef( 'removeID',	$removeID );
		parent::display($tpl);
	}
}
?>
