Passed
Push — master ( 730af0...3b14ce )
by Roeland
12:25 queued 11s
created
apps/user_ldap/lib/GroupPluginManager.php 1 patch
Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -27,143 +27,143 @@
 block discarded – undo
27 27
 
28 28
 class GroupPluginManager {
29 29
 
30
-	private $respondToActions = 0;
31
-
32
-	private $which = array(
33
-		GroupInterface::CREATE_GROUP => null,
34
-		GroupInterface::DELETE_GROUP => null,
35
-		GroupInterface::ADD_TO_GROUP => null,
36
-		GroupInterface::REMOVE_FROM_GROUP => null,
37
-		GroupInterface::COUNT_USERS => null,
38
-		GroupInterface::GROUP_DETAILS => null
39
-	);
40
-
41
-	/**
42
-	 * @return int All implemented actions
43
-	 */
44
-	public function getImplementedActions() {
45
-		return $this->respondToActions;
46
-	}
47
-
48
-	/**
49
-	 * Registers a group plugin that may implement some actions, overriding User_LDAP's group actions.
50
-	 * @param ILDAPGroupPlugin $plugin
51
-	 */
52
-	public function register(ILDAPGroupPlugin $plugin) {
53
-		$respondToActions = $plugin->respondToActions();
54
-		$this->respondToActions |= $respondToActions;
55
-
56
-		foreach($this->which as $action => $v) {
57
-			if ((bool)($respondToActions & $action)) {
58
-				$this->which[$action] = $plugin;
59
-				\OC::$server->getLogger()->debug("Registered action ".$action." to plugin ".get_class($plugin), ['app' => 'user_ldap']);
60
-			}
61
-		}
62
-	}
63
-
64
-	/**
65
-	 * Signal if there is a registered plugin that implements some given actions
66
-	 * @param int $actions Actions defined in \OCP\GroupInterface, like GroupInterface::REMOVE_FROM_GROUP
67
-	 * @return bool
68
-	 */
69
-	public function implementsActions($actions) {
70
-		return ($actions & $this->respondToActions) == $actions;
71
-	}
72
-
73
-	/**
74
-	 * Create a group
75
-	 * @param string $gid Group Id
76
-	 * @return string | null The group DN if group creation was successful.
77
-	 * @throws \Exception
78
-	 */
79
-	public function createGroup($gid) {
80
-		$plugin = $this->which[GroupInterface::CREATE_GROUP];
81
-
82
-		if ($plugin) {
83
-			return $plugin->createGroup($gid);
84
-		}
85
-		throw new \Exception('No plugin implements createGroup in this LDAP Backend.');
86
-	}
87
-
88
-	/**
89
-	 * Delete a group
90
-	 * @param string $gid Group Id of the group to delete
91
-	 * @return bool
92
-	 * @throws \Exception
93
-	 */
94
-	public function deleteGroup($gid) {
95
-		$plugin = $this->which[GroupInterface::DELETE_GROUP];
96
-
97
-		if ($plugin) {
98
-			return $plugin->deleteGroup($gid);
99
-		}
100
-		throw new \Exception('No plugin implements deleteGroup in this LDAP Backend.');
101
-	}
102
-
103
-	/**
104
-	 * Add a user to a group
105
-	 * @param string $uid ID of the user to add to group
106
-	 * @param string $gid ID of the group in which add the user
107
-	 * @return bool
108
-	 * @throws \Exception
109
-	 *
110
-	 * Adds a user to a group.
111
-	 */
112
-	public function addToGroup($uid, $gid) {
113
-		$plugin = $this->which[GroupInterface::ADD_TO_GROUP];
114
-
115
-		if ($plugin) {
116
-			return $plugin->addToGroup($uid, $gid);
117
-		}
118
-		throw new \Exception('No plugin implements addToGroup in this LDAP Backend.');
119
-	}
120
-
121
-	/**
122
-	 * Removes a user from a group
123
-	 * @param string $uid ID of the user to remove from group
124
-	 * @param string $gid ID of the group from which remove the user
125
-	 * @return bool
126
-	 * @throws \Exception
127
-	 *
128
-	 * removes the user from a group.
129
-	 */
130
-	public function removeFromGroup($uid, $gid) {
131
-		$plugin = $this->which[GroupInterface::REMOVE_FROM_GROUP];
132
-
133
-		if ($plugin) {
134
-			return $plugin->removeFromGroup($uid, $gid);
135
-		}
136
-		throw new \Exception('No plugin implements removeFromGroup in this LDAP Backend.');
137
-	}
138
-
139
-	/**
140
-	 * get the number of all users matching the search string in a group
141
-	 * @param string $gid ID of the group
142
-	 * @param string $search query string
143
-	 * @return int|false
144
-	 * @throws \Exception
145
-	 */
146
-	public function countUsersInGroup($gid, $search = '') {
147
-		$plugin = $this->which[GroupInterface::COUNT_USERS];
148
-
149
-		if ($plugin) {
150
-			return $plugin->countUsersInGroup($gid,$search);
151
-		}
152
-		throw new \Exception('No plugin implements countUsersInGroup in this LDAP Backend.');
153
-	}
154
-
155
-	/**
156
-	 * get an array with group details
157
-	 * @param string $gid
158
-	 * @return array|false
159
-	 * @throws \Exception
160
-	 */
161
-	public function getGroupDetails($gid) {
162
-		$plugin = $this->which[GroupInterface::GROUP_DETAILS];
163
-
164
-		if ($plugin) {
165
-			return $plugin->getGroupDetails($gid);
166
-		}
167
-		throw new \Exception('No plugin implements getGroupDetails in this LDAP Backend.');
168
-	}
30
+    private $respondToActions = 0;
31
+
32
+    private $which = array(
33
+        GroupInterface::CREATE_GROUP => null,
34
+        GroupInterface::DELETE_GROUP => null,
35
+        GroupInterface::ADD_TO_GROUP => null,
36
+        GroupInterface::REMOVE_FROM_GROUP => null,
37
+        GroupInterface::COUNT_USERS => null,
38
+        GroupInterface::GROUP_DETAILS => null
39
+    );
40
+
41
+    /**
42
+     * @return int All implemented actions
43
+     */
44
+    public function getImplementedActions() {
45
+        return $this->respondToActions;
46
+    }
47
+
48
+    /**
49
+     * Registers a group plugin that may implement some actions, overriding User_LDAP's group actions.
50
+     * @param ILDAPGroupPlugin $plugin
51
+     */
52
+    public function register(ILDAPGroupPlugin $plugin) {
53
+        $respondToActions = $plugin->respondToActions();
54
+        $this->respondToActions |= $respondToActions;
55
+
56
+        foreach($this->which as $action => $v) {
57
+            if ((bool)($respondToActions & $action)) {
58
+                $this->which[$action] = $plugin;
59
+                \OC::$server->getLogger()->debug("Registered action ".$action." to plugin ".get_class($plugin), ['app' => 'user_ldap']);
60
+            }
61
+        }
62
+    }
63
+
64
+    /**
65
+     * Signal if there is a registered plugin that implements some given actions
66
+     * @param int $actions Actions defined in \OCP\GroupInterface, like GroupInterface::REMOVE_FROM_GROUP
67
+     * @return bool
68
+     */
69
+    public function implementsActions($actions) {
70
+        return ($actions & $this->respondToActions) == $actions;
71
+    }
72
+
73
+    /**
74
+     * Create a group
75
+     * @param string $gid Group Id
76
+     * @return string | null The group DN if group creation was successful.
77
+     * @throws \Exception
78
+     */
79
+    public function createGroup($gid) {
80
+        $plugin = $this->which[GroupInterface::CREATE_GROUP];
81
+
82
+        if ($plugin) {
83
+            return $plugin->createGroup($gid);
84
+        }
85
+        throw new \Exception('No plugin implements createGroup in this LDAP Backend.');
86
+    }
87
+
88
+    /**
89
+     * Delete a group
90
+     * @param string $gid Group Id of the group to delete
91
+     * @return bool
92
+     * @throws \Exception
93
+     */
94
+    public function deleteGroup($gid) {
95
+        $plugin = $this->which[GroupInterface::DELETE_GROUP];
96
+
97
+        if ($plugin) {
98
+            return $plugin->deleteGroup($gid);
99
+        }
100
+        throw new \Exception('No plugin implements deleteGroup in this LDAP Backend.');
101
+    }
102
+
103
+    /**
104
+     * Add a user to a group
105
+     * @param string $uid ID of the user to add to group
106
+     * @param string $gid ID of the group in which add the user
107
+     * @return bool
108
+     * @throws \Exception
109
+     *
110
+     * Adds a user to a group.
111
+     */
112
+    public function addToGroup($uid, $gid) {
113
+        $plugin = $this->which[GroupInterface::ADD_TO_GROUP];
114
+
115
+        if ($plugin) {
116
+            return $plugin->addToGroup($uid, $gid);
117
+        }
118
+        throw new \Exception('No plugin implements addToGroup in this LDAP Backend.');
119
+    }
120
+
121
+    /**
122
+     * Removes a user from a group
123
+     * @param string $uid ID of the user to remove from group
124
+     * @param string $gid ID of the group from which remove the user
125
+     * @return bool
126
+     * @throws \Exception
127
+     *
128
+     * removes the user from a group.
129
+     */
130
+    public function removeFromGroup($uid, $gid) {
131
+        $plugin = $this->which[GroupInterface::REMOVE_FROM_GROUP];
132
+
133
+        if ($plugin) {
134
+            return $plugin->removeFromGroup($uid, $gid);
135
+        }
136
+        throw new \Exception('No plugin implements removeFromGroup in this LDAP Backend.');
137
+    }
138
+
139
+    /**
140
+     * get the number of all users matching the search string in a group
141
+     * @param string $gid ID of the group
142
+     * @param string $search query string
143
+     * @return int|false
144
+     * @throws \Exception
145
+     */
146
+    public function countUsersInGroup($gid, $search = '') {
147
+        $plugin = $this->which[GroupInterface::COUNT_USERS];
148
+
149
+        if ($plugin) {
150
+            return $plugin->countUsersInGroup($gid,$search);
151
+        }
152
+        throw new \Exception('No plugin implements countUsersInGroup in this LDAP Backend.');
153
+    }
154
+
155
+    /**
156
+     * get an array with group details
157
+     * @param string $gid
158
+     * @return array|false
159
+     * @throws \Exception
160
+     */
161
+    public function getGroupDetails($gid) {
162
+        $plugin = $this->which[GroupInterface::GROUP_DETAILS];
163
+
164
+        if ($plugin) {
165
+            return $plugin->getGroupDetails($gid);
166
+        }
167
+        throw new \Exception('No plugin implements getGroupDetails in this LDAP Backend.');
168
+    }
169 169
 }
