Completed
Push — stable13 ( 6e449f...ddd6c7 )
by
unknown
32:20 queued 16:25
created
lib/public/SystemTag/ISystemTagManager.php 1 patch
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -33,133 +33,133 @@
 block discarded – undo
33 33
  */
34 34
 interface ISystemTagManager {
35 35
 
36
-	/**
37
-	 * Returns the tag objects matching the given tag ids.
38
-	 *
39
-	 * @param array|string $tagIds id or array of unique ids of the tag to retrieve
40
-	 *
41
-	 * @return \OCP\SystemTag\ISystemTag[] array of system tags with tag id as key
42
-	 *
43
-	 * @throws \InvalidArgumentException if at least one given tag ids is invalid (string instead of integer, etc.)
44
-	 * @throws \OCP\SystemTag\TagNotFoundException if at least one given tag ids did no exist
45
-	 * 			The message contains a json_encoded array of the ids that could not be found
46
-	 *
47
-	 * @since 9.0.0
48
-	 */
49
-	public function getTagsByIds($tagIds);
36
+    /**
37
+     * Returns the tag objects matching the given tag ids.
38
+     *
39
+     * @param array|string $tagIds id or array of unique ids of the tag to retrieve
40
+     *
41
+     * @return \OCP\SystemTag\ISystemTag[] array of system tags with tag id as key
42
+     *
43
+     * @throws \InvalidArgumentException if at least one given tag ids is invalid (string instead of integer, etc.)
44
+     * @throws \OCP\SystemTag\TagNotFoundException if at least one given tag ids did no exist
45
+     * 			The message contains a json_encoded array of the ids that could not be found
46
+     *
47
+     * @since 9.0.0
48
+     */
49
+    public function getTagsByIds($tagIds);
50 50
 
51
-	/**
52
-	 * Returns the tag object matching the given attributes.
53
-	 *
54
-	 * @param string $tagName tag name
55
-	 * @param bool $userVisible whether the tag is visible by users
56
-	 * @param bool $userAssignable whether the tag is assignable by users
57
-	 *
58
-	 * @return \OCP\SystemTag\ISystemTag system tag
59
-	 *
60
-	 * @throws \OCP\SystemTag\TagNotFoundException if tag does not exist
61
-	 *
62
-	 * @since 9.0.0
63
-	 */
64
-	public function getTag($tagName, $userVisible, $userAssignable);
51
+    /**
52
+     * Returns the tag object matching the given attributes.
53
+     *
54
+     * @param string $tagName tag name
55
+     * @param bool $userVisible whether the tag is visible by users
56
+     * @param bool $userAssignable whether the tag is assignable by users
57
+     *
58
+     * @return \OCP\SystemTag\ISystemTag system tag
59
+     *
60
+     * @throws \OCP\SystemTag\TagNotFoundException if tag does not exist
61
+     *
62
+     * @since 9.0.0
63
+     */
64
+    public function getTag($tagName, $userVisible, $userAssignable);
65 65
 
66
-	/**
67
-	 * Creates the tag object using the given attributes.
68
-	 *
69
-	 * @param string $tagName tag name
70
-	 * @param bool $userVisible whether the tag is visible by users
71
-	 * @param bool $userAssignable whether the tag is assignable by users
72
-	 *
73
-	 * @return \OCP\SystemTag\ISystemTag system tag
74
-	 *
75
-	 * @throws \OCP\SystemTag\TagAlreadyExistsException if tag already exists
76
-	 *
77
-	 * @since 9.0.0
78
-	 */
79
-	public function createTag($tagName, $userVisible, $userAssignable);
66
+    /**
67
+     * Creates the tag object using the given attributes.
68
+     *
69
+     * @param string $tagName tag name
70
+     * @param bool $userVisible whether the tag is visible by users
71
+     * @param bool $userAssignable whether the tag is assignable by users
72
+     *
73
+     * @return \OCP\SystemTag\ISystemTag system tag
74
+     *
75
+     * @throws \OCP\SystemTag\TagAlreadyExistsException if tag already exists
76
+     *
77
+     * @since 9.0.0
78
+     */
79
+    public function createTag($tagName, $userVisible, $userAssignable);
80 80
 
81
-	/**
82
-	 * Returns all known tags, optionally filtered by visibility.
83
-	 *
84
-	 * @param bool|null $visibilityFilter filter by visibility if non-null
85
-	 * @param string $nameSearchPattern optional search pattern for the tag name
86
-	 *
87
-	 * @return \OCP\SystemTag\ISystemTag[] array of system tags or empty array if none found
88
-	 *
89
-	 * @since 9.0.0
90
-	 */
91
-	public function getAllTags($visibilityFilter = null, $nameSearchPattern = null);
81
+    /**
82
+     * Returns all known tags, optionally filtered by visibility.
83
+     *
84
+     * @param bool|null $visibilityFilter filter by visibility if non-null
85
+     * @param string $nameSearchPattern optional search pattern for the tag name
86
+     *
87
+     * @return \OCP\SystemTag\ISystemTag[] array of system tags or empty array if none found
88
+     *
89
+     * @since 9.0.0
90
+     */
91
+    public function getAllTags($visibilityFilter = null, $nameSearchPattern = null);
92 92
 
93
-	/**
94
-	 * Updates the given tag
95
-	 *
96
-	 * @param string $tagId tag id
97
-	 * @param string $newName the new tag name
98
-	 * @param bool $userVisible whether the tag is visible by users
99
-	 * @param bool $userAssignable whether the tag is assignable by users
100
-	 *
101
-	 * @throws \OCP\SystemTag\TagNotFoundException if tag with the given id does not exist
102
-	 * @throws \OCP\SystemTag\TagAlreadyExistsException if there is already another tag
103
-	 * with the same attributes
104
-	 *
105
-	 * @since 9.0.0
106
-	 */
107
-	public function updateTag($tagId, $newName, $userVisible, $userAssignable);
93
+    /**
94
+     * Updates the given tag
95
+     *
96
+     * @param string $tagId tag id
97
+     * @param string $newName the new tag name
98
+     * @param bool $userVisible whether the tag is visible by users
99
+     * @param bool $userAssignable whether the tag is assignable by users
100
+     *
101
+     * @throws \OCP\SystemTag\TagNotFoundException if tag with the given id does not exist
102
+     * @throws \OCP\SystemTag\TagAlreadyExistsException if there is already another tag
103
+     * with the same attributes
104
+     *
105
+     * @since 9.0.0
106
+     */
107
+    public function updateTag($tagId, $newName, $userVisible, $userAssignable);
108 108
 
109
-	/**
110
-	 * Delete the given tags from the database and all their relationships.
111
-	 *
112
-	 * @param string|array $tagIds array of tag ids
113
-	 *
114
-	 * @throws \OCP\SystemTag\TagNotFoundException if at least one tag did not exist
115
-	 *
116
-	 * @since 9.0.0
117
-	 */
118
-	public function deleteTags($tagIds);
109
+    /**
110
+     * Delete the given tags from the database and all their relationships.
111
+     *
112
+     * @param string|array $tagIds array of tag ids
113
+     *
114
+     * @throws \OCP\SystemTag\TagNotFoundException if at least one tag did not exist
115
+     *
116
+     * @since 9.0.0
117
+     */
118
+    public function deleteTags($tagIds);
119 119
 
120
-	/**
121
-	 * Checks whether the given user is allowed to assign/unassign the tag with the
122
-	 * given id.
123
-	 *
124
-	 * @param ISystemTag $tag tag to check permission for
125
-	 * @param IUser $user user to check permission for
126
-	 *
127
-	 * @return true if the user is allowed to assign/unassign the tag, false otherwise
128
-	 *
129
-	 * @since 9.1.0
130
-	 */
131
-	public function canUserAssignTag(ISystemTag $tag, IUser $user);
120
+    /**
121
+     * Checks whether the given user is allowed to assign/unassign the tag with the
122
+     * given id.
123
+     *
124
+     * @param ISystemTag $tag tag to check permission for
125
+     * @param IUser $user user to check permission for
126
+     *
127
+     * @return true if the user is allowed to assign/unassign the tag, false otherwise
128
+     *
129
+     * @since 9.1.0
130
+     */
131
+    public function canUserAssignTag(ISystemTag $tag, IUser $user);
132 132
 
133
-	/**
134
-	 * Checks whether the given user is allowed to see the tag with the given id.
135
-	 *
136
-	 * @param ISystemTag $tag tag to check permission for
137
-	 * @param IUser $user user to check permission for
138
-	 *
139
-	 * @return true if the user can see the tag, false otherwise
140
-	 *
141
-	 * @since 9.1.0
142
-	 */
143
-	public function canUserSeeTag(ISystemTag $tag, IUser $userId);
133
+    /**
134
+     * Checks whether the given user is allowed to see the tag with the given id.
135
+     *
136
+     * @param ISystemTag $tag tag to check permission for
137
+     * @param IUser $user user to check permission for
138
+     *
139
+     * @return true if the user can see the tag, false otherwise
140
+     *
141
+     * @since 9.1.0
142
+     */
143
+    public function canUserSeeTag(ISystemTag $tag, IUser $userId);
144 144
 
145
-	/**
146
-	 * Set groups that can assign a given tag.
147
-	 *
148
-	 * @param ISystemTag $tag tag for group assignment
149
-	 * @param string[] $groupIds group ids of groups that can assign/unassign the tag
150
-	 *
151
-	 * @since 9.1.0
152
-	 */
153
-	public function setTagGroups(ISystemTag $tag, $groupIds);
145
+    /**
146
+     * Set groups that can assign a given tag.
147
+     *
148
+     * @param ISystemTag $tag tag for group assignment
149
+     * @param string[] $groupIds group ids of groups that can assign/unassign the tag
150
+     *
151
+     * @since 9.1.0
152
+     */
153
+    public function setTagGroups(ISystemTag $tag, $groupIds);
154 154
 
155
-	/**
156
-	 * Get groups that can assign a given tag.
157
-	 *
158
-	 * @param ISystemTag $tag tag for group assignment
159
-	 *
160
-	 * @return string[] group ids of groups that can assign/unassign the tag
161
-	 *
162
-	 * @since 9.1.0
163
-	 */
164
-	public function getTagGroups(ISystemTag $tag);
155
+    /**
156
+     * Get groups that can assign a given tag.
157
+     *
158
+     * @param ISystemTag $tag tag for group assignment
159
+     *
160
+     * @return string[] group ids of groups that can assign/unassign the tag
161
+     *
162
+     * @since 9.1.0
163
+     */
164
+    public function getTagGroups(ISystemTag $tag);
165 165
 }
