Completed
Push — master ( 49662f...f67d94 )
by Joas
99:38 queued 81:58
created
lib/private/ContactsManager.php 1 patch
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -27,164 +27,164 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
lib/private/NaturalSort_DefaultCollator.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -25,14 +25,14 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
lib/private/Command/CallableJob.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -25,12 +25,12 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
lib/private/Command/ClosureJob.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -26,13 +26,13 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
lib/private/Command/FileAccess.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -25,12 +25,12 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
lib/private/Command/CommandJob.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,12 +29,12 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
lib/private/Template/ResourceNotFoundException.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -24,23 +24,23 @@
 block discarded – undo
24 24
 namespace OC\Template;
25 25
 
26 26
 class ResourceNotFoundException extends \LogicException {
27
-	protected $resource;
28
-	protected $webPath;
27
+    protected $resource;
28
+    protected $webPath;
29 29
 
30
-	/**
31
-	 * @param string $resource
32
-	 * @param string $webPath
33
-	 */
34
-	public function __construct($resource, $webPath) {
35
-		parent::__construct('Resource not found');
36
-		$this->resource = $resource;
37
-		$this->webPath = $webPath;
38
-	}
30
+    /**
31
+     * @param string $resource
32
+     * @param string $webPath
33
+     */
34
+    public function __construct($resource, $webPath) {
35
+        parent::__construct('Resource not found');
36
+        $this->resource = $resource;
37
+        $this->webPath = $webPath;
38
+    }
39 39
 
40
-	/**
41
-	 * @return string
42
-	 */
43
-	public function getResourcePath() {
44
-		return $this->webPath . '/' . $this->resource;
45
-	}
40
+    /**
41
+     * @return string
42
+     */
43
+    public function getResourcePath() {
44
+        return $this->webPath . '/' . $this->resource;
45
+    }
46 46
 }
Please login to merge, or discard this patch.
lib/private/Template/TemplateFileLocator.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -26,37 +26,37 @@
 block discarded – undo
26 26
 namespace OC\Template;
27 27
 
28 28
 class TemplateFileLocator {
29
-	protected $dirs;
30
-	private $path;
29
+    protected $dirs;
30
+    private $path;
31 31
 
32
-	/**
33
-	 * @param string[] $dirs
34
-	 */
35
-	public function __construct( $dirs ) {
36
-		$this->dirs = $dirs;
37
-	}
32
+    /**
33
+     * @param string[] $dirs
34
+     */
35
+    public function __construct( $dirs ) {
36
+        $this->dirs = $dirs;
37
+    }
38 38
 
39
-	/**
40
-	 * @param string $template
41
-	 * @return string
42
-	 * @throws \Exception
43
-	 */
44
-	public function find( $template ) {
45
-		if ($template === '') {
46
-			throw new \InvalidArgumentException('Empty template name');
47
-		}
39
+    /**
40
+     * @param string $template
41
+     * @return string
42
+     * @throws \Exception
43
+     */
44
+    public function find( $template ) {
45
+        if ($template === '') {
46
+            throw new \InvalidArgumentException('Empty template name');
47
+        }
48 48
 
49
-		foreach($this->dirs as $dir) {
50
-			$file = $dir.$template.'.php';
51
-			if (is_file($file)) {
52
-				$this->path = $dir;
53
-				return $file;
54
-			}
55
-		}
56
-		throw new \Exception('template file not found: template:'.$template);
57
-	}
49
+        foreach($this->dirs as $dir) {
50
+            $file = $dir.$template.'.php';
51
+            if (is_file($file)) {
52
+                $this->path = $dir;
53
+                return $file;
54
+            }
55
+        }
56
+        throw new \Exception('template file not found: template:'.$template);
57
+    }
58 58
 
59
-	public function getPath() {
60
-		return $this->path;
61
-	}
59
+    public function getPath() {
60
+        return $this->path;
61
+    }
62 62
 }
Please login to merge, or discard this patch.
lib/private/Hooks/BasicEmitter.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,5 +24,5 @@
 block discarded – undo
24 24
 namespace OC\Hooks;
25 25
 
26 26
 abstract class BasicEmitter implements Emitter {
27
-	use EmitterTrait;
27
+    use EmitterTrait;
28 28
 }
Please login to merge, or discard this patch.