Please login to merge, or discard this patch.
apps/dav/lib/DAV/SystemPrincipalBackend.php 1 patch
Indentation   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -27,165 +27,165 @@
 block discarded – undo
27 27
 
28 28
 class SystemPrincipalBackend extends AbstractBackend {
29 29
 
30
-	/**
31
-	 * Returns a list of principals based on a prefix.
32
-	 *
33
-	 * This prefix will often contain something like 'principals'. You are only
34
-	 * expected to return principals that are in this base path.
35
-	 *
36
-	 * You are expected to return at least a 'uri' for every user, you can
37
-	 * return any additional properties if you wish so. Common properties are:
38
-	 *   {DAV:}displayname
39
-	 *   {http://sabredav.org/ns}email-address - This is a custom SabreDAV
40
-	 *     field that's actually injected in a number of other properties. If
41
-	 *     you have an email address, use this property.
42
-	 *
43
-	 * @param string $prefixPath
44
-	 * @return array
45
-	 */
46
-	function getPrincipalsByPrefix($prefixPath) {
47
-		$principals = [];
48
-
49
-		if ($prefixPath === 'principals/system') {
50
-			$principals[] = [
51
-				'uri' => 'principals/system/system',
52
-				'{DAV:}displayname' => 'system',
53
-			];
54
-			$principals[] = [
55
-				'uri' => 'principals/system/public',
56
-				'{DAV:}displayname' => 'public',
57
-			];
58
-		}
59
-
60
-		return $principals;
61
-	}
62
-
63
-	/**
64
-	 * Returns a specific principal, specified by it's path.
65
-	 * The returned structure should be the exact same as from
66
-	 * getPrincipalsByPrefix.
67
-	 *
68
-	 * @param string $path
69
-	 * @return array
70
-	 */
71
-	function getPrincipalByPath($path) {
72
-
73
-		if ($path === 'principals/system/system') {
74
-			$principal = [
75
-				'uri' => 'principals/system/system',
76
-				'{DAV:}displayname' => 'system',
77
-			];
78
-			return $principal;
79
-		}
80
-		if ($path === 'principals/system/public') {
81
-			$principal = [
82
-				'uri' => 'principals/system/public',
83
-				'{DAV:}displayname' => 'public',
84
-			];
85
-			return $principal;
86
-		}
87
-
88
-		return null;
89
-	}
90
-
91
-	/**
92
-	 * Updates one ore more webdav properties on a principal.
93
-	 *
94
-	 * The list of mutations is stored in a Sabre\DAV\PropPatch object.
95
-	 * To do the actual updates, you must tell this object which properties
96
-	 * you're going to process with the handle() method.
97
-	 *
98
-	 * Calling the handle method is like telling the PropPatch object "I
99
-	 * promise I can handle updating this property".
100
-	 *
101
-	 * Read the PropPatch documentation for more info and examples.
102
-	 *
103
-	 * @param string $path
104
-	 * @param \Sabre\DAV\PropPatch $propPatch
105
-	 * @return void
106
-	 */
107
-	function updatePrincipal($path, \Sabre\DAV\PropPatch $propPatch) {
108
-	}
109
-
110
-	/**
111
-	 * This method is used to search for principals matching a set of
112
-	 * properties.
113
-	 *
114
-	 * This search is specifically used by RFC3744's principal-property-search
115
-	 * REPORT.
116
-	 *
117
-	 * The actual search should be a unicode-non-case-sensitive search. The
118
-	 * keys in searchProperties are the WebDAV property names, while the values
119
-	 * are the property values to search on.
120
-	 *
121
-	 * By default, if multiple properties are submitted to this method, the
122
-	 * various properties should be combined with 'AND'. If $test is set to
123
-	 * 'anyof', it should be combined using 'OR'.
124
-	 *
125
-	 * This method should simply return an array with full principal uri's.
126
-	 *
127
-	 * If somebody attempted to search on a property the backend does not
128
-	 * support, you should simply return 0 results.
129
-	 *
130
-	 * You can also just return 0 results if you choose to not support
131
-	 * searching at all, but keep in mind that this may stop certain features
132
-	 * from working.
133
-	 *
134
-	 * @param string $prefixPath
135
-	 * @param array $searchProperties
136
-	 * @param string $test
137
-	 * @return array
138
-	 */
139
-	function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof') {
140
-		return [];
141
-	}
142
-
143
-	/**
144
-	 * Returns the list of members for a group-principal
145
-	 *
146
-	 * @param string $principal
147
-	 * @return array
148
-	 */
149
-	function getGroupMemberSet($principal) {
150
-		// TODO: for now the group principal has only one member, the user itself
151
-		$principal = $this->getPrincipalByPath($principal);
152
-		if (!$principal) {
153
-			throw new \Sabre\DAV\Exception('Principal not found');
154
-		}
155
-
156
-		return [$principal['uri']];
157
-	}
158
-
159
-	/**
160
-	 * Returns the list of groups a principal is a member of
161
-	 *
162
-	 * @param string $principal
163
-	 * @return array
164
-	 */
165
-	function getGroupMembership($principal) {
166
-		list($prefix, ) = \Sabre\Uri\split($principal);
167
-
168
-		if ($prefix === 'principals/system') {
169
-			$principal = $this->getPrincipalByPath($principal);
170
-			if (!$principal) {
171
-				throw new \Sabre\DAV\Exception('Principal not found');
172
-			}
173
-
174
-			return [];
175
-		}
176
-		return [];
177
-	}
178
-
179
-	/**
180
-	 * Updates the list of group members for a group principal.
181
-	 *
182
-	 * The principals should be passed as a list of uri's.
183
-	 *
184
-	 * @param string $principal
185
-	 * @param array $members
186
-	 * @return void
187
-	 */
188
-	function setGroupMemberSet($principal, array $members) {
189
-		throw new \Sabre\DAV\Exception('Setting members of the group is not supported yet');
190
-	}
30
+    /**
31
+     * Returns a list of principals based on a prefix.
32
+     *
33
+     * This prefix will often contain something like 'principals'. You are only
34
+     * expected to return principals that are in this base path.
35
+     *
36
+     * You are expected to return at least a 'uri' for every user, you can
37
+     * return any additional properties if you wish so. Common properties are:
38
+     *   {DAV:}displayname
39
+     *   {http://sabredav.org/ns}email-address - This is a custom SabreDAV
40
+     *     field that's actually injected in a number of other properties. If
41
+     *     you have an email address, use this property.
42
+     *
43
+     * @param string $prefixPath
44
+     * @return array
45
+     */
46
+    function getPrincipalsByPrefix($prefixPath) {
47
+        $principals = [];
48
+
49
+        if ($prefixPath === 'principals/system') {
50
+            $principals[] = [
51
+                'uri' => 'principals/system/system',
52
+                '{DAV:}displayname' => 'system',
53
+            ];
54
+            $principals[] = [
55
+                'uri' => 'principals/system/public',
56
+                '{DAV:}displayname' => 'public',
57
+            ];
58
+        }
59
+
60
+        return $principals;
61
+    }
62
+
63
+    /**
64
+     * Returns a specific principal, specified by it's path.
65
+     * The returned structure should be the exact same as from
66
+     * getPrincipalsByPrefix.
67
+     *
68
+     * @param string $path
69
+     * @return array
70
+     */
71
+    function getPrincipalByPath($path) {
72
+
73
+        if ($path === 'principals/system/system') {
74
+            $principal = [
75
+                'uri' => 'principals/system/system',
76
+                '{DAV:}displayname' => 'system',
77
+            ];
78
+            return $principal;
79
+        }
80
+        if ($path === 'principals/system/public') {
81
+            $principal = [
82
+                'uri' => 'principals/system/public',
83
+                '{DAV:}displayname' => 'public',
84
+            ];
85
+            return $principal;
86
+        }
87
+
88
+        return null;
89
+    }
90
+
91
+    /**
92
+     * Updates one ore more webdav properties on a principal.
93
+     *
94
+     * The list of mutations is stored in a Sabre\DAV\PropPatch object.
95
+     * To do the actual updates, you must tell this object which properties
96
+     * you're going to process with the handle() method.
97
+     *
98
+     * Calling the handle method is like telling the PropPatch object "I
99
+     * promise I can handle updating this property".
100
+     *
101
+     * Read the PropPatch documentation for more info and examples.
102
+     *
103
+     * @param string $path
104
+     * @param \Sabre\DAV\PropPatch $propPatch
105
+     * @return void
106
+     */
107
+    function updatePrincipal($path, \Sabre\DAV\PropPatch $propPatch) {
108
+    }
109
+
110
+    /**
111
+     * This method is used to search for principals matching a set of
112
+     * properties.
113
+     *
114
+     * This search is specifically used by RFC3744's principal-property-search
115
+     * REPORT.
116
+     *
117
+     * The actual search should be a unicode-non-case-sensitive search. The
118
+     * keys in searchProperties are the WebDAV property names, while the values
119
+     * are the property values to search on.
120
+     *
121
+     * By default, if multiple properties are submitted to this method, the
122
+     * various properties should be combined with 'AND'. If $test is set to
123
+     * 'anyof', it should be combined using 'OR'.
124
+     *
125
+     * This method should simply return an array with full principal uri's.
126
+     *
127
+     * If somebody attempted to search on a property the backend does not
128
+     * support, you should simply return 0 results.
129
+     *
130
+     * You can also just return 0 results if you choose to not support
131
+     * searching at all, but keep in mind that this may stop certain features
132
+     * from working.
133
+     *
134
+     * @param string $prefixPath
135
+     * @param array $searchProperties
136
+     * @param string $test
137
+     * @return array
138
+     */
139
+    function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof') {
140
+        return [];
141
+    }
142
+
143
+    /**
144
+     * Returns the list of members for a group-principal
145
+     *
146
+     * @param string $principal
147
+     * @return array
148
+     */
149
+    function getGroupMemberSet($principal) {
150
+        // TODO: for now the group principal has only one member, the user itself
151
+        $principal = $this->getPrincipalByPath($principal);
152
+        if (!$principal) {
153
+            throw new \Sabre\DAV\Exception('Principal not found');
154
+        }
155
+
156
+        return [$principal['uri']];
157
+    }
158
+
159
+    /**
160
+     * Returns the list of groups a principal is a member of
161
+     *
162
+     * @param string $principal
163
+     * @return array
164
+     */
165
+    function getGroupMembership($principal) {
166
+        list($prefix, ) = \Sabre\Uri\split($principal);
167
+
168
+        if ($prefix === 'principals/system') {
169
+            $principal = $this->getPrincipalByPath($principal);
170
+            if (!$principal) {
171
+                throw new \Sabre\DAV\Exception('Principal not found');
172
+            }
173
+
174
+            return [];
175
+        }
176
+        return [];
177
+    }
178
+
179
+    /**
180
+     * Updates the list of group members for a group principal.
181
+     *
182
+     * The principals should be passed as a list of uri's.
183
+     *
184
+     * @param string $principal
185
+     * @param array $members
186
+     * @return void
187
+     */
188
+    function setGroupMemberSet($principal, array $members) {
189
+        throw new \Sabre\DAV\Exception('Setting members of the group is not supported yet');
190
+    }
191 191
 }
Please login to merge, or discard this patch.
apps/files_versions/lib/Command/Expire.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -30,35 +30,35 @@
 block discarded – undo
30 30
 use OCP\Command\ICommand;
31 31
 
32 32
 class Expire implements ICommand {
33
-	use FileAccess;
33
+    use FileAccess;
34 34
 
35
-	/**
36
-	 * @var string
37
-	 */
38
-	private $fileName;
35
+    /**
36
+     * @var string
37
+     */
38
+    private $fileName;
39 39
 
40
-	/**
41
-	 * @var string
42
-	 */
43
-	private $user;
40
+    /**
41
+     * @var string
42
+     */
43
+    private $user;
44 44
 
45
-	/**
46
-	 * @param string $user
47
-	 * @param string $fileName
48
-	 */
49
-	function __construct($user, $fileName) {
50
-		$this->user = $user;
51
-		$this->fileName = $fileName;
52
-	}
45
+    /**
46
+     * @param string $user
47
+     * @param string $fileName
48
+     */
49
+    function __construct($user, $fileName) {
50
+        $this->user = $user;
51
+        $this->fileName = $fileName;
52
+    }
53 53
 
54 54
 
55
-	public function handle() {
56
-		$userManager = \OC::$server->getUserManager();
57
-		if (!$userManager->userExists($this->user)) {
58
-			// User has been deleted already
59
-			return;
60
-		}
55
+    public function handle() {
56
+        $userManager = \OC::$server->getUserManager();
57
+        if (!$userManager->userExists($this->user)) {
58
+            // User has been deleted already
59
+            return;
60
+        }
61 61
 
62
-		Storage::expire($this->fileName, $this->user);
63
-	}
62
+        Storage::expire($this->fileName, $this->user);
63
+    }
64 64
 }
