<?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/
 */

include_once($_SERVER['DOCUMENT_ROOT'].'/inc/core.php');

function usernameExists($value) {
    global $mdb2;
    $sql = 'SELECT login_name FROM users'.
           ' WHERE login_name = '.$mdb2->quote($value);
    //echo $sql;

    $result = $mdb2->queryAll($sql);
    if (PEAR::isError($result)) {
        die('Error: '.$result->getMessage());
    } else {
        if(sizeof($user) > 0) {
            $result = true;
        }
    }
    return $result;
}

function emailExists($value) {
    global $mdb2;
    $sql = 'SELECT user_id FROM users'.
           ' WHERE email = '.$mdb2->quote($value);
    //echo $sql;

    $result = $mdb2->queryAll($sql);
    if (PEAR::isError($result)) {
        die('Error: '.$result->getMessage());
    } else {
        if(sizeof($result) > 0) {
            $result = true;
        }
    }
    return $result;
}
?>