Completed
Push — master ( 57ea46...72dc01 )
by Blizzz
14:28
created
lib/public/IUserManager.php 1 patch
Indentation   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -41,145 +41,145 @@
 block discarded – undo
41 41
  * @since 8.0.0
42 42
  */
43 43
 interface IUserManager {
44
-		/**
45
-	 * register a user backend
46
-	 *
47
-	 * @param \OCP\UserInterface $backend
48
-	 * @since 8.0.0
49
-	 */
50
-	public function registerBackend($backend);
51
-
52
-	/**
53
-	 * Get the active backends
54
-	 * @return \OCP\UserInterface[]
55
-	 * @since 8.0.0
56
-	 */
57
-	public function getBackends();
58
-
59
-	/**
60
-	 * remove a user backend
61
-	 *
62
-	 * @param \OCP\UserInterface $backend
63
-	 * @since 8.0.0
64
-	 */
65
-	public function removeBackend($backend);
66
-
67
-	/**
68
-	 * remove all user backends
69
-	 * @since 8.0.0
70
-	 */
71
-	public function clearBackends() ;
72
-
73
-	/**
74
-	 * get a user by user id
75
-	 *
76
-	 * @param string $uid
77
-	 * @return \OCP\IUser|null Either the user or null if the specified user does not exist
78
-	 * @since 8.0.0
79
-	 */
80
-	public function get($uid);
81
-
82
-	/**
83
-	 * check if a user exists
84
-	 *
85
-	 * @param string $uid
86
-	 * @return bool
87
-	 * @since 8.0.0
88
-	 */
89
-	public function userExists($uid);
90
-
91
-	/**
92
-	 * Check if the password is valid for the user
93
-	 *
94
-	 * @param string $loginName
95
-	 * @param string $password
96
-	 * @return mixed the User object on success, false otherwise
97
-	 * @since 8.0.0
98
-	 */
99
-	public function checkPassword($loginName, $password);
100
-
101
-	/**
102
-	 * search by user id
103
-	 *
104
-	 * @param string $pattern
105
-	 * @param int $limit
106
-	 * @param int $offset
107
-	 * @return \OCP\IUser[]
108
-	 * @since 8.0.0
109
-	 */
110
-	public function search($pattern, $limit = null, $offset = null);
111
-
112
-	/**
113
-	 * search by displayName
114
-	 *
115
-	 * @param string $pattern
116
-	 * @param int $limit
117
-	 * @param int $offset
118
-	 * @return \OCP\IUser[]
119
-	 * @since 8.0.0
120
-	 */
121
-	public function searchDisplayName($pattern, $limit = null, $offset = null);
122
-
123
-	/**
124
-	 * @param string $uid
125
-	 * @param string $password
126
-	 * @throws \InvalidArgumentException
127
-	 * @return bool|\OCP\IUser the created user of false
128
-	 * @since 8.0.0
129
-	 */
130
-	public function createUser($uid, $password);
131
-
132
-	/**
133
-	 * @param string $uid
134
-	 * @param string $password
135
-	 * @param UserInterface $backend
136
-	 * @return IUser|null
137
-	 * @throws \InvalidArgumentException
138
-	 * @since 12.0.0
139
-	 */
140
-	public function createUserFromBackend($uid, $password, UserInterface $backend);
141
-
142
-	/**
143
-	 * returns how many users per backend exist (if supported by backend)
144
-	 *
145
-	 * @return array an array of backend class as key and count number as value
146
-	 * @since 8.0.0
147
-	 */
148
-	public function countUsers();
149
-
150
-	/**
151
-	 * @param \Closure $callback
152
-	 * @param string $search
153
-	 * @since 9.0.0
154
-	 */
155
-	public function callForAllUsers(\Closure $callback, $search = '');
156
-
157
-	/**
158
-	 * returns how many users have logged in once
159
-	 *
160
-	 * @return int
161
-	 * @since 11.0.0
162
-	 */
163
-	public function countDisabledUsers();
164
-
165
-	/**
166
-	 * returns how many users have logged in once
167
-	 *
168
-	 * @return int
169
-	 * @since 11.0.0
170
-	 */
171
-	public function countSeenUsers();
172
-
173
-	/**
174
-	 * @param \Closure $callback
175
-	 * @since 11.0.0
176
-	 */
177
-	public function callForSeenUsers(\Closure $callback);
178
-
179
-	/**
180
-	 * @param string $email
181
-	 * @return IUser[]
182
-	 * @since 9.1.0
183
-	 */
184
-	public function getByEmail($email);
44
+        /**
45
+         * register a user backend
46
+         *
47
+         * @param \OCP\UserInterface $backend
48
+         * @since 8.0.0
49
+         */
50
+    public function registerBackend($backend);
51
+
52
+    /**
53
+     * Get the active backends
54
+     * @return \OCP\UserInterface[]
55
+     * @since 8.0.0
56
+     */
57
+    public function getBackends();
58
+
59
+    /**
60
+     * remove a user backend
61
+     *
62
+     * @param \OCP\UserInterface $backend
63
+     * @since 8.0.0
64
+     */
65
+    public function removeBackend($backend);
66
+
67
+    /**
68
+     * remove all user backends
69
+     * @since 8.0.0
70
+     */
71
+    public function clearBackends() ;
72
+
73
+    /**
74
+     * get a user by user id
75
+     *
76
+     * @param string $uid
77
+     * @return \OCP\IUser|null Either the user or null if the specified user does not exist
78
+     * @since 8.0.0
79
+     */
80
+    public function get($uid);
81
+
82
+    /**
83
+     * check if a user exists
84
+     *
85
+     * @param string $uid
86
+     * @return bool
87
+     * @since 8.0.0
88
+     */
89
+    public function userExists($uid);
90
+
91
+    /**
92
+     * Check if the password is valid for the user
93
+     *
94
+     * @param string $loginName
95
+     * @param string $password
96
+     * @return mixed the User object on success, false otherwise
97
+     * @since 8.0.0
98
+     */
99
+    public function checkPassword($loginName, $password);
100
+
101
+    /**
102
+     * search by user id
103
+     *
104
+     * @param string $pattern
105
+     * @param int $limit
106
+     * @param int $offset
107
+     * @return \OCP\IUser[]
108
+     * @since 8.0.0
109
+     */
110
+    public function search($pattern, $limit = null, $offset = null);
111
+
112
+    /**
113
+     * search by displayName
114
+     *
115
+     * @param string $pattern
116
+     * @param int $limit
117
+     * @param int $offset
118
+     * @return \OCP\IUser[]
119
+     * @since 8.0.0
120
+     */
121
+    public function searchDisplayName($pattern, $limit = null, $offset = null);
122
+
123
+    /**
124
+     * @param string $uid
125
+     * @param string $password
126
+     * @throws \InvalidArgumentException
127
+     * @return bool|\OCP\IUser the created user of false
128
+     * @since 8.0.0
129
+     */
130
+    public function createUser($uid, $password);
131
+
132
+    /**
133
+     * @param string $uid
134
+     * @param string $password
135
+     * @param UserInterface $backend
136
+     * @return IUser|null
137
+     * @throws \InvalidArgumentException
138
+     * @since 12.0.0
139
+     */
140
+    public function createUserFromBackend($uid, $password, UserInterface $backend);
141
+
142
+    /**
143
+     * returns how many users per backend exist (if supported by backend)
144
+     *
145
+     * @return array an array of backend class as key and count number as value
146
+     * @since 8.0.0
147
+     */
148
+    public function countUsers();
149
+
150
+    /**
151
+     * @param \Closure $callback
152
+     * @param string $search
153
+     * @since 9.0.0
154
+     */
155
+    public function callForAllUsers(\Closure $callback, $search = '');
156
+
157
+    /**
158
+     * returns how many users have logged in once
159
+     *
160
+     * @return int
161
+     * @since 11.0.0
162
+     */
163
+    public function countDisabledUsers();
164
+
165
+    /**
166
+     * returns how many users have logged in once
167
+     *
168
+     * @return int
169
+     * @since 11.0.0
170
+     */
171
+    public function countSeenUsers();
172
+
173
+    /**
174
+     * @param \Closure $callback
175
+     * @since 11.0.0
176
+     */
177
+    public function callForSeenUsers(\Closure $callback);
178
+
179
+    /**
180
+     * @param string $email
181
+     * @return IUser[]
182
+     * @since 9.1.0
183
+     */
184
+    public function getByEmail($email);
185 185
 }
Please login to merge, or discard this patch.
apps/dav/lib/Migration/BuildCalendarSearchIndexBackgroundJob.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -31,90 +31,90 @@
 block discarded – undo
31 31
 
32 32
 class BuildCalendarSearchIndexBackgroundJob extends QueuedJob {
33 33
 
34
-	/** @var IDBConnection */
35
-	private $db;
36
-
37
-	/** @var CalDavBackend */
38
-	private $calDavBackend;
39
-
40
-	/** @var ILogger */
41
-	private $logger;
42
-
43
-	/** @var IJobList */
44
-	private $jobList;
45
-
46
-	/** @var ITimeFactory */
47
-	private $timeFactory;
48
-
49
-	/**
50
-	 * @param IDBConnection $db
51
-	 * @param CalDavBackend $calDavBackend
52
-	 * @param ILogger $logger
53
-	 * @param IJobList $jobList
54
-	 * @param ITimeFactory $timeFactory
55
-	 */
56
-	public function __construct(IDBConnection $db,
57
-								CalDavBackend $calDavBackend,
58
-								ILogger $logger,
59
-								IJobList $jobList,
60
-								ITimeFactory $timeFactory) {
61
-		$this->db = $db;
62
-		$this->calDavBackend = $calDavBackend;
63
-		$this->logger = $logger;
64
-		$this->jobList = $jobList;
65
-		$this->timeFactory = $timeFactory;
66
-	}
67
-
68
-	public function run($arguments) {
69
-		$offset = $arguments['offset'];
70
-		$stopAt = $arguments['stopAt'];
71
-
72
-		$this->logger->info('Building calendar index (' . $offset .'/' . $stopAt . ')');
73
-
74
-		$offset = $this->buildIndex($offset, $stopAt);
75
-
76
-		if ($offset >= $stopAt) {
77
-			$this->logger->info('Building calendar index done');
78
-		} else {
79
-			$this->jobList->add(self::class, [
80
-				'offset' => $offset,
81
-				'stopAt' => $stopAt
82
-			]);
83
-			$this->logger->info('New building calendar index job scheduled with offset ' . $offset);
84
-		}
85
-	}
86
-
87
-	/**
88
-	 * @param int $offset
89
-	 * @param int $stopAt
90
-	 * @return int
91
-	 */
92
-	private function buildIndex($offset, $stopAt) {
93
-		$startTime = $this->timeFactory->getTime();
94
-
95
-		$query = $this->db->getQueryBuilder();
96
-		$query->select(['id', 'calendarid', 'uri', 'calendardata'])
97
-			->from('calendarobjects')
98
-			->where($query->expr()->lte('id', $query->createNamedParameter($stopAt)))
99
-			->andWhere($query->expr()->gt('id', $query->createNamedParameter($offset)))
100
-			->orderBy('id', 'ASC');
101
-
102
-		$stmt = $query->execute();
103
-		while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
104
-			$offset = $row['id'];
105
-
106
-			$calendarData = $row['calendardata'];
107
-			if (is_resource($calendarData)) {
108
-				$calendarData = stream_get_contents($calendarData);
109
-			}
110
-
111
-			$this->calDavBackend->updateProperties($row['calendarid'], $row['uri'], $calendarData);
112
-
113
-			if (($this->timeFactory->getTime() - $startTime) > 15) {
114
-				return $offset;
115
-			}
116
-		}
117
-
118
-		return $stopAt;
119
-	}
34
+    /** @var IDBConnection */
35
+    private $db;
36
+
37
+    /** @var CalDavBackend */
38
+    private $calDavBackend;
39
+
40
+    /** @var ILogger */
41
+    private $logger;
42
+
43
+    /** @var IJobList */
44
+    private $jobList;
45
+
46
+    /** @var ITimeFactory */
47
+    private $timeFactory;
48
+
49
+    /**
50
+     * @param IDBConnection $db
51
+     * @param CalDavBackend $calDavBackend
52
+     * @param ILogger $logger
53
+     * @param IJobList $jobList
54
+     * @param ITimeFactory $timeFactory
55
+     */
56
+    public function __construct(IDBConnection $db,
57
+                                CalDavBackend $calDavBackend,
58
+                                ILogger $logger,
59
+                                IJobList $jobList,
60
+                                ITimeFactory $timeFactory) {
61
+        $this->db = $db;
62
+        $this->calDavBackend = $calDavBackend;
63
+        $this->logger = $logger;
64
+        $this->jobList = $jobList;
65
+        $this->timeFactory = $timeFactory;
66
+    }
67
+
68
+    public function run($arguments) {
69
+        $offset = $arguments['offset'];
70
+        $stopAt = $arguments['stopAt'];
71
+
72
+        $this->logger->info('Building calendar index (' . $offset .'/' . $stopAt . ')');
73
+
74
+        $offset = $this->buildIndex($offset, $stopAt);
75
+
76
+        if ($offset >= $stopAt) {
77
+            $this->logger->info('Building calendar index done');
78
+        } else {
79
+            $this->jobList->add(self::class, [
80
+                'offset' => $offset,
81
+                'stopAt' => $stopAt
82
+            ]);
83
+            $this->logger->info('New building calendar index job scheduled with offset ' . $offset);
84
+        }
85
+    }
86
+
87
+    /**
88
+     * @param int $offset
89
+     * @param int $stopAt
90
+     * @return int
91
+     */
92
+    private function buildIndex($offset, $stopAt) {
93
+        $startTime = $this->timeFactory->getTime();
94
+
95
+        $query = $this->db->getQueryBuilder();
96
+        $query->select(['id', 'calendarid', 'uri', 'calendardata'])
97
+            ->from('calendarobjects')
98
+            ->where($query->expr()->lte('id', $query->createNamedParameter($stopAt)))
99
+            ->andWhere($query->expr()->gt('id', $query->createNamedParameter($offset)))
100
+            ->orderBy('id', 'ASC');
101
+
102
+        $stmt = $query->execute();
103
+        while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
104
+            $offset = $row['id'];
105
+
106
+            $calendarData = $row['calendardata'];
107
+            if (is_resource($calendarData)) {
108
+                $calendarData = stream_get_contents($calendarData);
109
+            }
110
+
111
+            $this->calDavBackend->updateProperties($row['calendarid'], $row['uri'], $calendarData);
112
+
113
+            if (($this->timeFactory->getTime() - $startTime) > 15) {
114
+                return $offset;
115
+            }
116
+        }
117
+
118
+        return $stopAt;
119
+    }
120 120
 }
Please login to merge, or discard this patch.
lib/public/IPreview.php 1 patch
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -43,86 +43,86 @@
 block discarded – undo
43 43
  */
44 44
 interface IPreview {
45 45
 
46
-	/**
47
-	 * @since 9.2.0
48
-	 */
49
-	const EVENT = self::class . ':' . 'PreviewRequested';
46
+    /**
47
+     * @since 9.2.0
48
+     */
49
+    const EVENT = self::class . ':' . 'PreviewRequested';
50 50
 
51
-	const MODE_FILL = 'fill';
52
-	const MODE_COVER = 'cover';
51
+    const MODE_FILL = 'fill';
52
+    const MODE_COVER = 'cover';
53 53
 
54
-	/**
55
-	 * In order to improve lazy loading a closure can be registered which will be
56
-	 * called in case preview providers are actually requested
57
-	 *
58
-	 * $callable has to return an instance of \OCP\Preview\IProvider
59
-	 *
60
-	 * @param string $mimeTypeRegex Regex with the mime types that are supported by this provider
61
-	 * @param \Closure $callable
62
-	 * @return void
63
-	 * @since 8.1.0
64
-	 */
65
-	public function registerProvider($mimeTypeRegex, \Closure $callable);
54
+    /**
55
+     * In order to improve lazy loading a closure can be registered which will be
56
+     * called in case preview providers are actually requested
57
+     *
58
+     * $callable has to return an instance of \OCP\Preview\IProvider
59
+     *
60
+     * @param string $mimeTypeRegex Regex with the mime types that are supported by this provider
61
+     * @param \Closure $callable
62
+     * @return void
63
+     * @since 8.1.0
64
+     */
65
+    public function registerProvider($mimeTypeRegex, \Closure $callable);
66 66
 
67
-	/**
68
-	 * Get all providers
69
-	 * @return array
70
-	 * @since 8.1.0
71
-	 */
72
-	public function getProviders();
67
+    /**
68
+     * Get all providers
69
+     * @return array
70
+     * @since 8.1.0
71
+     */
72
+    public function getProviders();
73 73
 
74
-	/**
75
-	 * Does the manager have any providers
76
-	 * @return bool
77
-	 * @since 8.1.0
78
-	 */
79
-	public function hasProviders();
74
+    /**
75
+     * Does the manager have any providers
76
+     * @return bool
77
+     * @since 8.1.0
78
+     */
79
+    public function hasProviders();
80 80
 
81
-	/**
82
-	 * Return a preview of a file
83
-	 * @param string $file The path to the file where you want a thumbnail from
84
-	 * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image
85
-	 * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image
86
-	 * @param boolean $scaleUp Scale smaller images up to the thumbnail size or not. Might look ugly
87
-	 * @return \OCP\IImage
88
-	 * @since 6.0.0
89
-	 * @deprecated 11 Use getPreview
90
-	 */
91
-	public function createPreview($file, $maxX = 100, $maxY = 75, $scaleUp = false);
81
+    /**
82
+     * Return a preview of a file
83
+     * @param string $file The path to the file where you want a thumbnail from
84
+     * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image
85
+     * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image
86
+     * @param boolean $scaleUp Scale smaller images up to the thumbnail size or not. Might look ugly
87
+     * @return \OCP\IImage
88
+     * @since 6.0.0
89
+     * @deprecated 11 Use getPreview
90
+     */
91
+    public function createPreview($file, $maxX = 100, $maxY = 75, $scaleUp = false);
92 92
 
93
-	/**
94
-	 * Returns a preview of a file
95
-	 *
96
-	 * The cache is searched first and if nothing usable was found then a preview is
97
-	 * generated by one of the providers
98
-	 *
99
-	 * @param File $file
100
-	 * @param int $width
101
-	 * @param int $height
102
-	 * @param bool $crop
103
-	 * @param string $mode
104
-	 * @param string $mimeType To force a given mimetype for the file (files_versions needs this)
105
-	 * @return ISimpleFile
106
-	 * @throws NotFoundException
107
-	 * @throws \InvalidArgumentException if the preview would be invalid (in case the original image is invalid)
108
-	 * @since 11.0.0 - \InvalidArgumentException was added in 12.0.0
109
-	 */
110
-	public function getPreview(File $file, $width = -1, $height = -1, $crop = false, $mode = IPreview::MODE_FILL, $mimeType = null);
93
+    /**
94
+     * Returns a preview of a file
95
+     *
96
+     * The cache is searched first and if nothing usable was found then a preview is
97
+     * generated by one of the providers
98
+     *
99
+     * @param File $file
100
+     * @param int $width
101
+     * @param int $height
102
+     * @param bool $crop
103
+     * @param string $mode
104
+     * @param string $mimeType To force a given mimetype for the file (files_versions needs this)
105
+     * @return ISimpleFile
106
+     * @throws NotFoundException
107
+     * @throws \InvalidArgumentException if the preview would be invalid (in case the original image is invalid)
108
+     * @since 11.0.0 - \InvalidArgumentException was added in 12.0.0
109
+     */
110
+    public function getPreview(File $file, $width = -1, $height = -1, $crop = false, $mode = IPreview::MODE_FILL, $mimeType = null);
111 111
 
112
-	/**
113
-	 * Returns true if the passed mime type is supported
114
-	 * @param string $mimeType
115
-	 * @return boolean
116
-	 * @since 6.0.0
117
-	 */
118
-	public function isMimeSupported($mimeType = '*');
112
+    /**
113
+     * Returns true if the passed mime type is supported
114
+     * @param string $mimeType
115
+     * @return boolean
116
+     * @since 6.0.0
117
+     */
118
+    public function isMimeSupported($mimeType = '*');
119 119
 
120
-	/**
121
-	 * Check if a preview can be generated for a file
122
-	 *
123
-	 * @param \OCP\Files\FileInfo $file
124
-	 * @return bool
125
-	 * @since 8.0.0
126
-	 */
127
-	public function isAvailable(\OCP\Files\FileInfo $file);
120
+    /**
121
+     * Check if a preview can be generated for a file
122
+     *
123
+     * @param \OCP\Files\FileInfo $file
124
+     * @return bool
125
+     * @since 8.0.0
126
+     */
127
+    public function isAvailable(\OCP\Files\FileInfo $file);
128 128
 }
Please login to merge, or discard this patch.
apps/files_trashbin/lib/Controller/PreviewController.php 1 patch
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -35,87 +35,87 @@
 block discarded – undo
35 35
 
36 36
 class PreviewController extends Controller {
37 37
 
38
-	/** @var IRootFolder */
39
-	private $rootFolder;
38
+    /** @var IRootFolder */
39
+    private $rootFolder;
40 40
 
41
-	/** @var string */
42
-	private $userId;
41
+    /** @var string */
42
+    private $userId;
43 43
 
44
-	/** @var IMimeTypeDetector */
45
-	private $mimeTypeDetector;
44
+    /** @var IMimeTypeDetector */
45
+    private $mimeTypeDetector;
46 46
 
47
-	/** @var IPreview */
48
-	private $previewManager;
47
+    /** @var IPreview */
48
+    private $previewManager;
49 49
 
50
-	/**
51
-	 * @param string $appName
52
-	 * @param IRequest $request
53
-	 * @param IRootFolder $rootFolder
54
-	 * @param $userId
55
-	 * @param IMimeTypeDetector $mimeTypeDetector
56
-	 * @param IPreview $previewManager
57
-	 */
58
-	public function __construct($appName,
59
-								IRequest $request,
60
-								IRootFolder $rootFolder,
61
-								$userId,
62
-								IMimeTypeDetector $mimeTypeDetector,
63
-								IPreview $previewManager) {
64
-		parent::__construct($appName, $request);
50
+    /**
51
+     * @param string $appName
52
+     * @param IRequest $request
53
+     * @param IRootFolder $rootFolder
54
+     * @param $userId
55
+     * @param IMimeTypeDetector $mimeTypeDetector
56
+     * @param IPreview $previewManager
57
+     */
58
+    public function __construct($appName,
59
+                                IRequest $request,
60
+                                IRootFolder $rootFolder,
61
+                                $userId,
62
+                                IMimeTypeDetector $mimeTypeDetector,
63
+                                IPreview $previewManager) {
64
+        parent::__construct($appName, $request);
65 65
 
66
-		$this->rootFolder = $rootFolder;
67
-		$this->userId = $userId;
68
-		$this->mimeTypeDetector = $mimeTypeDetector;
69
-		$this->previewManager = $previewManager;
70
-	}
66
+        $this->rootFolder = $rootFolder;
67
+        $this->userId = $userId;
68
+        $this->mimeTypeDetector = $mimeTypeDetector;
69
+        $this->previewManager = $previewManager;
70
+    }
71 71
 
72
-	/**
73
-	 * @NoAdminRequired
74
-	 * @NoCSRFRequired
75
-	 *
76
-	 * @param string $file
77
-	 * @param int $x
78
-	 * @param int $y
79
-	 * @return DataResponse|Http\FileDisplayResponse
80
-	 */
81
-	public function getPreview(
82
-		$file = '',
83
-		$x = 44,
84
-		$y = 44
85
-	) {
86
-		if ($file === '') {
87
-			return new DataResponse([], Http::STATUS_BAD_REQUEST);
88
-		}
72
+    /**
73
+     * @NoAdminRequired
74
+     * @NoCSRFRequired
75
+     *
76
+     * @param string $file
77
+     * @param int $x
78
+     * @param int $y
79
+     * @return DataResponse|Http\FileDisplayResponse
80
+     */
81
+    public function getPreview(
82
+        $file = '',
83
+        $x = 44,
84
+        $y = 44
85
+    ) {
86
+        if ($file === '') {
87
+            return new DataResponse([], Http::STATUS_BAD_REQUEST);
88
+        }
89 89
 
90
-		if ($x === 0 || $y === 0) {
91
-			return new DataResponse([], Http::STATUS_BAD_REQUEST);
92
-		}
90
+        if ($x === 0 || $y === 0) {
91
+            return new DataResponse([], Http::STATUS_BAD_REQUEST);
92
+        }
93 93
 
94
-		try {
95
-			$userFolder = $this->rootFolder->getUserFolder($this->userId);
96
-			/** @var Folder $trash */
97
-			$trash = $userFolder->getParent()->get('files_trashbin/files');
98
-			$trashFile = $trash->get($file);
94
+        try {
95
+            $userFolder = $this->rootFolder->getUserFolder($this->userId);
96
+            /** @var Folder $trash */
97
+            $trash = $userFolder->getParent()->get('files_trashbin/files');
98
+            $trashFile = $trash->get($file);
99 99
 
100
-			if ($trashFile instanceof Folder) {
101
-				return new DataResponse([], Http::STATUS_BAD_REQUEST);
102
-			}
100
+            if ($trashFile instanceof Folder) {
101
+                return new DataResponse([], Http::STATUS_BAD_REQUEST);
102
+            }
103 103
 
104
-			/** @var File $trashFile */
105
-			$fileName = $trashFile->getName();
106
-			$i = strrpos($fileName, '.');
107
-			if ($i !== false) {
108
-				$fileName = substr($fileName, 0, $i);
109
-			}
104
+            /** @var File $trashFile */
105
+            $fileName = $trashFile->getName();
106
+            $i = strrpos($fileName, '.');
107
+            if ($i !== false) {
108
+                $fileName = substr($fileName, 0, $i);
109
+            }
110 110
 
111
-			$mimeType = $this->mimeTypeDetector->detectPath($fileName);
111
+            $mimeType = $this->mimeTypeDetector->detectPath($fileName);
112 112
 
113
-			$f = $this->previewManager->getPreview($trashFile, $x, $y, true, IPreview::MODE_FILL, $mimeType);
114
-			return new Http\FileDisplayResponse($f, Http::STATUS_OK, ['Content-Type' => $f->getMimeType()]);
115
-		} catch (NotFoundException $e) {
116
-			return new DataResponse([], Http::STATUS_NOT_FOUND);
117
-		} catch (\InvalidArgumentException $e) {
118
-			return new DataResponse([], Http::STATUS_BAD_REQUEST);
119
-		}
120
-	}
113
+            $f = $this->previewManager->getPreview($trashFile, $x, $y, true, IPreview::MODE_FILL, $mimeType);
114
+            return new Http\FileDisplayResponse($f, Http::STATUS_OK, ['Content-Type' => $f->getMimeType()]);
115
+        } catch (NotFoundException $e) {
116
+            return new DataResponse([], Http::STATUS_NOT_FOUND);
117
+        } catch (\InvalidArgumentException $e) {
118
+            return new DataResponse([], Http::STATUS_BAD_REQUEST);
119
+        }
120
+    }
121 121
 }
Please login to merge, or discard this patch.
apps/files_versions/lib/Controller/PreviewController.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -36,66 +36,66 @@
 block discarded – undo
36 36
 
37 37
 class PreviewController extends Controller {
38 38
 
39
-	/** @var IRootFolder */
40
-	private $rootFolder;
39
+    /** @var IRootFolder */
40
+    private $rootFolder;
41 41
 
42
-	/** @var string */
43
-	private $userId;
42
+    /** @var string */
43
+    private $userId;
44 44
 
45
-	/** @var IMimeTypeDetector */
46
-	private $mimeTypeDetector;
45
+    /** @var IMimeTypeDetector */
46
+    private $mimeTypeDetector;
47 47
 
48
-	/** @var IPreview */
49
-	private $previewManager;
48
+    /** @var IPreview */
49
+    private $previewManager;
50 50
 
51
-	public function __construct($appName,
52
-								IRequest $request,
53
-								IRootFolder $rootFolder,
54
-								$userId,
55
-								IMimeTypeDetector $mimeTypeDetector,
56
-								IPreview $previewManager) {
57
-		parent::__construct($appName, $request);
51
+    public function __construct($appName,
52
+                                IRequest $request,
53
+                                IRootFolder $rootFolder,
54
+                                $userId,
55
+                                IMimeTypeDetector $mimeTypeDetector,
56
+                                IPreview $previewManager) {
57
+        parent::__construct($appName, $request);
58 58
 
59
-		$this->rootFolder = $rootFolder;
60
-		$this->userId = $userId;
61
-		$this->mimeTypeDetector = $mimeTypeDetector;
62
-		$this->previewManager = $previewManager;
63
-	}
59
+        $this->rootFolder = $rootFolder;
60
+        $this->userId = $userId;
61
+        $this->mimeTypeDetector = $mimeTypeDetector;
62
+        $this->previewManager = $previewManager;
63
+    }
64 64
 
65
-	/**
66
-	 * @NoAdminRequired
67
-	 * @NoCSRFRequired
68
-	 *
69
-	 * @param string $file
70
-	 * @param int $x
71
-	 * @param int $y
72
-	 * @param string $version
73
-	 * @return DataResponse|FileDisplayResponse
74
-	 */
75
-	public function getPreview(
76
-		$file = '',
77
-		$x = 44,
78
-		$y = 44,
79
-		$version = ''
80
-	) {
81
-		if($file === '' || $version === '' || $x === 0 || $y === 0) {
82
-			return new DataResponse([], Http::STATUS_BAD_REQUEST);
83
-		}
65
+    /**
66
+     * @NoAdminRequired
67
+     * @NoCSRFRequired
68
+     *
69
+     * @param string $file
70
+     * @param int $x
71
+     * @param int $y
72
+     * @param string $version
73
+     * @return DataResponse|FileDisplayResponse
74
+     */
75
+    public function getPreview(
76
+        $file = '',
77
+        $x = 44,
78
+        $y = 44,
79
+        $version = ''
80
+    ) {
81
+        if($file === '' || $version === '' || $x === 0 || $y === 0) {
82
+            return new DataResponse([], Http::STATUS_BAD_REQUEST);
83
+        }
84 84
 
85
-		try {
86
-			$userFolder = $this->rootFolder->getUserFolder($this->userId);
87
-			/** @var Folder $versionFolder */
88
-			$versionFolder = $userFolder->getParent()->get('files_versions');
89
-			$mimeType = $this->mimeTypeDetector->detectPath($file);
90
-			$file = $versionFolder->get($file.'.v'.$version);
85
+        try {
86
+            $userFolder = $this->rootFolder->getUserFolder($this->userId);
87
+            /** @var Folder $versionFolder */
88
+            $versionFolder = $userFolder->getParent()->get('files_versions');
89
+            $mimeType = $this->mimeTypeDetector->detectPath($file);
90
+            $file = $versionFolder->get($file.'.v'.$version);
91 91
 
92
-			/** @var File $file */
93
-			$f = $this->previewManager->getPreview($file, $x, $y, true, IPreview::MODE_FILL, $mimeType);
94
-			return new FileDisplayResponse($f, Http::STATUS_OK, ['Content-Type' => $f->getMimeType()]);
95
-		} catch (NotFoundException $e) {
96
-			return new DataResponse([], Http::STATUS_NOT_FOUND);
97
-		} catch (\InvalidArgumentException $e) {
98
-			return new DataResponse([], Http::STATUS_BAD_REQUEST);
99
-		}
100
-	}
92
+            /** @var File $file */
93
+            $f = $this->previewManager->getPreview($file, $x, $y, true, IPreview::MODE_FILL, $mimeType);
94
+            return new FileDisplayResponse($f, Http::STATUS_OK, ['Content-Type' => $f->getMimeType()]);
95
+        } catch (NotFoundException $e) {
96
+            return new DataResponse([], Http::STATUS_NOT_FOUND);
97
+        } catch (\InvalidArgumentException $e) {
98
+            return new DataResponse([], Http::STATUS_BAD_REQUEST);
99
+        }
100
+    }
101 101
 }
Please login to merge, or discard this patch.
apps/dav/lib/CardDAV/PhotoCache.php 1 patch
Indentation   +230 added lines, -230 removed lines patch added patch discarded remove patch
@@ -13,234 +13,234 @@
 block discarded – undo
13 13
 
14 14
 class PhotoCache {
15 15
 
16
-	/** @var IAppData $appData */
17
-	protected $appData;
18
-
19
-	/**
20
-	 * PhotoCache constructor.
21
-	 *
22
-	 * @param IAppData $appData
23
-	 */
24
-	public function __construct(IAppData $appData) {
25
-		$this->appData = $appData;
26
-	}
27
-
28
-	/**
29
-	 * @param int $addressBookId
30
-	 * @param string $cardUri
31
-	 * @param int $size
32
-	 * @param Card $card
33
-	 *
34
-	 * @return ISimpleFile
35
-	 * @throws NotFoundException
36
-	 */
37
-	public function get($addressBookId, $cardUri, $size, Card $card) {
38
-		$folder = $this->getFolder($addressBookId, $cardUri);
39
-
40
-		if ($this->isEmpty($folder)) {
41
-			$this->init($folder, $card);
42
-		}
43
-
44
-		if (!$this->hasPhoto($folder)) {
45
-			throw new NotFoundException();
46
-		}
47
-
48
-		if ($size !== -1) {
49
-			$size = 2 ** ceil(log($size) / log(2));
50
-		}
51
-
52
-		return $this->getFile($folder, $size);
53
-	}
54
-
55
-	/**
56
-	 * @param ISimpleFolder $folder
57
-	 * @return bool
58
-	 */
59
-	private function isEmpty(ISimpleFolder $folder) {
60
-		return $folder->getDirectoryListing() === [];
61
-	}
62
-
63
-	/**
64
-	 * @param ISimpleFolder $folder
65
-	 * @param Card $card
66
-	 */
67
-	private function init(ISimpleFolder $folder, Card $card) {
68
-		$data = $this->getPhoto($card);
69
-
70
-		if ($data === false) {
71
-			$folder->newFile('nophoto');
72
-		} else {
73
-			switch ($data['Content-Type']) {
74
-				case 'image/png':
75
-					$ext = 'png';
76
-					break;
77
-				case 'image/jpeg':
78
-					$ext = 'jpg';
79
-					break;
80
-				case 'image/gif':
81
-					$ext = 'gif';
82
-					break;
83
-			}
84
-			$file = $folder->newFile('photo.' . $ext);
85
-			$file->putContent($data['body']);
86
-		}
87
-	}
88
-
89
-	private function hasPhoto(ISimpleFolder $folder) {
90
-		return !$folder->fileExists('nophoto');
91
-	}
92
-
93
-	private function getFile(ISimpleFolder $folder, $size) {
94
-		$ext = $this->getExtension($folder);
95
-
96
-		if ($size === -1) {
97
-			$path = 'photo.' . $ext;
98
-		} else {
99
-			$path = 'photo.' . $size . '.' . $ext;
100
-		}
101
-
102
-		try {
103
-			$file = $folder->getFile($path);
104
-		} catch (NotFoundException $e) {
105
-			if ($size <= 0) {
106
-				throw new NotFoundException;
107
-			}
108
-
109
-			$photo = new \OC_Image();
110
-			/** @var ISimpleFile $file */
111
-			$file = $folder->getFile('photo.' . $ext);
112
-			$photo->loadFromData($file->getContent());
113
-
114
-			$ratio = $photo->width() / $photo->height();
115
-			if ($ratio < 1) {
116
-				$ratio = 1/$ratio;
117
-			}
118
-			$size = (int)($size * $ratio);
119
-
120
-			if ($size !== -1) {
121
-				$photo->resize($size);
122
-			}
123
-			try {
124
-				$file = $folder->newFile($path);
125
-				$file->putContent($photo->data());
126
-			} catch (NotPermittedException $e) {
127
-
128
-			}
129
-		}
130
-
131
-		return $file;
132
-	}
133
-
134
-
135
-	/**
136
-	 * @param int $addressBookId
137
-	 * @param string $cardUri
138
-	 * @return ISimpleFolder
139
-	 */
140
-	private function getFolder($addressBookId, $cardUri) {
141
-		$hash = md5($addressBookId . ' ' . $cardUri);
142
-		try {
143
-			return $this->appData->getFolder($hash);
144
-		} catch (NotFoundException $e) {
145
-			return $this->appData->newFolder($hash);
146
-		}
147
-	}
148
-
149
-	/**
150
-	 * Get the extension of the avatar. If there is no avatar throw Exception
151
-	 *
152
-	 * @param ISimpleFolder $folder
153
-	 * @return string
154
-	 * @throws NotFoundException
155
-	 */
156
-	private function getExtension(ISimpleFolder $folder) {
157
-		if ($folder->fileExists('photo.jpg')) {
158
-			return 'jpg';
159
-		} elseif ($folder->fileExists('photo.png')) {
160
-			return 'png';
161
-		} elseif ($folder->fileExists('photo.gif')) {
162
-			return 'gif';
163
-		}
164
-		throw new NotFoundException;
165
-	}
166
-
167
-	private function getPhoto(Card $node) {
168
-		try {
169
-			$vObject = $this->readCard($node->get());
170
-			if (!$vObject->PHOTO) {
171
-				return false;
172
-			}
173
-
174
-			$photo = $vObject->PHOTO;
175
-			$type = $this->getType($photo);
176
-
177
-			$val = $photo->getValue();
178
-			if ($photo->getValueType() === 'URI') {
179
-				$parsed = \Sabre\URI\parse($val);
180
-				//only allow data://
181
-				if ($parsed['scheme'] !== 'data') {
182
-					return false;
183
-				}
184
-				if (substr_count($parsed['path'], ';') === 1) {
185
-					list($type,) = explode(';', $parsed['path']);
186
-				}
187
-				$val = file_get_contents($val);
188
-			}
189
-
190
-			$allowedContentTypes = [
191
-				'image/png',
192
-				'image/jpeg',
193
-				'image/gif',
194
-			];
195
-
196
-			if(!in_array($type, $allowedContentTypes, true)) {
197
-				$type = 'application/octet-stream';
198
-			}
199
-
200
-			return [
201
-				'Content-Type' => $type,
202
-				'body' => $val
203
-			];
204
-		} catch(\Exception $ex) {
205
-
206
-		}
207
-		return false;
208
-	}
209
-
210
-	/**
211
-	 * @param string $cardData
212
-	 * @return \Sabre\VObject\Document
213
-	 */
214
-	private function readCard($cardData) {
215
-		return Reader::read($cardData);
216
-	}
217
-
218
-	/**
219
-	 * @param Binary $photo
220
-	 * @return string
221
-	 */
222
-	private function getType(Binary $photo) {
223
-		$params = $photo->parameters();
224
-		if (isset($params['TYPE']) || isset($params['MEDIATYPE'])) {
225
-			/** @var Parameter $typeParam */
226
-			$typeParam = isset($params['TYPE']) ? $params['TYPE'] : $params['MEDIATYPE'];
227
-			$type = $typeParam->getValue();
228
-
229
-			if (strpos($type, 'image/') === 0) {
230
-				return $type;
231
-			} else {
232
-				return 'image/' . strtolower($type);
233
-			}
234
-		}
235
-		return '';
236
-	}
237
-
238
-	/**
239
-	 * @param int $addressBookId
240
-	 * @param string $cardUri
241
-	 */
242
-	public function delete($addressBookId, $cardUri) {
243
-		$folder = $this->getFolder($addressBookId, $cardUri);
244
-		$folder->delete();
245
-	}
16
+    /** @var IAppData $appData */
17
+    protected $appData;
18
+
19
+    /**
20
+     * PhotoCache constructor.
21
+     *
22
+     * @param IAppData $appData
23
+     */
24
+    public function __construct(IAppData $appData) {
25
+        $this->appData = $appData;
26
+    }
27
+
28
+    /**
29
+     * @param int $addressBookId
30
+     * @param string $cardUri
31
+     * @param int $size
32
+     * @param Card $card
33
+     *
34
+     * @return ISimpleFile
35
+     * @throws NotFoundException
36
+     */
37
+    public function get($addressBookId, $cardUri, $size, Card $card) {
38
+        $folder = $this->getFolder($addressBookId, $cardUri);
39
+
40
+        if ($this->isEmpty($folder)) {
41
+            $this->init($folder, $card);
42
+        }
43
+
44
+        if (!$this->hasPhoto($folder)) {
45
+            throw new NotFoundException();
46
+        }
47
+
48
+        if ($size !== -1) {
49
+            $size = 2 ** ceil(log($size) / log(2));
50
+        }
51
+
52
+        return $this->getFile($folder, $size);
53
+    }
54
+
55
+    /**
56
+     * @param ISimpleFolder $folder
57
+     * @return bool
58
+     */
59
+    private function isEmpty(ISimpleFolder $folder) {
60
+        return $folder->getDirectoryListing() === [];
61
+    }
62
+
63
+    /**
64
+     * @param ISimpleFolder $folder
65
+     * @param Card $card
66
+     */
67
+    private function init(ISimpleFolder $folder, Card $card) {
68
+        $data = $this->getPhoto($card);
69
+
70
+        if ($data === false) {
71
+            $folder->newFile('nophoto');
72
+        } else {
73
+            switch ($data['Content-Type']) {
74
+                case 'image/png':
75
+                    $ext = 'png';
76
+                    break;
77
+                case 'image/jpeg':
78
+                    $ext = 'jpg';
79
+                    break;
80
+                case 'image/gif':
81
+                    $ext = 'gif';
82
+                    break;
83
+            }
84
+            $file = $folder->newFile('photo.' . $ext);
85
+            $file->putContent($data['body']);
86
+        }
87
+    }
88
+
89
+    private function hasPhoto(ISimpleFolder $folder) {
90
+        return !$folder->fileExists('nophoto');
91
+    }
92
+
93
+    private function getFile(ISimpleFolder $folder, $size) {
94
+        $ext = $this->getExtension($folder);
95
+
96
+        if ($size === -1) {
97
+            $path = 'photo.' . $ext;
98
+        } else {
99
+            $path = 'photo.' . $size . '.' . $ext;
100
+        }
101
+
102
+        try {
103
+            $file = $folder->getFile($path);
104
+        } catch (NotFoundException $e) {
105
+            if ($size <= 0) {
106
+                throw new NotFoundException;
107
+            }
108
+
109
+            $photo = new \OC_Image();
110
+            /** @var ISimpleFile $file */
111
+            $file = $folder->getFile('photo.' . $ext);
112
+            $photo->loadFromData($file->getContent());
113
+
114
+            $ratio = $photo->width() / $photo->height();
115
+            if ($ratio < 1) {
116
+                $ratio = 1/$ratio;
117
+            }
118
+            $size = (int)($size * $ratio);
119
+
120
+            if ($size !== -1) {
121
+                $photo->resize($size);
122
+            }
123
+            try {
124
+                $file = $folder->newFile($path);
125
+                $file->putContent($photo->data());
126
+            } catch (NotPermittedException $e) {
127
+
128
+            }
129
+        }
130
+
131
+        return $file;
132
+    }
133
+
134
+
135
+    /**
136
+     * @param int $addressBookId
137
+     * @param string $cardUri
138
+     * @return ISimpleFolder
139
+     */
140
+    private function getFolder($addressBookId, $cardUri) {
141
+        $hash = md5($addressBookId . ' ' . $cardUri);
142
+        try {
143
+            return $this->appData->getFolder($hash);
144
+        } catch (NotFoundException $e) {
145
+            return $this->appData->newFolder($hash);
146
+        }
147
+    }
148
+
149
+    /**
150
+     * Get the extension of the avatar. If there is no avatar throw Exception
151
+     *
152
+     * @param ISimpleFolder $folder
153
+     * @return string
154
+     * @throws NotFoundException
155
+     */
156
+    private function getExtension(ISimpleFolder $folder) {
157
+        if ($folder->fileExists('photo.jpg')) {
158
+            return 'jpg';
159
+        } elseif ($folder->fileExists('photo.png')) {
160
+            return 'png';
161
+        } elseif ($folder->fileExists('photo.gif')) {
162
+            return 'gif';
163
+        }
164
+        throw new NotFoundException;
165
+    }
166
+
167
+    private function getPhoto(Card $node) {
168
+        try {
169
+            $vObject = $this->readCard($node->get());
170
+            if (!$vObject->PHOTO) {
171
+                return false;
172
+            }
173
+
174
+            $photo = $vObject->PHOTO;
175
+            $type = $this->getType($photo);
176
+
177
+            $val = $photo->getValue();
178
+            if ($photo->getValueType() === 'URI') {
179
+                $parsed = \Sabre\URI\parse($val);
180
+                //only allow data://
181
+                if ($parsed['scheme'] !== 'data') {
182
+                    return false;
183
+                }
184
+                if (substr_count($parsed['path'], ';') === 1) {
185
+                    list($type,) = explode(';', $parsed['path']);
186
+                }
187
+                $val = file_get_contents($val);
188
+            }
189
+
190
+            $allowedContentTypes = [
191
+                'image/png',
192
+                'image/jpeg',
193
+                'image/gif',
194
+            ];
195
+
196
+            if(!in_array($type, $allowedContentTypes, true)) {
197
+                $type = 'application/octet-stream';
198
+            }
199
+
200
+            return [
201
+                'Content-Type' => $type,
202
+                'body' => $val
203
+            ];
204
+        } catch(\Exception $ex) {
205
+
206
+        }
207
+        return false;
208
+    }
209
+
210
+    /**
211
+     * @param string $cardData
212
+     * @return \Sabre\VObject\Document
213
+     */
214
+    private function readCard($cardData) {
215
+        return Reader::read($cardData);
216
+    }
217
+
218
+    /**
219
+     * @param Binary $photo
220
+     * @return string
221
+     */
222
+    private function getType(Binary $photo) {
223
+        $params = $photo->parameters();
224
+        if (isset($params['TYPE']) || isset($params['MEDIATYPE'])) {
225
+            /** @var Parameter $typeParam */
226
+            $typeParam = isset($params['TYPE']) ? $params['TYPE'] : $params['MEDIATYPE'];
227
+            $type = $typeParam->getValue();
228
+
229
+            if (strpos($type, 'image/') === 0) {
230
+                return $type;
231
+            } else {
232
+                return 'image/' . strtolower($type);
233
+            }
234
+        }
235
+        return '';
236
+    }
237
+
238
+    /**
239
+     * @param int $addressBookId
240
+     * @param string $cardUri
241
+     */
242
+    public function delete($addressBookId, $cardUri) {
243
+        $folder = $this->getFolder($addressBookId, $cardUri);
244
+        $folder->delete();
245
+    }
246 246
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/PublicAuth.php 1 patch
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -42,89 +42,89 @@
 block discarded – undo
42 42
  */
43 43
 class PublicAuth extends AbstractBasic {
44 44
 
45
-	/** @var \OCP\Share\IShare */
46
-	private $share;
45
+    /** @var \OCP\Share\IShare */
46
+    private $share;
47 47
 
48
-	/** @var IManager */
49
-	private $shareManager;
48
+    /** @var IManager */
49
+    private $shareManager;
50 50
 
51
-	/** @var ISession */
52
-	private $session;
51
+    /** @var ISession */
52
+    private $session;
53 53
 
54
-	/** @var IRequest */
55
-	private $request;
54
+    /** @var IRequest */
55
+    private $request;
56 56
 
57
-	/**
58
-	 * @param IRequest $request
59
-	 * @param IManager $shareManager
60
-	 * @param ISession $session
61
-	 */
62
-	public function __construct(IRequest $request,
63
-								IManager $shareManager,
64
-								ISession $session) {
65
-		$this->request = $request;
66
-		$this->shareManager = $shareManager;
67
-		$this->session = $session;
57
+    /**
58
+     * @param IRequest $request
59
+     * @param IManager $shareManager
60
+     * @param ISession $session
61
+     */
62
+    public function __construct(IRequest $request,
63
+                                IManager $shareManager,
64
+                                ISession $session) {
65
+        $this->request = $request;
66
+        $this->shareManager = $shareManager;
67
+        $this->session = $session;
68 68
 
69
-		// setup realm
70
-		$defaults = new \OCP\Defaults();
71
-		$this->realm = $defaults->getName();
72
-	}
69
+        // setup realm
70
+        $defaults = new \OCP\Defaults();
71
+        $this->realm = $defaults->getName();
72
+    }
73 73
 
74
-	/**
75
-	 * Validates a username and password
76
-	 *
77
-	 * This method should return true or false depending on if login
78
-	 * succeeded.
79
-	 *
80
-	 * @param string $username
81
-	 * @param string $password
82
-	 *
83
-	 * @return bool
84
-	 * @throws \Sabre\DAV\Exception\NotAuthenticated
85
-	 */
86
-	protected function validateUserPass($username, $password) {
87
-		try {
88
-			$share = $this->shareManager->getShareByToken($username);
89
-		} catch (ShareNotFound $e) {
90
-			return false;
91
-		}
74
+    /**
75
+     * Validates a username and password
76
+     *
77
+     * This method should return true or false depending on if login
78
+     * succeeded.
79
+     *
80
+     * @param string $username
81
+     * @param string $password
82
+     *
83
+     * @return bool
84
+     * @throws \Sabre\DAV\Exception\NotAuthenticated
85
+     */
86
+    protected function validateUserPass($username, $password) {
87
+        try {
88
+            $share = $this->shareManager->getShareByToken($username);
89
+        } catch (ShareNotFound $e) {
90
+            return false;
91
+        }
92 92
 
93
-		$this->share = $share;
93
+        $this->share = $share;
94 94
 
95
-		\OC_User::setIncognitoMode(true);
95
+        \OC_User::setIncognitoMode(true);
96 96
 
97
-		// check if the share is password protected
98
-		if ($share->getPassword() !== null) {
99
-			if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK || $share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) {
100
-				if ($this->shareManager->checkPassword($share, $password)) {
101
-					return true;
102
-				} else if ($this->session->exists('public_link_authenticated')
103
-					&& $this->session->get('public_link_authenticated') === (string)$share->getId()) {
104
-					return true;
105
-				} else {
106
-					if (in_array('XMLHttpRequest', explode(',', $this->request->getHeader('X-Requested-With')))) {
107
-						// do not re-authenticate over ajax, use dummy auth name to prevent browser popup
108
-						http_response_code(401);
109
-						header('WWW-Authenticate','DummyBasic realm="' . $this->realm . '"');
110
-						throw new \Sabre\DAV\Exception\NotAuthenticated('Cannot authenticate over ajax calls');
111
-					}
112
-					return false;
113
-				}
114
-			} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_REMOTE) {
115
-				return true;
116
-			} else {
117
-				return false;
118
-			}
119
-		} else {
120
-			return true;
121
-		}
122
-	}
97
+        // check if the share is password protected
98
+        if ($share->getPassword() !== null) {
99
+            if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK || $share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) {
100
+                if ($this->shareManager->checkPassword($share, $password)) {
101
+                    return true;
102
+                } else if ($this->session->exists('public_link_authenticated')
103
+                    && $this->session->get('public_link_authenticated') === (string)$share->getId()) {
104
+                    return true;
105
+                } else {
106
+                    if (in_array('XMLHttpRequest', explode(',', $this->request->getHeader('X-Requested-With')))) {
107
+                        // do not re-authenticate over ajax, use dummy auth name to prevent browser popup
108
+                        http_response_code(401);
109
+                        header('WWW-Authenticate','DummyBasic realm="' . $this->realm . '"');
110
+                        throw new \Sabre\DAV\Exception\NotAuthenticated('Cannot authenticate over ajax calls');
111
+                    }
112
+                    return false;
113
+                }
114
+            } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_REMOTE) {
115
+                return true;
116
+            } else {
117
+                return false;
118
+            }
119
+        } else {
120
+            return true;
121
+        }
122
+    }
123 123
 
124
-	/**
125
-	 * @return \OCP\Share\IShare
126
-	 */
127
-	public function getShare() {
128
-		return $this->share;
129
-	}
124
+    /**
125
+     * @return \OCP\Share\IShare
126
+     */
127
+    public function getShare() {
128
+        return $this->share;
129
+    }
130 130
 }
Please login to merge, or discard this patch.
apps/dav/lib/CardDAV/ImageExportPlugin.php 1 patch
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -32,85 +32,85 @@
 block discarded – undo
32 32
 
33 33
 class ImageExportPlugin extends ServerPlugin {
34 34
 
35
-	/** @var Server */
36
-	protected $server;
37
-	/** @var PhotoCache */
38
-	private $cache;
39
-
40
-	/**
41
-	 * ImageExportPlugin constructor.
42
-	 *
43
-	 * @param PhotoCache $cache
44
-	 */
45
-	public function __construct(PhotoCache $cache) {
46
-		$this->cache = $cache;
47
-	}
48
-
49
-	/**
50
-	 * Initializes the plugin and registers event handlers
51
-	 *
52
-	 * @param Server $server
53
-	 * @return void
54
-	 */
55
-	public function initialize(Server $server) {
56
-		$this->server = $server;
57
-		$this->server->on('method:GET', [$this, 'httpGet'], 90);
58
-	}
59
-
60
-	/**
61
-	 * Intercepts GET requests on addressbook urls ending with ?photo.
62
-	 *
63
-	 * @param RequestInterface $request
64
-	 * @param ResponseInterface $response
65
-	 * @return bool
66
-	 */
67
-	public function httpGet(RequestInterface $request, ResponseInterface $response) {
68
-
69
-		$queryParams = $request->getQueryParameters();
70
-		// TODO: in addition to photo we should also add logo some point in time
71
-		if (!array_key_exists('photo', $queryParams)) {
72
-			return true;
73
-		}
74
-
75
-		$size = isset($queryParams['size']) ? (int)$queryParams['size'] : -1;
76
-
77
-		$path = $request->getPath();
78
-		$node = $this->server->tree->getNodeForPath($path);
79
-
80
-		if (!($node instanceof Card)) {
81
-			return true;
82
-		}
83
-
84
-		$this->server->transactionType = 'carddav-image-export';
85
-
86
-		// Checking ACL, if available.
87
-		if ($aclPlugin = $this->server->getPlugin('acl')) {
88
-			/** @var \Sabre\DAVACL\Plugin $aclPlugin */
89
-			$aclPlugin->checkPrivileges($path, '{DAV:}read');
90
-		}
91
-
92
-		// Fetch addressbook
93
-		$addressbookpath = explode('/', $path);
94
-		array_pop($addressbookpath);
95
-		$addressbookpath = implode('/', $addressbookpath);
96
-		/** @var AddressBook $addressbook */
97
-		$addressbook = $this->server->tree->getNodeForPath($addressbookpath);
98
-
99
-		$response->setHeader('Cache-Control', 'private, max-age=3600, must-revalidate');
100
-		$response->setHeader('Etag', $node->getETag() );
101
-		$response->setHeader('Pragma', 'public');
102
-
103
-		try {
104
-			$file = $this->cache->get($addressbook->getResourceId(), $node->getName(), $size, $node);
105
-			$response->setHeader('Content-Type', $file->getMimeType());
106
-			$response->setHeader('Content-Disposition', 'attachment');
107
-			$response->setStatus(200);
108
-
109
-			$response->setBody($file->getContent());
110
-		} catch (NotFoundException $e) {
111
-			$response->setStatus(404);
112
-		}
113
-
114
-		return false;
115
-	}
35
+    /** @var Server */
36
+    protected $server;
37
+    /** @var PhotoCache */
38
+    private $cache;
39
+
40
+    /**
41
+     * ImageExportPlugin constructor.
42
+     *
43
+     * @param PhotoCache $cache
44
+     */
45
+    public function __construct(PhotoCache $cache) {
46
+        $this->cache = $cache;
47
+    }
48
+
49
+    /**
50
+     * Initializes the plugin and registers event handlers
51
+     *
52
+     * @param Server $server
53
+     * @return void
54
+     */
55
+    public function initialize(Server $server) {
56
+        $this->server = $server;
57
+        $this->server->on('method:GET', [$this, 'httpGet'], 90);
58
+    }
59
+
60
+    /**
61
+     * Intercepts GET requests on addressbook urls ending with ?photo.
62
+     *
63
+     * @param RequestInterface $request
64
+     * @param ResponseInterface $response
65
+     * @return bool
66
+     */
67
+    public function httpGet(RequestInterface $request, ResponseInterface $response) {
68
+
69
+        $queryParams = $request->getQueryParameters();
70
+        // TODO: in addition to photo we should also add logo some point in time
71
+        if (!array_key_exists('photo', $queryParams)) {
72
+            return true;
73
+        }
74
+
75
+        $size = isset($queryParams['size']) ? (int)$queryParams['size'] : -1;
76
+
77
+        $path = $request->getPath();
78
+        $node = $this->server->tree->getNodeForPath($path);
79
+
80
+        if (!($node instanceof Card)) {
81
+            return true;
82
+        }
83
+
84
+        $this->server->transactionType = 'carddav-image-export';
85
+
86
+        // Checking ACL, if available.
87
+        if ($aclPlugin = $this->server->getPlugin('acl')) {
88
+            /** @var \Sabre\DAVACL\Plugin $aclPlugin */
89
+            $aclPlugin->checkPrivileges($path, '{DAV:}read');
90
+        }
91
+
92
+        // Fetch addressbook
93
+        $addressbookpath = explode('/', $path);
94
+        array_pop($addressbookpath);
95
+        $addressbookpath = implode('/', $addressbookpath);
96
+        /** @var AddressBook $addressbook */
97
+        $addressbook = $this->server->tree->getNodeForPath($addressbookpath);
98
+
99
+        $response->setHeader('Cache-Control', 'private, max-age=3600, must-revalidate');
100
+        $response->setHeader('Etag', $node->getETag() );
101
+        $response->setHeader('Pragma', 'public');
102
+
103
+        try {
104
+            $file = $this->cache->get($addressbook->getResourceId(), $node->getName(), $size, $node);
105
+            $response->setHeader('Content-Type', $file->getMimeType());
106
+            $response->setHeader('Content-Disposition', 'attachment');
107
+            $response->setStatus(200);
108
+
109
+            $response->setBody($file->getContent());
110
+        } catch (NotFoundException $e) {
111
+            $response->setStatus(404);
112
+        }
113
+
114
+        return false;
115
+    }
116 116
 }
Please login to merge, or discard this patch.
core/templates/layout.guest.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
 									<?php p($theme->getName()); ?>
42 42
 								</h1>
43 43
 								<?php if(\OC::$server->getConfig()->getSystemValue('installed', false)
44
-									&& \OC::$server->getConfig()->getAppValue('theming', 'logoMime', false)): ?>
44
+                                    && \OC::$server->getConfig()->getAppValue('theming', 'logoMime', false)): ?>
45 45
 									<img src="<?php p($theme->getLogo()); ?>"/>
46 46
 								<?php endif; ?>
47 47
 							</div>
Please login to merge, or discard this patch.