Please login to merge, or discard this patch.
lib/private/AppFramework/Middleware/OCSMiddleware.php 1 patch
Indentation   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -39,116 +39,116 @@
 block discarded – undo
39 39
 
40 40
 class OCSMiddleware extends Middleware {
41 41
 
42
-	/** @var IRequest */
43
-	private $request;
44
-
45
-	/** @var int */
46
-	private $ocsVersion;
47
-
48
-	/**
49
-	 * @param IRequest $request
50
-	 */
51
-	public function __construct(IRequest $request) {
52
-		$this->request = $request;
53
-	}
54
-
55
-	/**
56
-	 * @param Controller $controller
57
-	 * @param string $methodName
58
-	 */
59
-	public function beforeController($controller, $methodName) {
60
-		if ($controller instanceof OCSController) {
61
-			if (substr_compare($this->request->getScriptName(), '/ocs/v2.php', -strlen('/ocs/v2.php')) === 0) {
62
-				$this->ocsVersion = 2;
63
-			} else {
64
-				$this->ocsVersion = 1;
65
-			}
66
-			$controller->setOCSVersion($this->ocsVersion);
67
-		}
68
-	}
69
-
70
-	/**
71
-	 * @param Controller $controller
72
-	 * @param string $methodName
73
-	 * @param \Exception $exception
74
-	 * @throws \Exception
75
-	 * @return BaseResponse
76
-	 */
77
-	public function afterException($controller, $methodName, \Exception $exception) {
78
-		if ($controller instanceof OCSController && $exception instanceof OCSException) {
79
-			$code = $exception->getCode();
80
-			if ($code === 0) {
81
-				$code = API::RESPOND_UNKNOWN_ERROR;
82
-			}
83
-
84
-			return $this->buildNewResponse($controller, $code, $exception->getMessage());
85
-		}
86
-
87
-		throw $exception;
88
-	}
89
-
90
-	/**
91
-	 * @param Controller $controller
92
-	 * @param string $methodName
93
-	 * @param Response $response
94
-	 * @return \OCP\AppFramework\Http\Response
95
-	 */
96
-	public function afterController($controller, $methodName, Response $response) {
97
-		/*
42
+    /** @var IRequest */
43
+    private $request;
44
+
45
+    /** @var int */
46
+    private $ocsVersion;
47
+
48
+    /**
49
+     * @param IRequest $request
50
+     */
51
+    public function __construct(IRequest $request) {
52
+        $this->request = $request;
53
+    }
54
+
55
+    /**
56
+     * @param Controller $controller
57
+     * @param string $methodName
58
+     */
59
+    public function beforeController($controller, $methodName) {
60
+        if ($controller instanceof OCSController) {
61
+            if (substr_compare($this->request->getScriptName(), '/ocs/v2.php', -strlen('/ocs/v2.php')) === 0) {
62
+                $this->ocsVersion = 2;
63
+            } else {
64
+                $this->ocsVersion = 1;
65
+            }
66
+            $controller->setOCSVersion($this->ocsVersion);
67
+        }
68
+    }
69
+
70
+    /**
71
+     * @param Controller $controller
72
+     * @param string $methodName
73
+     * @param \Exception $exception
74
+     * @throws \Exception
75
+     * @return BaseResponse
76
+     */
77
+    public function afterException($controller, $methodName, \Exception $exception) {
78
+        if ($controller instanceof OCSController && $exception instanceof OCSException) {
79
+            $code = $exception->getCode();
80
+            if ($code === 0) {
81
+                $code = API::RESPOND_UNKNOWN_ERROR;
82
+            }
83
+
84
+            return $this->buildNewResponse($controller, $code, $exception->getMessage());
85
+        }
86
+
87
+        throw $exception;
88
+    }
89
+
90
+    /**
91
+     * @param Controller $controller
92
+     * @param string $methodName
93
+     * @param Response $response
94
+     * @return \OCP\AppFramework\Http\Response
95
+     */
96
+    public function afterController($controller, $methodName, Response $response) {
97
+        /*
98 98
 		 * If a different middleware has detected that a request unauthorized or forbidden
99 99
 		 * we need to catch the response and convert it to a proper OCS response.
100 100
 		 */
101
-		if ($controller instanceof OCSController && !($response instanceof BaseResponse)) {
102
-			if ($response->getStatus() === Http::STATUS_UNAUTHORIZED ||
103
-			    $response->getStatus() === Http::STATUS_FORBIDDEN) {
104
-
105
-				$message = '';
106
-				if ($response instanceof JSONResponse) {
107
-					/** @var DataResponse $response */
108
-					$message = $response->getData()['message'];
109
-				}
110
-
111
-				return $this->buildNewResponse($controller, API::RESPOND_UNAUTHORISED, $message);
112
-			}
113
-		}
114
-
115
-		return $response;
116
-	}
117
-
118
-	/**
119
-	 * @param Controller $controller
120
-	 * @param int $code
121
-	 * @param string $message
122
-	 * @return V1Response|V2Response
123
-	 */
124
-	private function buildNewResponse(Controller $controller, $code, $message) {
125
-		$format = $this->getFormat($controller);
126
-
127
-		$data = new DataResponse();
128
-		$data->setStatus($code);
129
-		if ($this->ocsVersion === 1) {
130
-			$response = new V1Response($data, $format, $message);
131
-		} else {
132
-			$response = new V2Response($data, $format, $message);
133
-		}
134
-
135
-		return $response;
136
-	}
137
-
138
-	/**
139
-	 * @param Controller $controller
140
-	 * @return string
141
-	 */
142
-	private function getFormat(Controller $controller) {
143
-		// get format from the url format or request format parameter
144
-		$format = $this->request->getParam('format');
145
-
146
-		// if none is given try the first Accept header
147
-		if($format === null) {
148
-			$headers = $this->request->getHeader('Accept');
149
-			$format = $controller->getResponderByHTTPHeader($headers, 'xml');
150
-		}
151
-
152
-		return $format;
153
-	}
101
+        if ($controller instanceof OCSController && !($response instanceof BaseResponse)) {
102
+            if ($response->getStatus() === Http::STATUS_UNAUTHORIZED ||
103
+                $response->getStatus() === Http::STATUS_FORBIDDEN) {
104
+
105
+                $message = '';
106
+                if ($response instanceof JSONResponse) {
107
+                    /** @var DataResponse $response */
108
+                    $message = $response->getData()['message'];
109
+                }
110
+
111
+                return $this->buildNewResponse($controller, API::RESPOND_UNAUTHORISED, $message);
112
+            }
113
+        }
114
+
115
+        return $response;
116
+    }
117
+
118
+    /**
119
+     * @param Controller $controller
120
+     * @param int $code
121
+     * @param string $message
122
+     * @return V1Response|V2Response
123
+     */
124
+    private function buildNewResponse(Controller $controller, $code, $message) {
125
+        $format = $this->getFormat($controller);
126
+
127
+        $data = new DataResponse();
128
+        $data->setStatus($code);
129
+        if ($this->ocsVersion === 1) {
130
+            $response = new V1Response($data, $format, $message);
131
+        } else {
132
+            $response = new V2Response($data, $format, $message);
133
+        }
134
+
135
+        return $response;
136
+    }
137
+
138
+    /**
139
+     * @param Controller $controller
140
+     * @return string
141
+     */
142
+    private function getFormat(Controller $controller) {
143
+        // get format from the url format or request format parameter
144
+        $format = $this->request->getParam('format');
145
+
146
+        // if none is given try the first Accept header
147
+        if($format === null) {
148
+            $headers = $this->request->getHeader('Accept');
149
+            $format = $controller->getResponderByHTTPHeader($headers, 'xml');
150
+        }
151
+
152
+        return $format;
153
+    }
154 154
 }