Please login to merge, or discard this patch.
lib/private/Authentication/LoginCredentials/Credentials.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -28,45 +28,45 @@
 block discarded – undo
28 28
 
29 29
 class Credentials implements ICredentials {
30 30
 
31
-	/** @var string */
32
-	private $uid;
31
+    /** @var string */
32
+    private $uid;
33 33
 
34
-	/** @var string */
35
-	private $loginName;
34
+    /** @var string */
35
+    private $loginName;
36 36
 
37
-	/** @var string */
38
-	private $password;
37
+    /** @var string */
38
+    private $password;
39 39
 
40
-	/**
41
-	 * @param string $uid
42
-	 * @param string $loginName
43
-	 * @param string $password
44
-	 */
45
-	public function __construct($uid, $loginName, $password) {
46
-		$this->uid = $uid;
47
-		$this->loginName = $loginName;
48
-		$this->password = $password;
49
-	}
40
+    /**
41
+     * @param string $uid
42
+     * @param string $loginName
43
+     * @param string $password
44
+     */
45
+    public function __construct($uid, $loginName, $password) {
46
+        $this->uid = $uid;
47
+        $this->loginName = $loginName;
48
+        $this->password = $password;
49
+    }
50 50
 
51
-	/**
52
-	 * @return string
53
-	 */
54
-	public function getUID() {
55
-		return $this->uid;
56
-	}
51
+    /**
52
+     * @return string
53
+     */
54
+    public function getUID() {
55
+        return $this->uid;
56
+    }
57 57
 
58
-	/**
59
-	 * @return string
60
-	 */
61
-	public function getLoginName() {
62
-		return $this->loginName;
63
-	}
58
+    /**
59
+     * @return string
60
+     */
61
+    public function getLoginName() {
62
+        return $this->loginName;
63
+    }
64 64
 
65
-	/**
66
-	 * @return string
67
-	 */
68
-	public function getPassword() {
69
-		return $this->password;
70
-	}
65
+    /**
66
+     * @return string
67
+     */
68
+    public function getPassword() {
69
+        return $this->password;
70
+    }
71 71
 
72 72
 }
Please login to merge, or discard this patch.
lib/private/Authentication/LoginCredentials/Store.php 1 patch
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -37,84 +37,84 @@
 block discarded – undo
37 37
 
38 38
 class Store implements IStore {
39 39
 
40
-	/** @var ISession */
41
-	private $session;
42
-
43
-	/** @var ILogger */
44
-	private $logger;
45
-
46
-	/** @var IProvider|null */
47
-	private $tokenProvider;
48
-
49
-	/**
50
-	 * @param ISession $session
51
-	 * @param ILogger $logger
52
-	 * @param IProvider $tokenProvider
53
-	 */
54
-	public function __construct(ISession $session, ILogger $logger, IProvider $tokenProvider = null) {
55
-		$this->session = $session;
56
-		$this->logger = $logger;
57
-		$this->tokenProvider = $tokenProvider;
58
-
59
-		Util::connectHook('OC_User', 'post_login', $this, 'authenticate');
60
-	}
61
-
62
-	/**
63
-	 * Hook listener on post login
64
-	 *
65
-	 * @param array $params
66
-	 */
67
-	public function authenticate(array $params) {
68
-		$this->session->set('login_credentials', json_encode($params));
69
-	}
70
-
71
-	/**
72
-	 * Replace the session implementation
73
-	 *
74
-	 * @param ISession $session
75
-	 */
76
-	public function setSession(ISession $session) {
77
-		$this->session = $session;
78
-	}
79
-
80
-	/**
81
-	 * @since 12
82
-	 *
83
-	 * @return ICredentials the login credentials of the current user
84
-	 * @throws CredentialsUnavailableException
85
-	 */
86
-	public function getLoginCredentials() {
87
-		if (is_null($this->tokenProvider)) {
88
-			throw new CredentialsUnavailableException();
89
-		}
90
-
91
-		$trySession = false;
92
-		try {
93
-			$sessionId = $this->session->getId();
94
-			$token = $this->tokenProvider->getToken($sessionId);
95
-
96
-			$uid = $token->getUID();
97
-			$user = $token->getLoginName();
98
-			$password = $this->tokenProvider->getPassword($token, $sessionId);
99
-
100
-			return new Credentials($uid, $user, $password);
101
-		} catch (SessionNotAvailableException $ex) {
102
-			$this->logger->debug('could not get login credentials because session is unavailable', ['app' => 'core']);
103
-		} catch (InvalidTokenException $ex) {
104
-			$this->logger->debug('could not get login credentials because the token is invalid', ['app' => 'core']);
105
-			$trySession = true;
106
-		} catch (PasswordlessTokenException $ex) {
107
-			$this->logger->debug('could not get login credentials because the token has no password', ['app' => 'core']);
108
-			$trySession = true;
109
-		}
110
-
111
-		if ($trySession && $this->session->exists('login_credentials')) {
112
-			$creds = json_decode($this->session->get('login_credentials'));
113
-			return new Credentials($creds->uid, $creds->uid, $creds->password);
114
-		}
115
-
116
-		// If we reach this line, an exception was thrown.
117
-		throw new CredentialsUnavailableException();
118
-	}
40
+    /** @var ISession */
41
+    private $session;
42
+
43
+    /** @var ILogger */
44
+    private $logger;
45
+
46
+    /** @var IProvider|null */
47
+    private $tokenProvider;
48
+
49
+    /**
50
+     * @param ISession $session
51
+     * @param ILogger $logger
52
+     * @param IProvider $tokenProvider
53
+     */
54
+    public function __construct(ISession $session, ILogger $logger, IProvider $tokenProvider = null) {
55
+        $this->session = $session;
56
+        $this->logger = $logger;
57
+        $this->tokenProvider = $tokenProvider;
58
+
59
+        Util::connectHook('OC_User', 'post_login', $this, 'authenticate');
60
+    }
61
+
62
+    /**
63
+     * Hook listener on post login
64
+     *
65
+     * @param array $params
66
+     */
67
+    public function authenticate(array $params) {
68
+        $this->session->set('login_credentials', json_encode($params));
69
+    }
70
+
71
+    /**
72
+     * Replace the session implementation
73
+     *
74
+     * @param ISession $session
75
+     */
76
+    public function setSession(ISession $session) {
77
+        $this->session = $session;
78
+    }
79
+
80
+    /**
81
+     * @since 12
82
+     *
83
+     * @return ICredentials the login credentials of the current user
84
+     * @throws CredentialsUnavailableException
85
+     */
86
+    public function getLoginCredentials() {
87
+        if (is_null($this->tokenProvider)) {
88
+            throw new CredentialsUnavailableException();
89
+        }
90
+
91
+        $trySession = false;
92
+        try {
93
+            $sessionId = $this->session->getId();
94
+            $token = $this->tokenProvider->getToken($sessionId);
95
+
96
+            $uid = $token->getUID();
97
+            $user = $token->getLoginName();
98
+            $password = $this->tokenProvider->getPassword($token, $sessionId);
99
+
100
+            return new Credentials($uid, $user, $password);
101
+        } catch (SessionNotAvailableException $ex) {
102
+            $this->logger->debug('could not get login credentials because session is unavailable', ['app' => 'core']);
103
+        } catch (InvalidTokenException $ex) {
104
+            $this->logger->debug('could not get login credentials because the token is invalid', ['app' => 'core']);
105
+            $trySession = true;
106
+        } catch (PasswordlessTokenException $ex) {
107
+            $this->logger->debug('could not get login credentials because the token has no password', ['app' => 'core']);
108
+            $trySession = true;
109
+        }
110
+
111
+        if ($trySession && $this->session->exists('login_credentials')) {
112
+            $creds = json_decode($this->session->get('login_credentials'));
113
+            return new Credentials($creds->uid, $creds->uid, $creds->password);
114
+        }
115
+
116
+        // If we reach this line, an exception was thrown.
117
+        throw new CredentialsUnavailableException();
118
+    }
119 119
 
120 120
 }
Please login to merge, or discard this patch.
lib/private/Authentication/Token/DefaultTokenCleanupJob.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,10 +27,10 @@
 block discarded – undo
27 27
 
28 28
 class DefaultTokenCleanupJob extends Job {
29 29
 
30
-	protected function run($argument) {
31
-		/* @var $provider IProvider */
32
-		$provider = OC::$server->query('OC\Authentication\Token\IProvider');
33
-		$provider->invalidateOldTokens();
34
-	}
30
+    protected function run($argument) {
31
+        /* @var $provider IProvider */
32
+        $provider = OC::$server->query('OC\Authentication\Token\IProvider');
33
+        $provider->invalidateOldTokens();
34
+    }
35 35
 
36 36
 }
Please login to merge, or discard this patch.
lib/private/SubAdmin.php 1 patch
Indentation   +247 added lines, -247 removed lines patch added patch discarded remove patch
@@ -36,253 +36,253 @@
 block discarded – undo
36 36
 
