} elseif (!isset($_SESSION["isAuthorized"]) || !$_SESSION["isAuthorized"]) {
    header("Location: " . ENTRADA_URL);
    exit;
} elseif (!$ENTRADA_ACL->amIAllowed("evaluation", "create", false)) {
    add_error("You do not have the permissions required to use this module.<br /><br />If you believe you are receiving this message in error please contact <a href=\"mailto:" . html_encode($AGENT_CONTACTS["administrator"]["email"]) . "\">" . html_encode($AGENT_CONTACTS["administrator"]["name"]) . "</a> for assistance.");
    echo display_error();
    application_log("error", "Group [" . $GROUP . "] and role [" . $ROLE . "] do not have access to this module [" . $MODULE . "]");
} else {
    if (isset($_POST["ajax"]) && $_POST["ajax"] == 1) {
        $use_ajax = true;
    } else {
        $use_ajax = false;
    }
    if ($use_ajax) {
        /**
         * Clears all open buffers so we can return a plain response for the Javascript.
         */
        ob_clear_open_buffers();
        $PROCESSED = Models_Evaluation::processTargets($_POST);
    }
    if ($PROCESSED["eform_id"]) {
        Models_Evaluation::getTargetControls($PROCESSED, "", $PROCESSED["eform_id"]);
    }
    /**
     * If we are return this via Javascript,
     * exit now so we don't get the entire page.
     */
    if ($use_ajax) {
        exit;
    }
}
         * Clears all open buffers so we can return a plain response for the Javascript.
         */
        ob_clear_open_buffers();
        if (isset($_POST["form_id"]) && ($form_id = clean_input($_POST["form_id"], "int"))) {
            $PROCESSED["form_id"] = $form_id;
        }
        if (isset($_POST["evaluation_id"]) && ($evaluation_id = clean_input($_POST["evaluation_id"], "int"))) {
            $PROCESSED["evaluation_id"] = $evaluation_id;
        }
        if (isset($PROCESSED["evaluation_id"])) {
            $query = "SELECT * FROM `evaluation_evaluators` WHERE `evaluation_id` = " . $db->qstr($PROCESSED["evaluation_id"]);
            $evaluators = $db->GetAll();
            $PROCESSED["evaluation_evaluators"] = $evaluators;
            $query = "SELECT * FROM `evaluation_targets` WHERE `evaluation_id` = " . $db->qstr($PROCESSED["evaluation_id"]);
            $targets = $db->GetAll();
            $PROCESSED["evaluation_targets"] = $targets;
        }
        if (isset($_POST["options_for"]) && ($tmp_input = clean_input($_POST["options_for"], array("trim")))) {
            $options_for = $tmp_input;
        } else {
            $options_for = false;
        }
    }
    $form_id = 0;
    if ((!$use_ajax || $options_for) && $ENTRADA_USER->getActiveOrganisation()) {
        Models_Evaluation::getTargetControls($PROCESSED, $options_for);
    }
    if ($use_ajax) {
        exit;
    }
}