Please login to merge, or discard this patch.
lib/private/Calendar/Manager.php 1 patch
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -27,114 +27,114 @@
 block discarded – undo
27 27
 
28 28
 class Manager implements \OCP\Calendar\IManager {
29 29
 
30
-	/**
31
-	 * @var ICalendar[] holds all registered calendars
32
-	 */
33
-	private $calendars=[];
30
+    /**
31
+     * @var ICalendar[] holds all registered calendars
32
+     */
33
+    private $calendars=[];
34 34
 
35
-	/**
36
-	 * @var \Closure[] to call to load/register calendar providers
37
-	 */
38
-	private $calendarLoaders=[];
35
+    /**
36
+     * @var \Closure[] to call to load/register calendar providers
37
+     */
38
+    private $calendarLoaders=[];
39 39
 
40
-	/**
41
-	 * This function is used to search and find objects within the user's calendars.
42
-	 * In case $pattern is empty all events/journals/todos will be returned.
43
-	 *
44
-	 * @param string $pattern which should match within the $searchProperties
45
-	 * @param array $searchProperties defines the properties within the query pattern should match
46
-	 * @param array $options - optional parameters:
47
-	 * 	['timerange' => ['start' => new DateTime(...), 'end' => new DateTime(...)]]
48
-	 * @param integer|null $limit - limit number of search results
49
-	 * @param integer|null $offset - offset for paging of search results
50
-	 * @return array an array of events/journals/todos which are arrays of arrays of key-value-pairs
51
-	 * @since 13.0.0
52
-	 */
53
-	public function search($pattern, array $searchProperties=[], array $options=[], $limit=null, $offset=null) {
54
-		$this->loadCalendars();
55
-		$result = [];
56
-		foreach($this->calendars as $calendar) {
57
-			$r = $calendar->search($pattern, $searchProperties, $options, $limit, $offset);
58
-			foreach($r as $o) {
59
-				$o['calendar-key'] = $calendar->getKey();
60
-				$result[] = $o;
61
-			}
62
-		}
40
+    /**
41
+     * This function is used to search and find objects within the user's calendars.
42
+     * In case $pattern is empty all events/journals/todos will be returned.
43
+     *
44
+     * @param string $pattern which should match within the $searchProperties
45
+     * @param array $searchProperties defines the properties within the query pattern should match
46
+     * @param array $options - optional parameters:
47
+     * 	['timerange' => ['start' => new DateTime(...), 'end' => new DateTime(...)]]
48
+     * @param integer|null $limit - limit number of search results
49
+     * @param integer|null $offset - offset for paging of search results
50
+     * @return array an array of events/journals/todos which are arrays of arrays of key-value-pairs
51
+     * @since 13.0.0
52
+     */
53
+    public function search($pattern, array $searchProperties=[], array $options=[], $limit=null, $offset=null) {
54
+        $this->loadCalendars();
55
+        $result = [];
56
+        foreach($this->calendars as $calendar) {
57
+            $r = $calendar->search($pattern, $searchProperties, $options, $limit, $offset);
58
+            foreach($r as $o) {
59
+                $o['calendar-key'] = $calendar->getKey();
60
+                $result[] = $o;
61
+            }
62
+        }
63 63
 
64
-		return $result;
65
-	}
64
+        return $result;
65
+    }
66 66
 
67
-	/**
68
-	 * Check if calendars are available
69
-	 *
70
-	 * @return bool true if enabled, false if not
71
-	 * @since 13.0.0
72
-	 */
73
-	public function isEnabled() {
74
-		return !empty($this->calendars) || !empty($this->calendarLoaders);
75
-	}
67
+    /**
68
+     * Check if calendars are available
69
+     *
70
+     * @return bool true if enabled, false if not
71
+     * @since 13.0.0
72
+     */
73
+    public function isEnabled() {
74
+        return !empty($this->calendars) || !empty($this->calendarLoaders);
75
+    }
76 76
 
77
-	/**
78
-	 * Registers a calendar
79
-	 *
80
-	 * @param ICalendar $calendar
81
-	 * @return void
82
-	 * @since 13.0.0
83
-	 */
84
-	public function registerCalendar(ICalendar $calendar) {
85
-		$this->calendars[$calendar->getKey()] = $calendar;
86
-	}
77
+    /**
78
+     * Registers a calendar
79
+     *
80
+     * @param ICalendar $calendar
81
+     * @return void
82
+     * @since 13.0.0
83
+     */
84
+    public function registerCalendar(ICalendar $calendar) {
85
+        $this->calendars[$calendar->getKey()] = $calendar;
86
+    }
87 87
 
88
-	/**
89
-	 * Unregisters a calendar
90
-	 *
91
-	 * @param ICalendar $calendar
92
-	 * @return void
93
-	 * @since 13.0.0
94
-	 */
95
-	public function unregisterCalendar(ICalendar $calendar) {
96
-		unset($this->calendars[$calendar->getKey()]);
97
-	}
88
+    /**
89
+     * Unregisters a calendar
90
+     *
91
+     * @param ICalendar $calendar
92
+     * @return void
93
+     * @since 13.0.0
94
+     */
95
+    public function unregisterCalendar(ICalendar $calendar) {
96
+        unset($this->calendars[$calendar->getKey()]);
97
+    }
98 98
 
99
-	/**
100
-	 * In order to improve lazy loading a closure can be registered which will be called in case
101
-	 * calendars are actually requested
102
-	 *
103
-	 * @param \Closure $callable
104
-	 * @return void
105
-	 * @since 13.0.0
106
-	 */
107
-	public function register(\Closure $callable) {
108
-		$this->calendarLoaders[] = $callable;
109
-	}
99
+    /**
100
+     * In order to improve lazy loading a closure can be registered which will be called in case
101
+     * calendars are actually requested
102
+     *
103
+     * @param \Closure $callable
104
+     * @return void
105
+     * @since 13.0.0
106
+     */
107
+    public function register(\Closure $callable) {
108
+        $this->calendarLoaders[] = $callable;
109
+    }
110 110
 
111
-	/**
112
-	 * @return ICalendar[]
113
-	 * @since 13.0.0
114
-	 */
115
-	public function getCalendars() {
116
-		$this->loadCalendars();
111
+    /**
112
+     * @return ICalendar[]
113
+     * @since 13.0.0
114
+     */
115
+    public function getCalendars() {
116
+        $this->loadCalendars();
117 117
 
118
-		return array_values($this->calendars);
119
-	}
118
+        return array_values($this->calendars);
119
+    }
120 120
 
121
-	/**
122
-	 * removes all registered calendar instances
123
-	 * @return void
124
-	 * @since 13.0.0
125
-	 */
126
-	public function clear() {
127
-		$this->calendars = [];
128
-		$this->calendarLoaders = [];
129
-	}
121
+    /**
122
+     * removes all registered calendar instances
123
+     * @return void
124
+     * @since 13.0.0
125
+     */
126
+    public function clear() {
127
+        $this->calendars = [];
128
+        $this->calendarLoaders = [];
129
+    }
130 130
 
131
-	/**
132
-	 * loads all calendars
133
-	 */
134
-	private function loadCalendars() {
135
-		foreach($this->calendarLoaders as $callable) {
136
-			$callable($this);
137
-		}
138
-		$this->calendarLoaders = [];
139
-	}
131
+    /**
132
+     * loads all calendars
133
+     */
134
+    private function loadCalendars() {
135
+        foreach($this->calendarLoaders as $callable) {
136
+            $callable($this);
137
+        }
138
+        $this->calendarLoaders = [];
139
+    }
140 140
 }
