Passed
Push — master ( a47403...b46612 )
by Jan-Christoph
11:53
created
apps/workflowengine/lib/Check/AbstractStringCheck.php 1 patch
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -28,94 +28,94 @@
 block discarded – undo
28 28
 
29 29
 abstract class AbstractStringCheck implements ICheck {
30 30
 
31
-	/** @var array[] Nested array: [Pattern => [ActualValue => Regex Result]] */
32
-	protected $matches;
31
+    /** @var array[] Nested array: [Pattern => [ActualValue => Regex Result]] */
32
+    protected $matches;
33 33
 
34
-	/** @var IL10N */
35
-	protected $l;
34
+    /** @var IL10N */
35
+    protected $l;
36 36
 
37
-	/**
38
-	 * @param IL10N $l
39
-	 */
40
-	public function __construct(IL10N $l) {
41
-		$this->l = $l;
42
-	}
37
+    /**
38
+     * @param IL10N $l
39
+     */
40
+    public function __construct(IL10N $l) {
41
+        $this->l = $l;
42
+    }
43 43
 
44
-	/**
45
-	 * @param IStorage $storage
46
-	 * @param string $path
47
-	 */
48
-	public function setFileInfo(IStorage $storage, $path) {
49
-		// Nothing changes here with a different path
50
-	}
44
+    /**
45
+     * @param IStorage $storage
46
+     * @param string $path
47
+     */
48
+    public function setFileInfo(IStorage $storage, $path) {
49
+        // Nothing changes here with a different path
50
+    }
51 51
 
52
-	/**
53
-	 * @return string
54
-	 */
55
-	abstract protected function getActualValue();
52
+    /**
53
+     * @return string
54
+     */
55
+    abstract protected function getActualValue();
56 56
 
57
-	/**
58
-	 * @param string $operator
59
-	 * @param string $value
60
-	 * @return bool
61
-	 */
62
-	public function executeCheck($operator, $value)  {
63
-		$actualValue = $this->getActualValue();
64
-		return $this->executeStringCheck($operator, $value, $actualValue);
65
-	}
57
+    /**
58
+     * @param string $operator
59
+     * @param string $value
60
+     * @return bool
61
+     */
62
+    public function executeCheck($operator, $value)  {
63
+        $actualValue = $this->getActualValue();
64
+        return $this->executeStringCheck($operator, $value, $actualValue);
65
+    }
66 66
 
67
-	/**
68
-	 * @param string $operator
69
-	 * @param string $checkValue
70
-	 * @param string $actualValue
71
-	 * @return bool
72
-	 */
73
-	protected function executeStringCheck($operator, $checkValue, $actualValue) {
74
-		if ($operator === 'is') {
75
-			return $checkValue === $actualValue;
76
-		} else if ($operator === '!is') {
77
-			return $checkValue !== $actualValue;
78
-		} else {
79
-			$match = $this->match($checkValue, $actualValue);
80
-			if ($operator === 'matches') {
81
-				return $match === 1;
82
-			} else {
83
-				return $match === 0;
84
-			}
85
-		}
86
-	}
67
+    /**
68
+     * @param string $operator
69
+     * @param string $checkValue
70
+     * @param string $actualValue
71
+     * @return bool
72
+     */
73
+    protected function executeStringCheck($operator, $checkValue, $actualValue) {
74
+        if ($operator === 'is') {
75
+            return $checkValue === $actualValue;
76
+        } else if ($operator === '!is') {
77
+            return $checkValue !== $actualValue;
78
+        } else {
79
+            $match = $this->match($checkValue, $actualValue);
80
+            if ($operator === 'matches') {
81
+                return $match === 1;
82
+            } else {
83
+                return $match === 0;
84
+            }
85
+        }
86
+    }
87 87
 
88
-	/**
89
-	 * @param string $operator
90
-	 * @param string $value
91
-	 * @throws \UnexpectedValueException
92
-	 */
93
-	public function validateCheck($operator, $value) {
94
-		if (!in_array($operator, ['is', '!is', 'matches', '!matches'])) {
95
-			throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1);
96
-		}
88
+    /**
89
+     * @param string $operator
90
+     * @param string $value
91
+     * @throws \UnexpectedValueException
92
+     */
93
+    public function validateCheck($operator, $value) {
94
+        if (!in_array($operator, ['is', '!is', 'matches', '!matches'])) {
95
+            throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1);
96
+        }
97 97
 
98
-		if (in_array($operator, ['matches', '!matches']) &&
99
-			  @preg_match($value, null) === false) {
100
-			throw new \UnexpectedValueException($this->l->t('The given regular expression is invalid'), 2);
101
-		}
102
-	}
98
+        if (in_array($operator, ['matches', '!matches']) &&
99
+              @preg_match($value, null) === false) {
100
+            throw new \UnexpectedValueException($this->l->t('The given regular expression is invalid'), 2);
101
+        }
102
+    }
103 103
 
