<?PHP

global $AF;
$AF->SuppressHTMLOutput();

$MyPlugin = $GLOBALS["G_PluginManager"]->GetPlugin("AutoScreenshot");

if (isset($_GET["Id"]))
{
    if (Resource::ItemExists($_GET["Id"]))
    {
        $TargetResource = new Resource($_GET["Id"]);
        $Schema = new MetadataSchema();
        $Field = $Schema->GetFieldByName("Screenshot");

        $DB->Query("SELECT * FROM AutoScreenshot_ApprovalQueue "
        ."WHERE ResourceId=".intval($TargetResource->Id()) );
        $ApprovalQueue = $DB->FetchRows();

        if (count($TargetResource->Get($Field))==0 &&
            count($ApprovalQueue)==0)
        {
            $MyPlugin->ScreenshotForResource($TargetResource->Id() );
        }
    }
}


?>
