<?php
/**
 * @package linea21.modules
 * @subpackage newsletter
 * @author linea21 <info@linea21.com>
 * @version $id SVN
 * @access public
 * @license http://opensource.org/licenses/gpl-3.0.html
 */

include_once('../config/define.php');
include_once('../languages/'.U_L.'lang_newsletter.utf-8.php');

if(!isset($_GET['call'])) {
	$mode='plain';
} else {
	$id=strip_tags($_GET['id']);
	$mode='ajax';
	session_start();
	//////////// Check Droits utilisateur ////////////
	if (!$l21auth->isSuperAdmin()) ReloadIndex('admin');
	////////////
	
}

if(!isset($_REQUEST['newsletteremail'])) exit;
else $email=$_REQUEST['newsletteremail'];

include_once('../class/class.newsletter.php');

$newsletter_object = new newsletter;

if(!isset($_REQUEST['del_action']) || isset($_REQUEST['restore']) ) {
	$msg=$newsletter_object->AddEmail($email, $GLOBALS['sql_object']);
	$action= 'restored';
}
else {
	$msg=$newsletter_object->DeleteEmail($email, $GLOBALS['sql_object']);
	$action= 'deleted';
}


if($mode == 'ajax') {
	/* Return json values */
	echo json_encode(array('status'=> $msg['code'],'msg'=> $msg['string'], 'el'=> "#email-".$id, 'action' => $action));
}
?>