104
-	/**
105
-	 * @param string $pattern
106
-	 * @param string $subject
107
-	 * @return int|bool
108
-	 */
109
-	protected function match($pattern, $subject) {
110
-		$patternHash = md5($pattern);
111
-		$subjectHash = md5($subject);
112
-		if (isset($this->matches[$patternHash][$subjectHash])) {
113
-			return $this->matches[$patternHash][$subjectHash];
114
-		}
115
-		if (!isset($this->matches[$patternHash])) {
116
-			$this->matches[$patternHash] = [];
117
-		}
118
-		$this->matches[$patternHash][$subjectHash] = preg_match($pattern, $subject);
119
-		return $this->matches[$patternHash][$subjectHash];
120
-	}
104
+    /**
105
+     * @param string $pattern
106
+     * @param string $subject
107
+     * @return int|bool
108
+     */
109
+    protected function match($pattern, $subject) {
110
+        $patternHash = md5($pattern);
111
+        $subjectHash = md5($subject);
112
+        if (isset($this->matches[$patternHash][$subjectHash])) {
113
+            return $this->matches[$patternHash][$subjectHash];
114
+        }
115
+        if (!isset($this->matches[$patternHash])) {
116
+            $this->matches[$patternHash] = [];
117
+        }
118
+        $this->matches[$patternHash][$subjectHash] = preg_match($pattern, $subject);
119
+        return $this->matches[$patternHash][$subjectHash];
120
+    }
121 121
 }
Please login to merge, or discard this patch.
apps/workflowengine/lib/Check/RequestTime.php 1 patch
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -29,101 +29,101 @@
 block discarded – undo
29 29
 
30 30
 class RequestTime implements ICheck {
31 31
 
32
-	const REGEX_TIME = '([0-1][0-9]|2[0-3]):([0-5][0-9])';
33
-	const REGEX_TIMEZONE = '([a-zA-Z]+(?:\\/[a-zA-Z\-\_]+)+)';
34
-
35
-	/** @var bool[] */
36
-	protected $cachedResults;
37
-
38
-	/** @var IL10N */
39
-	protected $l;
40
-
41
-	/** @var ITimeFactory */
42
-	protected $timeFactory;
43
-
44
-	/**
45
-	 * @param ITimeFactory $timeFactory
46
-	 */
47
-	public function __construct(IL10N $l, ITimeFactory $timeFactory) {
48
-		$this->l = $l;
49
-		$this->timeFactory = $timeFactory;
50
-	}
51
-
52
-	/**
53
-	 * @param IStorage $storage
54
-	 * @param string $path
55
-	 */
56
-	public function setFileInfo(IStorage $storage, $path) {
57
-		// A different path doesn't change time, so nothing to do here.
58
-	}
59
-
60
-	/**
61
-	 * @param string $operator
62
-	 * @param string $value
63
-	 * @return bool
64
-	 */
65
-	public function executeCheck($operator, $value) {
66
-		$valueHash = md5($value);
67
-
68
-		if (isset($this->cachedResults[$valueHash])) {
69
-			return $this->cachedResults[$valueHash];
70
-		}
71
-
72
-		$timestamp = $this->timeFactory->getTime();
73
-
74
-		$values = json_decode($value, true);
75
-		$timestamp1 = $this->getTimestamp($timestamp, $values[0]);
76
-		$timestamp2 = $this->getTimestamp($timestamp, $values[1]);
77
-
78
-		if ($timestamp1 < $timestamp2) {
79
-			$in = $timestamp1 <= $timestamp && $timestamp <= $timestamp2;
80
-		} else {
81
-			$in = $timestamp1 <= $timestamp || $timestamp <= $timestamp2;
82
-		}
83
-
84
-		return ($operator === 'in') ? $in : !$in;
85
-	}
86
-
87
-	/**
88
-	 * @param int $currentTimestamp
89
-	 * @param string $value Format: "H:i e"
90
-	 * @return int
91
-	 */
92
-	protected function getTimestamp($currentTimestamp, $value) {
93
-		list($time1, $timezone1) = explode(' ', $value);
94
-		list($hour1, $minute1) = explode(':', $time1);
95
-		$date1 = new \DateTime('now', new \DateTimeZone($timezone1));
96
-		$date1->setTimestamp($currentTimestamp);
97
-		$date1->setTime($hour1, $minute1);
98
-
99
-		return $date1->getTimestamp();
100
-	}
101
-
102
-	/**
103
-	 * @param string $operator
104
-	 * @param string $value
105
-	 * @throws \UnexpectedValueException
106
-	 */
107
-	public function validateCheck($operator, $value) {
108
-		if (!in_array($operator, ['in', '!in'])) {
109
-			throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1);
110
-		}
111
-
112
-		$regexValue = '\"' . self::REGEX_TIME . ' ' . self::REGEX_TIMEZONE . '\"';
113
-		$result = preg_match('/^\[' . $regexValue . ',' . $regexValue . '\]$/', $value, $matches);
114
-		if (!$result) {
115
-			throw new \UnexpectedValueException($this->l->t('The given time span is invalid'), 2);
116
-		}
117
-
118
-		$values = json_decode($value, true);
119
-		$time1 = \DateTime::createFromFormat('H:i e', $values[0]);
120
-		if ($time1 === false) {
121
-			throw new \UnexpectedValueException($this->l->t('The given start time is invalid'), 3);
122
-		}
123
-
124
-		$time2 = \DateTime::createFromFormat('H:i e', $values[1]);
125
-		if ($time2 === false) {
126
-			throw new \UnexpectedValueException($this->l->t('The given end time is invalid'), 4);
127
-		}
128
-	}
32
+    const REGEX_TIME = '([0-1][0-9]|2[0-3]):([0-5][0-9])';
33
+    const REGEX_TIMEZONE = '([a-zA-Z]+(?:\\/[a-zA-Z\-\_]+)+)';
34
+
35
+    /** @var bool[] */
36
+    protected $cachedResults;
37
+
38
+    /** @var IL10N */
39
+    protected $l;
40
+
41
+    /** @var ITimeFactory */
42
+    protected $timeFactory;
43
+
44
+    /**
45
+     * @param ITimeFactory $timeFactory
46
+     */
47
+    public function __construct(IL10N $l, ITimeFactory $timeFactory) {
48
+        $this->l = $l;
49
+        $this->timeFactory = $timeFactory;
50
+    }
51
+
52
+    /**
53
+     * @param IStorage $storage
54
+     * @param string $path
55
+     */
56
+    public function setFileInfo(IStorage $storage, $path) {
57
+        // A different path doesn't change time, so nothing to do here.
58
+    }
59
+
60
+    /**
61
+     * @param string $operator
62
+     * @param string $value
63
+     * @return bool
64
+     */
65
+    public function executeCheck($operator, $value) {
66
+        $valueHash = md5($value);
67
+
68
+        if (isset($this->cachedResults[$valueHash])) {
69
+            return $this->cachedResults[$valueHash];
70
+        }
71
+
72
+        $timestamp = $this->timeFactory->getTime();
73
+
74
+        $values = json_decode($value, true);
75
+        $timestamp1 = $this->getTimestamp($timestamp, $values[0]);
76
+        $timestamp2 = $this->getTimestamp($timestamp, $values[1]);
77
+
78
+        if ($timestamp1 < $timestamp2) {
79
+            $in = $timestamp1 <= $timestamp && $timestamp <= $timestamp2;
80
+        } else {
81
+            $in = $timestamp1 <= $timestamp || $timestamp <= $timestamp2;
82
+        }
83
+
84
+        return ($operator === 'in') ? $in : !$in;
85
+    }
86
+
87
+    /**
88
+     * @param int $currentTimestamp
89
+     * @param string $value Format: "H:i e"
90
+     * @return int
91
+     */
92
+    protected function getTimestamp($currentTimestamp, $value) {
93
+        list($time1, $timezone1) = explode(' ', $value);
94
+        list($hour1, $minute1) = explode(':', $time1);
95
+        $date1 = new \DateTime('now', new \DateTimeZone($timezone1));
96
+        $date1->setTimestamp($currentTimestamp);
97
+        $date1->setTime($hour1, $minute1);
98
+
99
+        return $date1->getTimestamp();
100
+    }
101
+
102
+    /**
103
+     * @param string $operator
104
+     * @param string $value
105
+     * @throws \UnexpectedValueException
106
+     */
107
+    public function validateCheck($operator, $value) {
108
+        if (!in_array($operator, ['in', '!in'])) {
109
+            throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1);
110
+        }
111
+
112
+        $regexValue = '\"' . self::REGEX_TIME . ' ' . self::REGEX_TIMEZONE . '\"';
113
+        $result = preg_match('/^\[' . $regexValue . ',' . $regexValue . '\]$/', $value, $matches);
114
+        if (!$result) {
115
+            throw new \UnexpectedValueException($this->l->t('The given time span is invalid'), 2);
116
+        }
117
+
118
+        $values = json_decode($value, true);
119
+        $time1 = \DateTime::createFromFormat('H:i e', $values[0]);
120
+        if ($time1 === false) {
121
+            throw new \UnexpectedValueException($this->l->t('The given start time is invalid'), 3);
122
+        }
123
+
124
+        $time2 = \DateTime::createFromFormat('H:i e', $values[1]);
125
+        if ($time2 === false) {
126
+            throw new \UnexpectedValueException($this->l->t('The given end time is invalid'), 4);
127
+        }
128
+    }
129 129
 }
Please login to merge, or discard this patch.
apps/workflowengine/lib/Check/UserGroupMembership.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -31,84 +31,84 @@
 block discarded – undo
31 31
 
32 32
 class UserGroupMembership implements ICheck {
33 33
 
34
-	/** @var string */
35
-	protected $cachedUser;
36
-
37
-	/** @var string[] */
38
-	protected $cachedGroupMemberships;
39
-
40
-	/** @var IUserSession */
41
-	protected $userSession;
42
-
43
-	/** @var IGroupManager */
44
-	protected $groupManager;
45
-
46
-	/** @var IL10N */
47
-	protected $l;
48
-
49
-	/**
50
-	 * @param IUserSession $userSession
51
-	 * @param IGroupManager $groupManager
52
-	 * @param IL10N $l
53
-	 */
54
-	public function __construct(IUserSession $userSession, IGroupManager $groupManager, IL10N $l) {
55
-		$this->userSession = $userSession;
56
-		$this->groupManager = $groupManager;
57
-		$this->l = $l;
58
-	}
59
-
60
-	/**
61
-	 * @param IStorage $storage
62
-	 * @param string $path
63
-	 */
64
-	public function setFileInfo(IStorage $storage, $path) {
65
-		// A different path doesn't change group memberships, so nothing to do here.
66
-	}
67
-
68
-	/**
69
-	 * @param string $operator
70
-	 * @param string $value
71
-	 * @return bool
72
-	 */
73
-	public function executeCheck($operator, $value) {
74
-		$user = $this->userSession->getUser();
75
-
76
-		if ($user instanceof IUser) {
77
-			$groupIds = $this->getUserGroups($user);
78
-			return ($operator === 'is') === in_array($value, $groupIds);
79
-		} else {
80
-			return $operator !== 'is';
81
-		}
82
-	}
83
-
84
-
85
-	/**
86
-	 * @param string $operator
87
-	 * @param string $value
88
-	 * @throws \UnexpectedValueException
89
-	 */
90
-	public function validateCheck($operator, $value) {
91
-		if (!in_array($operator, ['is', '!is'])) {
92
-			throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1);
93
-		}
94
-
95
-		if (!$this->groupManager->groupExists($value)) {
96
-			throw new \UnexpectedValueException($this->l->t('The given group does not exist'), 2);
97
-		}
98
-	}
99
-
100
-	/**
101
-	 * @param IUser $user
102
-	 * @return string[]
103
-	 */
104
-	protected function getUserGroups(IUser $user) {
105
-		$uid = $user->getUID();
106
-
107
-		if ($this->cachedUser !== $uid) {
108
-			$this->cachedUser = $uid;
109
-			$this->cachedGroupMemberships = $this->groupManager->getUserGroupIds($user);
110
-		}
111
-
112
-		return $this->cachedGroupMemberships;
113
-	}
34
+    /** @var string */
35
+    protected $cachedUser;
36
+
37
+    /** @var string[] */
38
+    protected $cachedGroupMemberships;
39
+
40
+    /** @var IUserSession */
41
+    protected $userSession;
42
+
43
+    /** @var IGroupManager */
44
+    protected $groupManager;
45
+
46
+    /** @var IL10N */
47
+    protected $l;
48
+
49
+    /**
50
+     * @param IUserSession $userSession
51
+     * @param IGroupManager $groupManager
52
+     * @param IL10N $l
53
+     */
54
+    public function __construct(IUserSession $userSession, IGroupManager $groupManager, IL10N $l) {
55
+        $this->userSession = $userSession;
56
+        $this->groupManager = $groupManager;
57
+        $this->l = $l;
58
+    }
59
+
60
+    /**
61
+     * @param IStorage $storage
62
+     * @param string $path
63
+     */
64
+    public function setFileInfo(IStorage $storage, $path) {
65
+        // A different path doesn't change group memberships, so nothing to do here.
66
+    }
67
+
68
+    /**
69
+     * @param string $operator
70
+     * @param string $value
71
+     * @return bool
72
+     */
73
+    public function executeCheck($operator, $value) {
74
+        $user = $this->userSession->getUser();
75
+
76
+        if ($user instanceof IUser) {
77
+            $groupIds = $this->getUserGroups($user);
78
+            return ($operator === 'is') === in_array($value, $groupIds);
79
+        } else {
80
+            return $operator !== 'is';
81
+        }
82
+    }
83
+
84
+
85
+    /**
86
+     * @param string $operator
87
+     * @param string $value
88
+     * @throws \UnexpectedValueException
89
+     */
90
+    public function validateCheck($operator, $value) {
91
+        if (!in_array($operator, ['is', '!is'])) {
92
+            throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1);
93
+        }
94
+
95
+        if (!$this->groupManager->groupExists($value)) {
96
+            throw new \UnexpectedValueException($this->l->t('The given group does not exist'), 2);
97
+        }
98
+    }
99
+
100
+    /**
101
+     * @param IUser $user
102
+     * @return string[]
103
+     */
104
+    protected function getUserGroups(IUser $user) {
105
+        $uid = $user->getUID();
106
+
107
+        if ($this->cachedUser !== $uid) {
108
+            $this->cachedUser = $uid;
109
+            $this->cachedGroupMemberships = $this->groupManager->getUserGroupIds($user);
110
+        }
111
+
112
+        return $this->cachedGroupMemberships;
113
+    }
114 114
 }
Please login to merge, or discard this patch.
apps/workflowengine/lib/Check/RequestURL.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -27,66 +27,66 @@
 block discarded – undo
27 27
 
28 28
 class RequestURL extends AbstractStringCheck {
29 29
 
30
-	/** @var string */
31
-	protected $url;
30
+    /** @var string */
31
+    protected $url;
32 32
 
33
-	/** @var IRequest */
34
-	protected $request;
33
+    /** @var IRequest */
34
+    protected $request;
35 35
 
36
-	/**
37
-	 * @param IL10N $l
38
-	 * @param IRequest $request
39
-	 */
40
-	public function __construct(IL10N $l, IRequest $request) {
41
-		parent::__construct($l);
42
-		$this->request = $request;
43
-	}
36
+    /**
37
+     * @param IL10N $l
38
+     * @param IRequest $request
39
+     */
40
+    public function __construct(IL10N $l, IRequest $request) {
41
+        parent::__construct($l);
42
+        $this->request = $request;
43
+    }
44 44
 
45
-	/**
46
-	 * @param string $operator
47
-	 * @param string $value
48
-	 * @return bool
49
-	 */
50
-	public function executeCheck($operator, $value)  {
51
-		$actualValue = $this->getActualValue();
52
-		if (in_array($operator, ['is', '!is'])) {
53
-			switch ($value) {
54
-				case 'webdav':
55
-					if ($operator === 'is') {
56
-						return $this->isWebDAVRequest();
57
-					} else {
58
-						return !$this->isWebDAVRequest();
59
-					}
60
-			}
61
-		}
62
-		return $this->executeStringCheck($operator, $value, $actualValue);
63
-	}
45
+    /**
46
+     * @param string $operator
47
+     * @param string $value
48
+     * @return bool
49
+     */
50
+    public function executeCheck($operator, $value)  {
51
+        $actualValue = $this->getActualValue();
52
+        if (in_array($operator, ['is', '!is'])) {
53
+            switch ($value) {
54
+                case 'webdav':
55
+                    if ($operator === 'is') {
56
+                        return $this->isWebDAVRequest();
57
+                    } else {
58
+                        return !$this->isWebDAVRequest();
59
+                    }
60
+            }
61
+        }
62
+        return $this->executeStringCheck($operator, $value, $actualValue);
63
+    }
64 64
 
65
-	/**
66
-	 * @return string
67
-	 */
68
-	protected function getActualValue() {
69
-		if ($this->url !== null) {
70
-			return $this->url;
71
-		}
65
+    /**
66
+     * @return string
67
+     */
68
+    protected function getActualValue() {
69
+        if ($this->url !== null) {
70
+            return $this->url;
71
+        }
72 72
 
73
-		$this->url = $this->request->getServerProtocol() . '://';// E.g. http(s) + ://
74
-		$this->url .= $this->request->getServerHost();// E.g. localhost
75
-		$this->url .= $this->request->getScriptName();// E.g. /nextcloud/index.php
76
-		$this->url .= $this->request->getPathInfo();// E.g. /apps/files_texteditor/ajax/loadfile
73
+        $this->url = $this->request->getServerProtocol() . '://';// E.g. http(s) + ://
74
+        $this->url .= $this->request->getServerHost();// E.g. localhost
75
+        $this->url .= $this->request->getScriptName();// E.g. /nextcloud/index.php
76
+        $this->url .= $this->request->getPathInfo();// E.g. /apps/files_texteditor/ajax/loadfile
77 77
 
78
-		return $this->url; // E.g. https://localhost/nextcloud/index.php/apps/files_texteditor/ajax/loadfile
79
-	}
78
+        return $this->url; // E.g. https://localhost/nextcloud/index.php/apps/files_texteditor/ajax/loadfile
79
+    }
80 80
 
81
-	/**
82
-	 * @return bool
83
-	 */
84
-	protected function isWebDAVRequest() {
85
-		return substr($this->request->getScriptName(), 0 - strlen('/remote.php')) === '/remote.php' && (
86
-			$this->request->getPathInfo() === '/webdav' ||
87
-			strpos($this->request->getPathInfo(), '/webdav/') === 0 ||
88
-			$this->request->getPathInfo() === '/dav/files' ||
89
-			strpos($this->request->getPathInfo(), '/dav/files/') === 0
90
-		);
91
-	}
81
+    /**
82
+     * @return bool
83
+     */
84
+    protected function isWebDAVRequest() {
85
+        return substr($this->request->getScriptName(), 0 - strlen('/remote.php')) === '/remote.php' && (
86
+            $this->request->getPathInfo() === '/webdav' ||
87
+            strpos($this->request->getPathInfo(), '/webdav/') === 0 ||
88
+            $this->request->getPathInfo() === '/dav/files' ||
89
+            strpos($this->request->getPathInfo(), '/dav/files/') === 0
90
+        );
91
+    }
92 92
 }
Please login to merge, or discard this patch.
apps/workflowengine/appinfo/routes.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -20,11 +20,11 @@
 block discarded – undo
20 20
  */
21 21
 
22 22
 return [
23
-	'routes' => [
24
-		['name' => 'flowOperations#getOperations', 'url' => '/operations', 'verb' => 'GET'],
25
-		['name' => 'flowOperations#addOperation', 'url' => '/operations', 'verb' => 'POST'],
26
-		['name' => 'flowOperations#updateOperation', 'url' => '/operations/{id}', 'verb' => 'PUT'],
27
-		['name' => 'flowOperations#deleteOperation', 'url' => '/operations/{id}', 'verb' => 'DELETE'],
28
-		['name' => 'requestTime#getTimezones', 'url' => '/timezones', 'verb' => 'GET'],
29
-	]
23
+    'routes' => [
24
+        ['name' => 'flowOperations#getOperations', 'url' => '/operations', 'verb' => 'GET'],
25
+        ['name' => 'flowOperations#addOperation', 'url' => '/operations', 'verb' => 'POST'],
26
+        ['name' => 'flowOperations#updateOperation', 'url' => '/operations/{id}', 'verb' => 'PUT'],
27
+        ['name' => 'flowOperations#deleteOperation', 'url' => '/operations/{id}', 'verb' => 'DELETE'],
28
+        ['name' => 'requestTime#getTimezones', 'url' => '/timezones', 'verb' => 'GET'],
29
+    ]
30 30
 ];
Please login to merge, or discard this patch.
apps/testing/lib/AlternativeHomeUserBackend.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -34,23 +34,23 @@
 block discarded – undo
34 34
  *	]
35 35
  */
36 36
 class AlternativeHomeUserBackend extends \OC\User\Database {
37
-	public function __construct() {
38
-		parent::__construct();
39
-	}
40
-	/**
41
-	 * get the user's home directory
42
-	 * @param string $uid the username
43
-	 * @return string|false
44
-	 */
45
-	public function getHome($uid) {
46
-		if ($this->userExists($uid)) {
47
-			// workaround to avoid killing the admin
48
-			if ($uid !== 'admin') {
49
-				$uid = md5($uid);
50
-			}
51
-			return \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/' . $uid;
52
-		}
37
+    public function __construct() {
38
+        parent::__construct();
39
+    }
40
+    /**
41
+     * get the user's home directory
42
+     * @param string $uid the username
43
+     * @return string|false
44
+     */
45
+    public function getHome($uid) {
46
+        if ($this->userExists($uid)) {
47
+            // workaround to avoid killing the admin
48
+            if ($uid !== 'admin') {
49
+                $uid = md5($uid);
50
+            }
51
+            return \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/' . $uid;
52
+        }
53 53
 
54
-		return false;
55
-	}
54
+        return false;
55
+    }
56 56
 }
Please login to merge, or discard this patch.
apps/federatedfilesharing/lib/Notifier.php 1 patch
Indentation   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -34,197 +34,197 @@
 block discarded – undo
34 34
 use OCP\Notification\INotifier;
35 35
 