Please login to merge, or discard this patch.
lib/public/Calendar/IManager.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -55,67 +55,67 @@
 block discarded – undo
55 55
  */
56 56
 interface IManager {
57 57
 
58
-	/**
59
-	 * This function is used to search and find objects within the user's calendars.
60
-	 * In case $pattern is empty all events/journals/todos will be returned.
61
-	 *
62
-	 * @param string $pattern which should match within the $searchProperties
63
-	 * @param array $searchProperties defines the properties within the query pattern should match
64
-	 * @param array $options - optional parameters:
65
-	 * 	['timerange' => ['start' => new DateTime(...), 'end' => new DateTime(...)]]
66
-	 * @param integer|null $limit - limit number of search results
67
-	 * @param integer|null $offset - offset for paging of search results
68
-	 * @return array an array of events/journals/todos which are arrays of arrays of key-value-pairs
69
-	 * @since 13.0.0
70
-	 */
71
-	public function search($pattern, array $searchProperties=[], array $options=[], $limit=null, $offset=null);
58
+    /**
59
+     * This function is used to search and find objects within the user's calendars.
60
+     * In case $pattern is empty all events/journals/todos will be returned.
61
+     *
62
+     * @param string $pattern which should match within the $searchProperties
63
+     * @param array $searchProperties defines the properties within the query pattern should match
64
+     * @param array $options - optional parameters:
65
+     * 	['timerange' => ['start' => new DateTime(...), 'end' => new DateTime(...)]]
66
+     * @param integer|null $limit - limit number of search results
67
+     * @param integer|null $offset - offset for paging of search results
68
+     * @return array an array of events/journals/todos which are arrays of arrays of key-value-pairs
69
+     * @since 13.0.0
70
+     */
71
+    public function search($pattern, array $searchProperties=[], array $options=[], $limit=null, $offset=null);
72 72
 
73
-	/**
74
-	 * Check if calendars are available
75
-	 *
76
-	 * @return bool true if enabled, false if not
77
-	 * @since 13.0.0
78
-	 */
79
-	public function isEnabled();
73
+    /**
74
+     * Check if calendars are available
75
+     *
76
+     * @return bool true if enabled, false if not
77
+     * @since 13.0.0
78
+     */
79
+    public function isEnabled();
80 80
 
81
-	/**
82
-	 * Registers a calendar
83
-	 *
84
-	 * @param ICalendar $calendar
85
-	 * @return void
86
-	 * @since 13.0.0
87
-	 */
88
-	public function registerCalendar(ICalendar $calendar);
81
+    /**
82
+     * Registers a calendar
83
+     *
84
+     * @param ICalendar $calendar
85
+     * @return void
86
+     * @since 13.0.0
87
+     */
88
+    public function registerCalendar(ICalendar $calendar);
89 89
 
90
-	/**
91
-	 * Unregisters a calendar
92
-	 *
93
-	 * @param ICalendar $calendar
94
-	 * @return void
95
-	 * @since 13.0.0
96
-	 */
97
-	public function unregisterCalendar(ICalendar $calendar);
90
+    /**
91
+     * Unregisters a calendar
92
+     *
93
+     * @param ICalendar $calendar
94
+     * @return void
95
+     * @since 13.0.0
96
+     */
97
+    public function unregisterCalendar(ICalendar $calendar);
98 98
 
99
-	/**
100
-	 * In order to improve lazy loading a closure can be registered which will be called in case
101
-	 * calendars are actually requested
102
-	 *
103
-	 * @param \Closure $callable
104
-	 * @return void
105
-	 * @since 13.0.0
106
-	 */
107
-	public function register(\Closure $callable);
99
+    /**
100
+     * In order to improve lazy loading a closure can be registered which will be called in case
101
+     * calendars are actually requested
102
+     *
103
+     * @param \Closure $callable
104
+     * @return void
105
+     * @since 13.0.0
106
+     */
107
+    public function register(\Closure $callable);
108 108
 
109
-	/**
110
-	 * @return ICalendar[]
111
-	 * @since 13.0.0
112
-	 */
113
-	public function getCalendars();
109
+    /**
110
+     * @return ICalendar[]
111
+     * @since 13.0.0
112
+     */
113
+    public function getCalendars();
114 114
 
115
-	/**
116
-	 * removes all registered calendar instances
117
-	 * @return void
118
-	 * @since 13.0.0
119
-	 */
120
-	public function clear();
115
+    /**
116
+     * removes all registered calendar instances
117
+     * @return void
118
+     * @since 13.0.0
119
+     */
120
+    public function clear();
121 121
 }
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/CalendarImpl.php 1 patch
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -28,92 +28,92 @@
 block discarded – undo
28 28
 