37 37
 class SubAdmin extends PublicEmitter {
38 38
 
39
-	/** @var IUserManager */
40
-	private $userManager;
41
-
42
-	/** @var IGroupManager */
43
-	private $groupManager;
44
-
45
-	/** @var IDBConnection */
46
-	private $dbConn;
47
-
48
-	/**
49
-	 * @param IUserManager $userManager
50
-	 * @param IGroupManager $groupManager
51
-	 * @param IDBConnection $dbConn
52
-	 */
53
-	public function __construct(IUserManager $userManager,
54
-	                            IGroupManager $groupManager,
55
-								IDBConnection $dbConn) {
56
-		$this->userManager = $userManager;
57
-		$this->groupManager = $groupManager;
58
-		$this->dbConn = $dbConn;
59
-
60
-		$this->userManager->listen('\OC\User', 'postDelete', function($user) {
61
-			$this->post_deleteUser($user);
62
-		});
63
-		$this->groupManager->listen('\OC\Group', 'postDelete', function($group) {
64
-			$this->post_deleteGroup($group);	
65
-		});
66
-	}
67
-
68
-	/**
69
-	 * add a SubAdmin
70
-	 * @param IUser $user user to be SubAdmin
71
-	 * @param IGroup $group group $user becomes subadmin of
72
-	 * @return bool
73
-	 */
74
-	public function createSubAdmin(IUser $user, IGroup $group) {
75
-		$qb = $this->dbConn->getQueryBuilder();
76
-
77
-		$qb->insert('group_admin')
78
-			->values([
79
-				'gid' => $qb->createNamedParameter($group->getGID()),
80
-				'uid' => $qb->createNamedParameter($user->getUID())
81
-			])
82
-			->execute();
83
-
84
-		$this->emit('\OC\SubAdmin', 'postCreateSubAdmin', [$user, $group]);
85
-		\OC_Hook::emit("OC_SubAdmin", "post_createSubAdmin", ["gid" => $group->getGID()]);
86
-		return true;
87
-	}
88
-
89
-	/**
90
-	 * delete a SubAdmin
91
-	 * @param IUser $user the user that is the SubAdmin
92
-	 * @param IGroup $group the group
93
-	 * @return bool
94
-	 */
95
-	public function deleteSubAdmin(IUser $user, IGroup $group) {
96
-		$qb = $this->dbConn->getQueryBuilder();
97
-
98
-		$qb->delete('group_admin')
99
-			->where($qb->expr()->eq('gid', $qb->createNamedParameter($group->getGID())))
100
-			->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())))
101
-			->execute();
102
-
103
-		$this->emit('\OC\SubAdmin', 'postDeleteSubAdmin', [$user, $group]);
104
-		\OC_Hook::emit("OC_SubAdmin", "post_deleteSubAdmin", ["gid" => $group->getGID()]);
105
-		return true;
106
-	}
107
-
108
-	/**
109
-	 * get groups of a SubAdmin
110
-	 * @param IUser $user the SubAdmin
111
-	 * @return IGroup[]
112
-	 */
113
-	public function getSubAdminsGroups(IUser $user) {
114
-		$qb = $this->dbConn->getQueryBuilder();
115
-
116
-		$result = $qb->select('gid')
117
-			->from('group_admin')
118
-			->where($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())))
119
-			->execute();
120
-
121
-		$groups = [];
122
-		while($row = $result->fetch()) {
123
-			$group = $this->groupManager->get($row['gid']);
124
-			if(!is_null($group)) {
125
-				$groups[] = $group;
126
-			}
127
-		}
128
-		$result->closeCursor();
129
-
130
-		return $groups;
131
-	}
132
-
133
-	/**
134
-	 * get SubAdmins of a group
135
-	 * @param IGroup $group the group
136
-	 * @return IUser[]
137
-	 */
138
-	public function getGroupsSubAdmins(IGroup $group) {
139
-		$qb = $this->dbConn->getQueryBuilder();
140
-
141
-		$result = $qb->select('uid')
142
-			->from('group_admin')
143
-			->where($qb->expr()->eq('gid', $qb->createNamedParameter($group->getGID())))
144
-			->execute();
145
-
146
-		$users = [];
147
-		while($row = $result->fetch()) {
148
-			$user = $this->userManager->get($row['uid']);
149
-			if(!is_null($user)) {
150
-				$users[] = $user;
151
-			}
152
-		}
153
-		$result->closeCursor();
154
-
155
-		return $users;
156
-	}
157
-
158
-	/**
159
-	 * get all SubAdmins
160
-	 * @return array
161
-	 */
162
-	public function getAllSubAdmins() {
163
-		$qb = $this->dbConn->getQueryBuilder();
164
-
165
-		$result = $qb->select('*')
166
-			->from('group_admin')
167
-			->execute();
168
-
169
-		$subadmins = [];
170
-		while($row = $result->fetch()) {
171
-			$user = $this->userManager->get($row['uid']);
172
-			$group = $this->groupManager->get($row['gid']);
173
-			if(!is_null($user) && !is_null($group)) {
174
-				$subadmins[] = [
175
-					'user'  => $user,
176
-					'group' => $group
177
-				];
178
-			}
179
-		}
180
-		$result->closeCursor();
181
-
182
-		return $subadmins;
183
-	}
184
-
185
-	/**
186
-	 * checks if a user is a SubAdmin of a group
187
-	 * @param IUser $user 
188
-	 * @param IGroup $group
189
-	 * @return bool
190
-	 */
191
-	public function isSubAdminOfGroup(IUser $user, IGroup $group) {
192
-		$qb = $this->dbConn->getQueryBuilder();
193
-
194
-		/*
39
+    /** @var IUserManager */
40
+    private $userManager;
41
+
42
+    /** @var IGroupManager */
43
+    private $groupManager;
44
+
45
+    /** @var IDBConnection */
46
+    private $dbConn;
47
+
48
+    /**
49
+     * @param IUserManager $userManager
50
+     * @param IGroupManager $groupManager
51
+     * @param IDBConnection $dbConn
52
+     */
53
+    public function __construct(IUserManager $userManager,
54
+                                IGroupManager $groupManager,
55
+                                IDBConnection $dbConn) {
56
+        $this->userManager = $userManager;
57
+        $this->groupManager = $groupManager;
58
+        $this->dbConn = $dbConn;
59
+
60
+        $this->userManager->listen('\OC\User', 'postDelete', function($user) {
61
+            $this->post_deleteUser($user);
62
+        });
63
+        $this->groupManager->listen('\OC\Group', 'postDelete', function($group) {
64
+            $this->post_deleteGroup($group);	
65
+        });
66
+    }
67
+
68
+    /**
69
+     * add a SubAdmin
70
+     * @param IUser $user user to be SubAdmin
71
+     * @param IGroup $group group $user becomes subadmin of
72
+     * @return bool
73
+     */
74
+    public function createSubAdmin(IUser $user, IGroup $group) {
75
+        $qb = $this->dbConn->getQueryBuilder();
76
+
77
+        $qb->insert('group_admin')
78
+            ->values([
79
+                'gid' => $qb->createNamedParameter($group->getGID()),
80
+                'uid' => $qb->createNamedParameter($user->getUID())
81
+            ])
82
+            ->execute();
83
+
84
+        $this->emit('\OC\SubAdmin', 'postCreateSubAdmin', [$user, $group]);
85
+        \OC_Hook::emit("OC_SubAdmin", "post_createSubAdmin", ["gid" => $group->getGID()]);
86
+        return true;
87
+    }
88
+
89
+    /**
90
+     * delete a SubAdmin
91
+     * @param IUser $user the user that is the SubAdmin
92
+     * @param IGroup $group the group
93
+     * @return bool
94
+     */
95
+    public function deleteSubAdmin(IUser $user, IGroup $group) {
96
+        $qb = $this->dbConn->getQueryBuilder();
97
+
98
+        $qb->delete('group_admin')
99
+            ->where($qb->expr()->eq('gid', $qb->createNamedParameter($group->getGID())))
100
+            ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())))
101
+            ->execute();
102
+
103
+        $this->emit('\OC\SubAdmin', 'postDeleteSubAdmin', [$user, $group]);
104
+        \OC_Hook::emit("OC_SubAdmin", "post_deleteSubAdmin", ["gid" => $group->getGID()]);
105
+        return true;
106
+    }
107
+
108
+    /**
109
+     * get groups of a SubAdmin
110
+     * @param IUser $user the SubAdmin
111
+     * @return IGroup[]
112
+     */
113
+    public function getSubAdminsGroups(IUser $user) {
114
+        $qb = $this->dbConn->getQueryBuilder();
115
+
116
+        $result = $qb->select('gid')
117
+            ->from('group_admin')
118
+            ->where($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())))
119
+            ->execute();
120
+
121
+        $groups = [];
122
+        while($row = $result->fetch()) {
123
+            $group = $this->groupManager->get($row['gid']);
124
+            if(!is_null($group)) {
125
+                $groups[] = $group;
126
+            }
127
+        }
128
+        $result->closeCursor();
129
+
130
+        return $groups;
131
+    }
132
+
133
+    /**
134
+     * get SubAdmins of a group
135
+     * @param IGroup $group the group
136
+     * @return IUser[]
137
+     */
138
+    public function getGroupsSubAdmins(IGroup $group) {
139
+        $qb = $this->dbConn->getQueryBuilder();
140
+
141
+        $result = $qb->select('uid')
142
+            ->from('group_admin')
143
+            ->where($qb->expr()->eq('gid', $qb->createNamedParameter($group->getGID())))
144
+            ->execute();
145
+
146
+        $users = [];
147
+        while($row = $result->fetch()) {
148
+            $user = $this->userManager->get($row['uid']);
149
+            if(!is_null($user)) {
150
+                $users[] = $user;
151
+            }
152
+        }
153
+        $result->closeCursor();
154
+
155
+        return $users;
156
+    }
157
+
158
+    /**
159
+     * get all SubAdmins
160
+     * @return array
161
+     */
162
+    public function getAllSubAdmins() {
163
+        $qb = $this->dbConn->getQueryBuilder();
164
+
165
+        $result = $qb->select('*')
166
+            ->from('group_admin')
167
+            ->execute();
168
+
169
+        $subadmins = [];
170
+        while($row = $result->fetch()) {
171
+            $user = $this->userManager->get($row['uid']);
172
+            $group = $this->groupManager->get($row['gid']);
173
+            if(!is_null($user) && !is_null($group)) {
174
+                $subadmins[] = [
175
+                    'user'  => $user,
176
+                    'group' => $group
177
+                ];
178
+            }
179
+        }
180
+        $result->closeCursor();
181
+
182
+        return $subadmins;
183
+    }
184
+
185
+    /**
186
+     * checks if a user is a SubAdmin of a group
187
+     * @param IUser $user 
188
+     * @param IGroup $group
189
+     * @return bool
190
+     */
191
+    public function isSubAdminOfGroup(IUser $user, IGroup $group) {
192
+        $qb = $this->dbConn->getQueryBuilder();
193
+
194
+        /*
195 195
 		 * Primary key is ('gid', 'uid') so max 1 result possible here
196 196
 		 */
197
-		$result = $qb->select('*')
198
-			->from('group_admin')
199
-			->where($qb->expr()->eq('gid', $qb->createNamedParameter($group->getGID())))
200
-			->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())))
201
-			->execute();
202
-
203
-		$fetch =  $result->fetch();
204
-		$result->closeCursor();
205
-		$result = !empty($fetch) ? true : false;
206
-
207
-		return $result;
208
-	}
209
-
210
-	/**
211
-	 * checks if a user is a SubAdmin
212
-	 * @param IUser $user 
213
-	 * @return bool
214
-	 */
215
-	public function isSubAdmin(IUser $user) {
216
-		// Check if the user is already an admin
217
-		if ($this->groupManager->isAdmin($user->getUID())) {
218
-			return true;
219
-		}
220
-
221
-		$qb = $this->dbConn->getQueryBuilder();
222
-
223
-		$result = $qb->select('gid')
224
-			->from('group_admin')
225
-			->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())))
226
-			->setMaxResults(1)
227
-			->execute();
228
-
229
-		$isSubAdmin = $result->fetch();
230
-		$result->closeCursor();
231
-
232
-		$result = $isSubAdmin === false ? false : true;
233
-
234
-		return $result;
235
-	}
236
-
237
-	/**
238
-	 * checks if a user is a accessible by a subadmin
239
-	 * @param IUser $subadmin
240
-	 * @param IUser $user
241
-	 * @return bool
242
-	 */
243
-	public function isUserAccessible($subadmin, $user) {
244
-		if(!$this->isSubAdmin($subadmin)) {
245
-			return false;
246
-		}
247
-		if($this->groupManager->isAdmin($user->getUID())) {
248
-			return false;
249
-		}
250
-		$accessibleGroups = $this->getSubAdminsGroups($subadmin);
251
-		foreach($accessibleGroups as $accessibleGroup) {
252
-			if($accessibleGroup->inGroup($user)) {
253
-				return true;
254
-			}
255
-		}
256
-		return false;
257
-	}
258
-
259
-	/**
260
-	 * delete all SubAdmins by $user
261
-	 * @param IUser $user
262
-	 * @return boolean
263
-	 */
264
-	private function post_deleteUser($user) {
265
-		$qb = $this->dbConn->getQueryBuilder();
266
-
267
-		$qb->delete('group_admin')
268
-			->where($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())))
269
-			->execute();
270
-
271
-		return true;
272
-	}
273
-
274
-	/**
275
-	 * delete all SubAdmins by $group
276
-	 * @param IGroup $group
277
-	 * @return boolean
278
-	 */
279
-	private function post_deleteGroup($group) {
280
-		$qb = $this->dbConn->getQueryBuilder();
281
-
282
-		$qb->delete('group_admin')
283
-			->where($qb->expr()->eq('gid', $qb->createNamedParameter($group->getGID())))
284
-			->execute();
285
-
286
-		return true;
287
-	}
197
+        $result = $qb->select('*')
198
+            ->from('group_admin')
199
+            ->where($qb->expr()->eq('gid', $qb->createNamedParameter($group->getGID())))
200
+            ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())))
201
+            ->execute();
202
+
203
+        $fetch =  $result->fetch();
204
+        $result->closeCursor();
205
+        $result = !empty($fetch) ? true : false;
206
+
207
+        return $result;
208
+    }
209
+
210
+    /**
211
+     * checks if a user is a SubAdmin
212
+     * @param IUser $user 
213
+     * @return bool
214
+     */
215
+    public function isSubAdmin(IUser $user) {
216
+        // Check if the user is already an admin
217
+        if ($this->groupManager->isAdmin($user->getUID())) {
218
+            return true;
219
+        }
220
+
221
+        $qb = $this->dbConn->getQueryBuilder();
222
+
223
+        $result = $qb->select('gid')
224
+            ->from('group_admin')
225
+            ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())))
226
+            ->setMaxResults(1)
227
+            ->execute();
228
+
229
+        $isSubAdmin = $result->fetch();
230
+        $result->closeCursor();
231
+
232
+        $result = $isSubAdmin === false ? false : true;
233
+
234
+        return $result;
235
+    }
236
+
237
+    /**
238
+     * checks if a user is a accessible by a subadmin
239
+     * @param IUser $subadmin
240
+     * @param IUser $user
241
+     * @return bool
242
+     */
243
+    public function isUserAccessible($subadmin, $user) {
244
+        if(!$this->isSubAdmin($subadmin)) {
245
+            return false;
246
+        }
247
+        if($this->groupManager->isAdmin($user->getUID())) {
248
+            return false;
249
+        }
250
+        $accessibleGroups = $this->getSubAdminsGroups($subadmin);
251
+        foreach($accessibleGroups as $accessibleGroup) {
252
+            if($accessibleGroup->inGroup($user)) {
253
+                return true;
254
+            }
255
+        }
256
+        return false;
257
+    }
258
+
259
+    /**
260
+     * delete all SubAdmins by $user
261
+     * @param IUser $user
262
+     * @return boolean
263
+     */
264
+    private function post_deleteUser($user) {
265
+        $qb = $this->dbConn->getQueryBuilder();
266
+
267
+        $qb->delete('group_admin')
268
+            ->where($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())))
269
+            ->execute();
270
+
271
+        return true;
272
+    }
273
+
274
+    /**
275
+     * delete all SubAdmins by $group
276
+     * @param IGroup $group
277
+     * @return boolean
278
+     */
279
+    private function post_deleteGroup($group) {
280
+        $qb = $this->dbConn->getQueryBuilder();
281
+
282
+        $qb->delete('group_admin')
283
+            ->where($qb->expr()->eq('gid', $qb->createNamedParameter($group->getGID())))
284
+            ->execute();
285
+
286
+        return true;
287
+    }
288 288
 }
Please login to merge, or discard this patch.
lib/private/Activity/Event.php 1 patch
Indentation   +515 added lines, -515 removed lines patch added patch discarded remove patch
@@ -30,523 +30,523 @@
 block discarded – undo
30 30
 
31 31
 class Event implements IEvent {
32 32
 
33
-	/** @var string */
34
-	protected $app = '';
35
-	/** @var string */
36
-	protected $type = '';
37
-	/** @var string */
38
-	protected $affectedUser = '';
39
-	/** @var string */
40
-	protected $author = '';
41
-	/** @var int */
42
-	protected $timestamp = 0;
43
-	/** @var string */
44
-	protected $subject = '';
45
-	/** @var array */
46
-	protected $subjectParameters = [];
47
-	/** @var string */
48
-	protected $subjectParsed;
49
-	/** @var string */
50
-	protected $subjectRich;
51
-	/** @var array */
52
-	protected $subjectRichParameters;
53
-	/** @var string */
54
-	protected $message = '';
55
-	/** @var array */
56
-	protected $messageParameters = [];
57
-	/** @var string */
58
-	protected $messageParsed;
59
-	/** @var string */
60
-	protected $messageRich;
61
-	/** @var array */
62
-	protected $messageRichParameters;
63
-	/** @var string */
64
-	protected $objectType = '';
65
-	/** @var int */
66
-	protected $objectId = 0;
67
-	/** @var string */
68
-	protected $objectName = '';
69
-	/** @var string */
70
-	protected $link = '';
71
-	/** @var string */
72
-	protected $icon = '';
73
-
74
-	/** @var IEvent */
75
-	protected $child = null;
76
-	/** @var IValidator */
77
-	protected $richValidator;
78
-
79
-	/**
80
-	 * @param IValidator $richValidator
81
-	 */
82
-	public function __construct(IValidator $richValidator) {
83
-		$this->richValidator = $richValidator;
84
-	}
85
-
86
-	/**
87
-	 * Set the app of the activity
88
-	 *
89
-	 * @param string $app
90
-	 * @return IEvent
91
-	 * @throws \InvalidArgumentException if the app id is invalid
92
-	 * @since 8.2.0
93
-	 */
94
-	public function setApp($app) {
95
-		if (!is_string($app) || $app === '' || isset($app[32])) {
96
-			throw new \InvalidArgumentException('The given app is invalid');
97
-		}
98
-		$this->app = (string) $app;
99
-		return $this;
100
-	}
101
-
102
-	/**
103
-	 * @return string
104
-	 */
105
-	public function getApp() {
106
-		return $this->app;
107
-	}
108
-
109
-	/**
110
-	 * Set the type of the activity
111
-	 *
112
-	 * @param string $type
113
-	 * @return IEvent
114
-	 * @throws \InvalidArgumentException if the type is invalid
115
-	 * @since 8.2.0
116
-	 */
117
-	public function setType($type) {
118
-		if (!is_string($type) || $type === '' || isset($type[255])) {
119
-			throw new \InvalidArgumentException('The given type is invalid');
120
-		}
121
-		$this->type = (string) $type;
122
-		return $this;
123
-	}
124
-
125
-	/**
126
-	 * @return string
127
-	 */
128
-	public function getType() {
129
-		return $this->type;
130
-	}
131
-
132
-	/**
133
-	 * Set the affected user of the activity
134
-	 *
135
-	 * @param string $affectedUser
136
-	 * @return IEvent
137
-	 * @throws \InvalidArgumentException if the affected user is invalid
138
-	 * @since 8.2.0
139
-	 */
140
-	public function setAffectedUser($affectedUser) {
141
-		if (!is_string($affectedUser) || $affectedUser === '' || isset($affectedUser[64])) {
142
-			throw new \InvalidArgumentException('The given affected user is invalid');
143
-		}
144
-		$this->affectedUser = (string) $affectedUser;
145
-		return $this;
146
-	}
147
-
148
-	/**
149
-	 * @return string
150
-	 */
151
-	public function getAffectedUser() {
152
-		return $this->affectedUser;
153
-	}
154
-
155
-	/**
156
-	 * Set the author of the activity
157
-	 *
158
-	 * @param string $author
159
-	 * @return IEvent
160
-	 * @throws \InvalidArgumentException if the author is invalid
161
-	 * @since 8.2.0
162
-	 */
163
-	public function setAuthor($author) {
164
-		if (!is_string($author) || isset($author[64])) {
165
-			throw new \InvalidArgumentException('The given author user is invalid'. serialize($author));
166
-		}
167
-		$this->author = (string) $author;
168
-		return $this;
169
-	}
170
-
171
-	/**
172
-	 * @return string
173
-	 */
174
-	public function getAuthor() {
175
-		return $this->author;
176
-	}
177
-
178
-	/**
179
-	 * Set the timestamp of the activity
180
-	 *
181
-	 * @param int $timestamp
182
-	 * @return IEvent
183
-	 * @throws \InvalidArgumentException if the timestamp is invalid
184
-	 * @since 8.2.0
185
-	 */
186
-	public function setTimestamp($timestamp) {
187
-		if (!is_int($timestamp)) {
188
-			throw new \InvalidArgumentException('The given timestamp is invalid');
189
-		}
190
-		$this->timestamp = (int) $timestamp;
191
-		return $this;
192
-	}
193
-
194
-	/**
195
-	 * @return int
196
-	 */
197
-	public function getTimestamp() {
198
-		return $this->timestamp;
199
-	}
200
-
201
-	/**
202
-	 * Set the subject of the activity
203
-	 *
204
-	 * @param string $subject
205
-	 * @param array $parameters
206
-	 * @return IEvent
207
-	 * @throws \InvalidArgumentException if the subject or parameters are invalid
208
-	 * @since 8.2.0
209
-	 */
210
-	public function setSubject($subject, array $parameters = []) {
211
-		if (!is_string($subject) || isset($subject[255])) {
212
-			throw new \InvalidArgumentException('The given subject is invalid');
213
-		}
214
-		$this->subject = (string) $subject;
215
-		$this->subjectParameters = $parameters;
216
-		return $this;
217
-	}
218
-
219
-	/**
220
-	 * @return string
221
-	 */
222
-	public function getSubject() {
223
-		return $this->subject;
224
-	}
225
-
226
-	/**
227
-	 * @return array
228
-	 */
229
-	public function getSubjectParameters() {
230
-		return $this->subjectParameters;
231
-	}
232
-
233
-	/**
234
-	 * @param string $subject
235
-	 * @return $this
236
-	 * @throws \InvalidArgumentException if the subject is invalid
237
-	 * @since 11.0.0
238
-	 */
239
-	public function setParsedSubject($subject) {
240
-		if (!is_string($subject) || $subject === '') {
241
-			throw new \InvalidArgumentException('The given parsed subject is invalid');
242
-		}
243
-		$this->subjectParsed = $subject;
244
-		return $this;
245
-	}
246
-
247
-	/**
248
-	 * @return string
249
-	 * @since 11.0.0
250
-	 */
251
-	public function getParsedSubject() {
252
-		return $this->subjectParsed;
253
-	}
254
-
255
-	/**
256
-	 * @param string $subject
257
-	 * @param array $parameters
258
-	 * @return $this
259
-	 * @throws \InvalidArgumentException if the subject or parameters are invalid
260
-	 * @since 11.0.0
261
-	 */
262
-	public function setRichSubject($subject, array $parameters = []) {
263
-		if (!is_string($subject) || $subject === '') {
264
-			throw new \InvalidArgumentException('The given parsed subject is invalid');
265
-		}
266
-		$this->subjectRich = $subject;
267
-
268
-		if (!is_array($parameters)) {
269
-			throw new \InvalidArgumentException('The given subject parameters are invalid');
270
-		}
271
-		$this->subjectRichParameters = $parameters;
272
-
273
-		return $this;
274
-	}
275
-
276
-	/**
277
-	 * @return string
278
-	 * @since 11.0.0
279
-	 */
280
-	public function getRichSubject() {
281
-		return $this->subjectRich;
282
-	}
283
-
284
-	/**
285
-	 * @return array[]
286
-	 * @since 11.0.0
287
-	 */
288
-	public function getRichSubjectParameters() {
289
-		return $this->subjectRichParameters;
290
-	}
291
-
292
-	/**
293
-	 * Set the message of the activity
294
-	 *
295
-	 * @param string $message
296
-	 * @param array $parameters
297
-	 * @return IEvent
298
-	 * @throws \InvalidArgumentException if the message or parameters are invalid
299
-	 * @since 8.2.0
300
-	 */
301
-	public function setMessage($message, array $parameters = []) {
302
-		if (!is_string($message) || isset($message[255])) {
303
-			throw new \InvalidArgumentException('The given message is invalid');
304
-		}
305
-		$this->message = (string) $message;
306
-		$this->messageParameters = $parameters;
307
-		return $this;
308
-	}
309
-
310
-	/**
311
-	 * @return string
312
-	 */
313
-	public function getMessage() {
314
-		return $this->message;
315
-	}
316
-
317
-	/**
318
-	 * @return array
319
-	 */
320
-	public function getMessageParameters() {
321
-		return $this->messageParameters;
322
-	}
323
-
324
-	/**
325
-	 * @param string $message
326
-	 * @return $this
327
-	 * @throws \InvalidArgumentException if the message is invalid
328
-	 * @since 11.0.0
329
-	 */
330
-	public function setParsedMessage($message) {
331
-		if (!is_string($message)) {
332
-			throw new \InvalidArgumentException('The given parsed message is invalid');
333
-		}
334
-		$this->messageParsed = $message;
335
-		return $this;
336
-	}
337
-
338
-	/**
339
-	 * @return string
340
-	 * @since 11.0.0
341
-	 */
342
-	public function getParsedMessage() {
343
-		return $this->messageParsed;
344
-	}
345
-
346
-	/**
347
-	 * @param string $message
348
-	 * @param array $parameters
349
-	 * @return $this
350
-	 * @throws \InvalidArgumentException if the subject or parameters are invalid
351
-	 * @since 11.0.0
352
-	 */
353
-	public function setRichMessage($message, array $parameters = []) {
354
-		if (!is_string($message)) {
355
-			throw new \InvalidArgumentException('The given parsed message is invalid');
356
-		}
357
-		$this->messageRich = $message;
358
-
359
-		if (!is_array($parameters)) {
360
-			throw new \InvalidArgumentException('The given message parameters are invalid');
361
-		}
362
-		$this->messageRichParameters = $parameters;
363
-
364
-		return $this;
365
-	}
366
-
367
-	/**
368
-	 * @return string
369
-	 * @since 11.0.0
370
-	 */
371
-	public function getRichMessage() {
372
-		return $this->messageRich;
373
-	}
374
-
375
-	/**
376
-	 * @return array[]
377
-	 * @since 11.0.0
378
-	 */
379
-	public function getRichMessageParameters() {
380
-		return $this->messageRichParameters;
381
-	}
382
-
383
-	/**
384
-	 * Set the object of the activity
385
-	 *
386
-	 * @param string $objectType
387
-	 * @param int $objectId
388
-	 * @param string $objectName
389
-	 * @return IEvent
390
-	 * @throws \InvalidArgumentException if the object is invalid
391
-	 * @since 8.2.0
392
-	 */
393
-	public function setObject($objectType, $objectId, $objectName = '') {
394
-		if (!is_string($objectType) || isset($objectType[255])) {
395
-			throw new \InvalidArgumentException('The given object type is invalid');
396
-		}
397
-		if (!is_int($objectId)) {
398
-			throw new \InvalidArgumentException('The given object id is invalid');
399
-		}
400
-		if (!is_string($objectName) || isset($objectName[4000])) {
401
-			throw new \InvalidArgumentException('The given object name is invalid');
402
-		}
403
-		$this->objectType = (string) $objectType;
404
-		$this->objectId = (int) $objectId;
405
-		$this->objectName = (string) $objectName;
406
-		return $this;
407
-	}
408
-
409
-	/**
410
-	 * @return string
411
-	 */
412
-	public function getObjectType() {
413
-		return $this->objectType;
414
-	}
415
-
416
-	/**
417
-	 * @return string
418
-	 */
419
-	public function getObjectId() {
420
-		return $this->objectId;
421
-	}
422
-
423
-	/**
424
-	 * @return string
425
-	 */
426
-	public function getObjectName() {
427
-		return $this->objectName;
428
-	}
429
-
430
-	/**
431
-	 * Set the link of the activity
432
-	 *
433
-	 * @param string $link
434
-	 * @return IEvent
435
-	 * @throws \InvalidArgumentException if the link is invalid
436
-	 * @since 8.2.0
437
-	 */
438
-	public function setLink($link) {
439
-		if (!is_string($link) || isset($link[4000])) {
440
-			throw new \InvalidArgumentException('The given link is invalid');
441
-		}
442
-		$this->link = (string) $link;
443
-		return $this;
444
-	}
445
-
446
-	/**
447
-	 * @return string
448
-	 */
449
-	public function getLink() {
450
-		return $this->link;
451
-	}
452
-
453
-	/**
454
-	 * @param string $icon
455
-	 * @return $this
456
-	 * @throws \InvalidArgumentException if the icon is invalid
457
-	 * @since 11.0.0
458
-	 */
459
-	public function setIcon($icon) {
460
-		if (!is_string($icon) || isset($icon[4000])) {
461
-			throw new \InvalidArgumentException('The given icon is invalid');
462
-		}
463
-		$this->icon = $icon;
464
-		return $this;
465
-	}
466
-
467
-	/**
468
-	 * @return string
469
-	 * @since 11.0.0
470
-	 */
471
-	public function getIcon() {
472
-		return $this->icon;
473
-	}
474
-
475
-	/**
476
-	 * @param IEvent $child
477
-	 * @since 11.0.0
478
-	 */
479
-	public function setChildEvent(IEvent $child) {
480
-		$this->child = $child;
481
-	}
482
-
483
-	/**
484
-	 * @return IEvent|null
485
-	 * @since 11.0.0
486
-	 */
487
-	public function getChildEvent() {
488
-		return $this->child;
489
-	}
490
-
491
-	/**
492
-	 * @return bool
493
-	 * @since 8.2.0
494
-	 */
495
-	public function isValid() {
496
-		return
497
-			$this->isValidCommon()
498
-			&&
499
-			$this->getSubject() !== ''
500
-		;
501
-	}
502
-
503
-	/**
504
-	 * @return bool
505
-	 * @since 8.2.0
506
-	 */
507
-	public function isValidParsed() {
508
-		if ($this->getRichSubject() !== '' || !empty($this->getRichSubjectParameters())) {
509
-			try {
510
-				$this->richValidator->validate($this->getRichSubject(), $this->getRichSubjectParameters());
511
-			} catch (InvalidObjectExeption $e) {
512
-				return false;
513
-			}
514
-		}
515
-
516
-		if ($this->getRichMessage() !== '' || !empty($this->getRichMessageParameters())) {
517
-			try {
518
-				$this->richValidator->validate($this->getRichMessage(), $this->getRichMessageParameters());
519
-			} catch (InvalidObjectExeption $e) {
520
-				return false;
521
-			}
522
-		}
523
-
524
-		return
525
-			$this->isValidCommon()
526
-			&&
527
-			$this->getParsedSubject() !== ''
528
-		;
529
-	}
530
-
531
-	/**
532
-	 * @return bool
533
-	 */
534
-	protected function isValidCommon() {
535
-		return
536
-			$this->getApp() !== ''
537
-			&&
538
-			$this->getType() !== ''
539
-			&&
540
-			$this->getAffectedUser() !== ''
541
-			&&
542
-			$this->getTimestamp() !== 0
543
-			/**
544
-			 * Disabled for BC with old activities
33
+    /** @var string */
34
+    protected $app = '';
35
+    /** @var string */
36
+    protected $type = '';
37
+    /** @var string */
38
+    protected $affectedUser = '';
39
+    /** @var string */
40
+    protected $author = '';
41
+    /** @var int */
42
+    protected $timestamp = 0;
43
+    /** @var string */
44
+    protected $subject = '';
45
+    /** @var array */
46
+    protected $subjectParameters = [];
47
+    /** @var string */
48
+    protected $subjectParsed;
49
+    /** @var string */
50
+    protected $subjectRich;
51
+    /** @var array */
52
+    protected $subjectRichParameters;
53
+    /** @var string */
54
+    protected $message = '';
55
+    /** @var array */
56
+    protected $messageParameters = [];
57
+    /** @var string */
58
+    protected $messageParsed;
59
+    /** @var string */
60
+    protected $messageRich;
61
+    /** @var array */
62
+    protected $messageRichParameters;
63
+    /** @var string */
64
+    protected $objectType = '';
65
+    /** @var int */
66
+    protected $objectId = 0;
67
+    /** @var string */
68
+    protected $objectName = '';
69
+    /** @var string */
70
+    protected $link = '';
71
+    /** @var string */
72
+    protected $icon = '';
73
+
74
+    /** @var IEvent */
75
+    protected $child = null;
76
+    /** @var IValidator */
77
+    protected $richValidator;
78
+
79
+    /**
80
+     * @param IValidator $richValidator
81
+     */
82
+    public function __construct(IValidator $richValidator) {
83
+        $this->richValidator = $richValidator;
84
+    }
85
+
86
+    /**
87
+     * Set the app of the activity
88
+     *
89
+     * @param string $app
90
+     * @return IEvent
91
+     * @throws \InvalidArgumentException if the app id is invalid
92
+     * @since 8.2.0
93
+     */
94
+    public function setApp($app) {
95
+        if (!is_string($app) || $app === '' || isset($app[32])) {
96
+            throw new \InvalidArgumentException('The given app is invalid');
97
+        }
98
+        $this->app = (string) $app;
99
+        return $this;
100
+    }
101
+
102
+    /**
103
+     * @return string
104
+     */
105
+    public function getApp() {
106
+        return $this->app;
107
+    }
108
+
109
+    /**
110
+     * Set the type of the activity
111
+     *
112
+     * @param string $type
113
+     * @return IEvent
114
+     * @throws \InvalidArgumentException if the type is invalid
115
+     * @since 8.2.0
116
+     */
117
+    public function setType($type) {
118
+        if (!is_string($type) || $type === '' || isset($type[255])) {
119
+            throw new \InvalidArgumentException('The given type is invalid');
120
+        }
121
+        $this->type = (string) $type;
122
+        return $this;
123
+    }
124
+
125
+    /**
126
+     * @return string
127
+     */
128
+    public function getType() {
129
+        return $this->type;
130
+    }
131
+
132
+    /**
133
+     * Set the affected user of the activity
134
+     *
135
+     * @param string $affectedUser
136
+     * @return IEvent
137
+     * @throws \InvalidArgumentException if the affected user is invalid
138
+     * @since 8.2.0
139
+     */
140
+    public function setAffectedUser($affectedUser) {
141
+        if (!is_string($affectedUser) || $affectedUser === '' || isset($affectedUser[64])) {
142
+            throw new \InvalidArgumentException('The given affected user is invalid');
143
+        }
144
+        $this->affectedUser = (string) $affectedUser;
145
+        return $this;
146
+    }
147
+
148
+    /**
149
+     * @return string
150
+     */
151
+    public function getAffectedUser() {
152
+        return $this->affectedUser;
153
+    }
154
+
155
+    /**
156
+     * Set the author of the activity
157
+     *
158
+     * @param string $author
159
+     * @return IEvent
160
+     * @throws \InvalidArgumentException if the author is invalid
161
+     * @since 8.2.0
162
+     */
163
+    public function setAuthor($author) {
164
+        if (!is_string($author) || isset($author[64])) {
165
+            throw new \InvalidArgumentException('The given author user is invalid'. serialize($author));
166
+        }
167
+        $this->author = (string) $author;
168
+        return $this;
169
+    }
170
+
171
+    /**
172
+     * @return string
173
+     */
174
+    public function getAuthor() {
175
+        return $this->author;
176
+    }
177
+
178
+    /**
179
+     * Set the timestamp of the activity
180
+     *
181
+     * @param int $timestamp
182
+     * @return IEvent
183
+     * @throws \InvalidArgumentException if the timestamp is invalid
184
+     * @since 8.2.0
185
+     */
186
+    public function setTimestamp($timestamp) {
187
+        if (!is_int($timestamp)) {
188
+            throw new \InvalidArgumentException('The given timestamp is invalid');
189
+        }
190
+        $this->timestamp = (int) $timestamp;
191
+        return $this;
192
+    }
193
+
194
+    /**
195
+     * @return int
196
+     */
197
+    public function getTimestamp() {
198
+        return $this->timestamp;
199
+    }
200
+
201
+    /**
202
+     * Set the subject of the activity
203
+     *
204
+     * @param string $subject
205
+     * @param array $parameters
206
+     * @return IEvent
207
+     * @throws \InvalidArgumentException if the subject or parameters are invalid
208
+     * @since 8.2.0
209
+     */
210
+    public function setSubject($subject, array $parameters = []) {
211
+        if (!is_string($subject) || isset($subject[255])) {
212
+            throw new \InvalidArgumentException('The given subject is invalid');
213
+        }
214
+        $this->subject = (string) $subject;
215
+        $this->subjectParameters = $parameters;
216
+        return $this;
217
+    }
218
+
219
+    /**
220
+     * @return string
221
+     */
222
+    public function getSubject() {
223
+        return $this->subject;
224
+    }
225
+
226
+    /**
227
+     * @return array
228
+     */
229
+    public function getSubjectParameters() {
230
+        return $this->subjectParameters;
231
+    }
232
+
233
+    /**
234
+     * @param string $subject
235
+     * @return $this
236
+     * @throws \InvalidArgumentException if the subject is invalid
237
+     * @since 11.0.0
238
+     */
239
+    public function setParsedSubject($subject) {
240
+        if (!is_string($subject) || $subject === '') {
241
+            throw new \InvalidArgumentException('The given parsed subject is invalid');
242
+        }
243
+        $this->subjectParsed = $subject;
244
+        return $this;
245
+    }
246
+
247
+    /**
248
+     * @return string
249
+     * @since 11.0.0
250
+     */
251
+    public function getParsedSubject() {
252
+        return $this->subjectParsed;
253
+    }
254
+
255
+    /**
256
+     * @param string $subject
257
+     * @param array $parameters
258
+     * @return $this
259
+     * @throws \InvalidArgumentException if the subject or parameters are invalid
260
+     * @since 11.0.0
261
+     */
262
+    public function setRichSubject($subject, array $parameters = []) {
263
+        if (!is_string($subject) || $subject === '') {
264
+            throw new \InvalidArgumentException('The given parsed subject is invalid');
265
+        }
266
+        $this->subjectRich = $subject;
267
+
268
+        if (!is_array($parameters)) {
269
+            throw new \InvalidArgumentException('The given subject parameters are invalid');
270
+        }
271
+        $this->subjectRichParameters = $parameters;
272
+
273
+        return $this;
274
+    }
275
+
276
+    /**
277
+     * @return string
278
+     * @since 11.0.0
279
+     */
280
+    public function getRichSubject() {
281
+        return $this->subjectRich;
282
+    }
283
+
284
+    /**
285
+     * @return array[]
286
+     * @since 11.0.0
287
+     */
288
+    public function getRichSubjectParameters() {
289
+        return $this->subjectRichParameters;
290
+    }
291
+
292
+    /**
293
+     * Set the message of the activity
294
+     *
295
+     * @param string $message
296
+     * @param array $parameters
297
+     * @return IEvent
298
+     * @throws \InvalidArgumentException if the message or parameters are invalid
299
+     * @since 8.2.0
300
+     */
301
+    public function setMessage($message, array $parameters = []) {
302
+        if (!is_string($message) || isset($message[255])) {
303
+            throw new \InvalidArgumentException('The given message is invalid');
304
+        }
305
+        $this->message = (string) $message;
306
+        $this->messageParameters = $parameters;
307
+        return $this;
308
+    }
309
+
310
+    /**
311
+     * @return string
312
+     */
313
+    public function getMessage() {
314
+        return $this->message;
315
+    }
316
+
317
+    /**
318
+     * @return array
319
+     */
320
+    public function getMessageParameters() {
321
+        return $this->messageParameters;
322
+    }
323
+
324
+    /**
325
+     * @param string $message
326
+     * @return $this
327
+     * @throws \InvalidArgumentException if the message is invalid
328
+     * @since 11.0.0
329
+     */
330
+    public function setParsedMessage($message) {
331
+        if (!is_string($message)) {
332
+            throw new \InvalidArgumentException('The given parsed message is invalid');
333
+        }
334
+        $this->messageParsed = $message;
335
+        return $this;
336
+    }
337
+
338
+    /**
339
+     * @return string
340
+     * @since 11.0.0
341
+     */
342
+    public function getParsedMessage() {
343
+        return $this->messageParsed;
344
+    }
345
+
346
+    /**
347
+     * @param string $message
348
+     * @param array $parameters
349
+     * @return $this
350
+     * @throws \InvalidArgumentException if the subject or parameters are invalid
351
+     * @since 11.0.0
352
+     */
353
+    public function setRichMessage($message, array $parameters = []) {
354
+        if (!is_string($message)) {
355
+            throw new \InvalidArgumentException('The given parsed message is invalid');
356
+        }
357
+        $this->messageRich = $message;
358
+
359
+        if (!is_array($parameters)) {
360
+            throw new \InvalidArgumentException('The given message parameters are invalid');
361
+        }
362
+        $this->messageRichParameters = $parameters;
363
+
364
+        return $this;
365
+    }
366
+
367
+    /**
368
+     * @return string
369
+     * @since 11.0.0
370
+     */
371
+    public function getRichMessage() {
372
+        return $this->messageRich;
373
+    }
374
+
375
+    /**
376
+     * @return array[]
377
+     * @since 11.0.0
378
+     */
379
+    public function getRichMessageParameters() {
380
+        return $this->messageRichParameters;
381
+    }
382
+
383
+    /**
384
+     * Set the object of the activity
385
+     *
386
+     * @param string $objectType
387
+     * @param int $objectId
388
+     * @param string $objectName
389
+     * @return IEvent
390
+     * @throws \InvalidArgumentException if the object is invalid
391
+     * @since 8.2.0
392
+     */
393
+    public function setObject($objectType, $objectId, $objectName = '') {
394
+        if (!is_string($objectType) || isset($objectType[255])) {
395
+            throw new \InvalidArgumentException('The given object type is invalid');
396
+        }
397
+        if (!is_int($objectId)) {
398
+            throw new \InvalidArgumentException('The given object id is invalid');
399
+        }
400
+        if (!is_string($objectName) || isset($objectName[4000])) {
401
+            throw new \InvalidArgumentException('The given object name is invalid');
402
+        }
403
+        $this->objectType = (string) $objectType;
404
+        $this->objectId = (int) $objectId;
405
+        $this->objectName = (string) $objectName;
406
+        return $this;
407
+    }
408
+
409
+    /**
410
+     * @return string
411
+     */
412
+    public function getObjectType() {
413
+        return $this->objectType;
414
+    }
415
+
416
+    /**
417
+     * @return string
418
+     */
419
+    public function getObjectId() {
420
+        return $this->objectId;
421
+    }
422
+
423
+    /**
424
+     * @return string
425
+     */
426
+    public function getObjectName() {
427
+        return $this->objectName;
428
+    }
429
+
430
+    /**
431
+     * Set the link of the activity
432
+     *
433
+     * @param string $link
434
+     * @return IEvent
435
+     * @throws \InvalidArgumentException if the link is invalid
436
+     * @since 8.2.0
437
+     */
438
+    public function setLink($link) {
439
+        if (!is_string($link) || isset($link[4000])) {
440
+            throw new \InvalidArgumentException('The given link is invalid');
441
+        }
442
+        $this->link = (string) $link;
443
+        return $this;
444
+    }
445
+
446
+    /**
447
+     * @return string
448
+     */
449
+    public function getLink() {
450
+        return $this->link;
451
+    }
452
+
453
+    /**
454
+     * @param string $icon
455
+     * @return $this
456
+     * @throws \InvalidArgumentException if the icon is invalid
457
+     * @since 11.0.0
458
+     */
459
+    public function setIcon($icon) {
460
+        if (!is_string($icon) || isset($icon[4000])) {
461
+            throw new \InvalidArgumentException('The given icon is invalid');
462
+        }
463
+        $this->icon = $icon;
464
+        return $this;
465
+    }
466
+
467
+    /**
468
+     * @return string
469
+     * @since 11.0.0
470
+     */
471
+    public function getIcon() {
472
+        return $this->icon;
473
+    }
474
+
475
+    /**
476
+     * @param IEvent $child
477
+     * @since 11.0.0
478
+     */
479
+    public function setChildEvent(IEvent $child) {
480
+        $this->child = $child;
481
+    }
482
+
483
+    /**
484
+     * @return IEvent|null
485
+     * @since 11.0.0
486
+     */
487
+    public function getChildEvent() {
488
+        return $this->child;
489
+    }
490
+
491
+    /**
492
+     * @return bool
493
+     * @since 8.2.0
494
+     */
495
+    public function isValid() {
496
+        return
497
+            $this->isValidCommon()
498
+            &&
499
+            $this->getSubject() !== ''
500
+        ;
501
+    }
502
+
503
+    /**
504
+     * @return bool
505
+     * @since 8.2.0
506
+     */
507
+    public function isValidParsed() {
508
+        if ($this->getRichSubject() !== '' || !empty($this->getRichSubjectParameters())) {
509
+            try {
510
+                $this->richValidator->validate($this->getRichSubject(), $this->getRichSubjectParameters());
511
+            } catch (InvalidObjectExeption $e) {
512
+                return false;
513
+            }
514
+        }
515
+
516
+        if ($this->getRichMessage() !== '' || !empty($this->getRichMessageParameters())) {
517
+            try {
518
+                $this->richValidator->validate($this->getRichMessage(), $this->getRichMessageParameters());
519
+            } catch (InvalidObjectExeption $e) {
520
+                return false;
521
+            }
522
+        }
523
+
524
+        return
525
+            $this->isValidCommon()
526
+            &&
527
+            $this->getParsedSubject() !== ''
528
+        ;
529
+    }
530
+
531
+    /**
532
+     * @return bool
533
+     */
534
+    protected function isValidCommon() {
535
+        return
536
+            $this->getApp() !== ''
537
+            &&
538
+            $this->getType() !== ''
539
+            &&
540
+            $this->getAffectedUser() !== ''
541
+            &&
542
+            $this->getTimestamp() !== 0
543
+            /**
544
+             * Disabled for BC with old activities
545 545
 			&&
546 546
 			$this->getObjectType() !== ''
547 547
 			&&
548 548
 			$this->getObjectId() !== 0
549
-			 */
550
-		;
551
-	}
549
+             */
550
+        ;
551
+    }
552 552
 }
