<?PHP
#
#   FILE:  RateResource.php
#
#   Part of the Collection Workflow Integration System (CWIS)
#   Copyright 2011-2013 Edward Almasy and Internet Scout Research Group
#   http://scout.wisc.edu/cwis/
#

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

$ResourceId = (isset($_GET["F_ResourceId"])) ? intval($_GET["F_ResourceId"]) : NULL;
$Rating = (isset($_GET["F_Rating"])) ? intval($_GET["F_Rating"]) : NULL;

# check for the rating in POST variables
if (is_null($Rating) && isset($_POST["F_Rating"]))
{
    $Rating = intval($_POST["F_Rating"]);
}

# save the new rating for the user
if (!is_null($ResourceId))
{
    if (!is_null($Rating))
    {
        $Resource = new Resource($ResourceId);
        $Resource->Rating($Rating);
    }

    # go to full record page
    $AF->SetJumpToPage("FullRecord&ID=".$ResourceId);
}

# go to the home page
else
{
    $AF->SetJumpToPage("Home");
}

