Completed
Pull Request — master (#4888)
by Julius
32:02 queued 15:08
created
apps/dav/lib/SystemTag/SystemTagsObjectTypeCollection.php 2 patches
Indentation   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -39,136 +39,136 @@
 block discarded – undo
39 39
  */
40 40
 class SystemTagsObjectTypeCollection implements ICollection {
41 41
 
42
-	/**
43
-	 * @var string
44
-	 */
45
-	private $objectType;
46
-
47
-	/**
48
-	 * @var ISystemTagManager
49
-	 */
50
-	private $tagManager;
51
-
52
-	/**
53
-	 * @var ISystemTagObjectMapper
54
-	 */
55
-	private $tagMapper;
56
-
57
-	/**
58
-	 * @var IGroupManager
59
-	 */
60
-	private $groupManager;
61
-
62
-	/**
63
-	 * @var IUserSession
64
-	 */
65
-	private $userSession;
66
-
67
-	/**
68
-	 * @var \Closure
69
-	 **/
70
-	protected $childExistsFunction;
71
-
72
-	/**
73
-	 * Constructor
74
-	 *
75
-	 * @param string $objectType object type
76
-	 * @param ISystemTagManager $tagManager
77
-	 * @param ISystemTagObjectMapper $tagMapper
78
-	 * @param IUserSession $userSession
79
-	 * @param IGroupManager $groupManager
80
-	 * @param \Closure $childExistsFunction
81
-	 */
82
-	public function __construct(
83
-		$objectType, 
84
-		ISystemTagManager $tagManager,
85
-		ISystemTagObjectMapper $tagMapper,
86
-		IUserSession $userSession,
87
-		IGroupManager $groupManager,
88
-		\Closure $childExistsFunction
89
-	) {
90
-		$this->tagManager = $tagManager;
91
-		$this->tagMapper = $tagMapper;
92
-		$this->objectType = $objectType;
93
-		$this->userSession = $userSession;
94
-		$this->groupManager = $groupManager;
95
-		$this->childExistsFunction = $childExistsFunction;
96
-	}
97
-
98
-	/**
99
-	 * @param string $name
100
-	 * @param resource|string $data Initial payload
101
-	 * @return null|string
102
-	 * @throws Forbidden
103
-	 */
104
-	function createFile($name, $data = null) {
105
-		throw new Forbidden('Permission denied to create nodes');
106
-	}
107
-
108
-	/**
109
-	 * @param string $name
110
-	 * @throws Forbidden
111
-	 */
112
-	function createDirectory($name) {
113
-		throw new Forbidden('Permission denied to create collections');
114
-	}
115
-
116
-	/**
117
-	 * @param string $objectId
118
-	 * @return SystemTagsObjectMappingCollection
119
-	 * @throws NotFound
120
-	 */
121
-	function getChild($objectId) {
122
-		// make sure the object exists and is reachable
123
-		if(!$this->childExists($objectId)) {
124
-			throw new NotFound('Entity does not exist or is not available');
125
-		}
126
-		return new SystemTagsObjectMappingCollection(
127
-			$objectId,
128
-			$this->objectType,
129
-			$this->userSession->getUser(),
130
-			$this->tagManager,
131
-			$this->tagMapper
132
-		);
133
-	}
134
-
135
-	function getChildren() {
136
-		// do not list object ids
137
-		throw new MethodNotAllowed();
138
-	}
139
-
140
-	/**
141
-	 * Checks if a child-node with the specified name exists
142
-	 *
143
-	 * @param string $name
144
-	 * @return bool
145
-	 */
146
-	function childExists($name) {
147
-		return call_user_func($this->childExistsFunction, $name);
148
-	}
149
-
150
-	function delete() {
151
-		throw new Forbidden('Permission denied to delete this collection');
152
-	}
153
-
154
-	function getName() {
155
-		return $this->objectType;
156
-	}
157
-
158
-	/**
159
-	 * @param string $name
160
-	 * @throws Forbidden
161
-	 */
162
-	function setName($name) {
163
-		throw new Forbidden('Permission denied to rename this collection');
164
-	}
165
-
166
-	/**
167
-	 * Returns the last modification time, as a unix timestamp
168
-	 *
169
-	 * @return int
170
-	 */
171
-	function getLastModified() {
172
-		return null;
173
-	}
42
+    /**
43
+     * @var string
44
+     */
45
+    private $objectType;
46
+
47
+    /**
48
+     * @var ISystemTagManager
49
+     */
50
+    private $tagManager;
51
+
52
+    /**
53
+     * @var ISystemTagObjectMapper
54
+     */
55
+    private $tagMapper;
56
+
57
+    /**
58
+     * @var IGroupManager
59
+     */
60
+    private $groupManager;
61
+
62
+    /**
63
+     * @var IUserSession
64
+     */
65
+    private $userSession;
66
+
67
+    /**
68
+     * @var \Closure
69
+     **/
70
+    protected $childExistsFunction;
71
+
72
+    /**
73
+     * Constructor
74
+     *
75
+     * @param string $objectType object type
76
+     * @param ISystemTagManager $tagManager
77
+     * @param ISystemTagObjectMapper $tagMapper
78
+     * @param IUserSession $userSession
79
+     * @param IGroupManager $groupManager
80
+     * @param \Closure $childExistsFunction
81
+     */
82
+    public function __construct(
83
+        $objectType, 
84
+        ISystemTagManager $tagManager,
85
+        ISystemTagObjectMapper $tagMapper,
86
+        IUserSession $userSession,
87
+        IGroupManager $groupManager,
88
+        \Closure $childExistsFunction
89
+    ) {
90
+        $this->tagManager = $tagManager;
91
+        $this->tagMapper = $tagMapper;
92
+        $this->objectType = $objectType;
93
+        $this->userSession = $userSession;
94
+        $this->groupManager = $groupManager;
95
+        $this->childExistsFunction = $childExistsFunction;
96
+    }
97
+
98
+    /**
99
+     * @param string $name
100
+     * @param resource|string $data Initial payload
101
+     * @return null|string
102
+     * @throws Forbidden
103
+     */
104
+    function createFile($name, $data = null) {
105
+        throw new Forbidden('Permission denied to create nodes');
106
+    }
107
+
108
+    /**
109
+     * @param string $name
110
+     * @throws Forbidden
111
+     */
112
+    function createDirectory($name) {
113
+        throw new Forbidden('Permission denied to create collections');
114
+    }
115
+
116
+    /**
117
+     * @param string $objectId
118
+     * @return SystemTagsObjectMappingCollection
119
+     * @throws NotFound
120
+     */
121
+    function getChild($objectId) {
122
+        // make sure the object exists and is reachable
123
+        if(!$this->childExists($objectId)) {
124
+            throw new NotFound('Entity does not exist or is not available');
125
+        }
126
+        return new SystemTagsObjectMappingCollection(
127
+            $objectId,
128
+            $this->objectType,
129
+            $this->userSession->getUser(),
130
+            $this->tagManager,
131
+            $this->tagMapper
132
+        );
133
+    }
134
+
135
+    function getChildren() {
136
+        // do not list object ids
137
+        throw new MethodNotAllowed();
138
+    }
139
+
140
+    /**
141
+     * Checks if a child-node with the specified name exists
142
+     *
143
+     * @param string $name
144
+     * @return bool
145
+     */
146
+    function childExists($name) {
147
+        return call_user_func($this->childExistsFunction, $name);
148
+    }
149
+
150
+    function delete() {
151
+        throw new Forbidden('Permission denied to delete this collection');
152
+    }
153
+
154
+    function getName() {
155
+        return $this->objectType;
156
+    }
157
+
158
+    /**
159
+     * @param string $name
160
+     * @throws Forbidden
161
+     */
162
+    function setName($name) {
163
+        throw new Forbidden('Permission denied to rename this collection');
164
+    }
165
+
166
+    /**
167
+     * Returns the last modification time, as a unix timestamp
168
+     *
169
+     * @return int
170
+     */
171
+    function getLastModified() {
172
+        return null;
173
+    }
174 174
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@
 block discarded – undo
120 120
 	 */
121 121
 	function getChild($objectId) {
122 122
 		// make sure the object exists and is reachable
123
-		if(!$this->childExists($objectId)) {
123
+		if (!$this->childExists($objectId)) {
124 124
 			throw new NotFound('Entity does not exist or is not available');
125 125
 		}
126 126
 		return new SystemTagsObjectMappingCollection(
Please login to merge, or discard this patch.
apps/dav/lib/SystemTag/SystemTagMappingNode.php 2 patches
Indentation   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -37,134 +37,134 @@
 block discarded – undo
37 37
  * Mapping node for system tag to object id
38 38
  */
39 39
 class SystemTagMappingNode implements \Sabre\DAV\INode {
40
-	/**
41
-	 * @var ISystemTag
42
-	 */
43
-	protected $tag;
44
-
45
-	/**
46
-	 * @var string
47
-	 */
48
-	private $objectId;
49
-
50
-	/**
51
-	 * @var string
52
-	 */
53
-	private $objectType;
54
-
55
-	/**
56
-	 * User
57
-	 *
58
-	 * @var IUser
59
-	 */
60
-	protected $user;
61
-
62
-	/**
63
-	 * @var ISystemTagManager
64
-	 */
65
-	protected $tagManager;
66
-
67
-	/**
68
-	 * @var ISystemTagObjectMapper
69
-	 */
70
-	private $tagMapper;
71
-
72
-	/**
73
-	 * Sets up the node, expects a full path name
74
-	 *
75
-	 * @param ISystemTag $tag system tag
76
-	 * @param string $objectId
77
-	 * @param string $objectType
78
-	 * @param IUser $user user
79
-	 * @param ISystemTagManager $tagManager
80
-	 * @param ISystemTagObjectMapper $tagMapper
81
-	 */
82
-	public function __construct(
83
-		ISystemTag $tag,
84
-		$objectId,
85
-		$objectType,
86
-		IUser $user,
87
-		ISystemTagManager $tagManager,
88
-		ISystemTagObjectMapper $tagMapper
89
-	) {
90
-		$this->tag = $tag;
91
-		$this->objectId = $objectId;
92
-		$this->objectType = $objectType;
93
-		$this->user = $user;
94
-		$this->tagManager = $tagManager;
95
-		$this->tagMapper = $tagMapper;
96
-	}
97
-
98
-	/**
99
-	 * Returns the object id of the relationship
100
-	 *
101
-	 * @return string object id
102
-	 */
103
-	public function getObjectId() {
104
-		return $this->objectId;
105
-	}
106
-
107
-	/**
108
-	 * Returns the object type of the relationship
109
-	 *
110
-	 * @return string object type
111
-	 */
112
-	public function getObjectType() {
113
-		return $this->objectType;
114
-	}
115
-
116
-	/**
117
-	 * Returns the system tag represented by this node
118
-	 *
119
-	 * @return ISystemTag system tag
120
-	 */
121
-	public function getSystemTag() {
122
-		return $this->tag;
123
-	}
124
-
125
-	/**
126
-	 *  Returns the id of the tag
127
-	 *
128
-	 * @return string
129
-	 */
130
-	public function getName() {
131
-		return $this->tag->getId();
132
-	}
133
-
134
-	/**
135
-	 * Renames the node
136
-	 *
137
-	 * @param string $name The new name
138
-	 *
139
-	 * @throws MethodNotAllowed not allowed to rename node
140
-	 */
141
-	public function setName($name) {
142
-		throw new MethodNotAllowed();
143
-	}
144
-
145
-	/**
146
-	 * Returns null, not supported
147
-	 *
148
-	 */
149
-	public function getLastModified() {
150
-		return null;
151
-	}
152
-
153
-	/**
154
-	 * Delete tag to object association
155
-	 */
156
-	public function delete() {
157
-		try {
158
-			if (!$this->tagManager->canUserSeeTag($this->tag, $this->user)) {
159
-				throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found');
160
-			}
161
-			if (!$this->tagManager->canUserAssignTag($this->tag, $this->user)) {
162
-				throw new Forbidden('No permission to unassign tag ' . $this->tag->getId());
163
-			}
164
-			$this->tagMapper->unassignTags($this->objectId, $this->objectType, $this->tag->getId());
165
-		} catch (TagNotFoundException $e) {
166
-			// can happen if concurrent deletion occurred
167
-			throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found', 0, $e);
168
-		}
169
-	}
40
+    /**
41
+     * @var ISystemTag
42
+     */
43
+    protected $tag;
44
+
45
+    /**
46
+     * @var string
47
+     */
48
+    private $objectId;
49
+
50
+    /**
51
+     * @var string
52
+     */
53
+    private $objectType;
54
+
55
+    /**
56
+     * User
57
+     *
58
+     * @var IUser
59
+     */
60
+    protected $user;
61
+
62
+    /**
63
+     * @var ISystemTagManager
64
+     */
65
+    protected $tagManager;
66
+
67
+    /**
68
+     * @var ISystemTagObjectMapper
69
+     */
70
+    private $tagMapper;
71
+
72
+    /**
73
+     * Sets up the node, expects a full path name
74
+     *
75
+     * @param ISystemTag $tag system tag
76
+     * @param string $objectId
77
+     * @param string $objectType
78
+     * @param IUser $user user
79
+     * @param ISystemTagManager $tagManager
80
+     * @param ISystemTagObjectMapper $tagMapper
81
+     */
82
+    public function __construct(
83
+        ISystemTag $tag,
84
+        $objectId,
85
+        $objectType,
86
+        IUser $user,
87
+        ISystemTagManager $tagManager,
88
+        ISystemTagObjectMapper $tagMapper
89
+    ) {
90
+        $this->tag = $tag;
91
+        $this->objectId = $objectId;
92
+        $this->objectType = $objectType;
93
+        $this->user = $user;
94
+        $this->tagManager = $tagManager;
95
+        $this->tagMapper = $tagMapper;
96
+    }
97
+
98
+    /**
99
+     * Returns the object id of the relationship
100
+     *
101
+     * @return string object id
102
+     */
103
+    public function getObjectId() {
104
+        return $this->objectId;
105
+    }
106
+
107
+    /**
108
+     * Returns the object type of the relationship
109
+     *
110
+     * @return string object type
111
+     */
112
+    public function getObjectType() {
113
+        return $this->objectType;
114
+    }
115
+
116
+    /**
117
+     * Returns the system tag represented by this node
118
+     *
119
+     * @return ISystemTag system tag
120
+     */
121
+    public function getSystemTag() {
122
+        return $this->tag;
123
+    }
124
+
125
+    /**
126
+     *  Returns the id of the tag
127
+     *
128
+     * @return string
129
+     */
130
+    public function getName() {
131
+        return $this->tag->getId();
132
+    }
133
+
134
+    /**
135
+     * Renames the node
136
+     *
137
+     * @param string $name The new name
138
+     *
139
+     * @throws MethodNotAllowed not allowed to rename node
140
+     */
141
+    public function setName($name) {
142
+        throw new MethodNotAllowed();
143
+    }
144
+
145
+    /**
146
+     * Returns null, not supported
147
+     *
148
+     */
149
+    public function getLastModified() {
150
+        return null;
151
+    }
152
+
153
+    /**
154
+     * Delete tag to object association
155
+     */
156
+    public function delete() {
157
+        try {
158
+            if (!$this->tagManager->canUserSeeTag($this->tag, $this->user)) {
159
+                throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found');
160
+            }
161
+            if (!$this->tagManager->canUserAssignTag($this->tag, $this->user)) {
162
+                throw new Forbidden('No permission to unassign tag ' . $this->tag->getId());
163
+            }
164
+            $this->tagMapper->unassignTags($this->objectId, $this->objectType, $this->tag->getId());
165
+        } catch (TagNotFoundException $e) {
166
+            // can happen if concurrent deletion occurred
167
+            throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found', 0, $e);
168
+        }
169
+    }
170 170
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -156,15 +156,15 @@
 block discarded – undo
156 156
 	public function delete() {
157 157
 		try {
158 158
 			if (!$this->tagManager->canUserSeeTag($this->tag, $this->user)) {
159
-				throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found');
159
+				throw new NotFound('Tag with id '.$this->tag->getId().' not found');
160 160
 			}
161 161
 			if (!$this->tagManager->canUserAssignTag($this->tag, $this->user)) {
162
-				throw new Forbidden('No permission to unassign tag ' . $this->tag->getId());
162
+				throw new Forbidden('No permission to unassign tag '.$this->tag->getId());
163 163
 			}
164 164
 			$this->tagMapper->unassignTags($this->objectId, $this->objectType, $this->tag->getId());
165 165
 		} catch (TagNotFoundException $e) {
166 166
 			// can happen if concurrent deletion occurred
167
-			throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found', 0, $e);
167
+			throw new NotFound('Tag with id '.$this->tag->getId().' not found', 0, $e);
168 168
 		}
169 169
 	}
170 170
 }
Please login to merge, or discard this patch.
apps/dav/lib/SystemTag/SystemTagPlugin.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 			if ($node instanceof SystemTagsObjectMappingCollection) {
136 136
 				// also add to collection
137 137
 				$node->createFile($tag->getId());
138
-				$url = $request->getBaseUrl() . 'systemtags/';
138
+				$url = $request->getBaseUrl().'systemtags/';
139 139
 			} else {
140 140
 				$url = $request->getUrl();
141 141
 			}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 				$url .= '/';
145 145
 			}
146 146
 
147
-			$response->setHeader('Content-Location', $url . $tag->getId());
147
+			$response->setHeader('Content-Location', $url.$tag->getId());
148 148
 
149 149
 			// created
150 150
 			$response->setStatus(201);
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
 		$userAssignable = true;
180 180
 
181 181
 		if (isset($data['userVisible'])) {
182
-			$userVisible = (bool)$data['userVisible'];
182
+			$userVisible = (bool) $data['userVisible'];
183 183
 		}
184 184
 
185 185
 		if (isset($data['userAssignable'])) {
186
-			$userAssignable = (bool)$data['userAssignable'];
186
+			$userAssignable = (bool) $data['userAssignable'];
187 187
 		}
188 188
 
189 189
 		$groups = [];
@@ -194,8 +194,8 @@  discard block
 block discarded – undo
194 194
 			}
195 195
 		}
196 196
 
197
-		if($userVisible === false || $userAssignable === false || !empty($groups)) {
198
-			if(!$this->userSession->isLoggedIn() || !$this->groupManager->isAdmin($this->userSession->getUser()->getUID())) {
197
+		if ($userVisible === false || $userAssignable === false || !empty($groups)) {
198
+			if (!$this->userSession->isLoggedIn() || !$this->groupManager->isAdmin($this->userSession->getUser()->getUID())) {
199 199
 				throw new BadRequest('Not sufficient permissions');
200 200
 			}
201 201
 		}
Please login to merge, or discard this patch.
Indentation   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -46,280 +46,280 @@
 block discarded – undo
46 46
  */
47 47
 class SystemTagPlugin extends \Sabre\DAV\ServerPlugin {
48 48
 
49
-	// namespace
50
-	const NS_OWNCLOUD = 'http://owncloud.org/ns';
51
-	const ID_PROPERTYNAME = '{http://owncloud.org/ns}id';
52
-	const DISPLAYNAME_PROPERTYNAME = '{http://owncloud.org/ns}display-name';
53
-	const USERVISIBLE_PROPERTYNAME = '{http://owncloud.org/ns}user-visible';
54
-	const USERASSIGNABLE_PROPERTYNAME = '{http://owncloud.org/ns}user-assignable';
55
-	const GROUPS_PROPERTYNAME = '{http://owncloud.org/ns}groups';
56
-	const CANASSIGN_PROPERTYNAME = '{http://owncloud.org/ns}can-assign';
57
-
58
-	/**
59
-	 * @var \Sabre\DAV\Server $server
60
-	 */
61
-	private $server;
62
-
63
-	/**
64
-	 * @var ISystemTagManager
65
-	 */
66
-	protected $tagManager;
67
-
68
-	/**
69
-	 * @var IUserSession
70
-	 */
71
-	protected $userSession;
72
-
73
-	/**
74
-	 * @var IGroupManager
75
-	 */
76
-	protected $groupManager;
77
-
78
-	/**
79
-	 * @param ISystemTagManager $tagManager tag manager
80
-	 * @param IGroupManager $groupManager
81
-	 * @param IUserSession $userSession
82
-	 */
83
-	public function __construct(ISystemTagManager $tagManager,
84
-								IGroupManager $groupManager,
85
-								IUserSession $userSession) {
86
-		$this->tagManager = $tagManager;
87
-		$this->userSession = $userSession;
88
-		$this->groupManager = $groupManager;
89
-	}
90
-
91
-	/**
92
-	 * This initializes the plugin.
93
-	 *
94
-	 * This function is called by \Sabre\DAV\Server, after
95
-	 * addPlugin is called.
96
-	 *
97
-	 * This method should set up the required event subscriptions.
98
-	 *
99
-	 * @param \Sabre\DAV\Server $server
100
-	 * @return void
101
-	 */
102
-	public function initialize(\Sabre\DAV\Server $server) {
103
-
104
-		$server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc';
105
-
106
-		$server->protectedProperties[] = self::ID_PROPERTYNAME;
107
-
108
-		$server->on('propFind', array($this, 'handleGetProperties'));
109
-		$server->on('propPatch', array($this, 'handleUpdateProperties'));
110
-		$server->on('method:POST', [$this, 'httpPost']);
111
-
112
-		$this->server = $server;
113
-	}
114
-
115
-	/**
116
-	 * POST operation on system tag collections
117
-	 *
118
-	 * @param RequestInterface $request request object
119
-	 * @param ResponseInterface $response response object
120
-	 * @return null|false
121
-	 */
122
-	public function httpPost(RequestInterface $request, ResponseInterface $response) {
123
-		$path = $request->getPath();
124
-
125
-		// Making sure the node exists
126
-		$node = $this->server->tree->getNodeForPath($path);
127
-		if ($node instanceof SystemTagsByIdCollection || $node instanceof SystemTagsObjectMappingCollection) {
128
-			$data = $request->getBodyAsString();
129
-
130
-			$tag = $this->createTag($data, $request->getHeader('Content-Type'));
131
-
132
-			if ($node instanceof SystemTagsObjectMappingCollection) {
133
-				// also add to collection
134
-				$node->createFile($tag->getId());
135
-				$url = $request->getBaseUrl() . 'systemtags/';
136
-			} else {
137
-				$url = $request->getUrl();
138
-			}
139
-
140
-			if ($url[strlen($url) - 1] !== '/') {
141
-				$url .= '/';
142
-			}
143
-
144
-			$response->setHeader('Content-Location', $url . $tag->getId());
145
-
146
-			// created
147
-			$response->setStatus(201);
148
-			return false;
149
-		}
150
-	}
151
-
152
-	/**
153
-	 * Creates a new tag
154
-	 *
155
-	 * @param string $data JSON encoded string containing the properties of the tag to create
156
-	 * @param string $contentType content type of the data
157
-	 * @return ISystemTag newly created system tag
158
-	 *
159
-	 * @throws BadRequest if a field was missing
160
-	 * @throws Conflict if a tag with the same properties already exists
161
-	 * @throws UnsupportedMediaType if the content type is not supported
162
-	 */
163
-	private function createTag($data, $contentType = 'application/json') {
164
-		if (explode(';', $contentType)[0] === 'application/json') {
165
-			$data = json_decode($data, true);
166
-		} else {
167
-			throw new UnsupportedMediaType();
168
-		}
169
-
170
-		if (!isset($data['name'])) {
171
-			throw new BadRequest('Missing "name" attribute');
172
-		}
173
-
174
-		$tagName = $data['name'];
175
-		$userVisible = true;
176
-		$userAssignable = true;
177
-
178
-		if (isset($data['userVisible'])) {
179
-			$userVisible = (bool)$data['userVisible'];
180
-		}
181
-
182
-		if (isset($data['userAssignable'])) {
183
-			$userAssignable = (bool)$data['userAssignable'];
184
-		}
185
-
186
-		$groups = [];
187
-		if (isset($data['groups'])) {
188
-			$groups = $data['groups'];
189
-			if (is_string($groups)) {
190
-				$groups = explode('|', $groups);
191
-			}
192
-		}
193
-
194
-		if($userVisible === false || $userAssignable === false || !empty($groups)) {
195
-			if(!$this->userSession->isLoggedIn() || !$this->groupManager->isAdmin($this->userSession->getUser()->getUID())) {
196
-				throw new BadRequest('Not sufficient permissions');
197
-			}
198
-		}
199
-
200
-		try {
201
-			$tag = $this->tagManager->createTag($tagName, $userVisible, $userAssignable);
202
-			if (!empty($groups)) {
203
-				$this->tagManager->setTagGroups($tag, $groups);
204
-			}
205
-			return $tag;
206
-		} catch (TagAlreadyExistsException $e) {
207
-			throw new Conflict('Tag already exists', 0, $e);
208
-		}
209
-	}
210
-
211
-
212
-	/**
213
-	 * Retrieves system tag properties
214
-	 *
215
-	 * @param PropFind $propFind
216
-	 * @param \Sabre\DAV\INode $node
217
-	 */
218
-	public function handleGetProperties(
219
-		PropFind $propFind,
220
-		\Sabre\DAV\INode $node
221
-	) {
222
-		if (!($node instanceof SystemTagNode) && !($node instanceof SystemTagMappingNode)) {
223
-			return;
224
-		}
225
-
226
-		$propFind->handle(self::ID_PROPERTYNAME, function() use ($node) {
227
-			return $node->getSystemTag()->getId();
228
-		});
229
-
230
-		$propFind->handle(self::DISPLAYNAME_PROPERTYNAME, function() use ($node) {
231
-			return $node->getSystemTag()->getName();
232
-		});
233
-
234
-		$propFind->handle(self::USERVISIBLE_PROPERTYNAME, function() use ($node) {
235
-			return $node->getSystemTag()->isUserVisible() ? 'true' : 'false';
236
-		});
237
-
238
-		$propFind->handle(self::USERASSIGNABLE_PROPERTYNAME, function() use ($node) {
239
-			// this is the tag's inherent property "is user assignable"
240
-			return $node->getSystemTag()->isUserAssignable() ? 'true' : 'false';
241
-		});
242
-
243
-		$propFind->handle(self::CANASSIGN_PROPERTYNAME, function() use ($node) {
244
-			// this is the effective permission for the current user
245
-			return $this->tagManager->canUserAssignTag($node->getSystemTag(), $this->userSession->getUser()) ? 'true' : 'false';
246
-		});
247
-
248
-		$propFind->handle(self::GROUPS_PROPERTYNAME, function() use ($node) {
249
-			if (!$this->groupManager->isAdmin($this->userSession->getUser()->getUID())) {
250
-				// property only available for admins
251
-				throw new Forbidden();
252
-			}
253
-			$groups = [];
254
-			// no need to retrieve groups for namespaces that don't qualify
255
-			if ($node->getSystemTag()->isUserVisible() && !$node->getSystemTag()->isUserAssignable()) {
256
-				$groups = $this->tagManager->getTagGroups($node->getSystemTag());
257
-			}
258
-			return implode('|', $groups);
259
-		});
260
-	}
261
-
262
-	/**
263
-	 * Updates tag attributes
264
-	 *
265
-	 * @param string $path
266
-	 * @param PropPatch $propPatch
267
-	 *
268
-	 * @return void
269
-	 */
270
-	public function handleUpdateProperties($path, PropPatch $propPatch) {
271
-		$node = $this->server->tree->getNodeForPath($path);
272
-		if (!($node instanceof SystemTagNode)) {
273
-			return;
274
-		}
275
-
276
-		$propPatch->handle([
277
-			self::DISPLAYNAME_PROPERTYNAME,
278
-			self::USERVISIBLE_PROPERTYNAME,
279
-			self::USERASSIGNABLE_PROPERTYNAME,
280
-			self::GROUPS_PROPERTYNAME,
281
-		], function($props) use ($node) {
282
-			$tag = $node->getSystemTag();
283
-			$name = $tag->getName();
284
-			$userVisible = $tag->isUserVisible();
285
-			$userAssignable = $tag->isUserAssignable();
286
-
287
-			$updateTag = false;
288
-
289
-			if (isset($props[self::DISPLAYNAME_PROPERTYNAME])) {
290
-				$name = $props[self::DISPLAYNAME_PROPERTYNAME];
291
-				$updateTag = true;
292
-			}
293
-
294
-			if (isset($props[self::USERVISIBLE_PROPERTYNAME])) {
295
-				$propValue = $props[self::USERVISIBLE_PROPERTYNAME];
296
-				$userVisible = ($propValue !== 'false' && $propValue !== '0');
297
-				$updateTag = true;
298
-			}
299
-
300
-			if (isset($props[self::USERASSIGNABLE_PROPERTYNAME])) {
301
-				$propValue = $props[self::USERASSIGNABLE_PROPERTYNAME];
302
-				$userAssignable = ($propValue !== 'false' && $propValue !== '0');
303
-				$updateTag = true;
304
-			}
305
-
306
-			if (isset($props[self::GROUPS_PROPERTYNAME])) {
307
-				if (!$this->groupManager->isAdmin($this->userSession->getUser()->getUID())) {
308
-					// property only available for admins
309
-					throw new Forbidden();
310
-				}
311
-
312
-				$propValue = $props[self::GROUPS_PROPERTYNAME];
313
-				$groupIds = explode('|', $propValue);
314
-				$this->tagManager->setTagGroups($tag, $groupIds);
315
-			}
316
-
317
-			if ($updateTag) {
318
-				$node->update($name, $userVisible, $userAssignable);
319
-			}
320
-
321
-			return true;
322
-		});
323
-
324
-	}
49
+    // namespace
50
+    const NS_OWNCLOUD = 'http://owncloud.org/ns';
51
+    const ID_PROPERTYNAME = '{http://owncloud.org/ns}id';
52
+    const DISPLAYNAME_PROPERTYNAME = '{http://owncloud.org/ns}display-name';
53
+    const USERVISIBLE_PROPERTYNAME = '{http://owncloud.org/ns}user-visible';
54
+    const USERASSIGNABLE_PROPERTYNAME = '{http://owncloud.org/ns}user-assignable';
55
+    const GROUPS_PROPERTYNAME = '{http://owncloud.org/ns}groups';
56
+    const CANASSIGN_PROPERTYNAME = '{http://owncloud.org/ns}can-assign';
57
+
58
+    /**
59
+     * @var \Sabre\DAV\Server $server
60
+     */
61
+    private $server;
62
+
63
+    /**
64
+     * @var ISystemTagManager
65
+     */
66
+    protected $tagManager;
67
+
68
+    /**
69
+     * @var IUserSession
70
+     */
71
+    protected $userSession;
72
+
73
+    /**
74
+     * @var IGroupManager
75
+     */
76
+    protected $groupManager;
77
+
78
+    /**
79
+     * @param ISystemTagManager $tagManager tag manager
80
+     * @param IGroupManager $groupManager
81
+     * @param IUserSession $userSession
82
+     */
83
+    public function __construct(ISystemTagManager $tagManager,
84
+                                IGroupManager $groupManager,
85
+                                IUserSession $userSession) {
86
+        $this->tagManager = $tagManager;
87
+        $this->userSession = $userSession;
88
+        $this->groupManager = $groupManager;
89
+    }
90
+
91
+    /**
92
+     * This initializes the plugin.
93
+     *
94
+     * This function is called by \Sabre\DAV\Server, after
95
+     * addPlugin is called.
96
+     *
97
+     * This method should set up the required event subscriptions.
98
+     *
99
+     * @param \Sabre\DAV\Server $server
100
+     * @return void
101
+     */
102
+    public function initialize(\Sabre\DAV\Server $server) {
103
+
104
+        $server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc';
105
+
106
+        $server->protectedProperties[] = self::ID_PROPERTYNAME;
107
+
108
+        $server->on('propFind', array($this, 'handleGetProperties'));
109
+        $server->on('propPatch', array($this, 'handleUpdateProperties'));
110
+        $server->on('method:POST', [$this, 'httpPost']);
111
+
112
+        $this->server = $server;
113
+    }
114
+
115
+    /**
116
+     * POST operation on system tag collections
117
+     *
118
+     * @param RequestInterface $request request object
119
+     * @param ResponseInterface $response response object
120
+     * @return null|false
121
+     */
122
+    public function httpPost(RequestInterface $request, ResponseInterface $response) {
123
+        $path = $request->getPath();
124
+
125
+        // Making sure the node exists
126
+        $node = $this->server->tree->getNodeForPath($path);
127
+        if ($node instanceof SystemTagsByIdCollection || $node instanceof SystemTagsObjectMappingCollection) {
128
+            $data = $request->getBodyAsString();
129
+
130
+            $tag = $this->createTag($data, $request->getHeader('Content-Type'));
131
+
132
+            if ($node instanceof SystemTagsObjectMappingCollection) {
133
+                // also add to collection
134
+                $node->createFile($tag->getId());
135
+                $url = $request->getBaseUrl() . 'systemtags/';
136
+            } else {
137
+                $url = $request->getUrl();
138
+            }
139
+
140
+            if ($url[strlen($url) - 1] !== '/') {
141
+                $url .= '/';
142
+            }
143
+
144
+            $response->setHeader('Content-Location', $url . $tag->getId());
145
+
146
+            // created
147
+            $response->setStatus(201);
148
+            return false;
149
+        }
150
+    }
151
+
152
+    /**
153
+     * Creates a new tag
154
+     *
155
+     * @param string $data JSON encoded string containing the properties of the tag to create
156
+     * @param string $contentType content type of the data
157
+     * @return ISystemTag newly created system tag
158
+     *
159
+     * @throws BadRequest if a field was missing
160
+     * @throws Conflict if a tag with the same properties already exists
161
+     * @throws UnsupportedMediaType if the content type is not supported
162
+     */
163
+    private function createTag($data, $contentType = 'application/json') {
164
+        if (explode(';', $contentType)[0] === 'application/json') {
165
+            $data = json_decode($data, true);
166
+        } else {
167
+            throw new UnsupportedMediaType();
168
+        }
169
+
170
+        if (!isset($data['name'])) {
171
+            throw new BadRequest('Missing "name" attribute');
172
+        }
173
+
174
+        $tagName = $data['name'];
175
+        $userVisible = true;
176
+        $userAssignable = true;
177
+
178
+        if (isset($data['userVisible'])) {
179
+            $userVisible = (bool)$data['userVisible'];
180
+        }
181
+
182
+        if (isset($data['userAssignable'])) {
183
+            $userAssignable = (bool)$data['userAssignable'];
184
+        }
185
+
186
+        $groups = [];
187
+        if (isset($data['groups'])) {
188
+            $groups = $data['groups'];
189
+            if (is_string($groups)) {
190
+                $groups = explode('|', $groups);
191
+            }
192
+        }
193
+
194
+        if($userVisible === false || $userAssignable === false || !empty($groups)) {
195
+            if(!$this->userSession->isLoggedIn() || !$this->groupManager->isAdmin($this->userSession->getUser()->getUID())) {
196
+                throw new BadRequest('Not sufficient permissions');
197
+            }
198
+        }
199
+
200
+        try {
201
+            $tag = $this->tagManager->createTag($tagName, $userVisible, $userAssignable);
202
+            if (!empty($groups)) {
203
+                $this->tagManager->setTagGroups($tag, $groups);
204
+            }
205
+            return $tag;
206
+        } catch (TagAlreadyExistsException $e) {
207
+            throw new Conflict('Tag already exists', 0, $e);
208
+        }
209
+    }
210
+
211
+
212
+    /**
213
+     * Retrieves system tag properties
214
+     *
215
+     * @param PropFind $propFind
216
+     * @param \Sabre\DAV\INode $node
217
+     */
218
+    public function handleGetProperties(
219
+        PropFind $propFind,
220
+        \Sabre\DAV\INode $node
221
+    ) {
222
+        if (!($node instanceof SystemTagNode) && !($node instanceof SystemTagMappingNode)) {
223
+            return;
224
+        }
225
+
226
+        $propFind->handle(self::ID_PROPERTYNAME, function() use ($node) {
227
+            return $node->getSystemTag()->getId();
228
+        });
229
+
230
+        $propFind->handle(self::DISPLAYNAME_PROPERTYNAME, function() use ($node) {
231
+            return $node->getSystemTag()->getName();
232
+        });
233
+
234
+        $propFind->handle(self::USERVISIBLE_PROPERTYNAME, function() use ($node) {
235
+            return $node->getSystemTag()->isUserVisible() ? 'true' : 'false';
236
+        });
237
+
238
+        $propFind->handle(self::USERASSIGNABLE_PROPERTYNAME, function() use ($node) {
239
+            // this is the tag's inherent property "is user assignable"
240
+            return $node->getSystemTag()->isUserAssignable() ? 'true' : 'false';
241
+        });
242
+
243
+        $propFind->handle(self::CANASSIGN_PROPERTYNAME, function() use ($node) {
244
+            // this is the effective permission for the current user
245
+            return $this->tagManager->canUserAssignTag($node->getSystemTag(), $this->userSession->getUser()) ? 'true' : 'false';
246
+        });
247
+
248
+        $propFind->handle(self::GROUPS_PROPERTYNAME, function() use ($node) {
249
+            if (!$this->groupManager->isAdmin($this->userSession->getUser()->getUID())) {
250
+                // property only available for admins
251
+                throw new Forbidden();
252
+            }
253
+            $groups = [];
254
+            // no need to retrieve groups for namespaces that don't qualify
255
+            if ($node->getSystemTag()->isUserVisible() && !$node->getSystemTag()->isUserAssignable()) {
256
+                $groups = $this->tagManager->getTagGroups($node->getSystemTag());
257
+            }
258
+            return implode('|', $groups);
259
+        });
260
+    }
261
+
262
+    /**
263
+     * Updates tag attributes
264
+     *
265
+     * @param string $path
266
+     * @param PropPatch $propPatch
267
+     *
268
+     * @return void
269
+     */
270
+    public function handleUpdateProperties($path, PropPatch $propPatch) {
271
+        $node = $this->server->tree->getNodeForPath($path);
272
+        if (!($node instanceof SystemTagNode)) {
273
+            return;
274
+        }
275
+
276
+        $propPatch->handle([
277
+            self::DISPLAYNAME_PROPERTYNAME,
278
+            self::USERVISIBLE_PROPERTYNAME,
279
+            self::USERASSIGNABLE_PROPERTYNAME,
280
+            self::GROUPS_PROPERTYNAME,
281
+        ], function($props) use ($node) {
282
+            $tag = $node->getSystemTag();
283
+            $name = $tag->getName();
284
+            $userVisible = $tag->isUserVisible();
285
+            $userAssignable = $tag->isUserAssignable();
286
+
287
+            $updateTag = false;
288
+
289
+            if (isset($props[self::DISPLAYNAME_PROPERTYNAME])) {
290
+                $name = $props[self::DISPLAYNAME_PROPERTYNAME];
291
+                $updateTag = true;
292
+            }
293
+
294
+            if (isset($props[self::USERVISIBLE_PROPERTYNAME])) {
295
+                $propValue = $props[self::USERVISIBLE_PROPERTYNAME];
296
+                $userVisible = ($propValue !== 'false' && $propValue !== '0');
297
+                $updateTag = true;
298
+            }
299
+
300
+            if (isset($props[self::USERASSIGNABLE_PROPERTYNAME])) {
301
+                $propValue = $props[self::USERASSIGNABLE_PROPERTYNAME];
302
+                $userAssignable = ($propValue !== 'false' && $propValue !== '0');
303
+                $updateTag = true;
304
+            }
305
+
306
+            if (isset($props[self::GROUPS_PROPERTYNAME])) {
307
+                if (!$this->groupManager->isAdmin($this->userSession->getUser()->getUID())) {
308
+                    // property only available for admins
309
+                    throw new Forbidden();
310
+                }
311
+
312
+                $propValue = $props[self::GROUPS_PROPERTYNAME];
313
+                $groupIds = explode('|', $propValue);
314
+                $this->tagManager->setTagGroups($tag, $groupIds);
315
+            }
316
+
317
+            if ($updateTag) {
318
+                $node->update($name, $userVisible, $userAssignable);
319
+            }
320
+
321
+            return true;
322
+        });
323
+
324
+    }
325 325
 }
Please login to merge, or discard this patch.
apps/dav/lib/SystemTag/SystemTagsRelationsCollection.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -36,59 +36,59 @@
 block discarded – undo
36 36
 
37 37
 class SystemTagsRelationsCollection extends SimpleCollection {
38 38
 
39
-	/**
40
-	 * SystemTagsRelationsCollection constructor.
41
-	 *
42
-	 * @param ISystemTagManager $tagManager
43
-	 * @param ISystemTagObjectMapper $tagMapper
44
-	 * @param IUserSession $userSession
45
-	 * @param IGroupManager $groupManager
46
-	 * @param EventDispatcherInterface $dispatcher
47
-	 */
48
-	public function __construct(
49
-		ISystemTagManager $tagManager,
50
-		ISystemTagObjectMapper $tagMapper,
51
-		IUserSession $userSession,
52
-		IGroupManager $groupManager,
53
-		EventDispatcherInterface $dispatcher
54
-	) {
55
-		$children = [
56
-			new SystemTagsObjectTypeCollection(
57
-				'files',
58
-				$tagManager,
59
-				$tagMapper,
60
-				$userSession,
61
-				$groupManager,
62
-				function($name) {
63
-					$nodes = \OC::$server->getUserFolder()->getById(intval($name));
64
-					return !empty($nodes);
65
-				}
66
-			),
67
-		];
39
+    /**
40
+     * SystemTagsRelationsCollection constructor.
41
+     *
42
+     * @param ISystemTagManager $tagManager
43
+     * @param ISystemTagObjectMapper $tagMapper
44
+     * @param IUserSession $userSession
45
+     * @param IGroupManager $groupManager
46
+     * @param EventDispatcherInterface $dispatcher
47
+     */
48
+    public function __construct(
49
+        ISystemTagManager $tagManager,
50
+        ISystemTagObjectMapper $tagMapper,
51
+        IUserSession $userSession,
52
+        IGroupManager $groupManager,
53
+        EventDispatcherInterface $dispatcher
54
+    ) {
55
+        $children = [
56
+            new SystemTagsObjectTypeCollection(
57
+                'files',
58
+                $tagManager,
59
+                $tagMapper,
60
+                $userSession,
61
+                $groupManager,
62
+                function($name) {
63
+                    $nodes = \OC::$server->getUserFolder()->getById(intval($name));
64
+                    return !empty($nodes);
65
+                }
66
+            ),
67
+        ];
68 68
 
69
-		$event = new SystemTagsEntityEvent(SystemTagsEntityEvent::EVENT_ENTITY);
70
-		$dispatcher->dispatch(SystemTagsEntityEvent::EVENT_ENTITY, $event);
69
+        $event = new SystemTagsEntityEvent(SystemTagsEntityEvent::EVENT_ENTITY);
70
+        $dispatcher->dispatch(SystemTagsEntityEvent::EVENT_ENTITY, $event);
71 71
 
72
-		foreach ($event->getEntityCollections() as $entity => $entityExistsFunction) {
73
-			$children[] = new SystemTagsObjectTypeCollection(
74
-				$entity,
75
-				$tagManager,
76
-				$tagMapper,
77
-				$userSession,
78
-				$groupManager,
79
-				$entityExistsFunction
80
-			);
81
-		}
72
+        foreach ($event->getEntityCollections() as $entity => $entityExistsFunction) {
73
+            $children[] = new SystemTagsObjectTypeCollection(
74
+                $entity,
75
+                $tagManager,
76
+                $tagMapper,
77
+                $userSession,
78
+                $groupManager,
79
+                $entityExistsFunction
80
+            );
81
+        }
82 82
 
83
-		parent::__construct('root', $children);
84
-	}
83
+        parent::__construct('root', $children);
84
+    }
85 85
 
86
-	function getName() {
87
-		return 'systemtags-relations';
88
-	}
86
+    function getName() {
87
+        return 'systemtags-relations';
88
+    }
89 89
 
90
-	function setName($name) {
91
-		throw new Forbidden('Permission denied to rename this collection');
92
-	}
90
+    function setName($name) {
91
+        throw new Forbidden('Permission denied to rename this collection');
92
+    }
93 93
 
94 94
 }
Please login to merge, or discard this patch.
apps/dav/appinfo/v1/caldav.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -33,17 +33,17 @@  discard block
 block discarded – undo
33 33
 use OCA\DAV\Connector\Sabre\Principal;
34 34
 
35 35
 $authBackend = new Auth(
36
-	\OC::$server->getSession(),
37
-	\OC::$server->getUserSession(),
38
-	\OC::$server->getRequest(),
39
-	\OC::$server->getTwoFactorAuthManager(),
40
-	\OC::$server->getBruteForceThrottler(),
41
-	'principals/'
36
+    \OC::$server->getSession(),
37
+    \OC::$server->getUserSession(),
38
+    \OC::$server->getRequest(),
39
+    \OC::$server->getTwoFactorAuthManager(),
40
+    \OC::$server->getBruteForceThrottler(),
41
+    'principals/'
42 42
 );
43 43
 $principalBackend = new Principal(
44
-	\OC::$server->getUserManager(),
45
-	\OC::$server->getGroupManager(),
46
-	'principals/'
44
+    \OC::$server->getUserManager(),
45
+    \OC::$server->getGroupManager(),
46
+    'principals/'
47 47
 );
48 48
 $db = \OC::$server->getDatabaseConnection();
49 49
 $userManager = \OC::$server->getUserManager();
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 $addressBookRoot->disableListing = !$debugging; // Disable listing
62 62
 
63 63
 $nodes = array(
64
-	$principalCollection,
65
-	$addressBookRoot,
64
+    $principalCollection,
65
+    $addressBookRoot,
66 66
 );
67 67
 
68 68
 // Fire up server
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
 $server->addPlugin(new LegacyDAVACL());
80 80
 if ($debugging) {
81
-	$server->addPlugin(new Sabre\DAV\Browser\Plugin());
81
+    $server->addPlugin(new Sabre\DAV\Browser\Plugin());
82 82
 }
83 83
 
84 84
 $server->addPlugin(new \Sabre\DAV\Sync\Plugin());
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@
 block discarded – undo
84 84
 $server->addPlugin(new \Sabre\DAV\Sync\Plugin());
85 85
 $server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin());
86 86
 $server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin());
87
-$server->addPlugin(new \OCA\DAV\CalDAV\Schedule\IMipPlugin( \OC::$server->getMailer(), \OC::$server->getLogger()));
87
+$server->addPlugin(new \OCA\DAV\CalDAV\Schedule\IMipPlugin(\OC::$server->getMailer(), \OC::$server->getLogger()));
88 88
 $server->addPlugin(new ExceptionLoggerPlugin('caldav', \OC::$server->getLogger()));
89 89
 
90 90
 // And off we go!
Please login to merge, or discard this patch.
apps/dav/appinfo/v1/publicwebdav.php 2 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -38,20 +38,20 @@  discard block
 block discarded – undo
38 38
 
39 39
 // Backends
40 40
 $authBackend = new OCA\DAV\Connector\PublicAuth(
41
-	\OC::$server->getRequest(),
42
-	\OC::$server->getShareManager(),
43
-	\OC::$server->getSession()
41
+    \OC::$server->getRequest(),
42
+    \OC::$server->getShareManager(),
43
+    \OC::$server->getSession()
44 44
 );
45 45
 
46 46
 $serverFactory = new OCA\DAV\Connector\Sabre\ServerFactory(
47
-	\OC::$server->getConfig(),
48
-	\OC::$server->getLogger(),
49
-	\OC::$server->getDatabaseConnection(),
50
-	\OC::$server->getUserSession(),
51
-	\OC::$server->getMountManager(),
52
-	\OC::$server->getTagManager(),
53
-	\OC::$server->getRequest(),
54
-	\OC::$server->getPreviewManager()
47
+    \OC::$server->getConfig(),
48
+    \OC::$server->getLogger(),
49
+    \OC::$server->getDatabaseConnection(),
50
+    \OC::$server->getUserSession(),
51
+    \OC::$server->getMountManager(),
52
+    \OC::$server->getTagManager(),
53
+    \OC::$server->getRequest(),
54
+    \OC::$server->getPreviewManager()
55 55
 );
56 56
 
57 57
 $requestUri = \OC::$server->getRequest()->getRequestUri();
@@ -60,41 +60,41 @@  discard block
 block discarded – undo
60 60
 $filesDropPlugin = new \OCA\DAV\Files\Sharing\FilesDropPlugin();
61 61
 
62 62
 $server = $serverFactory->createServer($baseuri, $requestUri, $authBackend, function (\Sabre\DAV\Server $server) use ($authBackend, $linkCheckPlugin, $filesDropPlugin) {
63
-	$isAjax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest');
64
-	$federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application();
65
-	$federatedShareProvider = $federatedSharingApp->getFederatedShareProvider();
66
-	if ($federatedShareProvider->isOutgoingServer2serverShareEnabled() === false && !$isAjax) {
67
-		// this is what is thrown when trying to access a non-existing share
68
-		throw new \Sabre\DAV\Exception\NotAuthenticated();
69
-	}
70
-
71
-	$share = $authBackend->getShare();
72
-	$owner = $share->getShareOwner();
73
-	$isReadable = $share->getPermissions() & \OCP\Constants::PERMISSION_READ;
74
-	$fileId = $share->getNodeId();
75
-
76
-	// FIXME: should not add storage wrappers outside of preSetup, need to find a better way
77
-	$previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false);
78
-	\OC\Files\Filesystem::addStorageWrapper('sharePermissions', function ($mountPoint, $storage) use ($share) {
79
-		return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => $share->getPermissions() | \OCP\Constants::PERMISSION_SHARE));
80
-	});
81
-	\OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog);
82
-
83
-	OC_Util::setupFS($owner);
84
-	$ownerView = \OC\Files\Filesystem::getView();
85
-	$path = $ownerView->getPath($fileId);
86
-	$fileInfo = $ownerView->getFileInfo($path);
87
-	$linkCheckPlugin->setFileInfo($fileInfo);
88
-
89
-	// If not readble (files_drop) enable the filesdrop plugin
90
-	if (!$isReadable) {
91
-		$filesDropPlugin->enable();
92
-	}
93
-
94
-	$view = new \OC\Files\View($ownerView->getAbsolutePath($path));
95
-	$filesDropPlugin->setView($view);
96
-
97
-	return $view;
63
+    $isAjax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest');
64
+    $federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application();
65
+    $federatedShareProvider = $federatedSharingApp->getFederatedShareProvider();
66
+    if ($federatedShareProvider->isOutgoingServer2serverShareEnabled() === false && !$isAjax) {
67
+        // this is what is thrown when trying to access a non-existing share
68
+        throw new \Sabre\DAV\Exception\NotAuthenticated();
69
+    }
70
+
71
+    $share = $authBackend->getShare();
72
+    $owner = $share->getShareOwner();
73
+    $isReadable = $share->getPermissions() & \OCP\Constants::PERMISSION_READ;
74
+    $fileId = $share->getNodeId();
75
+
76
+    // FIXME: should not add storage wrappers outside of preSetup, need to find a better way
77
+    $previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false);
78
+    \OC\Files\Filesystem::addStorageWrapper('sharePermissions', function ($mountPoint, $storage) use ($share) {
79
+        return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => $share->getPermissions() | \OCP\Constants::PERMISSION_SHARE));
80
+    });
81
+    \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog);
82
+
83
+    OC_Util::setupFS($owner);
84
+    $ownerView = \OC\Files\Filesystem::getView();
85
+    $path = $ownerView->getPath($fileId);
86
+    $fileInfo = $ownerView->getFileInfo($path);
87
+    $linkCheckPlugin->setFileInfo($fileInfo);
88
+
89
+    // If not readble (files_drop) enable the filesdrop plugin
90
+    if (!$isReadable) {
91
+        $filesDropPlugin->enable();
92
+    }
93
+
94
+    $view = new \OC\Files\View($ownerView->getAbsolutePath($path));
95
+    $filesDropPlugin->setView($view);
96
+
97
+    return $view;
98 98
 });
