1: <?php
2: /**
3: * This class represents the Kolab user database behind the free/busy system.
4: *
5: * PHP version 5
6: *
7: * @category Kolab
8: * @package Kolab_FreeBusy
9: * @author Gunnar Wrobel <wrobel@pardus.de>
10: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
11: * @link http://pear.horde.org/index.php?package=Kolab_FreeBusy
12: */
13:
14: /**
15: * This class represents the Kolab user database behind the free/busy system.
16: *
17: * Copyright 2010 Kolab Systems AG
18: *
19: * See the enclosed file COPYING for license information (LGPL). If you did not
20: * receive this file, see
21: * http://www.horde.org/licenses/lgpl21.
22: *
23: * @category Kolab
24: * @package Kolab_FreeBusy
25: * @author Gunnar Wrobel <wrobel@pardus.de>
26: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
27: * @link http://pear.horde.org/index.php?package=Kolab_FreeBusy
28: */
29: class Horde_Kolab_FreeBusy_UserDb_Kolab
30: implements Horde_Kolab_FreeBusy_UserDb
31: {
32: /**
33: * The kolab user database connection.
34: *
35: * @var Horde_Kolab_Server_Composite
36: */
37: protected $_db;
38:
39: /**
40: * Constructor.
41: *
42: * @param Horde_Kolab_Server_Composite $db The connection to the Kolab user
43: * database.
44: */
45: public function __construct(Horde_Kolab_Server_Composite $db)
46: {
47: $this->_db = $db;
48: }
49:
50: /**
51: * Fetch an user representation from the user database.
52: *
53: * @param string $user The user name.
54: * @param string $pass An optional user password.
55: *
56: * @return Horde_Kolab_FreeBusy_User The user representation.
57: */
58: public function getUser($user, $pass = null)
59: {
60: if (!empty($user)) {
61: try {
62: return new Horde_Kolab_FreeBusy_User_Kolab(
63: $user, $this->_db, $pass
64: );
65: } catch (Horde_Kolab_FreeBusy_Exception $e) {
66: return new Horde_Kolab_FreeBusy_User_Anonymous();
67: }
68: } else {
69: return new Horde_Kolab_FreeBusy_User_Anonymous();
70: }
71: }
72:
73: /**
74: * Fetch an owner representation from the user database.
75: *
76: * @param string $owner The owner name.
77: * @param array $params Additonal parameters.
78: *
79: * @return Horde_Kolab_FreeBusy_Owner The owner representation.
80: */
81: public function getOwner($owner, $params = array())
82: {
83: return new Horde_Kolab_FreeBusy_Owner_Kolab(
84: $owner, $this->_db, $params
85: );
86: }
87: }
88: