<?php
/**
 * Phoebe pedagogic planner
 *
 * PHP version 5
 *
 * LICENSE: The GNU General Public License (GPL), version 2. See LICENSE.txt
 *
 * Copyright (c) 2006-2008 JISC/HEFCE/University of Oxford
 *
 * @author      David Balch <david.balch@conted.ox.ac.uk>
 * @license     http://opensource.org/licenses/gpl-license.php GPL2
 * @link        http://phoebe-project.conted.ox.ac.uk/
 */


/* Delete a property entry */
$content['settings'] = 'dbWrite';
include_once($_SERVER['DOCUMENT_ROOT'].'/inc/core.php');
include_once($_SERVER['DOCUMENT_ROOT'].'/inc/session.php');
include_once($_SERVER['DOCUMENT_ROOT'].'/inc/utils.php');

// Sanitise user data before sending to database
$goodVals = true;
foreach ($_POST as $key=>$value) {
    switch ($key) {
        case "refId":
            if (!ctype_digit($value)) {
                $goodVals = false;
            }
            break;
    }
}


if($goodVals) {
    $delFailure = false;
    // Delete any references for the property
    $sql = 'DELETE FROM refs '.
           'WHERE ref_id = '.$mdb2->quote($_POST['refId']);
    //echo $sql;

    $delRef = $mdb2->queryAll($sql);
    if (PEAR::isError($delRef)) {
        echo 'Error deleting reference - '.$insert->getMessage();
        echo $delFailure;
    } else {
        echo 'deleted';
    }
} else {
    echo 'Error deleting reference - invalid parameters.';
}
?>