con = new $driver($dns); } private function __clone() {} static function getInstance($db = NULL, $dns = NULL) { if (! self::$instance) { if (! $db) throw new Exception('Missing database driver'); switch (strtolower($db)) { case 'sqlite': self::$instance = new Persistens('SQLite', $dns); break; break; case 'pgsql': self::$instance = new Persistens('Pgsql', $dns); break; break; default: throw new Exception("$db: Unsupported driver"); } } return self::$instance; } function getViewStyle($uid) { return $this->con->getViewStyle($uid); } function getStartWeek($uid) { return $this->con->getStartWeek($uid); } function getStartHour($uid) { return $this->con->getStartHour($uid); } function getEndHour($uid) { return $this->con->getEndHour($uid); } function authenticate($uid, $pwd) { return $this->con->authenticate($uid, sha1($pwd)); } function getTimeout($uid) { return $this->con->getTimeout($uid); } function getRole($uid) { return $this->con->getRole($uid); } function createDatabase($name) { $this->con->createDatabase($name); } function initDatabase($name, $pwd, $uid = 'webcal') { $this->con->initDatabase($name, $pwd, $uid = 'webcal'); $this->con = NULL; self::$instance = NULL; } function newUser($data) { return $this->con->addUser($data); } function setUserSettings($uid, $settings) { return $this->con->setUserSettings($uid, $settings); } function deleteUser($uid) { return $this->con->deleteUser($uid); } function addCalendar($uid, CalendarInfo $calendar) { return $this->con->addCalendar($uid, $calendar); } function deleteCalendar($uid, $id) { return $this->con->deleteCalendar($uid, $id); } function updateCalendar($uid, $id, CalendarInfo $calendar) { return $this->con->updateCalendar($uid, $id, $calendar); } function changePassword($uid, $pwd) { return $this->con->changePassword($uid, $pwd); } function getAllUsers($limit = -1, $offset = 0) { return $this->con->getAllUsers($limit, $offset); } function getRoles() { return $this->con->getRoles(); } function getRoleName($id) { return $this->con->getRoleName($id); } function changeDefault($data) { return $this->con->changeDefault($data); } function getVersion() { $res = $this->con->getVersion(); if (! is_array($res)) throw new Exception($res); return $res; } function execute($sql) { return $this->con->execute($sql); } function getCalendarConfig($id = -1) { return $this->con->getCalendarConfig($id); } function nextTableNumber($name) { return $this->con->nextTableNumber($name); } function getLdapConfig() { return $this->con->getLdapConfig(); } function setLdapConfig(array $config) { return $this->con->setLdapConfig($config); } }