36 36
 class Notifier implements INotifier {
37
-	/** @var IFactory */
38
-	protected $factory;
39
-	/** @var IManager */
40
-	protected $contactsManager;
41
-	/** @var IURLGenerator */
42
-	protected $url;
43
-	/** @var array */
44
-	protected $federatedContacts;
45
-	/** @var ICloudIdManager */
46
-	protected $cloudIdManager;
47
-
48
-	/**
49
-	 * @param IFactory $factory
50
-	 * @param IManager $contactsManager
51
-	 * @param IURLGenerator $url
52
-	 * @param ICloudIdManager $cloudIdManager
53
-	 */
54
-	public function __construct(IFactory $factory, IManager $contactsManager, IURLGenerator $url, ICloudIdManager $cloudIdManager) {
55
-		$this->factory = $factory;
56
-		$this->contactsManager = $contactsManager;
57
-		$this->url = $url;
58
-		$this->cloudIdManager = $cloudIdManager;
59
-	}
60
-
61
-	/**
62
-	 * @param INotification $notification
63
-	 * @param string $languageCode The code of the language that should be used to prepare the notification
64
-	 * @return INotification
65
-	 * @throws \InvalidArgumentException
66
-	 */
67
-	public function prepare(INotification $notification, $languageCode) {
68
-		if ($notification->getApp() !== 'files_sharing') {
69
-			// Not my app => throw
70
-			throw new \InvalidArgumentException();
71
-		}
72
-
73
-		// Read the language from the notification
74
-		$l = $this->factory->get('files_sharing', $languageCode);
75
-
76
-		switch ($notification->getSubject()) {
77
-			// Deal with known subjects
78
-			case 'remote_share':
79
-				$notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
80
-
81
-				$params = $notification->getSubjectParameters();
82
-				if ($params[0] !== $params[1] && $params[1] !== null) {
83
-					$notification->setParsedSubject(
84
-						$l->t('You received "%3$s" as a remote share from %1$s (on behalf of %2$s)', $params)
85
-					);
86
-					$notification->setRichSubject(
87
-						$l->t('You received {share} as a remote share from {user} (on behalf of {behalf})'),
88
-						[
89
-							'share' => [
90
-								'type' => 'pending-federated-share',
91
-								'id' => $notification->getObjectId(),
92
-								'name' => $params[2],
93
-							],
94
-							'user' => $this->createRemoteUser($params[0]),
95
-							'behalf' => $this->createRemoteUser($params[1]),
96
-						]
97
-					);
98
-				} else {
99
-					$notification->setParsedSubject(
100
-						$l->t('You received "%3$s" as a remote share from %1$s', $params)
101
-					);
102
-					$notification->setRichSubject(
103
-						$l->t('You received {share} as a remote share from {user}'),
104
-						[
105
-							'share' => [
106
-								'type' => 'pending-federated-share',
107
-								'id' => $notification->getObjectId(),
108
-								'name' => $params[2],
109
-							],
110
-							'user' => $this->createRemoteUser($params[0]),
111
-						]
112
-					);
113
-				}
114
-
115
-				// Deal with the actions for a known subject
116
-				foreach ($notification->getActions() as $action) {
117
-					switch ($action->getLabel()) {
118
-						case 'accept':
119
-							$action->setParsedLabel(
120
-								(string) $l->t('Accept')
121
-							)
122
-							->setPrimary(true);
123
-							break;
124
-
125
-						case 'decline':
126
-							$action->setParsedLabel(
127
-								(string) $l->t('Decline')
128
-							);
129
-							break;
130
-					}
131
-
132
-					$notification->addParsedAction($action);
133
-				}
134
-				return $notification;
135
-
136
-			default:
137
-				// Unknown subject => Unknown notification => throw
138
-				throw new \InvalidArgumentException();
139
-		}
140
-	}
141
-
142
-	/**
143
-	 * @param string $cloudId
144
-	 * @return array
145
-	 */
146
-	protected function createRemoteUser($cloudId) {
147
-		$displayName = $cloudId;
148
-		try {
149
-			$resolvedId = $this->cloudIdManager->resolveCloudId($cloudId);
150
-			$displayName = $this->getDisplayName($resolvedId);
151
-			$user = $resolvedId->getUser();
152
-			$server = $resolvedId->getRemote();
153
-		} catch (HintException $e) {
154
-			$user = $cloudId;
155
-			$server = '';
156
-		}
157
-
158
-		return [
159
-			'type' => 'user',
160
-			'id' => $user,
161
-			'name' => $displayName,
162
-			'server' => $server,
163
-		];
164
-	}
165
-
166
-	/**
167
-	 * Try to find the user in the contacts
168
-	 *
169
-	 * @param ICloudId $cloudId
170
-	 * @return string
171
-	 */
172
-	protected function getDisplayName(ICloudId $cloudId) {
173
-		$server = $cloudId->getRemote();
174
-		$user = $cloudId->getUser();
175
-		if (strpos($server, 'http://') === 0) {
176
-			$server = substr($server, strlen('http://'));
177
-		} else if (strpos($server, 'https://') === 0) {
178
-			$server = substr($server, strlen('https://'));
179
-		}
180
-
181
-		try {
182
-			return $this->getDisplayNameFromContact($cloudId->getId());
183
-		} catch (\OutOfBoundsException $e) {
184
-		}
185
-
186
-		try {
187
-			$this->getDisplayNameFromContact($user . '@http://' . $server);
188
-		} catch (\OutOfBoundsException $e) {
189
-		}
190
-
191
-		try {
192
-			$this->getDisplayNameFromContact($user . '@https://' . $server);
193
-		} catch (\OutOfBoundsException $e) {
194
-		}
195
-
196
-		return $cloudId->getId();
197
-	}
198
-
199
-	/**
200
-	 * Try to find the user in the contacts
201
-	 *
202
-	 * @param string $federatedCloudId
203
-	 * @return string
204
-	 * @throws \OutOfBoundsException when there is no contact for the id
205
-	 */
206
-	protected function getDisplayNameFromContact($federatedCloudId) {
207
-		if (isset($this->federatedContacts[$federatedCloudId])) {
208
-			if ($this->federatedContacts[$federatedCloudId] !== '') {
209
-				return $this->federatedContacts[$federatedCloudId];
210
-			} else {
211
-				throw new \OutOfBoundsException('No contact found for federated cloud id');
212
-			}
213
-		}
214
-
215
-		$addressBookEntries = $this->contactsManager->search($federatedCloudId, ['CLOUD']);
216
-		foreach ($addressBookEntries as $entry) {
217
-			if (isset($entry['CLOUD'])) {
218
-				foreach ($entry['CLOUD'] as $cloudID) {
219
-					if ($cloudID === $federatedCloudId) {
220
-						$this->federatedContacts[$federatedCloudId] = $entry['FN'];
221
-						return $entry['FN'];
222
-					}
223
-				}
224
-			}
225
-		}
226
-
227
-		$this->federatedContacts[$federatedCloudId] = '';
228
-		throw new \OutOfBoundsException('No contact found for federated cloud id');
229
-	}
37
+    /** @var IFactory */
38
+    protected $factory;
39
+    /** @var IManager */
40
+    protected $contactsManager;
41
+    /** @var IURLGenerator */
42
+    protected $url;
43
+    /** @var array */
44
+    protected $federatedContacts;
45
+    /** @var ICloudIdManager */
46
+    protected $cloudIdManager;
47
+
48
+    /**
49
+     * @param IFactory $factory
50
+     * @param IManager $contactsManager
51
+     * @param IURLGenerator $url
52
+     * @param ICloudIdManager $cloudIdManager
53
+     */
54
+    public function __construct(IFactory $factory, IManager $contactsManager, IURLGenerator $url, ICloudIdManager $cloudIdManager) {
55
+        $this->factory = $factory;
56
+        $this->contactsManager = $contactsManager;
57
+        $this->url = $url;
58
+        $this->cloudIdManager = $cloudIdManager;
59
+    }
60
+
61
+    /**
62
+     * @param INotification $notification
63
+     * @param string $languageCode The code of the language that should be used to prepare the notification
64
+     * @return INotification
65
+     * @throws \InvalidArgumentException
66
+     */
67
+    public function prepare(INotification $notification, $languageCode) {
68
+        if ($notification->getApp() !== 'files_sharing') {
69
+            // Not my app => throw
70
+            throw new \InvalidArgumentException();
71
+        }
72
+
73
+        // Read the language from the notification
74
+        $l = $this->factory->get('files_sharing', $languageCode);
75
+
76
+        switch ($notification->getSubject()) {
77
+            // Deal with known subjects
78
+            case 'remote_share':
79
+                $notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
80
+
81
+                $params = $notification->getSubjectParameters();
82
+                if ($params[0] !== $params[1] && $params[1] !== null) {
83
+                    $notification->setParsedSubject(
84
+                        $l->t('You received "%3$s" as a remote share from %1$s (on behalf of %2$s)', $params)
85
+                    );
86
+                    $notification->setRichSubject(
87
+                        $l->t('You received {share} as a remote share from {user} (on behalf of {behalf})'),
88
+                        [
89
+                            'share' => [
90
+                                'type' => 'pending-federated-share',
91
+                                'id' => $notification->getObjectId(),
92
+                                'name' => $params[2],
93
+                            ],
94
+                            'user' => $this->createRemoteUser($params[0]),
95
+                            'behalf' => $this->createRemoteUser($params[1]),
96
+                        ]
97
+                    );
98
+                } else {
99
+                    $notification->setParsedSubject(
100
+                        $l->t('You received "%3$s" as a remote share from %1$s', $params)
101
+                    );
102
+                    $notification->setRichSubject(
103
+                        $l->t('You received {share} as a remote share from {user}'),
104
+                        [
105
+                            'share' => [
106
+                                'type' => 'pending-federated-share',
107
+                                'id' => $notification->getObjectId(),
108
+                                'name' => $params[2],
109
+                            ],
110
+                            'user' => $this->createRemoteUser($params[0]),
111
+                        ]
112
+                    );
113
+                }
114
+
115
+                // Deal with the actions for a known subject
116
+                foreach ($notification->getActions() as $action) {
117
+                    switch ($action->getLabel()) {
118
+                        case 'accept':
119
+                            $action->setParsedLabel(
120
+                                (string) $l->t('Accept')
121
+                            )
122
+                            ->setPrimary(true);
123
+                            break;
124
+
125
+                        case 'decline':
126
+                            $action->setParsedLabel(
127
+                                (string) $l->t('Decline')
128
+                            );
129
+                            break;
130
+                    }
131
+
132
+                    $notification->addParsedAction($action);
133
+                }
134
+                return $notification;
135
+
136
+            default:
137
+                // Unknown subject => Unknown notification => throw
138
+                throw new \InvalidArgumentException();
139
+        }
140
+    }
141
+
142
+    /**
143
+     * @param string $cloudId
144
+     * @return array
145
+     */
146
+    protected function createRemoteUser($cloudId) {
147
+        $displayName = $cloudId;
148
+        try {
149
+            $resolvedId = $this->cloudIdManager->resolveCloudId($cloudId);
150
+            $displayName = $this->getDisplayName($resolvedId);
151
+            $user = $resolvedId->getUser();
152
+            $server = $resolvedId->getRemote();
153
+        } catch (HintException $e) {
154
+            $user = $cloudId;
155
+            $server = '';
156
+        }
157
+
158
+        return [
159
+            'type' => 'user',
160
+            'id' => $user,
161
+            'name' => $displayName,
162
+            'server' => $server,
163
+        ];
164
+    }
165
+
166
+    /**
167
+     * Try to find the user in the contacts
168
+     *
169
+     * @param ICloudId $cloudId
170
+     * @return string
171
+     */
172
+    protected function getDisplayName(ICloudId $cloudId) {
173
+        $server = $cloudId->getRemote();
174
+        $user = $cloudId->getUser();
175
+        if (strpos($server, 'http://') === 0) {
176
+            $server = substr($server, strlen('http://'));
177
+        } else if (strpos($server, 'https://') === 0) {
178
+            $server = substr($server, strlen('https://'));
179
+        }
180
+
181
+        try {
182
+            return $this->getDisplayNameFromContact($cloudId->getId());
183
+        } catch (\OutOfBoundsException $e) {
184
+        }
185
+
186
+        try {
187
+            $this->getDisplayNameFromContact($user . '@http://' . $server);
188
+        } catch (\OutOfBoundsException $e) {
189
+        }
190
+
191
+        try {
192
+            $this->getDisplayNameFromContact($user . '@https://' . $server);
193
+        } catch (\OutOfBoundsException $e) {
194
+        }
195
+
196
+        return $cloudId->getId();
197
+    }
198
+
199
+    /**
200
+     * Try to find the user in the contacts
201
+     *
202
+     * @param string $federatedCloudId
203
+     * @return string
204
+     * @throws \OutOfBoundsException when there is no contact for the id
205
+     */
206
+    protected function getDisplayNameFromContact($federatedCloudId) {
207
+        if (isset($this->federatedContacts[$federatedCloudId])) {
208
+            if ($this->federatedContacts[$federatedCloudId] !== '') {
209
+                return $this->federatedContacts[$federatedCloudId];
210
+            } else {
211
+                throw new \OutOfBoundsException('No contact found for federated cloud id');
212
+            }
213
+        }
214
+
215
+        $addressBookEntries = $this->contactsManager->search($federatedCloudId, ['CLOUD']);
216
+        foreach ($addressBookEntries as $entry) {
217
+            if (isset($entry['CLOUD'])) {
218
+                foreach ($entry['CLOUD'] as $cloudID) {
219
+                    if ($cloudID === $federatedCloudId) {
220
+                        $this->federatedContacts[$federatedCloudId] = $entry['FN'];
221
+                        return $entry['FN'];
222
+                    }
223
+                }
224
+            }
225
+        }
226
+
227
+        $this->federatedContacts[$federatedCloudId] = '';
228
+        throw new \OutOfBoundsException('No contact found for federated cloud id');
229
+    }
230 230
 }
