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;
Sonia Zorba
committed
abstract class DAO {
Sonia Zorba
committed
public abstract function getDBHandler();
Sonia Zorba
committed
public abstract function insertTokenData($token, $data);
Sonia Zorba
committed
public abstract function findTokenData($token);
Sonia Zorba
committed
public abstract function deleteToken($token);
Sonia Zorba
committed
/**
* Return the new identity ID.
*/
public abstract function insertIdentity(Identity $identity, $userId);
Sonia Zorba
committed
/**
* Return the new user ID.
*/
public abstract function createUser();
Sonia Zorba
committed
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);
Sonia Zorba
committed
public abstract function addEmailToUser($email, $userId);
Sonia Zorba
committed
public $config;
Sonia Zorba
committed
public function __construct($config) {
$this->config = $config;
Sonia Zorba
committed
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');
}