Code Duplication    Length = 38-40 lines in 2 locations

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

@@ 99-138 (lines=40) @@
96
		return $this->calendarInfo['principaluri'];
97
	}
98
99
	function getACL() {
100
		$acl =  [
101
			[
102
				'privilege' => '{DAV:}read',
103
				'principal' => $this->getOwner(),
104
				'protected' => true,
105
			]];
106
		if ($this->getName() !== BirthdayService::BIRTHDAY_CALENDAR_URI) {
107
			$acl[] = [
108
				'privilege' => '{DAV:}write',
109
				'principal' => $this->getOwner(),
110
				'protected' => true,
111
			];
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->isPublic()) {
128
			$acl[] = [
129
				'privilege' => '{DAV:}read',
130
				'principal' => 'principals/system/public',
131
				'protected' => true,
132
			];
133
		}
134
135
		/** @var CalDavBackend $calDavBackend */
136
		$calDavBackend = $this->caldavBackend;
137
		return $calDavBackend->applyShareAcl($this->getResourceId(), $acl);
138
	}
139
140
	function getChildACL() {
141
		return $this->getACL();

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

@@ 74-111 (lines=38) @@
71
		return $carddavBackend->getShares($this->getResourceId());
72
	}
73
74
	function getACL() {
75
		$acl =  [
76
			[
77
				'privilege' => '{DAV:}read',
78
				'principal' => $this->getOwner(),
79
				'protected' => true,
80
			]];
81
		$acl[] = [
82
				'privilege' => '{DAV:}write',
83
				'principal' => $this->getOwner(),
84
				'protected' => true,
85
			];
86
		if ($this->getOwner() !== parent::getOwner()) {
87
			$acl[] =  [
88
					'privilege' => '{DAV:}read',
89
					'principal' => parent::getOwner(),
90
					'protected' => true,
91
				];
92
			if ($this->canWrite()) {
93
				$acl[] = [
94
					'privilege' => '{DAV:}write',
95
					'principal' => parent::getOwner(),
96
					'protected' => true,
97
				];
98
			}
99
		}
100
		if ($this->getOwner() === 'principals/system/system') {
101
			$acl[] = [
102
					'privilege' => '{DAV:}read',
103
					'principal' => '{DAV:}authenticated',
104
					'protected' => true,
105
			];
106
		}
107
108
		/** @var CardDavBackend $carddavBackend */
109
		$carddavBackend = $this->carddavBackend;
110
		return $carddavBackend->applyShareAcl($this->getResourceId(), $acl);
111
	}
112
113
	function getChildACL() {
114
		return $this->getACL();