Please login to merge, or discard this patch.
apps/federatedfilesharing/lib/TokenHandler.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -33,30 +33,30 @@
 block discarded – undo
33 33
  */
34 34
 class TokenHandler {
35 35
 
36
-	const TOKEN_LENGTH = 15;
37
-
38
-	/** @var ISecureRandom */
39
-	private $secureRandom;
40
-
41
-	/**
42
-	 * TokenHandler constructor.
43
-	 *
44
-	 * @param ISecureRandom $secureRandom
45
-	 */
46
-	public function __construct(ISecureRandom $secureRandom) {
47
-		$this->secureRandom = $secureRandom;
48
-	}
49
-
50
-	/**
51
-	 * generate to token used to authenticate federated shares
52
-	 *
53
-	 * @return string
54
-	 */
55
-	public function generateToken() {
56
-		$token = $this->secureRandom->generate(
57
-			self::TOKEN_LENGTH,
58
-			ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_DIGITS);
59
-		return $token;
60
-	}
36
+    const TOKEN_LENGTH = 15;
37
+
38
+    /** @var ISecureRandom */
39
+    private $secureRandom;
40
+
41
+    /**
42
+     * TokenHandler constructor.
43
+     *
44
+     * @param ISecureRandom $secureRandom
45
+     */
46
+    public function __construct(ISecureRandom $secureRandom) {
47
+        $this->secureRandom = $secureRandom;
48
+    }
49
+
50
+    /**
51
+     * generate to token used to authenticate federated shares
52
+     *
53
+     * @return string
54
+     */
55
+    public function generateToken() {
56
+        $token = $this->secureRandom->generate(
57
+            self::TOKEN_LENGTH,
58
+            ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_DIGITS);
59
+        return $token;
60
+    }
61 61
 
62 62
 }
Please login to merge, or discard this patch.
apps/federation/templates/settings-admin.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,10 +28,10 @@
 block discarded – undo
28 28
 				<?php if((int)$trustedServer['status'] === TrustedServers::STATUS_OK) { ?>
29 29
 					<span class="status success"></span>
30 30
 				<?php
31
-				} elseif(
32
-					(int)$trustedServer['status'] === TrustedServers::STATUS_PENDING ||
33
-					(int)$trustedServer['status'] === TrustedServers::STATUS_ACCESS_REVOKED
34
-				) { ?>
31
+                } elseif(
32
+                    (int)$trustedServer['status'] === TrustedServers::STATUS_PENDING ||
33
+                    (int)$trustedServer['status'] === TrustedServers::STATUS_ACCESS_REVOKED
34
+                ) { ?>
35 35
 					<span class="status indeterminate"></span>
36 36
 				<?php } else {?>
37 37
 					<span class="status error"></span>
Please login to merge, or discard this patch.