1: <?php
2: /**
3: * A shared IMAP folder.
4: *
5: * PHP version 5
6: *
7: * @category Kolab
8: * @package Kolab_Server
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_Server
12: */
13:
14: /**
15: * This class provides methods to deal with shared folders
16: * entries for Kolab.
17: *
18: * Copyright 2008-2012 Horde LLC (http://www.horde.org/)
19: *
20: * See the enclosed file COPYING for license information (LGPL). If you
21: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
22: *
23: * @category Kolab
24: * @package Kolab_Server
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_Server
28: */
29: class Horde_Kolab_Server_Object_Kolabsharedfolder extends Horde_Kolab_Server_Object_Top
30: {
31: /** Define attributes specific to this object type */
32:
33: /** The common name */
34: const ATTRIBUTE_CN = 'cn';
35:
36: /** The type of this folder */
37: const ATTRIBUTE_FOLDERTYPE = 'kolabFolderType';
38:
39: /** The home server of this folder */
40: const ATTRIBUTE_HOMESERVER = 'kolabHomeServer';
41:
42: /** The specific object class of this object type */
43: const OBJECTCLASS_KOLABSHAREDFOLDER = 'kolabSharedFolder';
44:
45: /**
46: * A structure to initialize the attribute structure for this class.
47: *
48: * @var array
49: */
50: static public $init_attributes = array(
51: 'defined' => array(
52: self::ATTRIBUTE_CN,
53: self::ATTRIBUTE_HOMESERVER,
54: ),
55: 'required' => array(
56: self::ATTRIBUTE_CN,
57: ),
58: 'object_classes' => array(
59: self::OBJECTCLASS_KOLABSHAREDFOLDER,
60: ),
61: );
62:
63: /**
64: * Return the filter string to retrieve this object type.
65: *
66: * @return string The filter to retrieve this object type from the server
67: * database.
68: */
69: public static function getFilter()
70: {
71: $criteria = array('AND' => array(array('field' => self::ATTRIBUTE_OC,
72: 'op' => '=',
73: 'test' => self::OBJECTCLASS_KOLABSHAREDFOLDER),
74: ),
75: );
76: return $criteria;
77: }
78:
79: /**
80: * Generates an ID for the given information.
81: *
82: * @param array &$info The data of the object.
83: *
84: * @static
85: *
86: * @return string|PEAR_Error The ID.
87: */
88: public function generateId(array &$info)
89: {
90: return self::ATTRIBUTE_CN . '=' . $this->server->structure->quoteForUid(trim($info['cn'], " \t\n\r\0\x0B,"));
91: }
92:
93: /**
94: * Convert the object attributes to a hash.
95: *
96: * @param string $attrs The attributes to return.
97: *
98: * @return array|PEAR_Error The hash representing this object.
99: */
100: public function toHash($attrs = null)
101: {
102: if (!isset($attrs)) {
103: $attrs = array(
104: self::ATTRIBUTE_CN,
105: self::ATTRIBUTE_HOMESERVER,
106: self::ATTRIBUTE_FOLDERTYPE,
107: );
108: }
109: return parent::toHash($attrs);
110: }
111: }
112: