<?php
/*
NmnNewsletter is a library that provides newsletter service
management for websites running php and mysql.
Copyright (C) 2006 Ivan Preziosi from netmeans.net - Rome.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
For more informations or to join the development of the library contact
the author at: hide@address.com
*/
require_once("includes/config.php");
sessCtrl();
if($_GET["action"] == "add")
{
$subscribers = NewsletterUsers::getUserArray(true,false);
foreach($subscribers as $subscriber)
{
if($subscriber == $_GET["email"])
{
$result = 1;
break;
}
else
{
$result = 0;
}
}
if($result == 1)
{
$msg = "<div class=error>".SUBSCRIBERS_ERROR_EXISTENT."</div>";
}
else
{
if (NewsletterUsers::subscribeUser($_GET["email"],true)){
$msg = "<div class=message>".SUBSCRIBERS_SUCCESSFULLY_ADDED."</div>";
}else{
$msg = "<div class=message>".SUBSCRIBERS_NOT_ADDED."</div>";
}
}
$subscribers = NewsletterUsers::getUserArray(true,true);
}else if($_GET["action"] == "delete")
{
if (NewsletterUsers::deleteUser($_GET["id_to_del"])){
$msg = "<div class=message>".SUBSCRIBERS_SUCCESSFULLY_DELETED."</div><br>";
}else{
$msg = "<div class=message>".SUBSCRIBERS_NOT_DELETED."</div><br>";
}
$subscribers = NewsletterUsers::getUserArray(true,true);
}else if($_GET["action"] == "search")
{
$subscribers = NewsletterUsers::getSearchArray($_GET["search"],$_GET["alsoDel"],$_GET["alsoUnconfirmed"],$_GET["alsoSubscribed"],true);
}else{
$subscribers = NewsletterUsers::getUserArray(true,true);
}
$main .= "
<div class=page_heading>".SUBSCRIBERS_TITLE."</div>
$msg
<table width=95%>
<tr>
<td align=right>
<span ><a href=\"exportUsers.php\">".SUBSCRIBERS_BATCH_EXPORT."</a> | <a href=\"importUsers.php\">".SUBSCRIBERS_BATCH_IMPORT."</a> | <a href=\"waitingList.php\">".SUBSCRIBERS_WAITING_LIST."</a> | <a href=\"subscribers_search.php\">".SUBSCRIBERS_SEARCH."</a></span>
</td>
</tr>
<tr>
<form name='add' action='subscribers.php' method='get'>
<td align='center' class='message'>
".SUBSCRIBERS_ADD_FORM." Email
<input class=textField type=text name=email title='".SUBSCRIBERS_FORM_POP."'>
<input type=hidden name=action value=add>
<input class=button type=submit value=Add>
</td>
</form>
<script language=javascript>
var validator = new Validator('add');
validator.addValidation('email','req','".SUBSCRIBERS_VALIDATOR_MESSAGE."');
validator.addValidation('email','email','".SUBSCRIBERS_VALIDATOR_MESSAGE."');
</script>
</tr>
<tr>
<td align=center>
<span class=error_text id=label_email></span>
</td>
</tr>
<tr>
<td align=center>
<div class=page_heading>".SUBSCRIBERS_LIST."</div><br>
";
foreach ($subscribers as $idSubscriber => $subscriber){
if (!is_array($subscriber)){
$main .= "<div style='border-bottom:1px solid #DFE8FF;'><table width=95%><tr><td >$subscriber</td><td align='right'>[<a href=\"subscriberInfo.php?id=$idSubscriber\">".SUBSCRIBERS_INFO_LINK."</a>] | [<a href=\"javascript:confirmClick('".SUBSCRIBERS_DEL_CONFIRM."','subscribers.php?action=delete&id_to_del=$idSubscriber');\">".SUBSCRIBERS_DEL_LINK."</a>]</td></tr></table></div>";
}else{
$emailColor = "";
$emailTitle = SUBSCRIBERS_TITLE_SUBSCRIBED;
if ($subscriber[1] == "deleted"){
$emailColor = "color:red;";
$emailTitle = SUBSCRIBERS_TITLE_DELETED;
}elseif($subscriber[1] == "unconfirmed"){
$emailColor = "color:#660066;";
$emailTitle = SUBSCRIBERS_TITLE_UNCONFIRMED;
}
$main .= "<div style='border-bottom:1px solid #DFE8FF;'><table width=95%><tr><td style=\"$emailColor\" title=\"$emailTitle\">$subscriber[0]</td><td style=\"$emailColor\" align='right'>[<a style=\"$emailColor\" href=\"subscriberInfo.php?id=$idSubscriber\">".SUBSCRIBERS_INFO_LINK."</a>] | [<a style=\"$emailColor\" href=\"javascript:confirmClick('".SUBSCRIBERS_DEL_CONFIRM."','subscribers.php?action=delete&id_to_del=$idSubscriber');\">".SUBSCRIBERS_DEL_LINK."</a>]</td></tr></table></div>";
}
}
if(isset($_SESSION["navigation"])) $main .= $_SESSION["navigation"];
unset($_SESSION["navigation"]);
$main .= "<br><br>
<input type=hidden name=action value=delete>
</td>
</tr>
</table>";
$page = "subscribers";
require_once("includes/template.php");
?>