]>
git.datanom.net - webcal.git/blob - utils/persistens.php
4 include_once 'config.inc.php';
5 require_once 'helper.php';
7 require_once 'sqlite.php';
8 require_once 'pgsql.php';
27 interface WebcalSupport
{
28 function getViewStyle($uid);
29 function getTimeout($uid);
30 function getRole($uid);
31 function getStartWeek($uid);
32 function getStartHour($uid);
33 function getEndHour($uid);
34 function getTimezone($uid);
35 function authenticate($uid, $pwd);
36 function createDatabase($name);
37 function initDatabase($name, $pwd, $uid);
38 function addUser($data);
39 function setUserSettings($uid, $data);
40 function deleteUser($uid);
41 function addCalendar($uid, CalendarInfo
$calendar);
42 function deleteCalendar($uid, $id);
43 function updateCalendar($uid, $id, CalendarInfo
$calendar);
44 function changePassword($uid, $pwd);
45 function getAllUsers($limit, $offset);
47 function getRoleName($id);
48 function changeDefault($data);
49 function getVersion();
50 function execute($sql);
51 function getCalendarConfig($id);
52 function nextTableNumber($name);
53 function getLdapConfig();
54 function setLdapConfig(array $config);
59 private static $instance = NULL;
62 private function __construct($driver, $dns) {
63 $this->con
= new $driver($dns);
66 private function __clone() {}
68 static function getInstance($db = NULL, $dns = NULL) {
69 if (! self
::$instance) {
71 throw new Exception('Missing database driver');
72 switch (strtolower($db)) {
74 self
::$instance = new Persistens('SQLite', $dns); break;
77 self
::$instance = new Persistens('Pgsql', $dns); break;
79 default: throw new Exception("$db: Unsupported driver");
82 return self
::$instance;
85 function getViewStyle($uid) {
86 return $this->con
->getViewStyle($uid);
89 function getStartWeek($uid) {
90 return $this->con
->getStartWeek($uid);
93 function getStartHour($uid) {
94 return $this->con
->getStartHour($uid);
97 function getEndHour($uid) {
98 return $this->con
->getEndHour($uid);
101 function authenticate($uid, $pwd) {
102 return $this->con
->authenticate($uid, sha1($pwd));
105 function getTimeout($uid) {
106 return $this->con
->getTimeout($uid);
109 function getRole($uid) {
110 return $this->con
->getRole($uid);
113 function createDatabase($name) {
114 $this->con
->createDatabase($name);
117 function initDatabase($name, $pwd, $uid = 'webcal') {
118 $this->con
->initDatabase($name, $pwd, $uid = 'webcal');
120 self
::$instance = NULL;
123 function newUser($data) {
124 return $this->con
->addUser($data);
127 function setUserSettings($uid, $settings) {
128 return $this->con
->setUserSettings($uid, $settings);
131 function deleteUser($uid) {
132 return $this->con
->deleteUser($uid);
135 function addCalendar($uid, CalendarInfo
$calendar) {
136 return $this->con
->addCalendar($uid, $calendar);
139 function deleteCalendar($uid, $id) {
140 return $this->con
->deleteCalendar($uid, $id);
143 function updateCalendar($uid, $id, CalendarInfo
$calendar) {
144 return $this->con
->updateCalendar($uid, $id, $calendar);
147 function changePassword($uid, $pwd) {
148 return $this->con
->changePassword($uid, $pwd);
151 function getAllUsers($limit = -1, $offset = 0) {
152 return $this->con
->getAllUsers($limit, $offset);
155 function getRoles() {
156 return $this->con
->getRoles();
159 function getRoleName($id) {
160 return $this->con
->getRoleName($id);
163 function changeDefault($data) {
164 return $this->con
->changeDefault($data);
167 function getVersion() {
168 $res = $this->con
->getVersion();
169 if (! is_array($res))
170 throw new Exception($res);
174 function execute($sql) {
175 return $this->con
->execute($sql);
178 function getCalendarConfig($id = -1) {
179 return $this->con
->getCalendarConfig($id);
182 function nextTableNumber($name) {
183 return $this->con
->nextTableNumber($name);
186 function getLdapConfig() {
187 return $this->con
->getLdapConfig();
190 function setLdapConfig(array $config) {
191 return $this->con
->setLdapConfig($config);
This page took 0.075303 seconds and 6 git commands to generate.