<?PHP

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

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

if (isset($_GET["Id"]))
{
    $TargetResource = new Resource( intval($_GET["Id"]) );

    if ($TargetResource->Status()==1)
    {
        $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() );
    }
}


?>
