Code Duplication    Length = 23-23 lines in 2 locations

code/model/DNEnvironment.php 2 locations

@@ 384-406 (lines=23) @@
381
	 * @param Member|null $member The {@link Member} object to test against. If null, uses Member::currentMember();
382
	 * @return boolean true if $member can backup, and false if they can't.
383
	 */
384
	public function canBackup($member = null) {
385
		$project = $this->Project();
386
		if ($project->HasDiskQuota() && $project->HasExceededDiskQuota()) {
387
			return false;
388
		}
389
390
		if (!$member) {
391
			$member = Member::currentUser();
392
		}
393
		// Must be logged in to check permissions
394
		if (!$member) {
395
			return false;
396
		}
397
398
		if ($this->Usage === self::PRODUCTION || $this->Usage === self::UNSPECIFIED) {
399
			if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) {
400
				return true;
401
			}
402
		} else {
403
			if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) {
404
				return true;
405
			}
406
		}
407
408
		return $this->CanBackupMembers()->byID($member->ID)
409
			|| $member->inGroups($this->CanBackupGroups());
@@ 423-445 (lines=23) @@
420
	 * @param Member|null $member The {@link Member} object to test against. If null, uses Member::currentMember();
421
	 * @return boolean true if $member can upload archives linked to this environment, false if they can't.
422
	 */
423
	public function canUploadArchive($member = null) {
424
		$project = $this->Project();
425
		if ($project->HasDiskQuota() && $project->HasExceededDiskQuota()) {
426
			return false;
427
		}
428
429
		if (!$member) {
430
			$member = Member::currentUser();
431
		}
432
		if (!$member) {
433
			return false;
434
		}
435
		// Must be logged in to check permissions
436
437
		if ($this->Usage === self::PRODUCTION || $this->Usage === self::UNSPECIFIED) {
438
			if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) {
439
				return true;
440
			}
441
		} else {
442
			if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) {
443
				return true;
444
			}
445
		}
446
447
		return $this->ArchiveUploaders()->byID($member->ID)
448
			|| $member->inGroups($this->ArchiveUploaderGroups());