Please login to merge, or discard this patch.
lib/private/Activity/LegacyFilter.php 1 patch
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -26,83 +26,83 @@
 block discarded – undo
26 26
 
27 27
 class LegacyFilter implements IFilter {
28 28
 
29
-	/** @var IManager */
30
-	protected $manager;
31
-	/** @var string */
32
-	protected $identifier;
33
-	/** @var string */
34
-	protected $name;
35
-	/** @var bool */
36
-	protected $isTopFilter;
29
+    /** @var IManager */
30
+    protected $manager;
31
+    /** @var string */
32
+    protected $identifier;
33
+    /** @var string */
34
+    protected $name;
35
+    /** @var bool */
36
+    protected $isTopFilter;
37 37
 
38
-	/**
39
-	 * LegacySetting constructor.
40
-	 *
41
-	 * @param IManager $manager
42
-	 * @param string $identifier
43
-	 * @param string $name
44
-	 * @param bool $isTopFilter
45
-	 */
46
-	public function __construct(IManager $manager,
47
-								$identifier,
48
-								$name,
49
-								$isTopFilter) {
50
-		$this->manager = $manager;
51
-		$this->identifier = $identifier;
52
-		$this->name = $name;
53
-		$this->isTopFilter = $isTopFilter;
54
-	}
38
+    /**
39
+     * LegacySetting constructor.
40
+     *
41
+     * @param IManager $manager
42
+     * @param string $identifier
43
+     * @param string $name
44
+     * @param bool $isTopFilter
45
+     */
46
+    public function __construct(IManager $manager,
47
+                                $identifier,
48
+                                $name,
49
+                                $isTopFilter) {
50
+        $this->manager = $manager;
51
+        $this->identifier = $identifier;
52
+        $this->name = $name;
53
+        $this->isTopFilter = $isTopFilter;
54
+    }
55 55
 
56
-	/**
57
-	 * @return string Lowercase a-z and underscore only identifier
58
-	 * @since 11.0.0
59
-	 */
60
-	public function getIdentifier() {
61
-		return $this->identifier;
62
-	}
56
+    /**
57
+     * @return string Lowercase a-z and underscore only identifier
58
+     * @since 11.0.0
59
+     */
60
+    public function getIdentifier() {
61
+        return $this->identifier;
62
+    }
63 63
 
64
-	/**
65
-	 * @return string A translated string
66
-	 * @since 11.0.0
67
-	 */
68
-	public function getName() {
69
-		return $this->name;
70
-	}
64
+    /**
65
+     * @return string A translated string
66
+     * @since 11.0.0
67
+     */
68
+    public function getName() {
69
+        return $this->name;
70
+    }
71 71
 
72
-	/**
73
-	 * @return int whether the filter should be rather on the top or bottom of
74
-	 * the admin section. The filters are arranged in ascending order of the
75
-	 * priority values. It is required to return a value between 0 and 100.
76
-	 * @since 11.0.0
77
-	 */
78
-	public function getPriority() {
79
-		return $this->isTopFilter ? 40 : 50;
80
-	}
72
+    /**
73
+     * @return int whether the filter should be rather on the top or bottom of
74
+     * the admin section. The filters are arranged in ascending order of the
75
+     * priority values. It is required to return a value between 0 and 100.
76
+     * @since 11.0.0
77
+     */
78
+    public function getPriority() {
79
+        return $this->isTopFilter ? 40 : 50;
80
+    }
81 81
 
82
-	/**
83
-	 * @return string Full URL to an icon, empty string when none is given
84
-	 * @since 11.0.0
85
-	 */
86
-	public function getIcon() {
87
-		// Old API was CSS class, so we can not use this...
88
-		return '';
89
-	}
82
+    /**
83
+     * @return string Full URL to an icon, empty string when none is given
84
+     * @since 11.0.0
85
+     */
86
+    public function getIcon() {
87
+        // Old API was CSS class, so we can not use this...
88
+        return '';
89
+    }
90 90
 
91
-	/**
92
-	 * @param string[] $types
93
-	 * @return string[] An array of allowed apps from which activities should be displayed
94
-	 * @since 11.0.0
95
-	 */
96
-	public function filterTypes(array $types) {
97
-		return $this->manager->filterNotificationTypes($types, $this->getIdentifier());
98
-	}
91
+    /**
92
+     * @param string[] $types
93
+     * @return string[] An array of allowed apps from which activities should be displayed
94
+     * @since 11.0.0
95
+     */
96
+    public function filterTypes(array $types) {
97
+        return $this->manager->filterNotificationTypes($types, $this->getIdentifier());
98
+    }
99 99
 
100
-	/**
101
-	 * @return string[] An array of allowed apps from which activities should be displayed
102
-	 * @since 11.0.0
103
-	 */
104
-	public function allowedApps() {
105
-		return [];
106
-	}
100
+    /**
101
+     * @return string[] An array of allowed apps from which activities should be displayed
102
+     * @since 11.0.0
103
+     */
104
+    public function allowedApps() {
105
+        return [];
106
+    }
107 107
 }
