<?PHP
#
#   FILE:  SPT--FileName.php
#
#   FUNCTIONS PROVIDED:
#       FunctionName($Parameter, $Parameter)
#           - brief description of function supplied for use in HTML file
#
#   FUNCTIONS EXPECTED:
#       FunctionName($Parameter, $Parameter)
#           - brief description of function that HTML file must supply
#
#   OPTIONAL FUNCTIONS:
#       FunctionName($Parameter, $Parameter)
#           - brief description of function that HTML file may supply
#
#   FORM FIELDS EXPECTED:
#       F_FormFieldName
#           - brief description of form field purpose and/or content
#
#   Part of the Scout Portal Toolkit
#   Copyright 2006 Internet Scout Project
#   http://scout.wisc.edu
#

if (!CheckAuthorization(PRIV_RESOURCEADMIN, PRIV_MYRESOURCEADMIN, PRIV_RELEASEADMIN)) {  return;  }

require_once('lib/AxisPHP/Axis--StandardLibrary.php');

# ----- CONFIGURATION  -------------------------------------------------------

# ----- EXPORTED FUNCTIONS ---------------------------------------------------
# (functions intended for use in corresponding HTML file)

# ----- LOCAL FUNCTIONS ------------------------------------------------------
# (functions intended for use only within this file)

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

# if resource ID was supplied
$G_AddingNewResource = FALSE;
if (isset($_GET["ID"]) )
{
    # retrieve resource ID (or NULL if adding new resource)
    $ResourceId = isset($_GET["ID"]) ? intval($_GET["ID"]) : NULL ;
    $ResourceId = ($ResourceId == "NEW") ? NULL : intval($ResourceId);

    # load resource to be edited
    $G_Resource = new Resource($ResourceId);

    # if resource failed to load
    if ($G_Resource->Status() != 1)
    {
        # set flag to indicate error message needed
        $G_ResourceNotFound = TRUE;
    }
    else
    {
        # set flag to indicate if we are adding a new resource
        $G_AddingNewResource = $G_Resource->IsTempResource();

        # set page title to indicate adding or editing
        PageTitle($G_AddingNewResource ? "Add Resource" : "Edit Resource");

        # load metadata fields
        $Schema = new MetadataSchema();
        $G_Fields = $Schema->GetFields(NULL, MetadataSchema::MDFORDER_EDITING);
    }
}
else
{
    # set flag to indicate error message needed
    $G_NoResourceIdFound = TRUE;
}

# grab error info if present
$G_ErrorCode = isset($_GET["ER"]) ? $_GET["ER"] : NULL;
$G_ErrorFieldIds = isset($_GET["EF"]) ? explode("-", $_GET["EF"]) : NULL;
$G_ErrorInfoOne = isset($_GET["E1"]) ? $_GET["E1"] : NULL;
$G_ErrorInfoTwo = isset($_GET["E2"]) ? $_GET["E2"] : NULL;

?>