29 29
 class CalendarImpl implements ICalendar {
30 30
 
31
-	/** @var CalDavBackend */
32
-	private $backend;
31
+    /** @var CalDavBackend */
32
+    private $backend;
33 33
 
34
-	/** @var Calendar */
35
-	private $calendar;
34
+    /** @var Calendar */
35
+    private $calendar;
36 36
 
37
-	/** @var array */
38
-	private $calendarInfo;
37
+    /** @var array */
38
+    private $calendarInfo;
39 39
 
40
-	/**
41
-	 * CalendarImpl constructor.
42
-	 *
43
-	 * @param Calendar $calendar
44
-	 * @param array $calendarInfo
45
-	 * @param CalDavBackend $backend
46
-	 */
47
-	public function __construct(Calendar $calendar, array $calendarInfo,
48
-								CalDavBackend $backend) {
49
-		$this->calendar = $calendar;
50
-		$this->calendarInfo = $calendarInfo;
51
-		$this->backend = $backend;
52
-	}
40
+    /**
41
+     * CalendarImpl constructor.
42
+     *
43
+     * @param Calendar $calendar
44
+     * @param array $calendarInfo
45
+     * @param CalDavBackend $backend
46
+     */
47
+    public function __construct(Calendar $calendar, array $calendarInfo,
48
+                                CalDavBackend $backend) {
49
+        $this->calendar = $calendar;
50
+        $this->calendarInfo = $calendarInfo;
51
+        $this->backend = $backend;
52
+    }
53 53
 	
54
-	/**
55
-	 * @return string defining the technical unique key
56
-	 * @since 13.0.0
57
-	 */
58
-	public function getKey() {
59
-		return $this->calendarInfo['id'];
60
-	}
54
+    /**
55
+     * @return string defining the technical unique key
56
+     * @since 13.0.0
57
+     */
58
+    public function getKey() {
59
+        return $this->calendarInfo['id'];
60
+    }
61 61
 
62
-	/**
63
-	 * In comparison to getKey() this function returns a human readable (maybe translated) name
64
-	 * @return null|string
65
-	 * @since 13.0.0
66
-	 */
67
-	public function getDisplayName() {
68
-		return $this->calendarInfo['{DAV:}displayname'];
69
-	}
62
+    /**
63
+     * In comparison to getKey() this function returns a human readable (maybe translated) name
64
+     * @return null|string
65
+     * @since 13.0.0
66
+     */
67
+    public function getDisplayName() {
68
+        return $this->calendarInfo['{DAV:}displayname'];
69
+    }
70 70
 
71
-	/**
72
-	 * Calendar color
73
-	 * @return null|string
74
-	 * @since 13.0.0
75
-	 */
76
-	public function getDisplayColor() {
77
-		return $this->calendarInfo['{http://apple.com/ns/ical/}calendar-color'];
78
-	}
71
+    /**
72
+     * Calendar color
73
+     * @return null|string
74
+     * @since 13.0.0
75
+     */
76
+    public function getDisplayColor() {
77
+        return $this->calendarInfo['{http://apple.com/ns/ical/}calendar-color'];
78
+    }
79 79
 
80
-	/**
81
-	 * @param string $pattern which should match within the $searchProperties
82
-	 * @param array $searchProperties defines the properties within the query pattern should match
83
-	 * @param array $options - optional parameters:
84
-	 * 	['timerange' => ['start' => new DateTime(...), 'end' => new DateTime(...)]]
85
-	 * @param integer|null $limit - limit number of search results
86
-	 * @param integer|null $offset - offset for paging of search results
87
-	 * @return array an array of events/journals/todos which are arrays of key-value-pairs
88
-	 * @since 13.0.0
89
-	 */
90
-	public function search($pattern, array $searchProperties=[], array $options=[], $limit=null, $offset=null) {
91
-		return $this->backend->search($this->calendarInfo, $pattern,
92
-			$searchProperties, $options, $limit, $offset);
93
-	}
80
+    /**
81
+     * @param string $pattern which should match within the $searchProperties
82
+     * @param array $searchProperties defines the properties within the query pattern should match
83
+     * @param array $options - optional parameters:
84
+     * 	['timerange' => ['start' => new DateTime(...), 'end' => new DateTime(...)]]
85
+     * @param integer|null $limit - limit number of search results
86
+     * @param integer|null $offset - offset for paging of search results
87
+     * @return array an array of events/journals/todos which are arrays of key-value-pairs
88
+     * @since 13.0.0
89
+     */
90
+    public function search($pattern, array $searchProperties=[], array $options=[], $limit=null, $offset=null) {
91
+        return $this->backend->search($this->calendarInfo, $pattern,
92
+            $searchProperties, $options, $limit, $offset);
93
+    }
94 94
 
95
-	/**
96
-	 * @return integer build up using \OCP\Constants
97
-	 * @since 13.0.0
98
-	 */
99
-	public function getPermissions() {
100
-		$permissions = $this->calendar->getACL();
101
-		$result = 0;
102
-		foreach ($permissions as $permission) {
103
-			switch($permission['privilege']) {
104
-				case '{DAV:}read':
105
-					$result |= Constants::PERMISSION_READ;
106
-					break;
107
-				case '{DAV:}write':
108
-					$result |= Constants::PERMISSION_CREATE;
109
-					$result |= Constants::PERMISSION_UPDATE;
110
-					break;
111
-				case '{DAV:}all':
112
-					$result |= Constants::PERMISSION_ALL;
113
-					break;
114
-			}
115
-		}
95
+    /**
96
+     * @return integer build up using \OCP\Constants
97
+     * @since 13.0.0
98
+     */
99
+    public function getPermissions() {
100
+        $permissions = $this->calendar->getACL();
101
+        $result = 0;
102
+        foreach ($permissions as $permission) {
103
+            switch($permission['privilege']) {
104
+                case '{DAV:}read':
105
+                    $result |= Constants::PERMISSION_READ;
106
+                    break;
107
+                case '{DAV:}write':
108
+                    $result |= Constants::PERMISSION_CREATE;
109
+                    $result |= Constants::PERMISSION_UPDATE;
110
+                    break;
111
+                case '{DAV:}all':
112
+                    $result |= Constants::PERMISSION_ALL;
113
+                    break;
114
+            }
115
+        }
116 116
 
117
-		return $result;
118
-	}
117
+        return $result;
118
+    }
119 119
 }
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/PublicCalendarRoot.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -30,49 +30,49 @@
 block discarded – undo
30 30
 
31 31
 class PublicCalendarRoot extends Collection {
32 32
 
33
-	/** @var CalDavBackend */
34
-	protected $caldavBackend;
33
+    /** @var CalDavBackend */
34
+    protected $caldavBackend;
35 35
 
36
-	/** @var \OCP\IL10N */
37
-	protected $l10n;
36
+    /** @var \OCP\IL10N */
37
+    protected $l10n;
38 38
 
39
-	/** @var \OCP\IConfig */
40
-	protected $config;
39
+    /** @var \OCP\IConfig */
40
+    protected $config;
41 41
 
42
-	/**
43
-	 * PublicCalendarRoot constructor.
44
-	 *
45
-	 * @param CalDavBackend $caldavBackend
46
-	 * @param IL10N $l10n
47
-	 * @param IConfig $config
48
-	 */
49
-	function __construct(CalDavBackend $caldavBackend, IL10N $l10n,
50
-						 IConfig $config) {
51
-		$this->caldavBackend = $caldavBackend;
52
-		$this->l10n = $l10n;
53
-		$this->config = $config;
42
+    /**
43
+     * PublicCalendarRoot constructor.
44
+     *
45
+     * @param CalDavBackend $caldavBackend
46
+     * @param IL10N $l10n
47
+     * @param IConfig $config
48
+     */
49
+    function __construct(CalDavBackend $caldavBackend, IL10N $l10n,
50
+                            IConfig $config) {
51
+        $this->caldavBackend = $caldavBackend;
52
+        $this->l10n = $l10n;
53
+        $this->config = $config;
54 54
 
55
-	}
55
+    }
56 56
 
57
-	/**
58
-	 * @inheritdoc
59
-	 */
60
-	function getName() {
61
-		return 'public-calendars';
62
-	}
57
+    /**
58
+     * @inheritdoc
59
+     */
60
+    function getName() {
61
+        return 'public-calendars';
62
+    }
63 63
 
64
-	/**
65
-	 * @inheritdoc
66
-	 */
67
-	function getChild($name) {
68
-		$calendar = $this->caldavBackend->getPublicCalendar($name);
69
-		return new PublicCalendar($this->caldavBackend, $calendar, $this->l10n, $this->config);
70
-	}
64
+    /**
65
+     * @inheritdoc
66
+     */
67
+    function getChild($name) {
68
+        $calendar = $this->caldavBackend->getPublicCalendar($name);
69
+        return new PublicCalendar($this->caldavBackend, $calendar, $this->l10n, $this->config);
70
+    }
71 71
 
72
-	/**
73
-	 * @inheritdoc
74
-	 */
75
-	function getChildren() {
76
-		return [];
77
-	}
72
+    /**
73
+     * @inheritdoc
74
+     */
75
+    function getChildren() {
76
+        return [];
77
+    }
78 78
 }
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/BirthdayCalendar/EnablePlugin.php 1 patch
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -38,102 +38,102 @@
 block discarded – undo