108 108
 
Please login to merge, or discard this patch.
lib/private/Activity/LegacySetting.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -25,99 +25,99 @@
 block discarded – undo
25 25
 
26 26
 class LegacySetting implements ISetting {
27 27
 
28
-	/** @var string */
29
-	protected $identifier;
30
-	/** @var string */
31
-	protected $name;
32
-	/** @var bool */
33
-	protected $canChangeStream;
34
-	/** @var bool */
35
-	protected $isDefaultEnabledStream;
36
-	/** @var bool */
37
-	protected $canChangeMail;
38
-	/** @var bool */
39
-	protected $isDefaultEnabledMail;
28
+    /** @var string */
29
+    protected $identifier;
30
+    /** @var string */
31
+    protected $name;
32
+    /** @var bool */
33
+    protected $canChangeStream;
34
+    /** @var bool */
35
+    protected $isDefaultEnabledStream;
36
+    /** @var bool */
37
+    protected $canChangeMail;
38
+    /** @var bool */
39
+    protected $isDefaultEnabledMail;
40 40
 
41
-	/**
42
-	 * LegacySetting constructor.
43
-	 *
44
-	 * @param string $identifier
45
-	 * @param string $name
46
-	 * @param bool $canChangeStream
47
-	 * @param bool $isDefaultEnabledStream
48
-	 * @param bool $canChangeMail
49
-	 * @param bool $isDefaultEnabledMail
50
-	 */
51
-	public function __construct($identifier,
52
-								$name,
53
-								$canChangeStream,
54
-								$isDefaultEnabledStream,
55
-								$canChangeMail,
56
-								$isDefaultEnabledMail) {
57
-		$this->identifier = $identifier;
58
-		$this->name = $name;
59
-		$this->canChangeStream = $canChangeStream;
60
-		$this->isDefaultEnabledStream = $isDefaultEnabledStream;
61
-		$this->canChangeMail = $canChangeMail;
62
-		$this->isDefaultEnabledMail = $isDefaultEnabledMail;
63
-	}
41
+    /**
42
+     * LegacySetting constructor.
43
+     *
44
+     * @param string $identifier
45
+     * @param string $name
46
+     * @param bool $canChangeStream
47
+     * @param bool $isDefaultEnabledStream
48
+     * @param bool $canChangeMail
49
+     * @param bool $isDefaultEnabledMail
50
+     */
51
+    public function __construct($identifier,
52
+                                $name,
53
+                                $canChangeStream,
54
+                                $isDefaultEnabledStream,
55
+                                $canChangeMail,
56
+                                $isDefaultEnabledMail) {
57
+        $this->identifier = $identifier;
58
+        $this->name = $name;
59
+        $this->canChangeStream = $canChangeStream;
60
+        $this->isDefaultEnabledStream = $isDefaultEnabledStream;
61
+        $this->canChangeMail = $canChangeMail;
62
+        $this->isDefaultEnabledMail = $isDefaultEnabledMail;
63
+    }
64 64
 
65
-	/**
66
-	 * @return string Lowercase a-z and underscore only identifier
67
-	 * @since 11.0.0
68
-	 */
69
-	public function getIdentifier() {
70
-		return $this->identifier;
71
-	}
65
+    /**
66
+     * @return string Lowercase a-z and underscore only identifier
67
+     * @since 11.0.0
68
+     */
69
+    public function getIdentifier() {
70
+        return $this->identifier;
71
+    }
72 72
 
73
-	/**
74
-	 * @return string A translated string
75
-	 * @since 11.0.0
76
-	 */
77
-	public function getName() {
78
-		return $this->name;
79
-	}
73
+    /**
74
+     * @return string A translated string
75
+     * @since 11.0.0
76
+     */
77
+    public function getName() {
78
+        return $this->name;
79
+    }
80 80
 
81
-	/**
82
-	 * @return int whether the filter should be rather on the top or bottom of
83
-	 * the admin section. The filters are arranged in ascending order of the
84
-	 * priority values. It is required to return a value between 0 and 100.
85
-	 * @since 11.0.0
86
-	 */
87
-	public function getPriority() {
88
-		return 70;
89
-	}
81
+    /**
82
+     * @return int whether the filter should be rather on the top or bottom of
83
+     * the admin section. The filters are arranged in ascending order of the
84
+     * priority values. It is required to return a value between 0 and 100.
85
+     * @since 11.0.0
86
+     */
87
+    public function getPriority() {
88
+        return 70;
89
+    }
90 90
 
91
-	/**
92
-	 * @return bool True when the option can be changed for the stream
93
-	 * @since 11.0.0
94
-	 */
95
-	public function canChangeStream() {
96
-		return $this->canChangeStream;
97
-	}
91
+    /**
92
+     * @return bool True when the option can be changed for the stream
93
+     * @since 11.0.0
94
+     */
95
+    public function canChangeStream() {
96
+        return $this->canChangeStream;
97
+    }
98 98
 
99
-	/**
100
-	 * @return bool True when the option can be changed for the stream
101
-	 * @since 11.0.0
102
-	 */
103
-	public function isDefaultEnabledStream() {
104
-		return $this->isDefaultEnabledStream;
105
-	}
99
+    /**
100
+     * @return bool True when the option can be changed for the stream
101
+     * @since 11.0.0
102
+     */
103
+    public function isDefaultEnabledStream() {
104
+        return $this->isDefaultEnabledStream;
105
+    }
106 106
 
107
-	/**
108
-	 * @return bool True when the option can be changed for the mail
109
-	 * @since 11.0.0
110
-	 */
111
-	public function canChangeMail() {
112
-		return $this->canChangeMail;
113
-	}
107
+    /**
108
+     * @return bool True when the option can be changed for the mail
109
+     * @since 11.0.0
110
+     */
111
+    public function canChangeMail() {
112
+        return $this->canChangeMail;
113
+    }
114 114
 
115
-	/**
116
-	 * @return bool True when the option can be changed for the stream
117
-	 * @since 11.0.0
118
-	 */
119
-	public function isDefaultEnabledMail() {
120
-		return $this->isDefaultEnabledMail;
121
-	}
115
+    /**
116
+     * @return bool True when the option can be changed for the stream
117
+     * @since 11.0.0
118
+     */
119
+    public function isDefaultEnabledMail() {
120
+        return $this->isDefaultEnabledMail;
121
+    }
122 122
 }
