@@ -26,79 +26,79 @@ |
||
26 | 26 | use OCP\Diagnostics\IEvent; |
27 | 27 | |
28 | 28 | class Event implements IEvent { |
29 | - /** |
|
30 | - * @var string |
|
31 | - */ |
|
32 | - protected $id; |
|
29 | + /** |
|
30 | + * @var string |
|
31 | + */ |
|
32 | + protected $id; |
|
33 | 33 | |
34 | - /** |
|
35 | - * @var float |
|
36 | - */ |
|
37 | - protected $start; |
|
34 | + /** |
|
35 | + * @var float |
|
36 | + */ |
|
37 | + protected $start; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @var float |
|
41 | - */ |
|
42 | - protected $end; |
|
39 | + /** |
|
40 | + * @var float |
|
41 | + */ |
|
42 | + protected $end; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @var string |
|
46 | - */ |
|
47 | - protected $description; |
|
44 | + /** |
|
45 | + * @var string |
|
46 | + */ |
|
47 | + protected $description; |
|
48 | 48 | |
49 | - /** |
|
50 | - * @param string $id |
|
51 | - * @param string $description |
|
52 | - * @param float $start |
|
53 | - */ |
|
54 | - public function __construct($id, $description, $start) { |
|
55 | - $this->id = $id; |
|
56 | - $this->description = $description; |
|
57 | - $this->start = $start; |
|
58 | - } |
|
49 | + /** |
|
50 | + * @param string $id |
|
51 | + * @param string $description |
|
52 | + * @param float $start |
|
53 | + */ |
|
54 | + public function __construct($id, $description, $start) { |
|
55 | + $this->id = $id; |
|
56 | + $this->description = $description; |
|
57 | + $this->start = $start; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @param float $time |
|
62 | - */ |
|
63 | - public function end($time) { |
|
64 | - $this->end = $time; |
|
65 | - } |
|
60 | + /** |
|
61 | + * @param float $time |
|
62 | + */ |
|
63 | + public function end($time) { |
|
64 | + $this->end = $time; |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * @return float |
|
69 | - */ |
|
70 | - public function getStart() { |
|
71 | - return $this->start; |
|
72 | - } |
|
67 | + /** |
|
68 | + * @return float |
|
69 | + */ |
|
70 | + public function getStart() { |
|
71 | + return $this->start; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return string |
|
76 | - */ |
|
77 | - public function getId() { |
|
78 | - return $this->id; |
|
79 | - } |
|
74 | + /** |
|
75 | + * @return string |
|
76 | + */ |
|
77 | + public function getId() { |
|
78 | + return $this->id; |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * @return string |
|
83 | - */ |
|
84 | - public function getDescription() { |
|
85 | - return $this->description; |
|
86 | - } |
|
81 | + /** |
|
82 | + * @return string |
|
83 | + */ |
|
84 | + public function getDescription() { |
|
85 | + return $this->description; |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * @return float |
|
90 | - */ |
|
91 | - public function getEnd() { |
|
92 | - return $this->end; |
|
93 | - } |
|
88 | + /** |
|
89 | + * @return float |
|
90 | + */ |
|
91 | + public function getEnd() { |
|
92 | + return $this->end; |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * @return float |
|
97 | - */ |
|
98 | - public function getDuration() { |
|
99 | - if (!$this->end) { |
|
100 | - $this->end = microtime(true); |
|
101 | - } |
|
102 | - return $this->end - $this->start; |
|
103 | - } |
|
95 | + /** |
|
96 | + * @return float |
|
97 | + */ |
|
98 | + public function getDuration() { |
|
99 | + if (!$this->end) { |
|
100 | + $this->end = microtime(true); |
|
101 | + } |
|
102 | + return $this->end - $this->start; |
|
103 | + } |
|
104 | 104 | } |
@@ -37,54 +37,54 @@ |
||
37 | 37 | */ |
38 | 38 | class Tag extends Entity { |
39 | 39 | |
40 | - protected $owner; |
|
41 | - protected $type; |
|
42 | - protected $name; |
|
40 | + protected $owner; |
|
41 | + protected $type; |
|
42 | + protected $name; |
|
43 | 43 | |
44 | - /** |
|
45 | - * Constructor. |
|
46 | - * |
|
47 | - * @param string $owner The tag's owner |
|
48 | - * @param string $type The type of item this tag is used for |
|
49 | - * @param string $name The tag's name |
|
50 | - */ |
|
51 | - public function __construct($owner = null, $type = null, $name = null) { |
|
52 | - $this->setOwner($owner); |
|
53 | - $this->setType($type); |
|
54 | - $this->setName($name); |
|
55 | - } |
|
44 | + /** |
|
45 | + * Constructor. |
|
46 | + * |
|
47 | + * @param string $owner The tag's owner |
|
48 | + * @param string $type The type of item this tag is used for |
|
49 | + * @param string $name The tag's name |
|
50 | + */ |
|
51 | + public function __construct($owner = null, $type = null, $name = null) { |
|
52 | + $this->setOwner($owner); |
|
53 | + $this->setType($type); |
|
54 | + $this->setName($name); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Transform a database columnname to a property |
|
59 | - * |
|
60 | - * @param string $columnName the name of the column |
|
61 | - * @return string the property name |
|
62 | - * @todo migrate existing database columns to the correct names |
|
63 | - * to be able to drop this direct mapping |
|
64 | - */ |
|
65 | - public function columnToProperty($columnName){ |
|
66 | - if ($columnName === 'category') { |
|
67 | - return 'name'; |
|
68 | - } elseif ($columnName === 'uid') { |
|
69 | - return 'owner'; |
|
70 | - } else { |
|
71 | - return parent::columnToProperty($columnName); |
|
72 | - } |
|
73 | - } |
|
57 | + /** |
|
58 | + * Transform a database columnname to a property |
|
59 | + * |
|
60 | + * @param string $columnName the name of the column |
|
61 | + * @return string the property name |
|
62 | + * @todo migrate existing database columns to the correct names |
|
63 | + * to be able to drop this direct mapping |
|
64 | + */ |
|
65 | + public function columnToProperty($columnName){ |
|
66 | + if ($columnName === 'category') { |
|
67 | + return 'name'; |
|
68 | + } elseif ($columnName === 'uid') { |
|
69 | + return 'owner'; |
|
70 | + } else { |
|
71 | + return parent::columnToProperty($columnName); |
|
72 | + } |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * Transform a property to a database column name |
|
77 | - * |
|
78 | - * @param string $property the name of the property |
|
79 | - * @return string the column name |
|
80 | - */ |
|
81 | - public function propertyToColumn($property){ |
|
82 | - if ($property === 'name') { |
|
83 | - return 'category'; |
|
84 | - } elseif ($property === 'owner') { |
|
85 | - return 'uid'; |
|
86 | - } else { |
|
87 | - return parent::propertyToColumn($property); |
|
88 | - } |
|
89 | - } |
|
75 | + /** |
|
76 | + * Transform a property to a database column name |
|
77 | + * |
|
78 | + * @param string $property the name of the property |
|
79 | + * @return string the column name |
|
80 | + */ |
|
81 | + public function propertyToColumn($property){ |
|
82 | + if ($property === 'name') { |
|
83 | + return 'category'; |
|
84 | + } elseif ($property === 'owner') { |
|
85 | + return 'uid'; |
|
86 | + } else { |
|
87 | + return parent::propertyToColumn($property); |
|
88 | + } |
|
89 | + } |
|
90 | 90 | } |
@@ -40,53 +40,53 @@ |
||
40 | 40 | |
41 | 41 | class TagManager implements \OCP\ITagManager { |
42 | 42 | |
43 | - /** |
|
44 | - * User session |
|
45 | - * |
|
46 | - * @var \OCP\IUserSession |
|
47 | - */ |
|
48 | - private $userSession; |
|
43 | + /** |
|
44 | + * User session |
|
45 | + * |
|
46 | + * @var \OCP\IUserSession |
|
47 | + */ |
|
48 | + private $userSession; |
|
49 | 49 | |
50 | - /** |
|
51 | - * TagMapper |
|
52 | - * |
|
53 | - * @var TagMapper |
|
54 | - */ |
|
55 | - private $mapper; |
|
50 | + /** |
|
51 | + * TagMapper |
|
52 | + * |
|
53 | + * @var TagMapper |
|
54 | + */ |
|
55 | + private $mapper; |
|
56 | 56 | |
57 | - /** |
|
58 | - * Constructor. |
|
59 | - * |
|
60 | - * @param TagMapper $mapper Instance of the TagMapper abstraction layer. |
|
61 | - * @param \OCP\IUserSession $userSession the user session |
|
62 | - */ |
|
63 | - public function __construct(TagMapper $mapper, \OCP\IUserSession $userSession) { |
|
64 | - $this->mapper = $mapper; |
|
65 | - $this->userSession = $userSession; |
|
57 | + /** |
|
58 | + * Constructor. |
|
59 | + * |
|
60 | + * @param TagMapper $mapper Instance of the TagMapper abstraction layer. |
|
61 | + * @param \OCP\IUserSession $userSession the user session |
|
62 | + */ |
|
63 | + public function __construct(TagMapper $mapper, \OCP\IUserSession $userSession) { |
|
64 | + $this->mapper = $mapper; |
|
65 | + $this->userSession = $userSession; |
|
66 | 66 | |
67 | - } |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * Create a new \OCP\ITags instance and load tags from db. |
|
71 | - * |
|
72 | - * @see \OCP\ITags |
|
73 | - * @param string $type The type identifier e.g. 'contact' or 'event'. |
|
74 | - * @param array $defaultTags An array of default tags to be used if none are stored. |
|
75 | - * @param boolean $includeShared Whether to include tags for items shared with this user by others. |
|
76 | - * @param string $userId user for which to retrieve the tags, defaults to the currently |
|
77 | - * logged in user |
|
78 | - * @return \OCP\ITags |
|
79 | - */ |
|
80 | - public function load($type, $defaultTags = array(), $includeShared = false, $userId = null) { |
|
81 | - if (is_null($userId)) { |
|
82 | - $user = $this->userSession->getUser(); |
|
83 | - if ($user === null) { |
|
84 | - // nothing we can do without a user |
|
85 | - return null; |
|
86 | - } |
|
87 | - $userId = $this->userSession->getUser()->getUId(); |
|
88 | - } |
|
89 | - return new Tags($this->mapper, $userId, $type, $defaultTags, $includeShared); |
|
90 | - } |
|
69 | + /** |
|
70 | + * Create a new \OCP\ITags instance and load tags from db. |
|
71 | + * |
|
72 | + * @see \OCP\ITags |
|
73 | + * @param string $type The type identifier e.g. 'contact' or 'event'. |
|
74 | + * @param array $defaultTags An array of default tags to be used if none are stored. |
|
75 | + * @param boolean $includeShared Whether to include tags for items shared with this user by others. |
|
76 | + * @param string $userId user for which to retrieve the tags, defaults to the currently |
|
77 | + * logged in user |
|
78 | + * @return \OCP\ITags |
|
79 | + */ |
|
80 | + public function load($type, $defaultTags = array(), $includeShared = false, $userId = null) { |
|
81 | + if (is_null($userId)) { |
|
82 | + $user = $this->userSession->getUser(); |
|
83 | + if ($user === null) { |
|
84 | + // nothing we can do without a user |
|
85 | + return null; |
|
86 | + } |
|
87 | + $userId = $this->userSession->getUser()->getUId(); |
|
88 | + } |
|
89 | + return new Tags($this->mapper, $userId, $type, $defaultTags, $includeShared); |
|
90 | + } |
|
91 | 91 | |
92 | 92 | } |
@@ -27,164 +27,164 @@ |
||
27 | 27 | |
28 | 28 | namespace OC { |
29 | 29 | |
30 | - class ContactsManager implements \OCP\Contacts\IManager { |
|
31 | - |
|
32 | - /** |
|
33 | - * This function is used to search and find contacts within the users address books. |
|
34 | - * In case $pattern is empty all contacts will be returned. |
|
35 | - * |
|
36 | - * @param string $pattern which should match within the $searchProperties |
|
37 | - * @param array $searchProperties defines the properties within the query pattern should match |
|
38 | - * @param array $options - for future use. One should always have options! |
|
39 | - * @return array an array of contacts which are arrays of key-value-pairs |
|
40 | - */ |
|
41 | - public function search($pattern, $searchProperties = array(), $options = array()) { |
|
42 | - $this->loadAddressBooks(); |
|
43 | - $result = array(); |
|
44 | - foreach($this->addressBooks as $addressBook) { |
|
45 | - $r = $addressBook->search($pattern, $searchProperties, $options); |
|
46 | - $contacts = array(); |
|
47 | - foreach($r as $c){ |
|
48 | - $c['addressbook-key'] = $addressBook->getKey(); |
|
49 | - $contacts[] = $c; |
|
50 | - } |
|
51 | - $result = array_merge($result, $contacts); |
|
52 | - } |
|
53 | - |
|
54 | - return $result; |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * This function can be used to delete the contact identified by the given id |
|
59 | - * |
|
60 | - * @param object $id the unique identifier to a contact |
|
61 | - * @param string $addressBookKey identifier of the address book in which the contact shall be deleted |
|
62 | - * @return bool successful or not |
|
63 | - */ |
|
64 | - public function delete($id, $addressBookKey) { |
|
65 | - $addressBook = $this->getAddressBook($addressBookKey); |
|
66 | - if (!$addressBook) { |
|
67 | - return null; |
|
68 | - } |
|
69 | - |
|
70 | - if ($addressBook->getPermissions() & \OCP\Constants::PERMISSION_DELETE) { |
|
71 | - return $addressBook->delete($id); |
|
72 | - } |
|
73 | - |
|
74 | - return null; |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * This function is used to create a new contact if 'id' is not given or not present. |
|
79 | - * Otherwise the contact will be updated by replacing the entire data set. |
|
80 | - * |
|
81 | - * @param array $properties this array if key-value-pairs defines a contact |
|
82 | - * @param string $addressBookKey identifier of the address book in which the contact shall be created or updated |
|
83 | - * @return array representing the contact just created or updated |
|
84 | - */ |
|
85 | - public function createOrUpdate($properties, $addressBookKey) { |
|
86 | - $addressBook = $this->getAddressBook($addressBookKey); |
|
87 | - if (!$addressBook) { |
|
88 | - return null; |
|
89 | - } |
|
90 | - |
|
91 | - if ($addressBook->getPermissions() & \OCP\Constants::PERMISSION_CREATE) { |
|
92 | - return $addressBook->createOrUpdate($properties); |
|
93 | - } |
|
94 | - |
|
95 | - return null; |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * Check if contacts are available (e.g. contacts app enabled) |
|
100 | - * |
|
101 | - * @return bool true if enabled, false if not |
|
102 | - */ |
|
103 | - public function isEnabled() { |
|
104 | - return !empty($this->addressBooks) || !empty($this->addressBookLoaders); |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * @param \OCP\IAddressBook $addressBook |
|
109 | - */ |
|
110 | - public function registerAddressBook(\OCP\IAddressBook $addressBook) { |
|
111 | - $this->addressBooks[$addressBook->getKey()] = $addressBook; |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * @param \OCP\IAddressBook $addressBook |
|
116 | - */ |
|
117 | - public function unregisterAddressBook(\OCP\IAddressBook $addressBook) { |
|
118 | - unset($this->addressBooks[$addressBook->getKey()]); |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * @return array |
|
123 | - */ |
|
124 | - public function getAddressBooks() { |
|
125 | - $this->loadAddressBooks(); |
|
126 | - $result = array(); |
|
127 | - foreach($this->addressBooks as $addressBook) { |
|
128 | - $result[$addressBook->getKey()] = $addressBook->getDisplayName(); |
|
129 | - } |
|
130 | - |
|
131 | - return $result; |
|
132 | - } |
|
133 | - |
|
134 | - /** |
|
135 | - * removes all registered address book instances |
|
136 | - */ |
|
137 | - public function clear() { |
|
138 | - $this->addressBooks = array(); |
|
139 | - $this->addressBookLoaders = array(); |
|
140 | - } |
|
141 | - |
|
142 | - /** |
|
143 | - * @var \OCP\IAddressBook[] which holds all registered address books |
|
144 | - */ |
|
145 | - private $addressBooks = array(); |
|
146 | - |
|
147 | - /** |
|
148 | - * @var \Closure[] to call to load/register address books |
|
149 | - */ |
|
150 | - private $addressBookLoaders = array(); |
|
151 | - |
|
152 | - /** |
|
153 | - * In order to improve lazy loading a closure can be registered which will be called in case |
|
154 | - * address books are actually requested |
|
155 | - * |
|
156 | - * @param \Closure $callable |
|
157 | - */ |
|
158 | - public function register(\Closure $callable) |
|
159 | - { |
|
160 | - $this->addressBookLoaders[] = $callable; |
|
161 | - } |
|
162 | - |
|
163 | - /** |
|
164 | - * Get (and load when needed) the address book for $key |
|
165 | - * |
|
166 | - * @param string $addressBookKey |
|
167 | - * @return \OCP\IAddressBook |
|
168 | - */ |
|
169 | - protected function getAddressBook($addressBookKey) |
|
170 | - { |
|
171 | - $this->loadAddressBooks(); |
|
172 | - if (!array_key_exists($addressBookKey, $this->addressBooks)) { |
|
173 | - return null; |
|
174 | - } |
|
175 | - |
|
176 | - return $this->addressBooks[$addressBookKey]; |
|
177 | - } |
|
178 | - |
|
179 | - /** |
|
180 | - * Load all address books registered with 'register' |
|
181 | - */ |
|
182 | - protected function loadAddressBooks() |
|
183 | - { |
|
184 | - foreach($this->addressBookLoaders as $callable) { |
|
185 | - $callable($this); |
|
186 | - } |
|
187 | - $this->addressBookLoaders = array(); |
|
188 | - } |
|
189 | - } |
|
30 | + class ContactsManager implements \OCP\Contacts\IManager { |
|
31 | + |
|
32 | + /** |
|
33 | + * This function is used to search and find contacts within the users address books. |
|
34 | + * In case $pattern is empty all contacts will be returned. |
|
35 | + * |
|
36 | + * @param string $pattern which should match within the $searchProperties |
|
37 | + * @param array $searchProperties defines the properties within the query pattern should match |
|
38 | + * @param array $options - for future use. One should always have options! |
|
39 | + * @return array an array of contacts which are arrays of key-value-pairs |
|
40 | + */ |
|
41 | + public function search($pattern, $searchProperties = array(), $options = array()) { |
|
42 | + $this->loadAddressBooks(); |
|
43 | + $result = array(); |
|
44 | + foreach($this->addressBooks as $addressBook) { |
|
45 | + $r = $addressBook->search($pattern, $searchProperties, $options); |
|
46 | + $contacts = array(); |
|
47 | + foreach($r as $c){ |
|
48 | + $c['addressbook-key'] = $addressBook->getKey(); |
|
49 | + $contacts[] = $c; |
|
50 | + } |
|
51 | + $result = array_merge($result, $contacts); |
|
52 | + } |
|
53 | + |
|
54 | + return $result; |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * This function can be used to delete the contact identified by the given id |
|
59 | + * |
|
60 | + * @param object $id the unique identifier to a contact |
|
61 | + * @param string $addressBookKey identifier of the address book in which the contact shall be deleted |
|
62 | + * @return bool successful or not |
|
63 | + */ |
|
64 | + public function delete($id, $addressBookKey) { |
|
65 | + $addressBook = $this->getAddressBook($addressBookKey); |
|
66 | + if (!$addressBook) { |
|
67 | + return null; |
|
68 | + } |
|
69 | + |
|
70 | + if ($addressBook->getPermissions() & \OCP\Constants::PERMISSION_DELETE) { |
|
71 | + return $addressBook->delete($id); |
|
72 | + } |
|
73 | + |
|
74 | + return null; |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * This function is used to create a new contact if 'id' is not given or not present. |
|
79 | + * Otherwise the contact will be updated by replacing the entire data set. |
|
80 | + * |
|
81 | + * @param array $properties this array if key-value-pairs defines a contact |
|
82 | + * @param string $addressBookKey identifier of the address book in which the contact shall be created or updated |
|
83 | + * @return array representing the contact just created or updated |
|
84 | + */ |
|
85 | + public function createOrUpdate($properties, $addressBookKey) { |
|
86 | + $addressBook = $this->getAddressBook($addressBookKey); |
|
87 | + if (!$addressBook) { |
|
88 | + return null; |
|
89 | + } |
|
90 | + |
|
91 | + if ($addressBook->getPermissions() & \OCP\Constants::PERMISSION_CREATE) { |
|
92 | + return $addressBook->createOrUpdate($properties); |
|
93 | + } |
|
94 | + |
|
95 | + return null; |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * Check if contacts are available (e.g. contacts app enabled) |
|
100 | + * |
|
101 | + * @return bool true if enabled, false if not |
|
102 | + */ |
|
103 | + public function isEnabled() { |
|
104 | + return !empty($this->addressBooks) || !empty($this->addressBookLoaders); |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * @param \OCP\IAddressBook $addressBook |
|
109 | + */ |
|
110 | + public function registerAddressBook(\OCP\IAddressBook $addressBook) { |
|
111 | + $this->addressBooks[$addressBook->getKey()] = $addressBook; |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * @param \OCP\IAddressBook $addressBook |
|
116 | + */ |
|
117 | + public function unregisterAddressBook(\OCP\IAddressBook $addressBook) { |
|
118 | + unset($this->addressBooks[$addressBook->getKey()]); |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * @return array |
|
123 | + */ |
|
124 | + public function getAddressBooks() { |
|
125 | + $this->loadAddressBooks(); |
|
126 | + $result = array(); |
|
127 | + foreach($this->addressBooks as $addressBook) { |
|
128 | + $result[$addressBook->getKey()] = $addressBook->getDisplayName(); |
|
129 | + } |
|
130 | + |
|
131 | + return $result; |
|
132 | + } |
|
133 | + |
|
134 | + /** |
|
135 | + * removes all registered address book instances |
|
136 | + */ |
|
137 | + public function clear() { |
|
138 | + $this->addressBooks = array(); |
|
139 | + $this->addressBookLoaders = array(); |
|
140 | + } |
|
141 | + |
|
142 | + /** |
|
143 | + * @var \OCP\IAddressBook[] which holds all registered address books |
|
144 | + */ |
|
145 | + private $addressBooks = array(); |
|
146 | + |
|
147 | + /** |
|
148 | + * @var \Closure[] to call to load/register address books |
|
149 | + */ |
|
150 | + private $addressBookLoaders = array(); |
|
151 | + |
|
152 | + /** |
|
153 | + * In order to improve lazy loading a closure can be registered which will be called in case |
|
154 | + * address books are actually requested |
|
155 | + * |
|
156 | + * @param \Closure $callable |
|
157 | + */ |
|
158 | + public function register(\Closure $callable) |
|
159 | + { |
|
160 | + $this->addressBookLoaders[] = $callable; |
|
161 | + } |
|
162 | + |
|
163 | + /** |
|
164 | + * Get (and load when needed) the address book for $key |
|
165 | + * |
|
166 | + * @param string $addressBookKey |
|
167 | + * @return \OCP\IAddressBook |
|
168 | + */ |
|
169 | + protected function getAddressBook($addressBookKey) |
|
170 | + { |
|
171 | + $this->loadAddressBooks(); |
|
172 | + if (!array_key_exists($addressBookKey, $this->addressBooks)) { |
|
173 | + return null; |
|
174 | + } |
|
175 | + |
|
176 | + return $this->addressBooks[$addressBookKey]; |
|
177 | + } |
|
178 | + |
|
179 | + /** |
|
180 | + * Load all address books registered with 'register' |
|
181 | + */ |
|
182 | + protected function loadAddressBooks() |
|
183 | + { |
|
184 | + foreach($this->addressBookLoaders as $callable) { |
|
185 | + $callable($this); |
|
186 | + } |
|
187 | + $this->addressBookLoaders = array(); |
|
188 | + } |
|
189 | + } |
|
190 | 190 | } |
@@ -25,14 +25,14 @@ |
||
25 | 25 | namespace OC; |
26 | 26 | |
27 | 27 | class NaturalSort_DefaultCollator { |
28 | - public function compare($a, $b) { |
|
29 | - $result = strcasecmp($a, $b); |
|
30 | - if ($result === 0) { |
|
31 | - if ($a === $b) { |
|
32 | - return 0; |
|
33 | - } |
|
34 | - return ($a > $b) ? -1 : 1; |
|
35 | - } |
|
36 | - return ($result < 0) ? -1 : 1; |
|
37 | - } |
|
28 | + public function compare($a, $b) { |
|
29 | + $result = strcasecmp($a, $b); |
|
30 | + if ($result === 0) { |
|
31 | + if ($a === $b) { |
|
32 | + return 0; |
|
33 | + } |
|
34 | + return ($a > $b) ? -1 : 1; |
|
35 | + } |
|
36 | + return ($result < 0) ? -1 : 1; |
|
37 | + } |
|
38 | 38 | } |
@@ -25,12 +25,12 @@ |
||
25 | 25 | use OC\BackgroundJob\QueuedJob; |
26 | 26 | |
27 | 27 | class CallableJob extends QueuedJob { |
28 | - protected function run($serializedCallable) { |
|
29 | - $callable = unserialize($serializedCallable); |
|
30 | - if (is_callable($callable)) { |
|
31 | - $callable(); |
|
32 | - } else { |
|
33 | - throw new \InvalidArgumentException('Invalid serialized callable'); |
|
34 | - } |
|
35 | - } |
|
28 | + protected function run($serializedCallable) { |
|
29 | + $callable = unserialize($serializedCallable); |
|
30 | + if (is_callable($callable)) { |
|
31 | + $callable(); |
|
32 | + } else { |
|
33 | + throw new \InvalidArgumentException('Invalid serialized callable'); |
|
34 | + } |
|
35 | + } |
|
36 | 36 | } |
@@ -26,13 +26,13 @@ |
||
26 | 26 | use SuperClosure\Serializer; |
27 | 27 | |
28 | 28 | class ClosureJob extends QueuedJob { |
29 | - protected function run($serializedCallable) { |
|
30 | - $serializer = new Serializer(); |
|
31 | - $callable = $serializer->unserialize($serializedCallable); |
|
32 | - if (is_callable($callable)) { |
|
33 | - $callable(); |
|
34 | - } else { |
|
35 | - throw new \InvalidArgumentException('Invalid serialized callable'); |
|
36 | - } |
|
37 | - } |
|
29 | + protected function run($serializedCallable) { |
|
30 | + $serializer = new Serializer(); |
|
31 | + $callable = $serializer->unserialize($serializedCallable); |
|
32 | + if (is_callable($callable)) { |
|
33 | + $callable(); |
|
34 | + } else { |
|
35 | + throw new \InvalidArgumentException('Invalid serialized callable'); |
|
36 | + } |
|
37 | + } |
|
38 | 38 | } |
@@ -25,12 +25,12 @@ |
||
25 | 25 | use OCP\IUser; |
26 | 26 | |
27 | 27 | trait FileAccess { |
28 | - protected function setupFS(IUser $user){ |
|
29 | - \OC_Util::setupFS($user->getUID()); |
|
30 | - } |
|
28 | + protected function setupFS(IUser $user){ |
|
29 | + \OC_Util::setupFS($user->getUID()); |
|
30 | + } |
|
31 | 31 | |
32 | - protected function getUserFolder(IUser $user) { |
|
33 | - $this->setupFS($user); |
|
34 | - return \OC::$server->getUserFolder($user->getUID()); |
|
35 | - } |
|
32 | + protected function getUserFolder(IUser $user) { |
|
33 | + $this->setupFS($user); |
|
34 | + return \OC::$server->getUserFolder($user->getUID()); |
|
35 | + } |
|
36 | 36 | } |
@@ -29,12 +29,12 @@ |
||
29 | 29 | * Wrap a command in the background job interface |
30 | 30 | */ |
31 | 31 | class CommandJob extends QueuedJob { |
32 | - protected function run($serializedCommand) { |
|
33 | - $command = unserialize($serializedCommand); |
|
34 | - if ($command instanceof ICommand) { |
|
35 | - $command->handle(); |
|
36 | - } else { |
|
37 | - throw new \InvalidArgumentException('Invalid serialized command'); |
|
38 | - } |
|
39 | - } |
|
32 | + protected function run($serializedCommand) { |
|
33 | + $command = unserialize($serializedCommand); |
|
34 | + if ($command instanceof ICommand) { |
|
35 | + $command->handle(); |
|
36 | + } else { |
|
37 | + throw new \InvalidArgumentException('Invalid serialized command'); |
|
38 | + } |
|
39 | + } |
|
40 | 40 | } |