Code Duplication    Length = 40-42 lines in 2 locations

apps/dav/lib/CalDAV/Calendar.php 1 location

@@ 112-153 (lines=42) @@
109
		return $this->calendarInfo['principaluri'];
110
	}
111
112
	public function getACL() {
113
		$acl =  [
114
			[
115
				'privilege' => '{DAV:}read',
116
				'principal' => $this->getOwner(),
117
				'protected' => true,
118
			]];
119
		if ($this->getName() !== BirthdayService::BIRTHDAY_CALENDAR_URI) {
120
			$acl[] = [
121
				'privilege' => '{DAV:}write',
122
				'principal' => $this->getOwner(),
123
				'protected' => true,
124
			];
125
		}
126
		if ($this->getOwner() !== parent::getOwner()) {
127
			$acl[] =  [
128
					'privilege' => '{DAV:}read',
129
					'principal' => parent::getOwner(),
130
					'protected' => true,
131
				];
132
			if ($this->canWrite()) {
133
				$acl[] = [
134
					'privilege' => '{DAV:}write',
135
					'principal' => parent::getOwner(),
136
					'protected' => true,
137
				];
138
			}
139
		}
140
		if ($this->isPublic()) {
141
			$acl[] = [
142
				'privilege' => '{DAV:}read',
143
				'principal' => 'principals/system/public',
144
				'protected' => true,
145
			];
146
		}
147
148
		if ($this->isShared()) {
149
			return $acl;
150
		}
151
152
		return $this->caldavBackend->applyShareAcl($this->getResourceId(), $acl);
153
	}
154
155
	public function getChildACL() {
156
		return $this->getACL();

apps/dav/lib/CardDAV/AddressBook.php 1 location

@@ 101-140 (lines=40) @@
98
		return $this->carddavBackend->getShares($this->getResourceId());
99
	}
100
101
	public function getACL() {
102
		$acl =  [
103
			[
104
				'privilege' => '{DAV:}read',
105
				'principal' => $this->getOwner(),
106
				'protected' => true,
107
			]];
108
		$acl[] = [
109
				'privilege' => '{DAV:}write',
110
				'principal' => $this->getOwner(),
111
				'protected' => true,
112
			];
113
		if ($this->getOwner() !== parent::getOwner()) {
114
			$acl[] =  [
115
					'privilege' => '{DAV:}read',
116
					'principal' => parent::getOwner(),
117
					'protected' => true,
118
				];
119
			if ($this->canWrite()) {
120
				$acl[] = [
121
					'privilege' => '{DAV:}write',
122
					'principal' => parent::getOwner(),
123
					'protected' => true,
124
				];
125
			}
126
		}
127
		if ($this->getOwner() === 'principals/system/system') {
128
			$acl[] = [
129
					'privilege' => '{DAV:}read',
130
					'principal' => '{DAV:}authenticated',
131
					'protected' => true,
132
			];
133
		}
134
135
		if ($this->isShared()) {
136
			return $acl;
137
		}
138
139
		return $this->carddavBackend->applyShareAcl($this->getResourceId(), $acl);
140
	}
141
142
	public function getChildACL() {
143
		return $this->getACL();