123 123
 
Please login to merge, or discard this patch.
lib/private/Security/CSP/ContentSecurityPolicyNonceManager.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -29,52 +29,52 @@
 block discarded – undo
29 29
  * @package OC\Security\CSP
30 30
  */
31 31
 class ContentSecurityPolicyNonceManager {
32
-	/** @var CsrfTokenManager */
33
-	private $csrfTokenManager;
34
-	/** @var IRequest */
35
-	private $request;
36
-	/** @var string */
37
-	private $nonce = '';
32
+    /** @var CsrfTokenManager */
33
+    private $csrfTokenManager;
34
+    /** @var IRequest */
35
+    private $request;
36
+    /** @var string */
37
+    private $nonce = '';
38 38
 
39
-	/**
40
-	 * @param CsrfTokenManager $csrfTokenManager
41
-	 * @param IRequest $request
42
-	 */
43
-	public function __construct(CsrfTokenManager $csrfTokenManager,
44
-								IRequest $request) {
45
-		$this->csrfTokenManager = $csrfTokenManager;
46
-		$this->request = $request;
47
-	}
39
+    /**
40
+     * @param CsrfTokenManager $csrfTokenManager
41
+     * @param IRequest $request
42
+     */
43
+    public function __construct(CsrfTokenManager $csrfTokenManager,
44
+                                IRequest $request) {
45
+        $this->csrfTokenManager = $csrfTokenManager;
46
+        $this->request = $request;
47
+    }
48 48
 
49
-	/**
50
-	 * Returns the current CSP nounce
51
-	 *
52
-	 * @return string
53
-	 */
54
-	public function getNonce() {
55
-		if($this->nonce === '') {
56
-			$this->nonce = base64_encode($this->csrfTokenManager->getToken()->getEncryptedValue());
57
-		}
49
+    /**
50
+     * Returns the current CSP nounce
51
+     *
52
+     * @return string
53
+     */
54
+    public function getNonce() {
55
+        if($this->nonce === '') {
56
+            $this->nonce = base64_encode($this->csrfTokenManager->getToken()->getEncryptedValue());
57
+        }
58 58
 
59
-		return $this->nonce;
60
-	}
59
+        return $this->nonce;
60
+    }
61 61
 
62
-	/**
63
-	 * Check if the browser supports CSP v3
64
-	 *
65
-	 * @return bool
66
-	 */
67
-	public function browserSupportsCspV3() {
68
-		$browserWhitelist = [
69
-			Request::USER_AGENT_CHROME,
70
-			// Firefox 45+
71
-			'/^Mozilla\/5\.0 \([^)]+\) Gecko\/[0-9.]+ Firefox\/(4[5-9]|[5-9][0-9])\.[0-9.]+$/',
72
-		];
62
+    /**
63
+     * Check if the browser supports CSP v3
64
+     *
65
+     * @return bool
66
+     */
67
+    public function browserSupportsCspV3() {
68
+        $browserWhitelist = [
69
+            Request::USER_AGENT_CHROME,
70
+            // Firefox 45+
71
+            '/^Mozilla\/5\.0 \([^)]+\) Gecko\/[0-9.]+ Firefox\/(4[5-9]|[5-9][0-9])\.[0-9.]+$/',
72
+        ];
73 73
 
74
-		if($this->request->isUserAgent($browserWhitelist)) {
75
-			return true;
76
-		}
74
+        if($this->request->isUserAgent($browserWhitelist)) {
75
+            return true;
76
+        }
77 77
 
78
-		return false;
79
-	}
78
+        return false;
79
+    }
80 80
 }
Please login to merge, or discard this patch.