Passed
Push — master ( 61a02b...010b07 )
by Roeland
19:08 queued 08:59
created
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.
apps/dav/lib/CalDAV/CalendarObject.php 1 patch
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -32,114 +32,114 @@
 block discarded – undo
32 32
 
33 33
 class CalendarObject extends \Sabre\CalDAV\CalendarObject {
34 34
 
35
-	/**
36
-	 * CalendarObject constructor.
37
-	 *
38
-	 * @param CalDavBackend $caldavBackend
39
-	 * @param array $calendarInfo
40
-	 * @param array $objectData
41
-	 */
42
-	public function __construct(CalDavBackend $caldavBackend, array $calendarInfo,
43
-								array $objectData) {
44
-		parent::__construct($caldavBackend, $calendarInfo, $objectData);
45
-
46
-		if ($this->isShared()) {
47
-			unset($this->objectData['size']);
48
-		}
49
-	}
50
-
51
-	/**
52
-	 * @inheritdoc
53
-	 */
54
-	function get() {
55
-		$data = parent::get();
56
-
57
-		if (!$this->isShared()) {
58
-			return $data;
59
-		}
60
-
61
-		$vObject = Reader::read($data);
62
-
63
-		// remove VAlarms if calendar is shared read-only
64
-		if (!$this->canWrite()) {
65
-			$this->removeVAlarms($vObject);
66
-		}
67
-
68
-		// shows as busy if event is declared confidential
69
-		if ($this->objectData['classification'] === CalDavBackend::CLASSIFICATION_CONFIDENTIAL) {
70
-			$this->createConfidentialObject($vObject);
71
-		}
72
-
73
-		return $vObject->serialize();
74
-	}
75
-
76
-	protected function isShared() {
77
-		if (!isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) {
78
-			return false;
79
-		}
80
-
81
-		return $this->calendarInfo['{http://owncloud.org/ns}owner-principal'] !== $this->calendarInfo['principaluri'];
82
-	}
83
-
84
-	/**
85
-	 * @param Component\VCalendar $vObject
86
-	 * @return void
87
-	 */
88
-	private static function createConfidentialObject(Component\VCalendar $vObject) {
89
-		/** @var Component $vElement */
90
-		$vElement = null;
91
-		if(isset($vObject->VEVENT)) {
92
-			$vElement = $vObject->VEVENT;
93
-		}
94
-		if(isset($vObject->VJOURNAL)) {
95
-			$vElement = $vObject->VJOURNAL;
96
-		}
97
-		if(isset($vObject->VTODO)) {
98
-			$vElement = $vObject->VTODO;
99
-		}
100
-		if(!is_null($vElement)) {
101
-			foreach ($vElement->children() as &$property) {
102
-				/** @var Property $property */
103
-				switch($property->name) {
104
-					case 'CREATED':
105
-					case 'DTSTART':
106
-					case 'RRULE':
107
-					case 'DURATION':
108
-					case 'DTEND':
109
-					case 'CLASS':
110
-					case 'UID':
111
-						break;
112
-					case 'SUMMARY':
113
-						$property->setValue('Busy');
114
-						break;
115
-					default:
116
-						$vElement->__unset($property->name);
117
-						unset($property);
118
-						break;
119
-				}
120
-			}
121
-		}
122
-	}
123
-
124
-	/**
125
-	 * @param Component\VCalendar $vObject
126
-	 * @return void
127
-	 */
128
-	private function removeVAlarms(Component\VCalendar $vObject) {
129
-		$subcomponents = $vObject->getComponents();
130
-
131
-		foreach($subcomponents as $subcomponent) {
132
-			unset($subcomponent->VALARM);
133
-		}
134
-	}
135
-
136
-	/**
137
-	 * @return bool
138
-	 */
139
-	private function canWrite() {
140
-		if (isset($this->calendarInfo['{http://owncloud.org/ns}read-only'])) {
141
-			return !$this->calendarInfo['{http://owncloud.org/ns}read-only'];
142
-		}
143
-		return true;
144
-	}
35
+    /**
36
+     * CalendarObject constructor.
37
+     *
38
+     * @param CalDavBackend $caldavBackend
39
+     * @param array $calendarInfo
40
+     * @param array $objectData
41
+     */
42
+    public function __construct(CalDavBackend $caldavBackend, array $calendarInfo,
43
+                                array $objectData) {
44
+        parent::__construct($caldavBackend, $calendarInfo, $objectData);
45
+
46
+        if ($this->isShared()) {
47
+            unset($this->objectData['size']);
48
+        }
49
+    }
50
+
51
+    /**
52
+     * @inheritdoc
53
+     */
54
+    function get() {
55
+        $data = parent::get();
56
+
57
+        if (!$this->isShared()) {
58
+            return $data;
59
+        }
60
+
61
+        $vObject = Reader::read($data);
62
+
63
+        // remove VAlarms if calendar is shared read-only
64
+        if (!$this->canWrite()) {
65
+            $this->removeVAlarms($vObject);
66
+        }
67
+
68
+        // shows as busy if event is declared confidential
69
+        if ($this->objectData['classification'] === CalDavBackend::CLASSIFICATION_CONFIDENTIAL) {
70
+            $this->createConfidentialObject($vObject);
71
+        }
72
+
73
+        return $vObject->serialize();
74
+    }
75
+
76
+    protected function isShared() {
77
+        if (!isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) {
78
+            return false;
79
+        }
80
+
81
+        return $this->calendarInfo['{http://owncloud.org/ns}owner-principal'] !== $this->calendarInfo['principaluri'];
82
+    }
83
+
84
+    /**
85
+     * @param Component\VCalendar $vObject
86
+     * @return void
87
+     */
88
+    private static function createConfidentialObject(Component\VCalendar $vObject) {
89
+        /** @var Component $vElement */
90
+        $vElement = null;
91
+        if(isset($vObject->VEVENT)) {
92
+            $vElement = $vObject->VEVENT;
93
+        }
94
+        if(isset($vObject->VJOURNAL)) {
95
+            $vElement = $vObject->VJOURNAL;
96
+        }
97
+        if(isset($vObject->VTODO)) {
98
+            $vElement = $vObject->VTODO;
99
+        }
100
+        if(!is_null($vElement)) {
101
+            foreach ($vElement->children() as &$property) {
102
+                /** @var Property $property */
103
+                switch($property->name) {
104
+                    case 'CREATED':
105
+                    case 'DTSTART':
106
+                    case 'RRULE':
107
+                    case 'DURATION':
108
+                    case 'DTEND':
109
+                    case 'CLASS':
110
+                    case 'UID':
111
+                        break;
112
+                    case 'SUMMARY':
113
+                        $property->setValue('Busy');
114
+                        break;
115
+                    default:
116
+                        $vElement->__unset($property->name);
117
+                        unset($property);
118
+                        break;
119
+                }
120
+            }
121
+        }
122
+    }
123
+
124
+    /**
125
+     * @param Component\VCalendar $vObject
126
+     * @return void
127
+     */
128
+    private function removeVAlarms(Component\VCalendar $vObject) {
129
+        $subcomponents = $vObject->getComponents();
130
+
131
+        foreach($subcomponents as $subcomponent) {
132
+            unset($subcomponent->VALARM);
133
+        }
134
+    }
135
+
136
+    /**
137
+     * @return bool
138
+     */
139
+    private function canWrite() {
140
+        if (isset($this->calendarInfo['{http://owncloud.org/ns}read-only'])) {
141
+            return !$this->calendarInfo['{http://owncloud.org/ns}read-only'];
142
+        }
143
+        return true;
144
+    }
145 145
 }
