<?php

Lib::loadClass('UserStorageDB');
Lib::loadClass('UserStorageMacOSX');

class UserStorage {

	public static function getStorage($clientType) {
		$usrStorage = null;
		if ($clientType == 'DB') {
			$db = DB::getDB();
			$usrStorage = new UserStorageDB($db);
		}
		else if ($clientType == 'MacOSX') {
			$ldapConfName = 'default_ldap';
			Lib::loadClass('Config');
			$conf = Config::getConfFile($ldapConfName);
			if ($conf) {
				$rootUser = V::get('user', '', $conf);
				$rootPass = V::get('pass', '', $conf);
				$host = $_SERVER['SERVER_NAME'];
				$usrStorage = new UserStorageMacOSX($rootUser, $rootPass, $host);
			}
		}
		return $usrStorage;
	}

}
