<?PHP
#
#   FILE:  Unsubscribe.php
#
#   Part of the Collection Workflow Integration System (CWIS)
#   Copyright 2015 Internet Scout Project
#   http://scout.wisc.edu/
#

# ----- MAIN -----------------------------------------------------------------

# make sure our plugin is enabled, bounce to Home if not
if (!$GLOBALS["G_PluginManager"]->PluginEnabled("MailingList"))
{
    $GLOBALS["AF"]->SetJumpToPage("Home");
    return;
}

$Jump = GetArrayValue($_GET, "ReturnTo", "Home");
$List = GetArrayValue($_GET, "List", NULL);

if ($List !== NULL && $GLOBALS["G_User"]->IsLoggedIn())
{
    $MyPlugin = $GLOBALS["G_PluginManager"]->GetPlugin("MailingList");
    $MyPlugin->Unsubscribe( $GLOBALS["G_User"], $List );
}

$GLOBALS["AF"]->SuppressHTMLOutput();
$GLOBALS["AF"]->SetJumpToPage($Jump);