Please login to merge, or discard this patch.
lib/public/Support/CrashReport/IReporter.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -30,12 +30,12 @@
 block discarded – undo
30 30
  */
31 31
 interface IReporter {
32 32
 
33
-	/**
34
-	 * Report an (unhandled) exception
35
-	 *
36
-	 * @since 13.0.0
37
-	 * @param Exception|Throwable $exception
38
-	 * @param array $context
39
-	 */
40
-	public function report($exception, array $context = []);
33
+    /**
34
+     * Report an (unhandled) exception
35
+     *
36
+     * @since 13.0.0
37
+     * @param Exception|Throwable $exception
38
+     * @param array $context
39
+     */
40
+    public function report($exception, array $context = []);
41 41
 }
Please login to merge, or discard this patch.
lib/private/Hooks/EmitterTrait.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -24,80 +24,80 @@
 block discarded – undo
24 24
 
25 25
 trait EmitterTrait {
26 26
 
27
-	/**
28
-	 * @var callable[][] $listeners
29
-	 */
30
-	protected $listeners = array();
27
+    /**
28
+     * @var callable[][] $listeners
29
+     */
30
+    protected $listeners = array();
31 31
 
32
-	/**
33
-	 * @param string $scope
34
-	 * @param string $method
35
-	 * @param callable $callback
36
-	 */
37
-	public function listen($scope, $method, callable $callback) {
38
-		$eventName = $scope . '::' . $method;
39
-		if (!isset($this->listeners[$eventName])) {
40
-			$this->listeners[$eventName] = array();
41
-		}
42
-		if (array_search($callback, $this->listeners[$eventName], true) === false) {
43
-			$this->listeners[$eventName][] = $callback;
44
-		}
45
-	}
32
+    /**
33
+     * @param string $scope
34
+     * @param string $method
35
+     * @param callable $callback
36
+     */
37
+    public function listen($scope, $method, callable $callback) {
38
+        $eventName = $scope . '::' . $method;
39
+        if (!isset($this->listeners[$eventName])) {
40
+            $this->listeners[$eventName] = array();
41
+        }
42
+        if (array_search($callback, $this->listeners[$eventName], true) === false) {
43
+            $this->listeners[$eventName][] = $callback;
44
+        }
45
+    }
46 46
 
47
-	/**
48
-	 * @param string $scope optional
49
-	 * @param string $method optional
50
-	 * @param callable $callback optional
51
-	 */
52
-	public function removeListener($scope = null, $method = null, callable $callback = null) {
53
-		$names = array();
54
-		$allNames = array_keys($this->listeners);
55
-		if ($scope and $method) {
56
-			$name = $scope . '::' . $method;
57
-			if (isset($this->listeners[$name])) {
58
-				$names[] = $name;
59
-			}
60
-		} elseif ($scope) {
61
-			foreach ($allNames as $name) {
62
-				$parts = explode('::', $name, 2);
63
-				if ($parts[0] == $scope) {
64
-					$names[] = $name;
65
-				}
66
-			}
67
-		} elseif ($method) {
68
-			foreach ($allNames as $name) {
69
-				$parts = explode('::', $name, 2);
70
-				if ($parts[1] == $method) {
71
-					$names[] = $name;
72
-				}
73
-			}
74
-		} else {
75
-			$names = $allNames;
76
-		}
47
+    /**
48
+     * @param string $scope optional
49
+     * @param string $method optional
50
+     * @param callable $callback optional
51
+     */
52
+    public function removeListener($scope = null, $method = null, callable $callback = null) {
53
+        $names = array();
54
+        $allNames = array_keys($this->listeners);
55
+        if ($scope and $method) {
56
+            $name = $scope . '::' . $method;
57
+            if (isset($this->listeners[$name])) {
58
+                $names[] = $name;
59
+            }
60
+        } elseif ($scope) {
61
+            foreach ($allNames as $name) {
62
+                $parts = explode('::', $name, 2);
63
+                if ($parts[0] == $scope) {
64
+                    $names[] = $name;
65
+                }
66
+            }
67
+        } elseif ($method) {
68
+            foreach ($allNames as $name) {
69
+                $parts = explode('::', $name, 2);
70
+                if ($parts[1] == $method) {
71
+                    $names[] = $name;
72
+                }
73
+            }
74
+        } else {
75
+            $names = $allNames;
76
+        }
77 77
 
78
-		foreach ($names as $name) {
79
-			if ($callback) {
80
-				$index = array_search($callback, $this->listeners[$name], true);
81
-				if ($index !== false) {
82
-					unset($this->listeners[$name][$index]);
83
-				}
84
-			} else {
85
-				$this->listeners[$name] = array();
86
-			}
87
-		}
88
-	}
78
+        foreach ($names as $name) {
79
+            if ($callback) {
80
+                $index = array_search($callback, $this->listeners[$name], true);
81
+                if ($index !== false) {
82
+                    unset($this->listeners[$name][$index]);
83
+                }
84
+            } else {
85
+                $this->listeners[$name] = array();
86
+            }
87
+        }
88
+    }
89 89
 
90
-	/**
91
-	 * @param string $scope
92
-	 * @param string $method
93
-	 * @param array $arguments optional
94
-	 */
95
-	protected function emit($scope, $method, array $arguments = array()) {
96
-		$eventName = $scope . '::' . $method;
97
-		if (isset($this->listeners[$eventName])) {
98
-			foreach ($this->listeners[$eventName] as $callback) {
99
-				call_user_func_array($callback, $arguments);
100
-			}
101
-		}
102
-	}
90
+    /**
91
+     * @param string $scope
92
+     * @param string $method
93
+     * @param array $arguments optional
94
+     */
95
+    protected function emit($scope, $method, array $arguments = array()) {
96
+        $eventName = $scope . '::' . $method;
97
+        if (isset($this->listeners[$eventName])) {
98
+            foreach ($this->listeners[$eventName] as $callback) {
99
+                call_user_func_array($callback, $arguments);
100
+            }
101
+        }
102
+    }
103 103
 }
Please login to merge, or discard this patch.