99 99
 
100 100
 $server->addPlugin($linkCheckPlugin);
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 $linkCheckPlugin = new \OCA\DAV\Files\Sharing\PublicLinkCheckPlugin();
60 60
 $filesDropPlugin = new \OCA\DAV\Files\Sharing\FilesDropPlugin();
61 61
 
62
-$server = $serverFactory->createServer($baseuri, $requestUri, $authBackend, function (\Sabre\DAV\Server $server) use ($authBackend, $linkCheckPlugin, $filesDropPlugin) {
62
+$server = $serverFactory->createServer($baseuri, $requestUri, $authBackend, function(\Sabre\DAV\Server $server) use ($authBackend, $linkCheckPlugin, $filesDropPlugin) {
63 63
 	$isAjax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest');
64 64
 	$federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application();
65 65
 	$federatedShareProvider = $federatedSharingApp->getFederatedShareProvider();
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 
76 76
 	// FIXME: should not add storage wrappers outside of preSetup, need to find a better way
77 77
 	$previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false);
78
-	\OC\Files\Filesystem::addStorageWrapper('sharePermissions', function ($mountPoint, $storage) use ($share) {
78
+	\OC\Files\Filesystem::addStorageWrapper('sharePermissions', function($mountPoint, $storage) use ($share) {
79 79
 		return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => $share->getPermissions() | \OCP\Constants::PERMISSION_SHARE));
80 80
 	});
81 81
 	\OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog);
Please login to merge, or discard this patch.
apps/dav/bin/chunkperf.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
 require '../../../../3rdparty/autoload.php';
24 24
 
25 25
 if ($argc !== 6) {
26
-	echo "Invalid number of arguments" . PHP_EOL;
27
-	exit;
26
+    echo "Invalid number of arguments" . PHP_EOL;
27
+    exit;
28 28
 }
29 29
 
30 30
 /**
@@ -33,15 +33,15 @@  discard block
 block discarded – undo
33 33
  * @return mixed
34 34
  */
35 35
 function request($client, $method, $uploadUrl, $data = null, $headers = []) {
36
-	echo "$method $uploadUrl ... ";
37
-	$t0 = microtime(true);
38
-	$result = $client->request($method, $uploadUrl, $data, $headers);
39
-	$t1 = microtime(true);
40
-	echo $result['statusCode'] . " - " . ($t1 - $t0) . ' seconds' . PHP_EOL;
41
-	if (!in_array($result['statusCode'],  [200, 201])) {
42
-		echo $result['body'] . PHP_EOL;
43
-	}
44
-	return $result;
36
+    echo "$method $uploadUrl ... ";
37
+    $t0 = microtime(true);
38
+    $result = $client->request($method, $uploadUrl, $data, $headers);
39
+    $t1 = microtime(true);
40
+    echo $result['statusCode'] . " - " . ($t1 - $t0) . ' seconds' . PHP_EOL;
41
+    if (!in_array($result['statusCode'],  [200, 201])) {
42
+        echo $result['body'] . PHP_EOL;
43
+    }
44
+    return $result;
45 45
 }
46 46
 
47 47
 $baseUri = $argv[1];
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
 $chunkSize = $argv[5] * 1024 * 1024;
52 52
 
53 53
 $client = new \Sabre\DAV\Client([
54
-	'baseUri' => $baseUri,
55
-	'userName' => $userName,
56
-	'password' => $password
54
+    'baseUri' => $baseUri,
55
+    'userName' => $userName,
56
+    'password' => $password
57 57
 ]);
58 58
 
59 59
 $transfer = uniqid('transfer', true);
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
 
67 67
 $index = 0;
68 68
 while(!feof($stream)) {
69
-	request($client, 'PUT', "$uploadUrl/$index", fread($stream, $chunkSize));
70
-	$index++;
69
+    request($client, 'PUT', "$uploadUrl/$index", fread($stream, $chunkSize));
70
+    $index++;
71 71
 }
72 72
 
73 73
 $destination = pathinfo($file, PATHINFO_BASENAME);
74 74
 //echo "Moving $uploadUrl/.file to it's final destination $baseUri/files/$userName/$destination" . PHP_EOL;
75 75
 request($client, 'MOVE', "$uploadUrl/.file", null, [
76
-	'Destination' => "$baseUri/files/$userName/$destination"
76
+    'Destination' => "$baseUri/files/$userName/$destination"
77 77
 ]);
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 require '../../../../3rdparty/autoload.php';
24 24
 
25 25
 if ($argc !== 6) {
26
-	echo "Invalid number of arguments" . PHP_EOL;
26
+	echo "Invalid number of arguments".PHP_EOL;
27 27
 	exit;
28 28
 }
29 29
 
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
 	$t0 = microtime(true);
38 38
 	$result = $client->request($method, $uploadUrl, $data, $headers);
39 39
 	$t1 = microtime(true);
40
-	echo $result['statusCode'] . " - " . ($t1 - $t0) . ' seconds' . PHP_EOL;
41
-	if (!in_array($result['statusCode'],  [200, 201])) {
42
-		echo $result['body'] . PHP_EOL;
40
+	echo $result['statusCode']." - ".($t1 - $t0).' seconds'.PHP_EOL;
41
+	if (!in_array($result['statusCode'], [200, 201])) {
42
+		echo $result['body'].PHP_EOL;
43 43
 	}
44 44
 	return $result;
45 45
 }
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 $stream = fopen($file, 'r');
66 66
 
67 67
 $index = 0;
68
-while(!feof($stream)) {
68
+while (!feof($stream)) {
69 69
 	request($client, 'PUT', "$uploadUrl/$index", fread($stream, $chunkSize));
70 70
 	$index++;
71 71
 }
Please login to merge, or discard this patch.
apps/admin_audit/lib/actions/usermanagement.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@
 block discarded – undo
66 66
 	 * @param IUser $user
67 67
 	 */
68 68
 	public function setPassword(IUser $user) {
69
-		if($user->getBackendClassName() === 'Database') {
69
+		if ($user->getBackendClassName() === 'Database') {
70 70
 			$this->log(
71 71
 				'Password of user "%s" has been changed',
72 72
 				[
Please login to merge, or discard this patch.
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -30,69 +30,69 @@
 block discarded – undo
30 30
  * @package OCA\Admin_Audit\Actions
31 31
  */
32 32
 class UserManagement extends Action {
33
-	/**
34
-	 * Log creation of users
35
-	 *
36
-	 * @param array $params
37
-	 */
38
-	public function create(array $params) {
39
-		$this->log(
40
-			'User created: "%s"',
41
-			$params,
42
-			[
43
-				'uid',
44
-			]
45
-		);
46
-	}
33
+    /**
34
+     * Log creation of users
35
+     *
36
+     * @param array $params
37
+     */
38
+    public function create(array $params) {
39
+        $this->log(
40
+            'User created: "%s"',
41
+            $params,
42
+            [
43
+                'uid',
44
+            ]
45
+        );
46
+    }
47 47
 
48
-	/**
49
-	 * Log deletion of users
50
-	 *
51
-	 * @param array $params
52
-	 */
53
-	public function delete(array $params) {
54
-		$this->log(
55
-			'User deleted: "%s"',
56
-			$params,
57
-			[
58
-				'uid',
59
-			]
60
-		);
61
-	}
48
+    /**
49
+     * Log deletion of users
50
+     *
51
+     * @param array $params
52
+     */
53
+    public function delete(array $params) {
54
+        $this->log(
55
+            'User deleted: "%s"',
56
+            $params,
57
+            [
58
+                'uid',
59
+            ]
60
+        );
61
+    }
62 62
 
63
-	/**
64
-	 * Log enabling of users
65
-	 *
66
-	 * @param array $params
67
-	 */
68
-	public function change(array $params) {
69
-		if ($params['feature'] === 'enabled') {
70
-			$this->log(
71
-				$params['value'] === 'true' ? 'User enabled: "%s"' : 'User disabled: "%s"',
72
-				['user' => $params['user']->getUID()],
73
-				[
74
-					'user',
75
-				]
76
-			);
77
-		}
78
-	}
63
+    /**
64
+     * Log enabling of users
65
+     *
66
+     * @param array $params
67
+     */
68
+    public function change(array $params) {
69
+        if ($params['feature'] === 'enabled') {
70
+            $this->log(
71
+                $params['value'] === 'true' ? 'User enabled: "%s"' : 'User disabled: "%s"',
72
+                ['user' => $params['user']->getUID()],
73
+                [
74
+                    'user',
75
+                ]
76
+            );
77
+        }
78
+    }
79 79
 
80
-	/**
81
-	 * Logs changing of the user scope
82
-	 *
83
-	 * @param IUser $user
84
-	 */
85
-	public function setPassword(IUser $user) {
86
-		if($user->getBackendClassName() === 'Database') {
87
-			$this->log(
88
-				'Password of user "%s" has been changed',
89
-				[
90
-					'user' => $user->getUID(),
91
-				],
92
-				[
93
-					'user',
94
-				]
95
-			);
96
-		}
97
-	}
80
+    /**
81
+     * Logs changing of the user scope
82
+     *
83
+     * @param IUser $user
84
+     */
85
+    public function setPassword(IUser $user) {
86
+        if($user->getBackendClassName() === 'Database') {
87
+            $this->log(
88
+                'Password of user "%s" has been changed',
89
+                [
90
+                    'user' => $user->getUID(),
91
+                ],
92
+                [
93
+                    'user',
94
+                ]
95
+            );
96
+        }
97
+    }
98 98
 }
Please login to merge, or discard this patch.
apps/admin_audit/lib/actions/action.php 2 patches
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -25,64 +25,64 @@
 block discarded – undo
25 25
 use OCP\ILogger;
26 26
 
27 27
 class Action {
28
-	/** @var ILogger */
29
-	private $logger;
28
+    /** @var ILogger */
29
+    private $logger;
30 30
 
31
-	/**
32
-	 * @param ILogger $logger
33
-	 */
34
-	public function __construct(ILogger $logger) {
35
-		$this->logger = $logger;
36
-	}
31
+    /**
32
+     * @param ILogger $logger
33
+     */
34
+    public function __construct(ILogger $logger) {
35
+        $this->logger = $logger;
36
+    }
37 37
 
38
-	/**
39
-	 * Log a single action with a log level of info
40
-	 *
41
-	 * @param string $text
42
-	 * @param array $params
43
-	 * @param array $elements
44
-	 * @param bool $obfuscateParameters
45
-	 */
46
-	public function log($text,
47
-						array $params,
48
-						array $elements,
49
-						$obfuscateParameters = false) {
50
-		foreach($elements as $element) {
51
-			if(!isset($params[$element])) {
52
-				if ($obfuscateParameters) {
53
-					$this->logger->critical(
54
-						'$params["'.$element.'"] was missing.',
55
-						['app' => 'admin_audit']
56
-					);
57
-				} else {
58
-					$this->logger->critical(
59
-						sprintf(
60
-							'$params["'.$element.'"] was missing. Transferred value: %s',
61
-							print_r($params, true)
62
-						),
63
-						['app' => 'admin_audit']
64
-					);
65
-				}
66
-				return;
67
-			}
68
-		}
38
+    /**
39
+     * Log a single action with a log level of info
40
+     *
41
+     * @param string $text
42
+     * @param array $params
43
+     * @param array $elements
44
+     * @param bool $obfuscateParameters
45
+     */
46
+    public function log($text,
47
+                        array $params,
48
+                        array $elements,
49
+                        $obfuscateParameters = false) {
50
+        foreach($elements as $element) {
51
+            if(!isset($params[$element])) {
52
+                if ($obfuscateParameters) {
53
+                    $this->logger->critical(
54
+                        '$params["'.$element.'"] was missing.',
55
+                        ['app' => 'admin_audit']
56
+                    );
57
+                } else {
58
+                    $this->logger->critical(
59
+                        sprintf(
60
+                            '$params["'.$element.'"] was missing. Transferred value: %s',
61
+                            print_r($params, true)
62
+                        ),
63
+                        ['app' => 'admin_audit']
64
+                    );
65
+                }
66
+                return;
67
+            }
68
+        }
69 69
 
70
-		$replaceArray = [];
71
-		foreach($elements as $element) {
72
-			if($params[$element] instanceof \DateTime) {
73
-				$params[$element] = $params[$element]->format('Y-m-d H:i:s');
74
-			}
75
-			$replaceArray[] = $params[$element];
76
-		}
70
+        $replaceArray = [];
71
+        foreach($elements as $element) {
72
+            if($params[$element] instanceof \DateTime) {
73
+                $params[$element] = $params[$element]->format('Y-m-d H:i:s');
74
+            }
75
+            $replaceArray[] = $params[$element];
76
+        }
77 77
 
78
-		$this->logger->info(
79
-			vsprintf(
80
-				$text,
81
-				$replaceArray
82
-			),
83
-			[
84
-				'app' => 'admin_audit'
85
-			]
86
-		);
87
-	}
78
+        $this->logger->info(
79
+            vsprintf(
80
+                $text,
81
+                $replaceArray
82
+            ),
83
+            [
84
+                'app' => 'admin_audit'
85
+            ]
86
+        );
87
+    }
88 88
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 						array $params,
48 48
 						array $elements,
49 49
 						$obfuscateParameters = false) {
50
-		foreach($elements as $element) {
51
-			if(!isset($params[$element])) {
50
+		foreach ($elements as $element) {
51
+			if (!isset($params[$element])) {
52 52
 				if ($obfuscateParameters) {
53 53
 					$this->logger->critical(
54 54
 						'$params["'.$element.'"] was missing.',
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
 		}
69 69
 
70 70
 		$replaceArray = [];
71
-		foreach($elements as $element) {
72
-			if($params[$element] instanceof \DateTime) {
71
+		foreach ($elements as $element) {
72
+			if ($params[$element] instanceof \DateTime) {
73 73
 				$params[$element] = $params[$element]->format('Y-m-d H:i:s');
74 74
 			}
75 75
 			$replaceArray[] = $params[$element];
Please login to merge, or discard this patch.