Code Duplication    Length = 38-40 lines in 2 locations

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

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

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

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