1: <?php
2: /**
3: * The Kolab implementation of the free/busy system.
4: *
5: * PHP version 5
6: *
7: * @category Kolab
8: * @package Kolab_FreeBusy
9: * @author Steffen Hansen <steffen@klaralvdalens-datakonsult.se>
10: * @author Gunnar Wrobel <wrobel@pardus.de>
11: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
12: * @link http://pear.horde.org/index.php?package=Kolab_FreeBusy
13: */
14:
15: /**
16: * The Horde_Kolab_FreeBusy class serves as Registry aka ServiceLocator for the
17: * Free/Busy application. It also provides the entry point into the the Horde
18: * MVC system and allows to dispatch a request.
19: *
20: * Copyright 2009-2012 Horde LLC (http://www.horde.org/)
21: *
22: * See the enclosed file COPYING for license information (LGPL). If you did not
23: * receive this file, see
24: * http://www.horde.org/licenses/lgpl21.
25: *
26: * @category Kolab
27: * @package Kolab_FreeBusy
28: * @author Steffen Hansen <steffen@klaralvdalens-datakonsult.se>
29: * @author Gunnar Wrobel <wrobel@pardus.de>
30: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
31: * @link http://pear.horde.org/index.php?package=Kolab_FreeBusy
32: */
33: class Horde_Kolab_FreeBusy_Driver_Base
34: {
35: /**
36: * The logging handler.
37: *
38: * @var Horde_Log_Logger
39: */
40: protected $logger;
41:
42: /**
43: * Constructor.
44: *
45: * @param array $params Any additional options
46: */
47: public function __construct($callee = null, $callee_part = null,
48: $logger = null)
49: {
50:
51: if (!empty($callee)) {
52: list($this->callee, $this->remote) = $this->handleCallee($callee);
53: }
54: if (!empty($callee_part)) {
55: list($this->callee, $this->remote, $this->part) = $this->handleCallee($callee_part);
56: }
57:
58: $this->logger = $logger;
59: }
60:
61: /**
62: * Create a new driver.
63: *
64: * @param Horde_Provider $provider The instance providing required
65: * dependencies.
66: *
67: * @return Horde_Kolab_FreeBusy_Driver_Base The new driver.
68: */
69: static public function factory($provider)
70: {
71: $class = 'Horde_Kolab_FreeBusy_Driver_Freebusy_Kolab';
72: $callee = isset($provider->callee) ? $provider->callee : null;
73: $callee_part = isset($provider->callee_part) ? $provider->callee_part : null;
74: $driver = new $class($callee, $callee_part, $provider->logger);
75: return $driver;
76: }
77:
78: /**
79: * Check if we are in an authenticated situation.
80: *
81: * @return boolean|PEAR_Error True if successful.
82: */
83: public function authenticated()
84: {
85: global $conf;
86:
87: if (empty($this->user)) {
88: header('WWW-Authenticate: Basic realm="Kolab Freebusy"');
89: return PEAR::raiseError(Horde_Kolab_FreeBusy_Translation::t("Please authenticate!"));
90: }
91:
92: if (!$this->_authenticated) {
93: return PEAR::raiseError(sprintf(Horde_Kolab_FreeBusy_Translation::t("Invalid authentication for user %s!"),
94: $this->user));
95: }
96: return true;
97: }
98:
99: /**
100: * Fetch the data.
101: *
102: * @params array $params Additional options.
103: *
104: * @return array The fetched data.
105: */
106: //abstract public function fetch($params = array());
107: }
108: