Passed
Push — master ( 9348fd...7904dd )
by Roeland
11:27 queued 12s
created
lib/public/Diagnostics/IEventLogger.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -35,55 +35,55 @@
 block discarded – undo
35 35
  * @since 8.0.0
36 36
  */
37 37
 interface IEventLogger {
38
-	/**
39
-	 * Mark the start of an event setting its ID $id and providing event description $description.
40
-	 *
41
-	 * @param string $id
42
-	 * @param string $description
43
-	 * @since 8.0.0
44
-	 */
45
-	public function start($id, $description);
38
+    /**
39
+     * Mark the start of an event setting its ID $id and providing event description $description.
40
+     *
41
+     * @param string $id
42
+     * @param string $description
43
+     * @since 8.0.0
44
+     */
45
+    public function start($id, $description);
46 46
 
47
-	/**
48
-	 * Mark the end of an event with specific ID $id, marked by start() method.
49
-	 * Ending event should store \OCP\Diagnostics\IEvent to
50
-	 * be returned with getEvents() method.
51
-	 *
52
-	 * @param string $id
53
-	 * @since 8.0.0
54
-	 */
55
-	public function end($id);
47
+    /**
48
+     * Mark the end of an event with specific ID $id, marked by start() method.
49
+     * Ending event should store \OCP\Diagnostics\IEvent to
50
+     * be returned with getEvents() method.
51
+     *
52
+     * @param string $id
53
+     * @since 8.0.0
54
+     */
55
+    public function end($id);
56 56
 
57
-	/**
58
-	 * Mark the start and the end of an event with specific ID $id and description $description,
59
-	 * explicitly marking start and end of the event, represented by $start and $end timestamps.
60
-	 * Logging event should store \OCP\Diagnostics\IEvent to
61
-	 * be returned with getEvents() method.
62
-	 *
63
-	 * @param string $id
64
-	 * @param string $description
65
-	 * @param float $start
66
-	 * @param float $end
67
-	 * @since 8.0.0
68
-	 */
69
-	public function log($id, $description, $start, $end);
57
+    /**
58
+     * Mark the start and the end of an event with specific ID $id and description $description,
59
+     * explicitly marking start and end of the event, represented by $start and $end timestamps.
60
+     * Logging event should store \OCP\Diagnostics\IEvent to
61
+     * be returned with getEvents() method.
62
+     *
63
+     * @param string $id
64
+     * @param string $description
65
+     * @param float $start
66
+     * @param float $end
67
+     * @since 8.0.0
68
+     */
69
+    public function log($id, $description, $start, $end);
70 70
 
71
-	/**
72
-	 * This method should return all \OCP\Diagnostics\IEvent objects stored using
73
-	 * start()/end() or log() methods
74
-	 *
75
-	 * @return \OCP\Diagnostics\IEvent[]
76
-	 * @since 8.0.0
77
-	 */
78
-	public function getEvents();
71
+    /**
72
+     * This method should return all \OCP\Diagnostics\IEvent objects stored using
73
+     * start()/end() or log() methods
74
+     *
75
+     * @return \OCP\Diagnostics\IEvent[]
76
+     * @since 8.0.0
77
+     */
78
+    public function getEvents();
79 79
 
80
-	/**
81
-	 * Activate the module for the duration of the request. Deactivated module
82
-	 * does not create and store \OCP\Diagnostics\IEvent objects.
83
-	 * Only activated module should create and store objects to be
84
-	 * returned with getEvents() call.
85
-	 *
86
-	 * @since 12.0.0
87
-	 */
88
-	public function activate();
80
+    /**
81
+     * Activate the module for the duration of the request. Deactivated module
82
+     * does not create and store \OCP\Diagnostics\IEvent objects.
83
+     * Only activated module should create and store objects to be
84
+     * returned with getEvents() call.
85
+     *
86
+     * @since 12.0.0
87
+     */
88
+    public function activate();
89 89
 }
Please login to merge, or discard this patch.
lib/public/Diagnostics/IQuery.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -30,38 +30,38 @@
 block discarded – undo
30 30
  * @since 8.0.0
31 31
  */
32 32
 interface IQuery {
33
-	/**
34
-	 * @return string
35
-	 * @since 8.0.0
36
-	 */
37
-	public function getSql();
33
+    /**
34
+     * @return string
35
+     * @since 8.0.0
36
+     */
37
+    public function getSql();
38 38
 
39
-	/**
40
-	 * @return array
41
-	 * @since 8.0.0
42
-	 */
43
-	public function getParams();
39
+    /**
40
+     * @return array
41
+     * @since 8.0.0
42
+     */
43
+    public function getParams();
44 44
 
45
-	/**
46
-	 * @return float
47
-	 * @since 8.0.0
48
-	 */
49
-	public function getDuration();
45
+    /**
46
+     * @return float
47
+     * @since 8.0.0
48
+     */
49
+    public function getDuration();
50 50
 
51
-	/**
52
-	 * @return float
53
-	 * @since 11.0.0
54
-	 */
55
-	public function getStartTime();
51
+    /**
52
+     * @return float
53
+     * @since 11.0.0
54
+     */
55
+    public function getStartTime();
56 56
 
57
-	/**
58
-	 * @return array
59
-	 * @since 11.0.0
60
-	 */
61
-	public function getStacktrace();
62
-	/**
63
-	 * @return array
64
-	 * @since 12.0.0
65
-	 */
66
-	public function getStart();
57
+    /**
58
+     * @return array
59
+     * @since 11.0.0
60
+     */
61
+    public function getStacktrace();
62
+    /**
63
+     * @return array
64
+     * @since 12.0.0
65
+     */
66
+    public function getStart();
67 67
 }
Please login to merge, or discard this patch.
lib/private/Diagnostics/EventLogger.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -28,56 +28,56 @@
 block discarded – undo
28 28
 use OCP\Diagnostics\IEventLogger;
29 29
 
30 30
 class EventLogger implements IEventLogger {
31
-	/**
32
-	 * @var \OC\Diagnostics\Event[]
33
-	 */
34
-	private $events = [];
31
+    /**
32
+     * @var \OC\Diagnostics\Event[]
33
+     */
34
+    private $events = [];
35 35
 	
36
-	/**
37
-	 * @var bool - Module needs to be activated by some app
38
-	 */
39
-	private $activated = false;
36
+    /**
37
+     * @var bool - Module needs to be activated by some app
38
+     */
39
+    private $activated = false;
40 40
 
41
-	/**
42
-	 * @inheritdoc
43
-	 */
44
-	public function start($id, $description) {
45
-		if ($this->activated){
46
-			$this->events[$id] = new Event($id, $description, microtime(true));
47
-		}
48
-	}
41
+    /**
42
+     * @inheritdoc
43
+     */
44
+    public function start($id, $description) {
45
+        if ($this->activated){
46
+            $this->events[$id] = new Event($id, $description, microtime(true));
47
+        }
48
+    }
49 49
 
50
-	/**
51
-	 * @inheritdoc
52
-	 */
53
-	public function end($id) {
54
-		if ($this->activated && isset($this->events[$id])) {
55
-			$timing = $this->events[$id];
56
-			$timing->end(microtime(true));
57
-		}
58
-	}
50
+    /**
51
+     * @inheritdoc
52
+     */
53
+    public function end($id) {
54
+        if ($this->activated && isset($this->events[$id])) {
55
+            $timing = $this->events[$id];
56
+            $timing->end(microtime(true));
57
+        }
58
+    }
59 59
 
60
-	/**
61
-	 * @inheritdoc
62
-	 */
63
-	public function log($id, $description, $start, $end) {
64
-		if ($this->activated) {
65
-			$this->events[$id] = new Event($id, $description, $start);
66
-			$this->events[$id]->end($end);
67
-		}
68
-	}
60
+    /**
61
+     * @inheritdoc
62
+     */
63
+    public function log($id, $description, $start, $end) {
64
+        if ($this->activated) {
65
+            $this->events[$id] = new Event($id, $description, $start);
66
+            $this->events[$id]->end($end);
67
+        }
68
+    }
69 69
 
70
-	/**
71
-	 * @inheritdoc
72
-	 */
73
-	public function getEvents() {
74
-		return $this->events;
75
-	}
70
+    /**
71
+     * @inheritdoc
72
+     */
73
+    public function getEvents() {
74
+        return $this->events;
75
+    }
76 76
 	
77
-	/**
78
-	 * @inheritdoc
79
-	 */
80
-	public function activate() {
81
-		$this->activated = true;
82
-	}
77
+    /**
78
+     * @inheritdoc
79
+     */
80
+    public function activate() {
81
+        $this->activated = true;
82
+    }
83 83
 }
Please login to merge, or discard this patch.
lib/private/Diagnostics/Query.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -26,65 +26,65 @@
 block discarded – undo
26 26
 use OCP\Diagnostics\IQuery;
27 27
 
28 28
 class Query implements IQuery {
29
-	private $sql;
29
+    private $sql;
30 30
 
31
-	private $params;
31
+    private $params;
32 32
 
33
-	private $start;
33
+    private $start;
34 34
 
35
-	private $end;
35
+    private $end;
36 36
 
37
-	private $stack;
37
+    private $stack;
38 38
 
39
-	/**
40
-	 * @param string $sql
41
-	 * @param array $params
42
-	 * @param int $start
43
-	 */
44
-	public function __construct($sql, $params, $start, array $stack) {
45
-		$this->sql = $sql;
46
-		$this->params = $params;
47
-		$this->start = $start;
48
-		$this->stack = $stack;
49
-	}
39
+    /**
40
+     * @param string $sql
41
+     * @param array $params
42
+     * @param int $start
43
+     */
44
+    public function __construct($sql, $params, $start, array $stack) {
45
+        $this->sql = $sql;
46
+        $this->params = $params;
47
+        $this->start = $start;
48
+        $this->stack = $stack;
49
+    }
50 50
 
51
-	public function end($time) {
52
-		$this->end = $time;
53
-	}
51
+    public function end($time) {
52
+        $this->end = $time;
53
+    }
54 54
 
55
-	/**
56
-	 * @return array
57
-	 */
58
-	public function getParams() {
59
-		return $this->params;
60
-	}
55
+    /**
56
+     * @return array
57
+     */
58
+    public function getParams() {
59
+        return $this->params;
60
+    }
61 61
 
62
-	/**
63
-	 * @return string
64
-	 */
65
-	public function getSql() {
66
-		return $this->sql;
67
-	}
62
+    /**
63
+     * @return string
64
+     */
65
+    public function getSql() {
66
+        return $this->sql;
67
+    }
68 68
 
69
-	/**
70
-	 * @return float
71
-	 */
72
-	public function getStart() {
73
-		return $this->start;
74
-	}
69
+    /**
70
+     * @return float
71
+     */
72
+    public function getStart() {
73
+        return $this->start;
74
+    }
75 75
 	
76
-	/**
77
-	 * @return float
78
-	 */
79
-	public function getDuration() {
80
-		return $this->end - $this->start;
81
-	}
76
+    /**
77
+     * @return float
78
+     */
79
+    public function getDuration() {
80
+        return $this->end - $this->start;
81
+    }
82 82
 
83
-	public function getStartTime() {
84
-		return $this->start;
85
-	}
83
+    public function getStartTime() {
84
+        return $this->start;
85
+    }
86 86
 
87
-	public function getStacktrace() {
88
-		return $this->stack;
89
-	}
87
+    public function getStacktrace() {
88
+        return $this->stack;
89
+    }
90 90
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Config/ExternalMountPoint.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 use OC\Files\Mount\MountPoint;
25 25
 
26 26
 class ExternalMountPoint extends MountPoint {
27
-	public function getMountType() {
28
-		return 'external';
29
-	}
27
+    public function getMountType() {
28
+        return 'external';
29
+    }
30 30
 }
Please login to merge, or discard this patch.
lib/public/Files/Mount/IMountPoint.php 1 patch
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -29,103 +29,103 @@
 block discarded – undo
29 29
  */
30 30
 interface IMountPoint {
31 31
 
32
-	/**
33
-	 * get complete path to the mount point
34
-	 *
35
-	 * @return string
36
-	 * @since 8.0.0
37
-	 */
38
-	public function getMountPoint();
32
+    /**
33
+     * get complete path to the mount point
34
+     *
35
+     * @return string
36
+     * @since 8.0.0
37
+     */
38
+    public function getMountPoint();
39 39
 
40
-	/**
41
-	 * Set the mountpoint
42
-	 *
43
-	 * @param string $mountPoint new mount point
44
-	 * @since 8.0.0
45
-	 */
46
-	public function setMountPoint($mountPoint);
40
+    /**
41
+     * Set the mountpoint
42
+     *
43
+     * @param string $mountPoint new mount point
44
+     * @since 8.0.0
45
+     */
46
+    public function setMountPoint($mountPoint);
47 47
 
48
-	/**
49
-	 * Get the storage that is mounted
50
-	 *
51
-	 * @return \OC\Files\Storage\Storage
52
-	 * @since 8.0.0
53
-	 */
54
-	public function getStorage();
48
+    /**
49
+     * Get the storage that is mounted
50
+     *
51
+     * @return \OC\Files\Storage\Storage
52
+     * @since 8.0.0
53
+     */
54
+    public function getStorage();
55 55
 
56
-	/**
57
-	 * Get the id of the storages
58
-	 *
59
-	 * @return string
60
-	 * @since 8.0.0
61
-	 */
62
-	public function getStorageId();
56
+    /**
57
+     * Get the id of the storages
58
+     *
59
+     * @return string
60
+     * @since 8.0.0
61
+     */
62
+    public function getStorageId();
63 63
 
64
-	/**
65
-	 * Get the id of the storages
66
-	 *
67
-	 * @return int
68
-	 * @since 9.1.0
69
-	 */
70
-	public function getNumericStorageId();
64
+    /**
65
+     * Get the id of the storages
66
+     *
67
+     * @return int
68
+     * @since 9.1.0
69
+     */
70
+    public function getNumericStorageId();
71 71
 
72
-	/**
73
-	 * Get the path relative to the mountpoint
74
-	 *
75
-	 * @param string $path absolute path to a file or folder
76
-	 * @return string
77
-	 * @since 8.0.0
78
-	 */
79
-	public function getInternalPath($path);
72
+    /**
73
+     * Get the path relative to the mountpoint
74
+     *
75
+     * @param string $path absolute path to a file or folder
76
+     * @return string
77
+     * @since 8.0.0
78
+     */
79
+    public function getInternalPath($path);
80 80
 
81
-	/**
82
-	 * Apply a storage wrapper to the mounted storage
83
-	 *
84
-	 * @param callable $wrapper
85
-	 * @since 8.0.0
86
-	 */
87
-	public function wrapStorage($wrapper);
81
+    /**
82
+     * Apply a storage wrapper to the mounted storage
83
+     *
84
+     * @param callable $wrapper
85
+     * @since 8.0.0
86
+     */
87
+    public function wrapStorage($wrapper);
88 88
 
89
-	/**
90
-	 * Get a mount option
91
-	 *
92
-	 * @param string $name Name of the mount option to get
93
-	 * @param mixed $default Default value for the mount option
94
-	 * @return mixed
95
-	 * @since 8.0.0
96
-	 */
97
-	public function getOption($name, $default);
89
+    /**
90
+     * Get a mount option
91
+     *
92
+     * @param string $name Name of the mount option to get
93
+     * @param mixed $default Default value for the mount option
94
+     * @return mixed
95
+     * @since 8.0.0
96
+     */
97
+    public function getOption($name, $default);
98 98
 
99
-	/**
100
-	 * Get all options for the mount
101
-	 *
102
-	 * @return array
103
-	 * @since 8.1.0
104
-	 */
105
-	public function getOptions();
99
+    /**
100
+     * Get all options for the mount
101
+     *
102
+     * @return array
103
+     * @since 8.1.0
104
+     */
105
+    public function getOptions();
106 106
 
107
-	/**
108
-	 * Get the file id of the root of the storage
109
-	 *
110
-	 * @return int
111
-	 * @since 9.1.0
112
-	 */
113
-	public function getStorageRootId();
107
+    /**
108
+     * Get the file id of the root of the storage
109
+     *
110
+     * @return int
111
+     * @since 9.1.0
112
+     */
113
+    public function getStorageRootId();
114 114
 
115
-	/**
116
-	 * Get the id of the configured mount
117
-	 *
118
-	 * @return int|null mount id or null if not applicable
119
-	 * @since 9.1.0
120
-	 */
121
-	public function getMountId();
115
+    /**
116
+     * Get the id of the configured mount
117
+     *
118
+     * @return int|null mount id or null if not applicable
119
+     * @since 9.1.0
120
+     */
121
+    public function getMountId();
122 122
 
123
-	/**
124
-	 * Get the type of mount point, used to distinguish things like shares and external storages
125
-	 * in the web interface
126
-	 *
127
-	 * @return string
128
-	 * @since 12.0.0
129
-	 */
130
-	public function getMountType();
123
+    /**
124
+     * Get the type of mount point, used to distinguish things like shares and external storages
125
+     * in the web interface
126
+     *
127
+     * @return string
128
+     * @since 12.0.0
129
+     */
130
+    public function getMountType();
131 131
 }
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.
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.