38 38
  * @package OCA\DAV\CalDAV\BirthdayCalendar
39 39
  */
40 40
 class EnablePlugin extends ServerPlugin {
41
-	const NS_Nextcloud = 'http://nextcloud.com/ns';
42
-
43
-	/**
44
-	 * @var IConfig
45
-	 */
46
-	protected $config;
47
-
48
-	/**
49
-	 * @var BirthdayService
50
-	 */
51
-	protected $birthdayService;
52
-
53
-	/**
54
-	 * @var Server
55
-	 */
56
-	protected $server;
57
-
58
-	/**
59
-	 * PublishPlugin constructor.
60
-	 *
61
-	 * @param IConfig $config
62
-	 * @param BirthdayService $birthdayService
63
-	 */
64
-	public function __construct(IConfig $config, BirthdayService $birthdayService) {
65
-		$this->config = $config;
66
-		$this->birthdayService = $birthdayService;
67
-	}
68
-
69
-	/**
70
-	 * This method should return a list of server-features.
71
-	 *
72
-	 * This is for example 'versioning' and is added to the DAV: header
73
-	 * in an OPTIONS response.
74
-	 *
75
-	 * @return string[]
76
-	 */
77
-	public function getFeatures() {
78
-		return ['nc-enable-birthday-calendar'];
79
-	}
80
-
81
-	/**
82
-	 * Returns a plugin name.
83
-	 *
84
-	 * Using this name other plugins will be able to access other plugins
85
-	 * using Sabre\DAV\Server::getPlugin
86
-	 *
87
-	 * @return string
88
-	 */
89
-	public function getPluginName()	{
90
-		return 'nc-enable-birthday-calendar';
91
-	}
92
-
93
-	/**
94
-	 * This initializes the plugin.
95
-	 *
96
-	 * This function is called by Sabre\DAV\Server, after
97
-	 * addPlugin is called.
98
-	 *
99
-	 * This method should set up the required event subscriptions.
100
-	 *
101
-	 * @param Server $server
102
-	 */
103
-	public function initialize(Server $server) {
104
-		$this->server = $server;
105
-
106
-		$this->server->on('method:POST', [$this, 'httpPost']);
107
-	}
108
-
109
-	/**
110
-	 * We intercept this to handle POST requests on calendar homes.
111
-	 *
112
-	 * @param RequestInterface $request
113
-	 * @param ResponseInterface $response
114
-	 *
115
-	 * @return bool|void
116
-	 */
117
-	public function httpPost(RequestInterface $request, ResponseInterface $response) {
118
-		$node = $this->server->tree->getNodeForPath($this->server->getRequestUri());
119
-		if (!($node instanceof CalendarHome)) {
120
-			return;
121
-		}
122
-
123
-		$requestBody = $request->getBodyAsString();
124
-		$this->server->xml->parse($requestBody, $request->getUrl(), $documentType);
125
-		if ($documentType !== '{'.self::NS_Nextcloud.'}enable-birthday-calendar') {
126
-			return;
127
-		}
128
-
129
-		$principalUri = $node->getOwner();
130
-		$userId = substr($principalUri, 17);
131
-
132
-		$this->config->setUserValue($userId, 'dav', 'generateBirthdayCalendar', 'yes');
133
-		$this->birthdayService->syncUser($userId);
134
-
135
-		$this->server->httpResponse->setStatus(204);
136
-
137
-		return false;
138
-	}
41
+    const NS_Nextcloud = 'http://nextcloud.com/ns';
42
+
43
+    /**
44
+     * @var IConfig
45
+     */
46
+    protected $config;
47
+
48
+    /**
49
+     * @var BirthdayService
50
+     */
51
+    protected $birthdayService;
52
+
53
+    /**
54
+     * @var Server
55
+     */
56
+    protected $server;
57
+
58
+    /**
59
+     * PublishPlugin constructor.
60
+     *
61
+     * @param IConfig $config
62
+     * @param BirthdayService $birthdayService
63
+     */
64
+    public function __construct(IConfig $config, BirthdayService $birthdayService) {
65
+        $this->config = $config;
66
+        $this->birthdayService = $birthdayService;
67
+    }
68
+
69
+    /**
70
+     * This method should return a list of server-features.
71
+     *
72
+     * This is for example 'versioning' and is added to the DAV: header
73
+     * in an OPTIONS response.
74
+     *
75
+     * @return string[]
76
+     */
77
+    public function getFeatures() {
78
+        return ['nc-enable-birthday-calendar'];
79
+    }
80
+
81
+    /**
82
+     * Returns a plugin name.
83
+     *
84
+     * Using this name other plugins will be able to access other plugins
85
+     * using Sabre\DAV\Server::getPlugin
86
+     *
87
+     * @return string
88
+     */
89
+    public function getPluginName()	{
90
+        return 'nc-enable-birthday-calendar';
91
+    }
92
+
93
+    /**
94
+     * This initializes the plugin.
95
+     *
96
+     * This function is called by Sabre\DAV\Server, after
97
+     * addPlugin is called.
98
+     *
99
+     * This method should set up the required event subscriptions.
100
+     *
101
+     * @param Server $server
102
+     */
103
+    public function initialize(Server $server) {
104
+        $this->server = $server;
105
+
106
+        $this->server->on('method:POST', [$this, 'httpPost']);
107
+    }
108
+
109
+    /**
110
+     * We intercept this to handle POST requests on calendar homes.
111
+     *
112
+     * @param RequestInterface $request
113
+     * @param ResponseInterface $response
114
+     *
115
+     * @return bool|void
116
+     */
117
+    public function httpPost(RequestInterface $request, ResponseInterface $response) {
118
+        $node = $this->server->tree->getNodeForPath($this->server->getRequestUri());
119
+        if (!($node instanceof CalendarHome)) {
120
+            return;
121
+        }
122
+
123
+        $requestBody = $request->getBodyAsString();
124
+        $this->server->xml->parse($requestBody, $request->getUrl(), $documentType);
125
+        if ($documentType !== '{'.self::NS_Nextcloud.'}enable-birthday-calendar') {
126
+            return;
127
+        }
128
+
129
+        $principalUri = $node->getOwner();
130
+        $userId = substr($principalUri, 17);
131
+
132
+        $this->config->setUserValue($userId, 'dav', 'generateBirthdayCalendar', 'yes');
133
+        $this->birthdayService->syncUser($userId);
134
+
135
+        $this->server->httpResponse->setStatus(204);
136
+
137
+        return false;
138
+    }
139 139
 }
Please login to merge, or discard this patch.