Skip to content
DAO.php 2.43 KiB
Newer Older
<?php

/* ----------------------------------------------------------------------------
 *               INAF - National Institute for Astrophysics
 *               IRA  - Radioastronomical Institute - Bologna
 *               OATS - Astronomical Observatory - Trieste
 * ----------------------------------------------------------------------------
 *
 * Copyright (C) 2016 Istituto Nazionale di Astrofisica
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License Version 3 as published by the
 * Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 51
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

namespace RAP;

    public abstract function getDBHandler();
    public abstract function insertTokenData($token, $data);
    public abstract function findTokenData($token);
    public abstract function deleteToken($token);
    /**
     * Return the new identity ID.
     */
    public abstract function insertIdentity(Identity $identity, $userId);
    /**
     * Return the new user ID.
     */
    public abstract function createUser();
    public abstract function findUserById($userId);
    
    /**
     * Return a User object, null if nothing was found.
     * @param type $type Identity type (EDU_GAIN, X509, GOOGLE, ...)
     * @param type $identifier value used to search the identity in the database
     * @param type $dbIdentifier identifier of the database (used only for local identities)
     */
    public abstract function findUserByIdentity($type, $identifier, $dbIdentifier);
    public abstract function addEmailToUser($email, $userId);
    public function __construct($config) {
        $this->config = $config;
    public static function get() {
        $config = parse_ini_file(ROOT . '/config.ini', true);
        switch ($config['dbtype']) {
            case 'MySQL':
                return new MySQLDAO($config);
            default:
                throw new \Exception($config['dbtype'] . ' not supported yet');
        }