@@ -75,6 +75,7 @@ discard block |
||
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
| 78 | + * @param string $code |
|
| 78 | 79 | */ |
| 79 | 80 | public function setActionCode($code) { |
| 80 | 81 | $this->actionCode = $code; |
@@ -89,6 +90,7 @@ discard block |
||
| 89 | 90 | |
| 90 | 91 | /** |
| 91 | 92 | * @param int |
| 93 | + * @param string $seconds |
|
| 92 | 94 | */ |
| 93 | 95 | public function setEstimatedTime($seconds) { |
| 94 | 96 | $this->estimatedTime = $seconds; |
@@ -130,10 +130,10 @@ |
||
| 130 | 130 | */ |
| 131 | 131 | public function getChangesModificationNeeded() { |
| 132 | 132 | $filtered = []; |
| 133 | - foreach ($this->changes as $change => $details) { |
|
| 134 | - if (array_key_exists('description', $details)) { |
|
| 133 | + foreach($this->changes as $change => $details) { |
|
| 134 | + if(array_key_exists('description', $details)) { |
|
| 135 | 135 | $filtered[$change] = $details; |
| 136 | - } else if ( |
|
| 136 | + } else if( |
|
| 137 | 137 | (array_key_exists('from', $details) || array_key_exists('to', $details)) |
| 138 | 138 | && $details['from'] !== $details['to'] |
| 139 | 139 | ) { |
@@ -110,8 +110,12 @@ |
||
| 110 | 110 | // Normalise "empty" values into dashes so comparisons are done properly. |
| 111 | 111 | // This means there is no diference between an empty string and a null |
| 112 | 112 | // but "0" is considered to be non-empty. |
| 113 | - if(empty($from) && !strlen($from)) $from = '-'; |
|
| 114 | - if(empty($to) && !strlen($to)) $to = '-'; |
|
| 113 | + if(empty($from) && !strlen($from)) { |
|
| 114 | + $from = '-'; |
|
| 115 | + } |
|
| 116 | + if(empty($to) && !strlen($to)) { |
|
| 117 | + $to = '-'; |
|
| 118 | + } |
|
| 115 | 119 | |
| 116 | 120 | return $this->changes[$title] = array( |
| 117 | 121 | 'from' => $from, |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | class FrontendLink extends DataExtension { |
| 4 | 4 | |
| 5 | 5 | public function updateItemEditForm($form) { |
| 6 | - if ($this->owner->record->hasMethod('Link')) { |
|
| 6 | + if($this->owner->record->hasMethod('Link')) { |
|
| 7 | 7 | $link = sprintf( |
| 8 | 8 | '<a style="margin: 0.5em" target="deploynaut-frontend" href="%s">Preview »</a>', |
| 9 | 9 | $this->owner->record->Link() |
@@ -386,9 +386,13 @@ discard block |
||
| 386 | 386 | // Must be logged in to check permissions |
| 387 | 387 | |
| 388 | 388 | if ($this->Usage==='Production' || $this->Usage==='Unspecified') { |
| 389 | - if ($this->Project()->allowed(DNRoot::ALLOW_PROD_DEPLOYMENT, $member)) return true; |
|
| 389 | + if ($this->Project()->allowed(DNRoot::ALLOW_PROD_DEPLOYMENT, $member)) { |
|
| 390 | + return true; |
|
| 391 | + } |
|
| 390 | 392 | } else { |
| 391 | - if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_DEPLOYMENT, $member)) return true; |
|
| 393 | + if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_DEPLOYMENT, $member)) { |
|
| 394 | + return true; |
|
| 395 | + } |
|
| 392 | 396 | } |
| 393 | 397 | |
| 394 | 398 | return $this->Deployers()->byID($member->ID) |
@@ -412,9 +416,13 @@ discard block |
||
| 412 | 416 | // Must be logged in to check permissions |
| 413 | 417 | |
| 414 | 418 | if ($this->Usage==='Production' || $this->Usage==='Unspecified') { |
| 415 | - if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true; |
|
| 419 | + if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) { |
|
| 420 | + return true; |
|
| 421 | + } |
|
| 416 | 422 | } else { |
| 417 | - if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true; |
|
| 423 | + if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) { |
|
| 424 | + return true; |
|
| 425 | + } |
|
| 418 | 426 | } |
| 419 | 427 | |
| 420 | 428 | return $this->CanRestoreMembers()->byID($member->ID) |
@@ -443,9 +451,13 @@ discard block |
||
| 443 | 451 | } |
| 444 | 452 | |
| 445 | 453 | if ($this->Usage==='Production' || $this->Usage==='Unspecified') { |
| 446 | - if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true; |
|
| 454 | + if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) { |
|
| 455 | + return true; |
|
| 456 | + } |
|
| 447 | 457 | } else { |
| 448 | - if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true; |
|
| 458 | + if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) { |
|
| 459 | + return true; |
|
| 460 | + } |
|
| 449 | 461 | } |
| 450 | 462 | |
| 451 | 463 | return $this->CanBackupMembers()->byID($member->ID) |
@@ -478,9 +490,13 @@ discard block |
||
| 478 | 490 | // Must be logged in to check permissions |
| 479 | 491 | |
| 480 | 492 | if ($this->Usage==='Production' || $this->Usage==='Unspecified') { |
| 481 | - if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true; |
|
| 493 | + if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) { |
|
| 494 | + return true; |
|
| 495 | + } |
|
| 482 | 496 | } else { |
| 483 | - if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true; |
|
| 497 | + if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) { |
|
| 498 | + return true; |
|
| 499 | + } |
|
| 484 | 500 | } |
| 485 | 501 | |
| 486 | 502 | return $this->ArchiveUploaders()->byID($member->ID) |
@@ -504,9 +520,13 @@ discard block |
||
| 504 | 520 | // Must be logged in to check permissions |
| 505 | 521 | |
| 506 | 522 | if ($this->Usage==='Production' || $this->Usage==='Unspecified') { |
| 507 | - if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true; |
|
| 523 | + if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) { |
|
| 524 | + return true; |
|
| 525 | + } |
|
| 508 | 526 | } else { |
| 509 | - if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true; |
|
| 527 | + if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) { |
|
| 528 | + return true; |
|
| 529 | + } |
|
| 510 | 530 | } |
| 511 | 531 | |
| 512 | 532 | return $this->ArchiveDownloaders()->byID($member->ID) |
@@ -573,9 +593,13 @@ discard block |
||
| 573 | 593 | // Must be logged in to check permissions |
| 574 | 594 | |
| 575 | 595 | if ($this->Usage==='Production' || $this->Usage==='Unspecified') { |
| 576 | - if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true; |
|
| 596 | + if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) { |
|
| 597 | + return true; |
|
| 598 | + } |
|
| 577 | 599 | } else { |
| 578 | - if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true; |
|
| 600 | + if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) { |
|
| 601 | + return true; |
|
| 602 | + } |
|
| 579 | 603 | } |
| 580 | 604 | |
| 581 | 605 | return $this->ArchiveDeleters()->byID($member->ID) |
@@ -954,7 +954,7 @@ |
||
| 954 | 954 | to other environments, alongside the "Who can restore" permission.<br> |
| 955 | 955 | Should include all users with upload permissions, otherwise they can't download |
| 956 | 956 | their own uploads. |
| 957 | -PHP |
|
| 957 | +php |
|
| 958 | 958 | ), |
| 959 | 959 | |
| 960 | 960 | // The Main.PipelineApprovers |
@@ -311,10 +311,10 @@ discard block |
||
| 311 | 311 | } |
| 312 | 312 | // Must be logged in to check permissions |
| 313 | 313 | |
| 314 | - if ($this->Usage === self::PRODUCTION || $this->Usage === self::UNSPECIFIED) { |
|
| 315 | - if ($this->Project()->allowed(DNRoot::ALLOW_PROD_DEPLOYMENT, $member)) return true; |
|
| 314 | + if($this->Usage === self::PRODUCTION || $this->Usage === self::UNSPECIFIED) { |
|
| 315 | + if($this->Project()->allowed(DNRoot::ALLOW_PROD_DEPLOYMENT, $member)) return true; |
|
| 316 | 316 | } else { |
| 317 | - if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_DEPLOYMENT, $member)) return true; |
|
| 317 | + if($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_DEPLOYMENT, $member)) return true; |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | return $this->Deployers()->byID($member->ID) |
@@ -346,10 +346,10 @@ discard block |
||
| 346 | 346 | } |
| 347 | 347 | // Must be logged in to check permissions |
| 348 | 348 | |
| 349 | - if ($this->Usage === self::PRODUCTION || $this->Usage === self::UNSPECIFIED) { |
|
| 350 | - if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true; |
|
| 349 | + if($this->Usage === self::PRODUCTION || $this->Usage === self::UNSPECIFIED) { |
|
| 350 | + if($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true; |
|
| 351 | 351 | } else { |
| 352 | - if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true; |
|
| 352 | + if($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true; |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | return $this->CanRestoreMembers()->byID($member->ID) |
@@ -377,10 +377,10 @@ discard block |
||
| 377 | 377 | return false; |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | - if ($this->Usage === self::PRODUCTION || $this->Usage === self::UNSPECIFIED) { |
|
| 381 | - if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true; |
|
| 380 | + if($this->Usage === self::PRODUCTION || $this->Usage === self::UNSPECIFIED) { |
|
| 381 | + if($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true; |
|
| 382 | 382 | } else { |
| 383 | - if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true; |
|
| 383 | + if($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true; |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | return $this->CanBackupMembers()->byID($member->ID) |
@@ -412,10 +412,10 @@ discard block |
||
| 412 | 412 | } |
| 413 | 413 | // Must be logged in to check permissions |
| 414 | 414 | |
| 415 | - if ($this->Usage === self::PRODUCTION || $this->Usage === self::UNSPECIFIED) { |
|
| 416 | - if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true; |
|
| 415 | + if($this->Usage === self::PRODUCTION || $this->Usage === self::UNSPECIFIED) { |
|
| 416 | + if($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true; |
|
| 417 | 417 | } else { |
| 418 | - if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true; |
|
| 418 | + if($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true; |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | return $this->ArchiveUploaders()->byID($member->ID) |
@@ -438,10 +438,10 @@ discard block |
||
| 438 | 438 | } |
| 439 | 439 | // Must be logged in to check permissions |
| 440 | 440 | |
| 441 | - if ($this->Usage === self::PRODUCTION || $this->Usage === self::UNSPECIFIED) { |
|
| 442 | - if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true; |
|
| 441 | + if($this->Usage === self::PRODUCTION || $this->Usage === self::UNSPECIFIED) { |
|
| 442 | + if($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true; |
|
| 443 | 443 | } else { |
| 444 | - if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true; |
|
| 444 | + if($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true; |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | return $this->ArchiveDownloaders()->byID($member->ID) |
@@ -464,10 +464,10 @@ discard block |
||
| 464 | 464 | } |
| 465 | 465 | // Must be logged in to check permissions |
| 466 | 466 | |
| 467 | - if ($this->Usage === self::PRODUCTION || $this->Usage === self::UNSPECIFIED) { |
|
| 468 | - if ($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true; |
|
| 467 | + if($this->Usage === self::PRODUCTION || $this->Usage === self::UNSPECIFIED) { |
|
| 468 | + if($this->Project()->allowed(DNRoot::ALLOW_PROD_SNAPSHOT, $member)) return true; |
|
| 469 | 469 | } else { |
| 470 | - if ($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true; |
|
| 470 | + if($this->Project()->allowed(DNRoot::ALLOW_NON_PROD_SNAPSHOT, $member)) return true; |
|
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | return $this->ArchiveDeleters()->byID($member->ID) |
@@ -804,7 +804,7 @@ discard block |
||
| 804 | 804 | ->buildPermissionField('ArchiveUploaderGroups', 'ArchiveUploaders', $groups, $members) |
| 805 | 805 | ->setTitle('Who can upload?') |
| 806 | 806 | ->setDescription( |
| 807 | - 'Users who can upload archives linked to this environment into Deploynaut.<br />' . |
|
| 807 | + 'Users who can upload archives linked to this environment into Deploynaut.<br />'. |
|
| 808 | 808 | 'Linking them to an environment allows limiting download permissions (see below).' |
| 809 | 809 | ), |
| 810 | 810 | |
@@ -851,7 +851,7 @@ discard block |
||
| 851 | 851 | // Add actions |
| 852 | 852 | $action = new FormAction('check', 'Check Connection'); |
| 853 | 853 | $action->setUseButtonTag(true); |
| 854 | - $dataURL = Director::absoluteBaseURL() . 'naut/api/' . $this->Project()->Name . '/' . $this->Name . '/ping'; |
|
| 854 | + $dataURL = Director::absoluteBaseURL().'naut/api/'.$this->Project()->Name.'/'.$this->Name.'/ping'; |
|
| 855 | 855 | $action->setAttribute('data-url', $dataURL); |
| 856 | 856 | $fields->insertBefore($action, 'Name'); |
| 857 | 857 | |
@@ -888,8 +888,8 @@ discard block |
||
| 888 | 888 | */ |
| 889 | 889 | public function onBeforeWrite() { |
| 890 | 890 | parent::onBeforeWrite(); |
| 891 | - if($this->Name && $this->Name . '.rb' != $this->Filename) { |
|
| 892 | - $this->Filename = $this->Name . '.rb'; |
|
| 891 | + if($this->Name && $this->Name.'.rb' != $this->Filename) { |
|
| 892 | + $this->Filename = $this->Name.'.rb'; |
|
| 893 | 893 | } |
| 894 | 894 | $this->checkEnvironmentPath(); |
| 895 | 895 | $this->writeConfigFile(); |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | && $this->Filename |
| 937 | 937 | && $this->CreateEnvConfig |
| 938 | 938 | ) { |
| 939 | - $templateFile = $this->config()->template_file ?: BASE_PATH . '/deploynaut/environment.template'; |
|
| 939 | + $templateFile = $this->config()->template_file ?: BASE_PATH.'/deploynaut/environment.template'; |
|
| 940 | 940 | file_put_contents($this->getConfigFilename(), file_get_contents($templateFile)); |
| 941 | 941 | } else if($this->envFileExists() && $this->DeployConfig) { |
| 942 | 942 | file_put_contents($this->getConfigFilename(), $this->DeployConfig); |
@@ -991,7 +991,7 @@ discard block |
||
| 991 | 991 | if(!$this->Filename) { |
| 992 | 992 | return ''; |
| 993 | 993 | } |
| 994 | - return $this->DNData()->getEnvironmentDir() . '/' . $this->Project()->Name . '/' . $this->Filename; |
|
| 994 | + return $this->DNData()->getEnvironmentDir().'/'.$this->Project()->Name.'/'.$this->Filename; |
|
| 995 | 995 | } |
| 996 | 996 | |
| 997 | 997 | /** |
@@ -578,7 +578,7 @@ |
||
| 578 | 578 | * Dear people of the future: If you are looking to optimize this, simply create a CurrentBuildSHA(), which can be |
| 579 | 579 | * a lot faster. I presume you came here because of the Project display template, which only needs a SHA. |
| 580 | 580 | * |
| 581 | - * @return false|DNDeployment |
|
| 581 | + * @return DNDeployment |
|
| 582 | 582 | */ |
| 583 | 583 | public function CurrentBuild() { |
| 584 | 584 | // The DeployHistory function is far too slow to use for this |
@@ -929,7 +929,9 @@ discard block |
||
| 929 | 929 | * @return SS_List |
| 930 | 930 | */ |
| 931 | 931 | public function whoIsAllowedAny($codes) { |
| 932 | - if(!is_array($codes)) $codes = array($codes); |
|
| 932 | + if(!is_array($codes)) { |
|
| 933 | + $codes = array($codes); |
|
| 934 | + } |
|
| 933 | 935 | |
| 934 | 936 | $SQLa_codes = Convert::raw2sql($codes); |
| 935 | 937 | $SQL_codes = join("','", $SQLa_codes); |
@@ -991,7 +993,9 @@ discard block |
||
| 991 | 993 | $member = Member::currentUser(); |
| 992 | 994 | } |
| 993 | 995 | |
| 994 | - if(Permission::checkMember($member, 'ADMIN')) return true; |
|
| 996 | + if(Permission::checkMember($member, 'ADMIN')) { |
|
| 997 | + return true; |
|
| 998 | + } |
|
| 995 | 999 | |
| 996 | 1000 | $hits = $this->whoIsAllowedAny($codes)->filter('Member.ID', $member->ID)->count(); |
| 997 | 1001 | return ($hits>0 ? true : false); |
@@ -1018,7 +1022,9 @@ discard block |
||
| 1018 | 1022 | }); |
| 1019 | 1023 | |
| 1020 | 1024 | // If anything returns false then we're not ready. |
| 1021 | - if($isDone) return min($isDone); |
|
| 1025 | + if($isDone) { |
|
| 1026 | + return min($isDone); |
|
| 1027 | + } |
|
| 1022 | 1028 | } |
| 1023 | 1029 | |
| 1024 | 1030 | return true; |
@@ -1099,8 +1105,12 @@ discard block |
||
| 1099 | 1105 | * @return bool |
| 1100 | 1106 | */ |
| 1101 | 1107 | public function canCreate($member = null) { |
| 1102 | - if(!$member) $member = Member::currentUser(); |
|
| 1103 | - if(!$member) return false; |
|
| 1108 | + if(!$member) { |
|
| 1109 | + $member = Member::currentUser(); |
|
| 1110 | + } |
|
| 1111 | + if(!$member) { |
|
| 1112 | + return false; |
|
| 1113 | + } |
|
| 1104 | 1114 | |
| 1105 | 1115 | if(Permission::checkMember($member, 'ADMIN')) { |
| 1106 | 1116 | return true; |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | * @return bool |
| 263 | 263 | */ |
| 264 | 264 | public function canRestore($member = null) { |
| 265 | - if ($this->allowedAny( |
|
| 265 | + if($this->allowedAny( |
|
| 266 | 266 | array( |
| 267 | 267 | DNRoot::ALLOW_PROD_SNAPSHOT, |
| 268 | 268 | DNRoot::ALLOW_NON_PROD_SNAPSHOT |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | * @return bool |
| 283 | 283 | */ |
| 284 | 284 | public function canBackup($member = null) { |
| 285 | - if ($this->allowedAny( |
|
| 285 | + if($this->allowedAny( |
|
| 286 | 286 | array( |
| 287 | 287 | DNRoot::ALLOW_PROD_SNAPSHOT, |
| 288 | 288 | DNRoot::ALLOW_NON_PROD_SNAPSHOT |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | * @return bool |
| 303 | 303 | */ |
| 304 | 304 | public function canUploadArchive($member = null) { |
| 305 | - if ($this->allowedAny( |
|
| 305 | + if($this->allowedAny( |
|
| 306 | 306 | array( |
| 307 | 307 | DNRoot::ALLOW_PROD_SNAPSHOT, |
| 308 | 308 | DNRoot::ALLOW_NON_PROD_SNAPSHOT |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | * @return bool |
| 323 | 323 | */ |
| 324 | 324 | public function canDownloadArchive($member = null) { |
| 325 | - if ($this->allowedAny( |
|
| 325 | + if($this->allowedAny( |
|
| 326 | 326 | array( |
| 327 | 327 | DNRoot::ALLOW_PROD_SNAPSHOT, |
| 328 | 328 | DNRoot::ALLOW_NON_PROD_SNAPSHOT |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | // Key-pair is available, use it. |
| 392 | 392 | $processEnv = array( |
| 393 | 393 | 'IDENT_KEY' => $this->getPrivateKeyPath(), |
| 394 | - 'GIT_SSH' => BASE_PATH . "/deploynaut/git-deploy.sh" |
|
| 394 | + 'GIT_SSH' => BASE_PATH."/deploynaut/git-deploy.sh" |
|
| 395 | 395 | ); |
| 396 | 396 | } else { |
| 397 | 397 | $processEnv = array(); |
@@ -746,7 +746,7 @@ discard block |
||
| 746 | 746 | */ |
| 747 | 747 | public function getPublicKeyPath() { |
| 748 | 748 | if($privateKey = $this->getPrivateKeyPath()) { |
| 749 | - return $privateKey . '.pub'; |
|
| 749 | + return $privateKey.'.pub'; |
|
| 750 | 750 | } |
| 751 | 751 | return null; |
| 752 | 752 | } |
@@ -761,7 +761,7 @@ discard block |
||
| 761 | 761 | if(!empty($keyDir)) { |
| 762 | 762 | $filter = FileNameFilter::create(); |
| 763 | 763 | $name = $filter->filter($this->Name); |
| 764 | - return $keyDir . '/' . $name; |
|
| 764 | + return $keyDir.'/'.$name; |
|
| 765 | 765 | } |
| 766 | 766 | return null; |
| 767 | 767 | } |
@@ -780,7 +780,7 @@ discard block |
||
| 780 | 780 | $filter = FileNameFilter::create(); |
| 781 | 781 | $name = $filter->filter($this->Name); |
| 782 | 782 | |
| 783 | - return $this->DNData()->getKeyDir() . '/' . $name; |
|
| 783 | + return $this->DNData()->getKeyDir().'/'.$name; |
|
| 784 | 784 | } |
| 785 | 785 | |
| 786 | 786 | /** |
@@ -869,7 +869,7 @@ discard block |
||
| 869 | 869 | /* Look for each whitelisted hostname */ |
| 870 | 870 | foreach($interfaces as $host => $interface) { |
| 871 | 871 | /* See if the CVS Path is for this hostname, followed by some junk (maybe a port), then the path */ |
| 872 | - if(preg_match('{^[^.]*' . $host . '(.*?)([/a-zA-Z].+)}', $this->CVSPath, $match)) { |
|
| 872 | + if(preg_match('{^[^.]*'.$host.'(.*?)([/a-zA-Z].+)}', $this->CVSPath, $match)) { |
|
| 873 | 873 | |
| 874 | 874 | $path = $match[2]; |
| 875 | 875 | |
@@ -880,10 +880,10 @@ discard block |
||
| 880 | 880 | $components = explode('.', $host); |
| 881 | 881 | |
| 882 | 882 | foreach($regex as $pattern => $replacement) { |
| 883 | - $path = preg_replace('/' . $pattern . '/', $replacement, $path); |
|
| 883 | + $path = preg_replace('/'.$pattern.'/', $replacement, $path); |
|
| 884 | 884 | } |
| 885 | 885 | |
| 886 | - $uxurl = Controller::join_links($scheme . '://', $host, $path); |
|
| 886 | + $uxurl = Controller::join_links($scheme.'://', $host, $path); |
|
| 887 | 887 | |
| 888 | 888 | if(array_key_exists('commit', $interface) && $interface['commit'] == false) { |
| 889 | 889 | $commiturl = false; |
@@ -987,14 +987,14 @@ discard block |
||
| 987 | 987 | * @return bool |
| 988 | 988 | */ |
| 989 | 989 | public function allowedAny($codes, $member = null) { |
| 990 | - if (!$member) { |
|
| 990 | + if(!$member) { |
|
| 991 | 991 | $member = Member::currentUser(); |
| 992 | 992 | } |
| 993 | 993 | |
| 994 | 994 | if(Permission::checkMember($member, 'ADMIN')) return true; |
| 995 | 995 | |
| 996 | 996 | $hits = $this->whoIsAllowedAny($codes)->filter('Member.ID', $member->ID)->count(); |
| 997 | - return ($hits>0 ? true : false); |
|
| 997 | + return ($hits > 0 ? true : false); |
|
| 998 | 998 | } |
| 999 | 999 | |
| 1000 | 1000 | /** |
@@ -961,7 +961,7 @@ |
||
| 961 | 961 | * @param array $data |
| 962 | 962 | * @param Form $form |
| 963 | 963 | * |
| 964 | - * @return bool|HTMLText|SS_HTTPResponse |
|
| 964 | + * @return SS_HTTPResponse|null |
|
| 965 | 965 | */ |
| 966 | 966 | public function doCreateEnvironment($data, Form $form) { |
| 967 | 967 | $this->setCurrentActionType(self::ACTION_ENVIRONMENTS); |
@@ -178,8 +178,8 @@ discard block |
||
| 178 | 178 | Requirements::javascript('deploynaut/javascript/material.js'); |
| 179 | 179 | |
| 180 | 180 | // Load the buildable dependencies only if not loaded centrally. |
| 181 | - if (!is_dir(BASE_PATH . DIRECTORY_SEPARATOR . 'static')) { |
|
| 182 | - if (\Director::isDev()) { |
|
| 181 | + if(!is_dir(BASE_PATH.DIRECTORY_SEPARATOR.'static')) { |
|
| 182 | + if(\Director::isDev()) { |
|
| 183 | 183 | \Requirements::javascript('deploynaut/static/bundle-debug.js'); |
| 184 | 184 | } else { |
| 185 | 185 | \Requirements::javascript('deploynaut/static/bundle.js'); |
@@ -197,13 +197,13 @@ discard block |
||
| 197 | 197 | * @return boolean |
| 198 | 198 | */ |
| 199 | 199 | public static function FlagSnapshotsEnabled() { |
| 200 | - if (defined('FLAG_SNAPSHOTS_ENABLED') && FLAG_SNAPSHOTS_ENABLED) { |
|
| 200 | + if(defined('FLAG_SNAPSHOTS_ENABLED') && FLAG_SNAPSHOTS_ENABLED) { |
|
| 201 | 201 | return true; |
| 202 | 202 | } |
| 203 | - if (defined('FLAG_SNAPSHOTS_ENABLED_FOR_MEMBERS') && FLAG_SNAPSHOTS_ENABLED_FOR_MEMBERS) { |
|
| 203 | + if(defined('FLAG_SNAPSHOTS_ENABLED_FOR_MEMBERS') && FLAG_SNAPSHOTS_ENABLED_FOR_MEMBERS) { |
|
| 204 | 204 | $allowedMembers = explode(';', FLAG_SNAPSHOTS_ENABLED_FOR_MEMBERS); |
| 205 | 205 | $member = Member::currentUser(); |
| 206 | - if ($allowedMembers && $member && in_array($member->Email, $allowedMembers)) { |
|
| 206 | + if($allowedMembers && $member && in_array($member->Email, $allowedMembers)) { |
|
| 207 | 207 | return true; |
| 208 | 208 | } |
| 209 | 209 | } |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | public static function get_support_links() { |
| 217 | 217 | $supportLinks = self::config()->support_links; |
| 218 | - if ($supportLinks) { |
|
| 218 | + if($supportLinks) { |
|
| 219 | 219 | return new ArrayList($supportLinks); |
| 220 | 220 | } |
| 221 | 221 | } |
@@ -237,12 +237,12 @@ discard block |
||
| 237 | 237 | public function init() { |
| 238 | 238 | parent::init(); |
| 239 | 239 | |
| 240 | - if (!Member::currentUser() && !Session::get('AutoLoginHash')) { |
|
| 240 | + if(!Member::currentUser() && !Session::get('AutoLoginHash')) { |
|
| 241 | 241 | return Security::permissionFailure(); |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | // Block framework jquery |
| 245 | - Requirements::block(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js'); |
|
| 245 | + Requirements::block(FRAMEWORK_DIR.'/thirdparty/jquery/jquery.js'); |
|
| 246 | 246 | |
| 247 | 247 | self::include_requirements(); |
| 248 | 248 | } |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | * @return \SS_HTTPResponse |
| 262 | 262 | */ |
| 263 | 263 | public function index(SS_HTTPRequest $request) { |
| 264 | - return $this->redirect($this->Link() . 'projects/'); |
|
| 264 | + return $this->redirect($this->Link().'projects/'); |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | /** |
@@ -317,11 +317,11 @@ discard block |
||
| 317 | 317 | |
| 318 | 318 | // Performs canView permission check by limiting visible projects |
| 319 | 319 | $project = $this->getCurrentProject(); |
| 320 | - if (!$project) { |
|
| 320 | + if(!$project) { |
|
| 321 | 321 | return $this->project404Response(); |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - if (!$project->canBackup()) { |
|
| 324 | + if(!$project->canBackup()) { |
|
| 325 | 325 | return new SS_HTTPResponse("Not allowed to create snapshots on any environments", 401); |
| 326 | 326 | } |
| 327 | 327 | |
@@ -343,11 +343,11 @@ discard block |
||
| 343 | 343 | |
| 344 | 344 | // Performs canView permission check by limiting visible projects |
| 345 | 345 | $project = $this->getCurrentProject(); |
| 346 | - if (!$project) { |
|
| 346 | + if(!$project) { |
|
| 347 | 347 | return $this->project404Response(); |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | - if (!$project->canUploadArchive()) { |
|
| 350 | + if(!$project->canUploadArchive()) { |
|
| 351 | 351 | return new SS_HTTPResponse("Not allowed to upload", 401); |
| 352 | 352 | } |
| 353 | 353 | |
@@ -378,22 +378,22 @@ discard block |
||
| 378 | 378 | public function getUploadSnapshotForm(SS_HTTPRequest $request) { |
| 379 | 379 | // Performs canView permission check by limiting visible projects |
| 380 | 380 | $project = $this->getCurrentProject(); |
| 381 | - if (!$project) { |
|
| 381 | + if(!$project) { |
|
| 382 | 382 | return $this->project404Response(); |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - if (!$project->canUploadArchive()) { |
|
| 385 | + if(!$project->canUploadArchive()) { |
|
| 386 | 386 | return new SS_HTTPResponse("Not allowed to upload", 401); |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | // Framing an environment as a "group of people with download access" |
| 390 | 390 | // makes more sense to the user here, while still allowing us to enforce |
| 391 | 391 | // environment specific restrictions on downloading the file later on. |
| 392 | - $envs = $project->DNEnvironmentList()->filterByCallback(function ($item) { |
|
| 392 | + $envs = $project->DNEnvironmentList()->filterByCallback(function($item) { |
|
| 393 | 393 | return $item->canUploadArchive(); |
| 394 | 394 | }); |
| 395 | 395 | $envsMap = []; |
| 396 | - foreach ($envs as $env) { |
|
| 396 | + foreach($envs as $env) { |
|
| 397 | 397 | $envsMap[$env->ID] = $env->Name; |
| 398 | 398 | } |
| 399 | 399 | |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | $form->disableSecurityToken(); |
| 422 | 422 | $form->addExtraClass('fields-wide'); |
| 423 | 423 | // Tweak the action so it plays well with our fake URL structure. |
| 424 | - $form->setFormAction($project->Link() . '/UploadSnapshotForm'); |
|
| 424 | + $form->setFormAction($project->Link().'/UploadSnapshotForm'); |
|
| 425 | 425 | |
| 426 | 426 | return $form; |
| 427 | 427 | } |
@@ -437,18 +437,18 @@ discard block |
||
| 437 | 437 | |
| 438 | 438 | // Performs canView permission check by limiting visible projects |
| 439 | 439 | $project = $this->getCurrentProject(); |
| 440 | - if (!$project) { |
|
| 440 | + if(!$project) { |
|
| 441 | 441 | return $this->project404Response(); |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | $validEnvs = $project->DNEnvironmentList() |
| 445 | - ->filterByCallback(function ($item) { |
|
| 445 | + ->filterByCallback(function($item) { |
|
| 446 | 446 | return $item->canUploadArchive(); |
| 447 | 447 | }); |
| 448 | 448 | |
| 449 | 449 | // Validate $data['EnvironmentID'] by checking against $validEnvs. |
| 450 | 450 | $environment = $validEnvs->find('ID', $data['EnvironmentID']); |
| 451 | - if (!$environment) { |
|
| 451 | + if(!$environment) { |
|
| 452 | 452 | throw new LogicException('Invalid environment'); |
| 453 | 453 | } |
| 454 | 454 | |
@@ -471,9 +471,9 @@ discard block |
||
| 471 | 471 | $dataArchive->DataTransfers()->add($dataTransfer); |
| 472 | 472 | $form->saveInto($dataArchive); |
| 473 | 473 | $dataArchive->write(); |
| 474 | - $workingDir = TEMP_FOLDER . DIRECTORY_SEPARATOR . 'deploynaut-transfer-' . $dataTransfer->ID; |
|
| 474 | + $workingDir = TEMP_FOLDER.DIRECTORY_SEPARATOR.'deploynaut-transfer-'.$dataTransfer->ID; |
|
| 475 | 475 | |
| 476 | - $cleanupFn = function () use ($workingDir, $dataTransfer, $dataArchive) { |
|
| 476 | + $cleanupFn = function() use ($workingDir, $dataTransfer, $dataArchive) { |
|
| 477 | 477 | $process = new AbortableProcess(sprintf('rm -rf %s', escapeshellarg($workingDir))); |
| 478 | 478 | $process->setTimeout(120); |
| 479 | 479 | $process->run(); |
@@ -484,7 +484,7 @@ discard block |
||
| 484 | 484 | // extract the sspak contents so we can inspect them |
| 485 | 485 | try { |
| 486 | 486 | $dataArchive->extractArchive($workingDir); |
| 487 | - } catch (Exception $e) { |
|
| 487 | + } catch(Exception $e) { |
|
| 488 | 488 | $cleanupFn(); |
| 489 | 489 | $form->sessionMessage( |
| 490 | 490 | 'There was a problem trying to open your snapshot for processing. Please try uploading again', |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | |
| 496 | 496 | // validate that the sspak contents match the declared contents |
| 497 | 497 | $result = $dataArchive->validateArchiveContents(); |
| 498 | - if (!$result->valid()) { |
|
| 498 | + if(!$result->valid()) { |
|
| 499 | 499 | $cleanupFn(); |
| 500 | 500 | $form->sessionMessage($result->message(), 'bad'); |
| 501 | 501 | return $this->redirectBack(); |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | try { |
| 506 | 506 | $dataArchive->fixArchivePermissions($workingDir); |
| 507 | 507 | $dataArchive->setArchiveFromFiles($workingDir); |
| 508 | - } catch (Exception $e) { |
|
| 508 | + } catch(Exception $e) { |
|
| 509 | 509 | $cleanupFn(); |
| 510 | 510 | $form->sessionMessage( |
| 511 | 511 | 'There was a problem processing your snapshot. Please try uploading again', |
@@ -536,22 +536,22 @@ discard block |
||
| 536 | 536 | public function getPostSnapshotForm(SS_HTTPRequest $request) { |
| 537 | 537 | // Performs canView permission check by limiting visible projects |
| 538 | 538 | $project = $this->getCurrentProject(); |
| 539 | - if (!$project) { |
|
| 539 | + if(!$project) { |
|
| 540 | 540 | return $this->project404Response(); |
| 541 | 541 | } |
| 542 | 542 | |
| 543 | - if (!$project->canUploadArchive()) { |
|
| 543 | + if(!$project->canUploadArchive()) { |
|
| 544 | 544 | return new SS_HTTPResponse("Not allowed to upload", 401); |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | // Framing an environment as a "group of people with download access" |
| 548 | 548 | // makes more sense to the user here, while still allowing us to enforce |
| 549 | 549 | // environment specific restrictions on downloading the file later on. |
| 550 | - $envs = $project->DNEnvironmentList()->filterByCallback(function ($item) { |
|
| 550 | + $envs = $project->DNEnvironmentList()->filterByCallback(function($item) { |
|
| 551 | 551 | return $item->canUploadArchive(); |
| 552 | 552 | }); |
| 553 | 553 | $envsMap = []; |
| 554 | - foreach ($envs as $env) { |
|
| 554 | + foreach($envs as $env) { |
|
| 555 | 555 | $envsMap[$env->ID] = $env->Name; |
| 556 | 556 | } |
| 557 | 557 | |
@@ -573,7 +573,7 @@ discard block |
||
| 573 | 573 | $form->disableSecurityToken(); |
| 574 | 574 | $form->addExtraClass('fields-wide'); |
| 575 | 575 | // Tweak the action so it plays well with our fake URL structure. |
| 576 | - $form->setFormAction($project->Link() . '/PostSnapshotForm'); |
|
| 576 | + $form->setFormAction($project->Link().'/PostSnapshotForm'); |
|
| 577 | 577 | |
| 578 | 578 | return $form; |
| 579 | 579 | } |
@@ -588,17 +588,17 @@ discard block |
||
| 588 | 588 | $this->setCurrentActionType(self::ACTION_SNAPSHOT); |
| 589 | 589 | |
| 590 | 590 | $project = $this->getCurrentProject(); |
| 591 | - if (!$project) { |
|
| 591 | + if(!$project) { |
|
| 592 | 592 | return $this->project404Response(); |
| 593 | 593 | } |
| 594 | 594 | |
| 595 | - $validEnvs = $project->DNEnvironmentList()->filterByCallback(function ($item) { |
|
| 595 | + $validEnvs = $project->DNEnvironmentList()->filterByCallback(function($item) { |
|
| 596 | 596 | return $item->canUploadArchive(); |
| 597 | 597 | }); |
| 598 | 598 | |
| 599 | 599 | // Validate $data['EnvironmentID'] by checking against $validEnvs. |
| 600 | 600 | $environment = $validEnvs->find('ID', $data['EnvironmentID']); |
| 601 | - if (!$environment) { |
|
| 601 | + if(!$environment) { |
|
| 602 | 602 | throw new LogicException('Invalid environment'); |
| 603 | 603 | } |
| 604 | 604 | |
@@ -636,20 +636,20 @@ discard block |
||
| 636 | 636 | |
| 637 | 637 | // Performs canView permission check by limiting visible projects |
| 638 | 638 | $project = $this->getCurrentProject(); |
| 639 | - if (!$project) { |
|
| 639 | + if(!$project) { |
|
| 640 | 640 | return $this->project404Response(); |
| 641 | 641 | } |
| 642 | 642 | |
| 643 | - if (!$project->canUploadArchive()) { |
|
| 643 | + if(!$project->canUploadArchive()) { |
|
| 644 | 644 | return new SS_HTTPResponse("Not allowed to upload", 401); |
| 645 | 645 | } |
| 646 | 646 | |
| 647 | 647 | $dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID')); |
| 648 | - if (!$dataArchive) { |
|
| 648 | + if(!$dataArchive) { |
|
| 649 | 649 | return new SS_HTTPResponse("Archive not found.", 404); |
| 650 | 650 | } |
| 651 | 651 | |
| 652 | - if (!$dataArchive->canRestore()) { |
|
| 652 | + if(!$dataArchive->canRestore()) { |
|
| 653 | 653 | throw new SS_HTTPResponse_Exception('Not allowed to restore archive', 403); |
| 654 | 654 | } |
| 655 | 655 | |
@@ -679,19 +679,19 @@ discard block |
||
| 679 | 679 | */ |
| 680 | 680 | public function toggleprojectstar(SS_HTTPRequest $request) { |
| 681 | 681 | $project = $this->getCurrentProject(); |
| 682 | - if (!$project) { |
|
| 682 | + if(!$project) { |
|
| 683 | 683 | return $this->project404Response(); |
| 684 | 684 | } |
| 685 | 685 | |
| 686 | 686 | $member = Member::currentUser(); |
| 687 | - if ($member === null) { |
|
| 687 | + if($member === null) { |
|
| 688 | 688 | return $this->project404Response(); |
| 689 | 689 | } |
| 690 | 690 | $favProject = $member->StarredProjects() |
| 691 | 691 | ->filter('DNProjectID', $project->ID) |
| 692 | 692 | ->first(); |
| 693 | 693 | |
| 694 | - if ($favProject) { |
|
| 694 | + if($favProject) { |
|
| 695 | 695 | $member->StarredProjects()->remove($favProject); |
| 696 | 696 | } else { |
| 697 | 697 | $member->StarredProjects()->add($project); |
@@ -705,14 +705,14 @@ discard block |
||
| 705 | 705 | */ |
| 706 | 706 | public function branch(SS_HTTPRequest $request) { |
| 707 | 707 | $project = $this->getCurrentProject(); |
| 708 | - if (!$project) { |
|
| 708 | + if(!$project) { |
|
| 709 | 709 | return $this->project404Response(); |
| 710 | 710 | } |
| 711 | 711 | |
| 712 | 712 | $branchName = $request->getVar('name'); |
| 713 | 713 | $branch = $project->DNBranchList()->byName($branchName); |
| 714 | - if (!$branch) { |
|
| 715 | - return new SS_HTTPResponse("Branch '" . Convert::raw2xml($branchName) . "' not found.", 404); |
|
| 714 | + if(!$branch) { |
|
| 715 | + return new SS_HTTPResponse("Branch '".Convert::raw2xml($branchName)."' not found.", 404); |
|
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | return $this->render([ |
@@ -727,20 +727,20 @@ discard block |
||
| 727 | 727 | public function environment(SS_HTTPRequest $request) { |
| 728 | 728 | // Performs canView permission check by limiting visible projects |
| 729 | 729 | $project = $this->getCurrentProject(); |
| 730 | - if (!$project) { |
|
| 730 | + if(!$project) { |
|
| 731 | 731 | return $this->project404Response(); |
| 732 | 732 | } |
| 733 | 733 | |
| 734 | 734 | // Performs canView permission check by limiting visible projects |
| 735 | 735 | $env = $this->getCurrentEnvironment($project); |
| 736 | - if (!$env) { |
|
| 736 | + if(!$env) { |
|
| 737 | 737 | return $this->environment404Response(); |
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | return $this->render([ |
| 741 | 741 | 'DNEnvironmentList' => $this->getCurrentProject()->DNEnvironmentList(), |
| 742 | 742 | 'FlagSnapshotsEnabled' => $this->FlagSnapshotsEnabled(), |
| 743 | - 'Redeploy' => (bool) $request->getVar('redeploy') |
|
| 743 | + 'Redeploy' => (bool)$request->getVar('redeploy') |
|
| 744 | 744 | ]); |
| 745 | 745 | } |
| 746 | 746 | |
@@ -752,22 +752,22 @@ discard block |
||
| 752 | 752 | */ |
| 753 | 753 | public function createenv(SS_HTTPRequest $request) { |
| 754 | 754 | $params = $request->params(); |
| 755 | - if ($params['Identifier']) { |
|
| 755 | + if($params['Identifier']) { |
|
| 756 | 756 | $record = DNCreateEnvironment::get()->byId($params['Identifier']); |
| 757 | 757 | |
| 758 | - if (!$record || !$record->ID) { |
|
| 758 | + if(!$record || !$record->ID) { |
|
| 759 | 759 | throw new SS_HTTPResponse_Exception('Create environment not found', 404); |
| 760 | 760 | } |
| 761 | - if (!$record->canView()) { |
|
| 761 | + if(!$record->canView()) { |
|
| 762 | 762 | return Security::permissionFailure(); |
| 763 | 763 | } |
| 764 | 764 | |
| 765 | 765 | $project = $this->getCurrentProject(); |
| 766 | - if (!$project) { |
|
| 766 | + if(!$project) { |
|
| 767 | 767 | return $this->project404Response(); |
| 768 | 768 | } |
| 769 | 769 | |
| 770 | - if ($project->Name != $params['Project']) { |
|
| 770 | + if($project->Name != $params['Project']) { |
|
| 771 | 771 | throw new LogicException("Project in URL doesn't match this creation"); |
| 772 | 772 | } |
| 773 | 773 | |
@@ -782,21 +782,21 @@ discard block |
||
| 782 | 782 | $params = $request->params(); |
| 783 | 783 | $env = DNCreateEnvironment::get()->byId($params['Identifier']); |
| 784 | 784 | |
| 785 | - if (!$env || !$env->ID) { |
|
| 785 | + if(!$env || !$env->ID) { |
|
| 786 | 786 | throw new SS_HTTPResponse_Exception('Log not found', 404); |
| 787 | 787 | } |
| 788 | - if (!$env->canView()) { |
|
| 788 | + if(!$env->canView()) { |
|
| 789 | 789 | return Security::permissionFailure(); |
| 790 | 790 | } |
| 791 | 791 | |
| 792 | 792 | $project = $env->Project(); |
| 793 | 793 | |
| 794 | - if ($project->Name != $params['Project']) { |
|
| 794 | + if($project->Name != $params['Project']) { |
|
| 795 | 795 | throw new LogicException("Project in URL doesn't match this deploy"); |
| 796 | 796 | } |
| 797 | 797 | |
| 798 | 798 | $log = $env->log(); |
| 799 | - if ($log->exists()) { |
|
| 799 | + if($log->exists()) { |
|
| 800 | 800 | $content = $log->content(); |
| 801 | 801 | } else { |
| 802 | 802 | $content = 'Waiting for action to start'; |
@@ -813,27 +813,27 @@ discard block |
||
| 813 | 813 | $this->setCurrentActionType(self::ACTION_ENVIRONMENTS); |
| 814 | 814 | |
| 815 | 815 | $project = $this->getCurrentProject(); |
| 816 | - if (!$project) { |
|
| 816 | + if(!$project) { |
|
| 817 | 817 | return $this->project404Response(); |
| 818 | 818 | } |
| 819 | 819 | |
| 820 | 820 | $envType = $project->AllowedEnvironmentType; |
| 821 | - if (!$envType || !class_exists($envType)) { |
|
| 821 | + if(!$envType || !class_exists($envType)) { |
|
| 822 | 822 | return null; |
| 823 | 823 | } |
| 824 | 824 | |
| 825 | 825 | $backend = Injector::inst()->get($envType); |
| 826 | - if (!($backend instanceof EnvironmentCreateBackend)) { |
|
| 826 | + if(!($backend instanceof EnvironmentCreateBackend)) { |
|
| 827 | 827 | // Only allow this for supported backends. |
| 828 | 828 | return null; |
| 829 | 829 | } |
| 830 | 830 | |
| 831 | 831 | $fields = $backend->getCreateEnvironmentFields($project); |
| 832 | - if (!$fields) { |
|
| 832 | + if(!$fields) { |
|
| 833 | 833 | return null; |
| 834 | 834 | } |
| 835 | 835 | |
| 836 | - if (!$project->canCreateEnvironments()) { |
|
| 836 | + if(!$project->canCreateEnvironments()) { |
|
| 837 | 837 | return new SS_HTTPResponse('Not allowed to create environments for this project', 401); |
| 838 | 838 | } |
| 839 | 839 | |
@@ -849,7 +849,7 @@ discard block |
||
| 849 | 849 | ); |
| 850 | 850 | |
| 851 | 851 | // Tweak the action so it plays well with our fake URL structure. |
| 852 | - $form->setFormAction($project->Link() . '/CreateEnvironmentForm'); |
|
| 852 | + $form->setFormAction($project->Link().'/CreateEnvironmentForm'); |
|
| 853 | 853 | |
| 854 | 854 | return $form; |
| 855 | 855 | } |
@@ -864,11 +864,11 @@ discard block |
||
| 864 | 864 | $this->setCurrentActionType(self::ACTION_ENVIRONMENTS); |
| 865 | 865 | |
| 866 | 866 | $project = $this->getCurrentProject(); |
| 867 | - if (!$project) { |
|
| 867 | + if(!$project) { |
|
| 868 | 868 | return $this->project404Response(); |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | - if (!$project->canCreateEnvironments()) { |
|
| 871 | + if(!$project->canCreateEnvironments()) { |
|
| 872 | 872 | return new SS_HTTPResponse('Not allowed to create environments for this project', 401); |
| 873 | 873 | } |
| 874 | 874 | |
@@ -882,7 +882,7 @@ discard block |
||
| 882 | 882 | $job->write(); |
| 883 | 883 | $job->start(); |
| 884 | 884 | |
| 885 | - return $this->redirect($project->Link('createenv') . '/' . $job->ID); |
|
| 885 | + return $this->redirect($project->Link('createenv').'/'.$job->ID); |
|
| 886 | 886 | } |
| 887 | 887 | |
| 888 | 888 | /** |
@@ -893,13 +893,13 @@ discard block |
||
| 893 | 893 | public function metrics(SS_HTTPRequest $request) { |
| 894 | 894 | // Performs canView permission check by limiting visible projects |
| 895 | 895 | $project = $this->getCurrentProject(); |
| 896 | - if (!$project) { |
|
| 896 | + if(!$project) { |
|
| 897 | 897 | return $this->project404Response(); |
| 898 | 898 | } |
| 899 | 899 | |
| 900 | 900 | // Performs canView permission check by limiting visible projects |
| 901 | 901 | $env = $this->getCurrentEnvironment($project); |
| 902 | - if (!$env) { |
|
| 902 | + if(!$env) { |
|
| 903 | 903 | return $this->environment404Response(); |
| 904 | 904 | } |
| 905 | 905 | |
@@ -922,11 +922,11 @@ discard block |
||
| 922 | 922 | */ |
| 923 | 923 | public function DNProjectList() { |
| 924 | 924 | $memberId = Member::currentUserID(); |
| 925 | - if (!$memberId) { |
|
| 925 | + if(!$memberId) { |
|
| 926 | 926 | return new ArrayList(); |
| 927 | 927 | } |
| 928 | 928 | |
| 929 | - if (Permission::check('ADMIN')) { |
|
| 929 | + if(Permission::check('ADMIN')) { |
|
| 930 | 930 | return DNProject::get(); |
| 931 | 931 | } |
| 932 | 932 | |
@@ -943,7 +943,7 @@ discard block |
||
| 943 | 943 | */ |
| 944 | 944 | public function getPlatformSpecificStrings() { |
| 945 | 945 | $strings = $this->config()->platform_specific_strings; |
| 946 | - if ($strings) { |
|
| 946 | + if($strings) { |
|
| 947 | 947 | return new ArrayList($strings); |
| 948 | 948 | } |
| 949 | 949 | } |
@@ -955,15 +955,15 @@ discard block |
||
| 955 | 955 | */ |
| 956 | 956 | public function getStarredProjects() { |
| 957 | 957 | $member = Member::currentUser(); |
| 958 | - if ($member === null) { |
|
| 958 | + if($member === null) { |
|
| 959 | 959 | return new ArrayList(); |
| 960 | 960 | } |
| 961 | 961 | |
| 962 | 962 | $favProjects = $member->StarredProjects(); |
| 963 | 963 | |
| 964 | 964 | $list = new ArrayList(); |
| 965 | - foreach ($favProjects as $project) { |
|
| 966 | - if ($project->canView($member)) { |
|
| 965 | + foreach($favProjects as $project) { |
|
| 966 | + if($project->canView($member)) { |
|
| 967 | 967 | $list->add($project); |
| 968 | 968 | } |
| 969 | 969 | } |
@@ -985,30 +985,30 @@ discard block |
||
| 985 | 985 | $actionType = $this->getCurrentActionType(); |
| 986 | 986 | |
| 987 | 987 | $projects = $this->getStarredProjects(); |
| 988 | - if ($projects->count() < 1) { |
|
| 988 | + if($projects->count() < 1) { |
|
| 989 | 989 | $projects = $this->DNProjectList(); |
| 990 | 990 | } else { |
| 991 | 991 | $limit = -1; |
| 992 | 992 | } |
| 993 | 993 | |
| 994 | - if ($projects->count() > 0) { |
|
| 994 | + if($projects->count() > 0) { |
|
| 995 | 995 | $activeProject = false; |
| 996 | 996 | |
| 997 | - if ($limit > 0) { |
|
| 997 | + if($limit > 0) { |
|
| 998 | 998 | $limitedProjects = $projects->limit($limit); |
| 999 | 999 | } else { |
| 1000 | 1000 | $limitedProjects = $projects; |
| 1001 | 1001 | } |
| 1002 | 1002 | |
| 1003 | - foreach ($limitedProjects as $project) { |
|
| 1003 | + foreach($limitedProjects as $project) { |
|
| 1004 | 1004 | $isActive = $currentProject && $currentProject->ID == $project->ID; |
| 1005 | - if ($isActive) { |
|
| 1005 | + if($isActive) { |
|
| 1006 | 1006 | $activeProject = true; |
| 1007 | 1007 | } |
| 1008 | 1008 | |
| 1009 | 1009 | $isCurrentEnvironment = false; |
| 1010 | - if ($project && $currentEnvironment) { |
|
| 1011 | - $isCurrentEnvironment = (bool) $project->DNEnvironmentList()->find('ID', $currentEnvironment->ID); |
|
| 1010 | + if($project && $currentEnvironment) { |
|
| 1011 | + $isCurrentEnvironment = (bool)$project->DNEnvironmentList()->find('ID', $currentEnvironment->ID); |
|
| 1012 | 1012 | } |
| 1013 | 1013 | |
| 1014 | 1014 | $navigation->push([ |
@@ -1020,14 +1020,14 @@ discard block |
||
| 1020 | 1020 | } |
| 1021 | 1021 | |
| 1022 | 1022 | // Ensure the current project is in the list |
| 1023 | - if (!$activeProject && $currentProject) { |
|
| 1023 | + if(!$activeProject && $currentProject) { |
|
| 1024 | 1024 | $navigation->unshift([ |
| 1025 | 1025 | 'Project' => $currentProject, |
| 1026 | 1026 | 'IsActive' => true, |
| 1027 | 1027 | 'IsCurrentEnvironment' => $currentEnvironment, |
| 1028 | 1028 | 'IsOverview' => $actionType == self::PROJECT_OVERVIEW |
| 1029 | 1029 | ]); |
| 1030 | - if ($limit > 0 && $navigation->count() > $limit) { |
|
| 1030 | + if($limit > 0 && $navigation->count() > $limit) { |
|
| 1031 | 1031 | $navigation->pop(); |
| 1032 | 1032 | } |
| 1033 | 1033 | } |
@@ -1047,17 +1047,17 @@ discard block |
||
| 1047 | 1047 | |
| 1048 | 1048 | // Performs canView permission check by limiting visible projects |
| 1049 | 1049 | $project = $this->getCurrentProject(); |
| 1050 | - if (!$project) { |
|
| 1050 | + if(!$project) { |
|
| 1051 | 1051 | return $this->project404Response(); |
| 1052 | 1052 | } |
| 1053 | 1053 | |
| 1054 | 1054 | // Performs canView permission check by limiting visible projects |
| 1055 | 1055 | $environment = $this->getCurrentEnvironment($project); |
| 1056 | - if (!$environment) { |
|
| 1056 | + if(!$environment) { |
|
| 1057 | 1057 | return $this->environment404Response(); |
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | - if (!$environment->canDeploy()) { |
|
| 1060 | + if(!$environment->canDeploy()) { |
|
| 1061 | 1061 | return new SS_HTTPResponse("Not allowed to deploy", 401); |
| 1062 | 1062 | } |
| 1063 | 1063 | |
@@ -1065,7 +1065,7 @@ discard block |
||
| 1065 | 1065 | $form = new DeployForm($this, 'DeployForm', $environment, $project); |
| 1066 | 1066 | |
| 1067 | 1067 | // If this is an ajax request we don't want to submit the form - we just want to retrieve the markup. |
| 1068 | - if ( |
|
| 1068 | + if( |
|
| 1069 | 1069 | $request && |
| 1070 | 1070 | !$request->requestVar('action_showDeploySummary') && |
| 1071 | 1071 | $this->getRequest()->isAjax() && |
@@ -1080,7 +1080,7 @@ discard block |
||
| 1080 | 1080 | return $body; |
| 1081 | 1081 | } |
| 1082 | 1082 | |
| 1083 | - $form->setFormAction($this->getRequest()->getURL() . '/DeployForm'); |
|
| 1083 | + $form->setFormAction($this->getRequest()->getURL().'/DeployForm'); |
|
| 1084 | 1084 | return $form; |
| 1085 | 1085 | } |
| 1086 | 1086 | |
@@ -1095,18 +1095,18 @@ discard block |
||
| 1095 | 1095 | |
| 1096 | 1096 | // Performs canView permission check by limiting visible projects |
| 1097 | 1097 | $project = $this->getCurrentProject(); |
| 1098 | - if (!$project) { |
|
| 1098 | + if(!$project) { |
|
| 1099 | 1099 | return $this->project404Response(); |
| 1100 | 1100 | } |
| 1101 | 1101 | |
| 1102 | 1102 | // Performs canView permission check by limiting visible projects |
| 1103 | 1103 | $env = $this->getCurrentEnvironment($project); |
| 1104 | - if (!$env) { |
|
| 1104 | + if(!$env) { |
|
| 1105 | 1105 | return $this->environment404Response(); |
| 1106 | 1106 | } |
| 1107 | 1107 | |
| 1108 | 1108 | $options = []; |
| 1109 | - foreach ($env->Backend()->getDeployOptions($env) as $option) { |
|
| 1109 | + foreach($env->Backend()->getDeployOptions($env) as $option) { |
|
| 1110 | 1110 | $options[] = [ |
| 1111 | 1111 | 'name' => $option->getName(), |
| 1112 | 1112 | 'title' => $option->getTitle(), |
@@ -1125,7 +1125,7 @@ discard block |
||
| 1125 | 1125 | 'field_data' => [], |
| 1126 | 1126 | 'options' => $options |
| 1127 | 1127 | ]; |
| 1128 | - foreach ($project->DNBranchList() as $branch) { |
|
| 1128 | + foreach($project->DNBranchList() as $branch) { |
|
| 1129 | 1129 | $sha = $branch->SHA(); |
| 1130 | 1130 | $name = $branch->Name(); |
| 1131 | 1131 | $branchValue = sprintf("%s (%s, %s old)", |
@@ -1151,7 +1151,7 @@ discard block |
||
| 1151 | 1151 | 'options' => $options |
| 1152 | 1152 | ]; |
| 1153 | 1153 | |
| 1154 | - foreach ($project->DNTagList()->setLimit(null) as $tag) { |
|
| 1154 | + foreach($project->DNTagList()->setLimit(null) as $tag) { |
|
| 1155 | 1155 | $name = $tag->Name(); |
| 1156 | 1156 | $data['field_data'][] = [ |
| 1157 | 1157 | 'id' => $tag->SHA(), |
@@ -1177,15 +1177,15 @@ discard block |
||
| 1177 | 1177 | // We are aiming at the format: |
| 1178 | 1178 | // [{text: 'optgroup text', children: [{id: '<sha>', text: '<inner text>'}]}] |
| 1179 | 1179 | $redeploy = []; |
| 1180 | - foreach ($project->DNEnvironmentList() as $dnEnvironment) { |
|
| 1180 | + foreach($project->DNEnvironmentList() as $dnEnvironment) { |
|
| 1181 | 1181 | $envName = $dnEnvironment->Name; |
| 1182 | 1182 | $perEnvDeploys = []; |
| 1183 | 1183 | |
| 1184 | - foreach ($dnEnvironment->DeployHistory() as $deploy) { |
|
| 1184 | + foreach($dnEnvironment->DeployHistory() as $deploy) { |
|
| 1185 | 1185 | $sha = $deploy->SHA; |
| 1186 | 1186 | |
| 1187 | 1187 | // Check if exists to make sure the newest deployment date is used. |
| 1188 | - if (!isset($perEnvDeploys[$sha])) { |
|
| 1188 | + if(!isset($perEnvDeploys[$sha])) { |
|
| 1189 | 1189 | $pastValue = sprintf("%s (deployed %s)", |
| 1190 | 1190 | substr($sha, 0, 8), |
| 1191 | 1191 | $deploy->obj('LastEdited')->Ago() |
@@ -1197,12 +1197,12 @@ discard block |
||
| 1197 | 1197 | } |
| 1198 | 1198 | } |
| 1199 | 1199 | |
| 1200 | - if (!empty($perEnvDeploys)) { |
|
| 1200 | + if(!empty($perEnvDeploys)) { |
|
| 1201 | 1201 | $redeploy[$envName] = array_values($perEnvDeploys); |
| 1202 | 1202 | } |
| 1203 | 1203 | } |
| 1204 | 1204 | // Convert the array to the frontend format (i.e. keyed to regular array) |
| 1205 | - foreach ($redeploy as $name => $descr) { |
|
| 1205 | + foreach($redeploy as $name => $descr) { |
|
| 1206 | 1206 | $data['field_data'][] = ['text' => $name, 'children' => $descr]; |
| 1207 | 1207 | } |
| 1208 | 1208 | $tabs[] = $data; |
@@ -1224,7 +1224,7 @@ discard block |
||
| 1224 | 1224 | ->filter('ProjectID', $project->ID) |
| 1225 | 1225 | ->sort('LastEdited', 'DESC') |
| 1226 | 1226 | ->first(); |
| 1227 | - if ($fetch) { |
|
| 1227 | + if($fetch) { |
|
| 1228 | 1228 | $lastFetched = $fetch->dbObject('LastEdited')->Ago(); |
| 1229 | 1229 | } |
| 1230 | 1230 | |
@@ -1249,13 +1249,13 @@ discard block |
||
| 1249 | 1249 | |
| 1250 | 1250 | // Performs canView permission check by limiting visible projects |
| 1251 | 1251 | $project = $this->getCurrentProject(); |
| 1252 | - if (!$project) { |
|
| 1252 | + if(!$project) { |
|
| 1253 | 1253 | return $this->project404Response(); |
| 1254 | 1254 | } |
| 1255 | 1255 | |
| 1256 | 1256 | // Performs canView permission check by limiting visible projects |
| 1257 | 1257 | $environment = $this->getCurrentEnvironment($project); |
| 1258 | - if (!$environment) { |
|
| 1258 | + if(!$environment) { |
|
| 1259 | 1259 | return $this->environment404Response(); |
| 1260 | 1260 | } |
| 1261 | 1261 | |
@@ -1266,7 +1266,7 @@ discard block |
||
| 1266 | 1266 | // Add in a URL for comparing from->to code changes. Ensure that we have |
| 1267 | 1267 | // two proper 40 character SHAs, otherwise we can't show the compare link. |
| 1268 | 1268 | $interface = $project->getRepositoryInterface(); |
| 1269 | - if ( |
|
| 1269 | + if( |
|
| 1270 | 1270 | !empty($interface) && !empty($interface->URL) |
| 1271 | 1271 | && !empty($data['changes']['Code version']['from']) |
| 1272 | 1272 | && strlen($data['changes']['Code version']['from']) == '40' |
@@ -1310,26 +1310,26 @@ discard block |
||
| 1310 | 1310 | |
| 1311 | 1311 | // Ensure the submitted token has a value |
| 1312 | 1312 | $submittedToken = $request->postVar(\Dispatcher::SECURITY_TOKEN_NAME); |
| 1313 | - if (!$submittedToken) { |
|
| 1313 | + if(!$submittedToken) { |
|
| 1314 | 1314 | return false; |
| 1315 | 1315 | } |
| 1316 | 1316 | // Do the actual check. |
| 1317 | 1317 | $check = $token->check($submittedToken); |
| 1318 | 1318 | // Ensure the CSRF Token is correct |
| 1319 | - if (!$check) { |
|
| 1319 | + if(!$check) { |
|
| 1320 | 1320 | // CSRF token didn't match |
| 1321 | 1321 | return $this->httpError(400, 'Bad Request'); |
| 1322 | 1322 | } |
| 1323 | 1323 | |
| 1324 | 1324 | // Performs canView permission check by limiting visible projects |
| 1325 | 1325 | $project = $this->getCurrentProject(); |
| 1326 | - if (!$project) { |
|
| 1326 | + if(!$project) { |
|
| 1327 | 1327 | return $this->project404Response(); |
| 1328 | 1328 | } |
| 1329 | 1329 | |
| 1330 | 1330 | // Performs canView permission check by limiting visible projects |
| 1331 | 1331 | $environment = $this->getCurrentEnvironment($project); |
| 1332 | - if (!$environment) { |
|
| 1332 | + if(!$environment) { |
|
| 1333 | 1333 | return $this->environment404Response(); |
| 1334 | 1334 | } |
| 1335 | 1335 | |
@@ -1346,7 +1346,7 @@ discard block |
||
| 1346 | 1346 | $deployment->getMachine()->apply(DNDeployment::TR_QUEUE); |
| 1347 | 1347 | |
| 1348 | 1348 | return json_encode([ |
| 1349 | - 'url' => Director::absoluteBaseURL() . $deployment->Link() |
|
| 1349 | + 'url' => Director::absoluteBaseURL().$deployment->Link() |
|
| 1350 | 1350 | ], JSON_PRETTY_PRINT); |
| 1351 | 1351 | } |
| 1352 | 1352 | |
@@ -1364,20 +1364,20 @@ discard block |
||
| 1364 | 1364 | $params = $request->params(); |
| 1365 | 1365 | $deployment = DNDeployment::get()->byId($params['Identifier']); |
| 1366 | 1366 | |
| 1367 | - if (!$deployment || !$deployment->ID) { |
|
| 1367 | + if(!$deployment || !$deployment->ID) { |
|
| 1368 | 1368 | throw new SS_HTTPResponse_Exception('Deployment not found', 404); |
| 1369 | 1369 | } |
| 1370 | - if (!$deployment->canView()) { |
|
| 1370 | + if(!$deployment->canView()) { |
|
| 1371 | 1371 | return Security::permissionFailure(); |
| 1372 | 1372 | } |
| 1373 | 1373 | |
| 1374 | 1374 | $environment = $deployment->Environment(); |
| 1375 | 1375 | $project = $environment->Project(); |
| 1376 | 1376 | |
| 1377 | - if ($environment->Name != $params['Environment']) { |
|
| 1377 | + if($environment->Name != $params['Environment']) { |
|
| 1378 | 1378 | throw new LogicException("Environment in URL doesn't match this deploy"); |
| 1379 | 1379 | } |
| 1380 | - if ($project->Name != $params['Project']) { |
|
| 1380 | + if($project->Name != $params['Project']) { |
|
| 1381 | 1381 | throw new LogicException("Project in URL doesn't match this deploy"); |
| 1382 | 1382 | } |
| 1383 | 1383 | |
@@ -1400,25 +1400,25 @@ discard block |
||
| 1400 | 1400 | $params = $request->params(); |
| 1401 | 1401 | $deployment = DNDeployment::get()->byId($params['Identifier']); |
| 1402 | 1402 | |
| 1403 | - if (!$deployment || !$deployment->ID) { |
|
| 1403 | + if(!$deployment || !$deployment->ID) { |
|
| 1404 | 1404 | throw new SS_HTTPResponse_Exception('Deployment not found', 404); |
| 1405 | 1405 | } |
| 1406 | - if (!$deployment->canView()) { |
|
| 1406 | + if(!$deployment->canView()) { |
|
| 1407 | 1407 | return Security::permissionFailure(); |
| 1408 | 1408 | } |
| 1409 | 1409 | |
| 1410 | 1410 | $environment = $deployment->Environment(); |
| 1411 | 1411 | $project = $environment->Project(); |
| 1412 | 1412 | |
| 1413 | - if ($environment->Name != $params['Environment']) { |
|
| 1413 | + if($environment->Name != $params['Environment']) { |
|
| 1414 | 1414 | throw new LogicException("Environment in URL doesn't match this deploy"); |
| 1415 | 1415 | } |
| 1416 | - if ($project->Name != $params['Project']) { |
|
| 1416 | + if($project->Name != $params['Project']) { |
|
| 1417 | 1417 | throw new LogicException("Project in URL doesn't match this deploy"); |
| 1418 | 1418 | } |
| 1419 | 1419 | |
| 1420 | 1420 | $log = $deployment->log(); |
| 1421 | - if ($log->exists()) { |
|
| 1421 | + if($log->exists()) { |
|
| 1422 | 1422 | $content = $log->content(); |
| 1423 | 1423 | } else { |
| 1424 | 1424 | $content = 'Waiting for action to start'; |
@@ -1431,29 +1431,29 @@ discard block |
||
| 1431 | 1431 | $params = $request->params(); |
| 1432 | 1432 | $deployment = DNDeployment::get()->byId($params['Identifier']); |
| 1433 | 1433 | |
| 1434 | - if (!$deployment || !$deployment->ID) { |
|
| 1434 | + if(!$deployment || !$deployment->ID) { |
|
| 1435 | 1435 | throw new SS_HTTPResponse_Exception('Deployment not found', 404); |
| 1436 | 1436 | } |
| 1437 | - if (!$deployment->canView()) { |
|
| 1437 | + if(!$deployment->canView()) { |
|
| 1438 | 1438 | return Security::permissionFailure(); |
| 1439 | 1439 | } |
| 1440 | 1440 | |
| 1441 | 1441 | // For now restrict to ADMINs only. |
| 1442 | - if (!Permission::check('ADMIN')) { |
|
| 1442 | + if(!Permission::check('ADMIN')) { |
|
| 1443 | 1443 | return Security::permissionFailure(); |
| 1444 | 1444 | } |
| 1445 | 1445 | |
| 1446 | 1446 | $environment = $deployment->Environment(); |
| 1447 | 1447 | $project = $environment->Project(); |
| 1448 | 1448 | |
| 1449 | - if ($environment->Name != $params['Environment']) { |
|
| 1449 | + if($environment->Name != $params['Environment']) { |
|
| 1450 | 1450 | throw new LogicException("Environment in URL doesn't match this deploy"); |
| 1451 | 1451 | } |
| 1452 | - if ($project->Name != $params['Project']) { |
|
| 1452 | + if($project->Name != $params['Project']) { |
|
| 1453 | 1453 | throw new LogicException("Project in URL doesn't match this deploy"); |
| 1454 | 1454 | } |
| 1455 | 1455 | |
| 1456 | - if (!in_array($deployment->Status, ['Queued', 'Deploying', 'Aborting'])) { |
|
| 1456 | + if(!in_array($deployment->Status, ['Queued', 'Deploying', 'Aborting'])) { |
|
| 1457 | 1457 | throw new LogicException(sprintf("Cannot abort from %s state.", $deployment->Status)); |
| 1458 | 1458 | } |
| 1459 | 1459 | |
@@ -1469,11 +1469,11 @@ discard block |
||
| 1469 | 1469 | */ |
| 1470 | 1470 | public function getDataTransferForm(SS_HTTPRequest $request = null) { |
| 1471 | 1471 | // Performs canView permission check by limiting visible projects |
| 1472 | - $envs = $this->getCurrentProject()->DNEnvironmentList()->filterByCallback(function ($item) { |
|
| 1472 | + $envs = $this->getCurrentProject()->DNEnvironmentList()->filterByCallback(function($item) { |
|
| 1473 | 1473 | return $item->canBackup(); |
| 1474 | 1474 | }); |
| 1475 | 1475 | |
| 1476 | - if (!$envs) { |
|
| 1476 | + if(!$envs) { |
|
| 1477 | 1477 | return $this->environment404Response(); |
| 1478 | 1478 | } |
| 1479 | 1479 | |
@@ -1491,7 +1491,7 @@ discard block |
||
| 1491 | 1491 | ->addExtraClass('btn') |
| 1492 | 1492 | ) |
| 1493 | 1493 | ); |
| 1494 | - $form->setFormAction($this->getRequest()->getURL() . '/DataTransferForm'); |
|
| 1494 | + $form->setFormAction($this->getRequest()->getURL().'/DataTransferForm'); |
|
| 1495 | 1495 | |
| 1496 | 1496 | return $form; |
| 1497 | 1497 | } |
@@ -1508,21 +1508,21 @@ discard block |
||
| 1508 | 1508 | |
| 1509 | 1509 | // Performs canView permission check by limiting visible projects |
| 1510 | 1510 | $project = $this->getCurrentProject(); |
| 1511 | - if (!$project) { |
|
| 1511 | + if(!$project) { |
|
| 1512 | 1512 | return $this->project404Response(); |
| 1513 | 1513 | } |
| 1514 | 1514 | |
| 1515 | 1515 | $dataArchive = null; |
| 1516 | 1516 | |
| 1517 | 1517 | // Validate direction. |
| 1518 | - if ($data['Direction'] == 'get') { |
|
| 1518 | + if($data['Direction'] == 'get') { |
|
| 1519 | 1519 | $validEnvs = $this->getCurrentProject()->DNEnvironmentList() |
| 1520 | - ->filterByCallback(function ($item) { |
|
| 1520 | + ->filterByCallback(function($item) { |
|
| 1521 | 1521 | return $item->canBackup(); |
| 1522 | 1522 | }); |
| 1523 | - } else if ($data['Direction'] == 'push') { |
|
| 1523 | + } else if($data['Direction'] == 'push') { |
|
| 1524 | 1524 | $validEnvs = $this->getCurrentProject()->DNEnvironmentList() |
| 1525 | - ->filterByCallback(function ($item) { |
|
| 1525 | + ->filterByCallback(function($item) { |
|
| 1526 | 1526 | return $item->canRestore(); |
| 1527 | 1527 | }); |
| 1528 | 1528 | } else { |
@@ -1531,24 +1531,24 @@ discard block |
||
| 1531 | 1531 | |
| 1532 | 1532 | // Validate $data['EnvironmentID'] by checking against $validEnvs. |
| 1533 | 1533 | $environment = $validEnvs->find('ID', $data['EnvironmentID']); |
| 1534 | - if (!$environment) { |
|
| 1534 | + if(!$environment) { |
|
| 1535 | 1535 | throw new LogicException('Invalid environment'); |
| 1536 | 1536 | } |
| 1537 | 1537 | |
| 1538 | 1538 | $this->validateSnapshotMode($data['Mode']); |
| 1539 | 1539 | |
| 1540 | 1540 | // Only 'push' direction is allowed an association with an existing archive. |
| 1541 | - if ( |
|
| 1541 | + if( |
|
| 1542 | 1542 | $data['Direction'] == 'push' |
| 1543 | 1543 | && isset($data['DataArchiveID']) |
| 1544 | 1544 | && is_numeric($data['DataArchiveID']) |
| 1545 | 1545 | ) { |
| 1546 | 1546 | $dataArchive = DNDataArchive::get()->byId($data['DataArchiveID']); |
| 1547 | - if (!$dataArchive) { |
|
| 1547 | + if(!$dataArchive) { |
|
| 1548 | 1548 | throw new LogicException('Invalid data archive'); |
| 1549 | 1549 | } |
| 1550 | 1550 | |
| 1551 | - if (!$dataArchive->canDownload()) { |
|
| 1551 | + if(!$dataArchive->canDownload()) { |
|
| 1552 | 1552 | throw new SS_HTTPResponse_Exception('Not allowed to access archive', 403); |
| 1553 | 1553 | } |
| 1554 | 1554 | } |
@@ -1558,7 +1558,7 @@ discard block |
||
| 1558 | 1558 | $transfer->Direction = $data['Direction']; |
| 1559 | 1559 | $transfer->Mode = $data['Mode']; |
| 1560 | 1560 | $transfer->DataArchiveID = $dataArchive ? $dataArchive->ID : null; |
| 1561 | - if ($data['Direction'] == 'push') { |
|
| 1561 | + if($data['Direction'] == 'push') { |
|
| 1562 | 1562 | $transfer->setBackupBeforePush(!empty($data['BackupBeforePush'])); |
| 1563 | 1563 | } |
| 1564 | 1564 | $transfer->write(); |
@@ -1581,17 +1581,17 @@ discard block |
||
| 1581 | 1581 | $params = $request->params(); |
| 1582 | 1582 | $transfer = DNDataTransfer::get()->byId($params['Identifier']); |
| 1583 | 1583 | |
| 1584 | - if (!$transfer || !$transfer->ID) { |
|
| 1584 | + if(!$transfer || !$transfer->ID) { |
|
| 1585 | 1585 | throw new SS_HTTPResponse_Exception('Transfer not found', 404); |
| 1586 | 1586 | } |
| 1587 | - if (!$transfer->canView()) { |
|
| 1587 | + if(!$transfer->canView()) { |
|
| 1588 | 1588 | return Security::permissionFailure(); |
| 1589 | 1589 | } |
| 1590 | 1590 | |
| 1591 | 1591 | $environment = $transfer->Environment(); |
| 1592 | 1592 | $project = $environment->Project(); |
| 1593 | 1593 | |
| 1594 | - if ($project->Name != $params['Project']) { |
|
| 1594 | + if($project->Name != $params['Project']) { |
|
| 1595 | 1595 | throw new LogicException("Project in URL doesn't match this deploy"); |
| 1596 | 1596 | } |
| 1597 | 1597 | |
@@ -1615,22 +1615,22 @@ discard block |
||
| 1615 | 1615 | $params = $request->params(); |
| 1616 | 1616 | $transfer = DNDataTransfer::get()->byId($params['Identifier']); |
| 1617 | 1617 | |
| 1618 | - if (!$transfer || !$transfer->ID) { |
|
| 1618 | + if(!$transfer || !$transfer->ID) { |
|
| 1619 | 1619 | throw new SS_HTTPResponse_Exception('Transfer not found', 404); |
| 1620 | 1620 | } |
| 1621 | - if (!$transfer->canView()) { |
|
| 1621 | + if(!$transfer->canView()) { |
|
| 1622 | 1622 | return Security::permissionFailure(); |
| 1623 | 1623 | } |
| 1624 | 1624 | |
| 1625 | 1625 | $environment = $transfer->Environment(); |
| 1626 | 1626 | $project = $environment->Project(); |
| 1627 | 1627 | |
| 1628 | - if ($project->Name != $params['Project']) { |
|
| 1628 | + if($project->Name != $params['Project']) { |
|
| 1629 | 1629 | throw new LogicException("Project in URL doesn't match this deploy"); |
| 1630 | 1630 | } |
| 1631 | 1631 | |
| 1632 | 1632 | $log = $transfer->log(); |
| 1633 | - if ($log->exists()) { |
|
| 1633 | + if($log->exists()) { |
|
| 1634 | 1634 | $content = $log->content(); |
| 1635 | 1635 | } else { |
| 1636 | 1636 | $content = 'Waiting for action to start'; |
@@ -1653,22 +1653,22 @@ discard block |
||
| 1653 | 1653 | |
| 1654 | 1654 | // Performs canView permission check by limiting visible projects |
| 1655 | 1655 | $project = $this->getCurrentProject(); |
| 1656 | - $envs = $project->DNEnvironmentList()->filterByCallback(function ($item) { |
|
| 1656 | + $envs = $project->DNEnvironmentList()->filterByCallback(function($item) { |
|
| 1657 | 1657 | return $item->canRestore(); |
| 1658 | 1658 | }); |
| 1659 | 1659 | |
| 1660 | - if (!$envs) { |
|
| 1660 | + if(!$envs) { |
|
| 1661 | 1661 | return $this->environment404Response(); |
| 1662 | 1662 | } |
| 1663 | 1663 | |
| 1664 | 1664 | $modesMap = []; |
| 1665 | - if (in_array($dataArchive->Mode, ['all'])) { |
|
| 1665 | + if(in_array($dataArchive->Mode, ['all'])) { |
|
| 1666 | 1666 | $modesMap['all'] = 'Database and Assets'; |
| 1667 | 1667 | }; |
| 1668 | - if (in_array($dataArchive->Mode, ['all', 'db'])) { |
|
| 1668 | + if(in_array($dataArchive->Mode, ['all', 'db'])) { |
|
| 1669 | 1669 | $modesMap['db'] = 'Database only'; |
| 1670 | 1670 | }; |
| 1671 | - if (in_array($dataArchive->Mode, ['all', 'assets'])) { |
|
| 1671 | + if(in_array($dataArchive->Mode, ['all', 'assets'])) { |
|
| 1672 | 1672 | $modesMap['assets'] = 'Assets only'; |
| 1673 | 1673 | }; |
| 1674 | 1674 | |
@@ -1692,7 +1692,7 @@ discard block |
||
| 1692 | 1692 | ->addExtraClass('btn') |
| 1693 | 1693 | ) |
| 1694 | 1694 | ); |
| 1695 | - $form->setFormAction($project->Link() . '/DataTransferRestoreForm'); |
|
| 1695 | + $form->setFormAction($project->Link().'/DataTransferRestoreForm'); |
|
| 1696 | 1696 | |
| 1697 | 1697 | return $form; |
| 1698 | 1698 | } |
@@ -1713,13 +1713,13 @@ discard block |
||
| 1713 | 1713 | /** @var DNDataArchive $dataArchive */ |
| 1714 | 1714 | $dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID')); |
| 1715 | 1715 | |
| 1716 | - if (!$dataArchive) { |
|
| 1716 | + if(!$dataArchive) { |
|
| 1717 | 1717 | throw new SS_HTTPResponse_Exception('Archive not found', 404); |
| 1718 | 1718 | } |
| 1719 | 1719 | |
| 1720 | 1720 | // We check for canDownload because that implies access to the data. |
| 1721 | 1721 | // canRestore is later checked on the actual restore action per environment. |
| 1722 | - if (!$dataArchive->canDownload()) { |
|
| 1722 | + if(!$dataArchive->canDownload()) { |
|
| 1723 | 1723 | throw new SS_HTTPResponse_Exception('Not allowed to access archive', 403); |
| 1724 | 1724 | } |
| 1725 | 1725 | |
@@ -1745,11 +1745,11 @@ discard block |
||
| 1745 | 1745 | /** @var DNDataArchive $dataArchive */ |
| 1746 | 1746 | $dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID')); |
| 1747 | 1747 | |
| 1748 | - if (!$dataArchive) { |
|
| 1748 | + if(!$dataArchive) { |
|
| 1749 | 1749 | throw new SS_HTTPResponse_Exception('Archive not found', 404); |
| 1750 | 1750 | } |
| 1751 | 1751 | |
| 1752 | - if (!$dataArchive->canDelete()) { |
|
| 1752 | + if(!$dataArchive->canDelete()) { |
|
| 1753 | 1753 | throw new SS_HTTPResponse_Exception('Not allowed to delete archive', 403); |
| 1754 | 1754 | } |
| 1755 | 1755 | |
@@ -1770,7 +1770,7 @@ discard block |
||
| 1770 | 1770 | |
| 1771 | 1771 | // Performs canView permission check by limiting visible projects |
| 1772 | 1772 | $project = $this->getCurrentProject(); |
| 1773 | - if (!$project) { |
|
| 1773 | + if(!$project) { |
|
| 1774 | 1774 | return $this->project404Response(); |
| 1775 | 1775 | } |
| 1776 | 1776 | |
@@ -1790,7 +1790,7 @@ discard block |
||
| 1790 | 1790 | ->addExtraClass('btn') |
| 1791 | 1791 | ) |
| 1792 | 1792 | ); |
| 1793 | - $form->setFormAction($project->Link() . '/DeleteForm'); |
|
| 1793 | + $form->setFormAction($project->Link().'/DeleteForm'); |
|
| 1794 | 1794 | |
| 1795 | 1795 | return $form; |
| 1796 | 1796 | } |
@@ -1807,24 +1807,24 @@ discard block |
||
| 1807 | 1807 | |
| 1808 | 1808 | // Performs canView permission check by limiting visible projects |
| 1809 | 1809 | $project = $this->getCurrentProject(); |
| 1810 | - if (!$project) { |
|
| 1810 | + if(!$project) { |
|
| 1811 | 1811 | return $this->project404Response(); |
| 1812 | 1812 | } |
| 1813 | 1813 | |
| 1814 | 1814 | $dataArchive = null; |
| 1815 | 1815 | |
| 1816 | - if ( |
|
| 1816 | + if( |
|
| 1817 | 1817 | isset($data['DataArchiveID']) |
| 1818 | 1818 | && is_numeric($data['DataArchiveID']) |
| 1819 | 1819 | ) { |
| 1820 | 1820 | $dataArchive = DNDataArchive::get()->byId($data['DataArchiveID']); |
| 1821 | 1821 | } |
| 1822 | 1822 | |
| 1823 | - if (!$dataArchive) { |
|
| 1823 | + if(!$dataArchive) { |
|
| 1824 | 1824 | throw new LogicException('Invalid data archive'); |
| 1825 | 1825 | } |
| 1826 | 1826 | |
| 1827 | - if (!$dataArchive->canDelete()) { |
|
| 1827 | + if(!$dataArchive->canDelete()) { |
|
| 1828 | 1828 | throw new SS_HTTPResponse_Exception('Not allowed to delete archive', 403); |
| 1829 | 1829 | } |
| 1830 | 1830 | |
@@ -1847,12 +1847,12 @@ discard block |
||
| 1847 | 1847 | /** @var DNDataArchive $dataArchive */ |
| 1848 | 1848 | $dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID')); |
| 1849 | 1849 | |
| 1850 | - if (!$dataArchive) { |
|
| 1850 | + if(!$dataArchive) { |
|
| 1851 | 1851 | throw new SS_HTTPResponse_Exception('Archive not found', 404); |
| 1852 | 1852 | } |
| 1853 | 1853 | |
| 1854 | 1854 | // We check for canDownload because that implies access to the data. |
| 1855 | - if (!$dataArchive->canDownload()) { |
|
| 1855 | + if(!$dataArchive->canDownload()) { |
|
| 1856 | 1856 | throw new SS_HTTPResponse_Exception('Not allowed to access archive', 403); |
| 1857 | 1857 | } |
| 1858 | 1858 | |
@@ -1874,7 +1874,7 @@ discard block |
||
| 1874 | 1874 | $dataArchive = $dataArchive ? $dataArchive : DNDataArchive::get()->byId($request->requestVar('DataArchiveID')); |
| 1875 | 1875 | |
| 1876 | 1876 | $envs = $dataArchive->validTargetEnvironments(); |
| 1877 | - if (!$envs) { |
|
| 1877 | + if(!$envs) { |
|
| 1878 | 1878 | return $this->environment404Response(); |
| 1879 | 1879 | } |
| 1880 | 1880 | |
@@ -1896,7 +1896,7 @@ discard block |
||
| 1896 | 1896 | ->addExtraClass('btn') |
| 1897 | 1897 | ) |
| 1898 | 1898 | ); |
| 1899 | - $form->setFormAction($this->getCurrentProject()->Link() . '/MoveForm'); |
|
| 1899 | + $form->setFormAction($this->getCurrentProject()->Link().'/MoveForm'); |
|
| 1900 | 1900 | |
| 1901 | 1901 | return $form; |
| 1902 | 1902 | } |
@@ -1915,25 +1915,25 @@ discard block |
||
| 1915 | 1915 | |
| 1916 | 1916 | // Performs canView permission check by limiting visible projects |
| 1917 | 1917 | $project = $this->getCurrentProject(); |
| 1918 | - if (!$project) { |
|
| 1918 | + if(!$project) { |
|
| 1919 | 1919 | return $this->project404Response(); |
| 1920 | 1920 | } |
| 1921 | 1921 | |
| 1922 | 1922 | /** @var DNDataArchive $dataArchive */ |
| 1923 | 1923 | $dataArchive = DNDataArchive::get()->byId($data['DataArchiveID']); |
| 1924 | - if (!$dataArchive) { |
|
| 1924 | + if(!$dataArchive) { |
|
| 1925 | 1925 | throw new LogicException('Invalid data archive'); |
| 1926 | 1926 | } |
| 1927 | 1927 | |
| 1928 | 1928 | // We check for canDownload because that implies access to the data. |
| 1929 | - if (!$dataArchive->canDownload()) { |
|
| 1929 | + if(!$dataArchive->canDownload()) { |
|
| 1930 | 1930 | throw new SS_HTTPResponse_Exception('Not allowed to access archive', 403); |
| 1931 | 1931 | } |
| 1932 | 1932 | |
| 1933 | 1933 | // Validate $data['EnvironmentID'] by checking against $validEnvs. |
| 1934 | 1934 | $validEnvs = $dataArchive->validTargetEnvironments(); |
| 1935 | 1935 | $environment = $validEnvs->find('ID', $data['EnvironmentID']); |
| 1936 | - if (!$environment) { |
|
| 1936 | + if(!$environment) { |
|
| 1937 | 1937 | throw new LogicException('Invalid environment'); |
| 1938 | 1938 | } |
| 1939 | 1939 | |
@@ -1951,7 +1951,7 @@ discard block |
||
| 1951 | 1951 | public static function RedisUnavailable() { |
| 1952 | 1952 | try { |
| 1953 | 1953 | Resque::queues(); |
| 1954 | - } catch (Exception $e) { |
|
| 1954 | + } catch(Exception $e) { |
|
| 1955 | 1955 | return $e->getMessage(); |
| 1956 | 1956 | } |
| 1957 | 1957 | return ''; |
@@ -2005,10 +2005,10 @@ discard block |
||
| 2005 | 2005 | */ |
| 2006 | 2006 | public function getCurrentProject() { |
| 2007 | 2007 | $projectName = trim($this->getRequest()->param('Project')); |
| 2008 | - if (!$projectName) { |
|
| 2008 | + if(!$projectName) { |
|
| 2009 | 2009 | return null; |
| 2010 | 2010 | } |
| 2011 | - if (empty(self::$_project_cache[$projectName])) { |
|
| 2011 | + if(empty(self::$_project_cache[$projectName])) { |
|
| 2012 | 2012 | self::$_project_cache[$projectName] = $this->DNProjectList()->filter('Name', $projectName)->First(); |
| 2013 | 2013 | } |
| 2014 | 2014 | return self::$_project_cache[$projectName]; |
@@ -2019,14 +2019,14 @@ discard block |
||
| 2019 | 2019 | * @return DNEnvironment|null |
| 2020 | 2020 | */ |
| 2021 | 2021 | public function getCurrentEnvironment(DNProject $project = null) { |
| 2022 | - if ($this->getRequest()->param('Environment') === null) { |
|
| 2022 | + if($this->getRequest()->param('Environment') === null) { |
|
| 2023 | 2023 | return null; |
| 2024 | 2024 | } |
| 2025 | - if ($project === null) { |
|
| 2025 | + if($project === null) { |
|
| 2026 | 2026 | $project = $this->getCurrentProject(); |
| 2027 | 2027 | } |
| 2028 | 2028 | // project can still be null |
| 2029 | - if ($project === null) { |
|
| 2029 | + if($project === null) { |
|
| 2030 | 2030 | return null; |
| 2031 | 2031 | } |
| 2032 | 2032 | return $project->DNEnvironmentList()->filter('Name', $this->getRequest()->param('Environment'))->First(); |
@@ -2065,23 +2065,23 @@ discard block |
||
| 2065 | 2065 | * @return boolean|null true if $member has access to upload or download to at least one {@link DNEnvironment}. |
| 2066 | 2066 | */ |
| 2067 | 2067 | public function CanViewArchives(Member $member = null) { |
| 2068 | - if ($member === null) { |
|
| 2068 | + if($member === null) { |
|
| 2069 | 2069 | $member = Member::currentUser(); |
| 2070 | 2070 | } |
| 2071 | 2071 | |
| 2072 | - if (Permission::checkMember($member, 'ADMIN')) { |
|
| 2072 | + if(Permission::checkMember($member, 'ADMIN')) { |
|
| 2073 | 2073 | return true; |
| 2074 | 2074 | } |
| 2075 | 2075 | |
| 2076 | 2076 | $allProjects = $this->DNProjectList(); |
| 2077 | - if (!$allProjects) { |
|
| 2077 | + if(!$allProjects) { |
|
| 2078 | 2078 | return false; |
| 2079 | 2079 | } |
| 2080 | 2080 | |
| 2081 | - foreach ($allProjects as $project) { |
|
| 2082 | - if ($project->Environments()) { |
|
| 2083 | - foreach ($project->Environments() as $environment) { |
|
| 2084 | - if ( |
|
| 2081 | + foreach($allProjects as $project) { |
|
| 2082 | + if($project->Environments()) { |
|
| 2083 | + foreach($project->Environments() as $environment) { |
|
| 2084 | + if( |
|
| 2085 | 2085 | $environment->canRestore($member) || |
| 2086 | 2086 | $environment->canBackup($member) || |
| 2087 | 2087 | $environment->canUploadArchive($member) || |
@@ -2102,7 +2102,7 @@ discard block |
||
| 2102 | 2102 | */ |
| 2103 | 2103 | public function CreateEnvironmentList() { |
| 2104 | 2104 | $project = $this->getCurrentProject(); |
| 2105 | - if ($project) { |
|
| 2105 | + if($project) { |
|
| 2106 | 2106 | $dataList = $project->CreateEnvironments(); |
| 2107 | 2107 | } else { |
| 2108 | 2108 | $dataList = new ArrayList(); |
@@ -2122,9 +2122,9 @@ discard block |
||
| 2122 | 2122 | $archives = new ArrayList(); |
| 2123 | 2123 | |
| 2124 | 2124 | $archiveList = $project->Environments()->relation("DataArchives"); |
| 2125 | - if ($archiveList->count() > 0) { |
|
| 2126 | - foreach ($archiveList as $archive) { |
|
| 2127 | - if (!$archive->isPending()) { |
|
| 2125 | + if($archiveList->count() > 0) { |
|
| 2126 | + foreach($archiveList as $archive) { |
|
| 2127 | + if(!$archive->isPending()) { |
|
| 2128 | 2128 | $archives->push($archive); |
| 2129 | 2129 | } |
| 2130 | 2130 | } |
@@ -2139,9 +2139,9 @@ discard block |
||
| 2139 | 2139 | public function PendingDataArchives() { |
| 2140 | 2140 | $project = $this->getCurrentProject(); |
| 2141 | 2141 | $archives = new ArrayList(); |
| 2142 | - foreach ($project->DNEnvironmentList() as $env) { |
|
| 2143 | - foreach ($env->DataArchives() as $archive) { |
|
| 2144 | - if ($archive->isPending()) { |
|
| 2142 | + foreach($project->DNEnvironmentList() as $env) { |
|
| 2143 | + foreach($env->DataArchives() as $archive) { |
|
| 2144 | + if($archive->isPending()) { |
|
| 2145 | 2145 | $archives->push($archive); |
| 2146 | 2146 | } |
| 2147 | 2147 | } |
@@ -2157,7 +2157,7 @@ discard block |
||
| 2157 | 2157 | $transfers = DNDataTransfer::get() |
| 2158 | 2158 | ->filter('EnvironmentID', $environments) |
| 2159 | 2159 | ->filterByCallback( |
| 2160 | - function ($record) { |
|
| 2160 | + function($record) { |
|
| 2161 | 2161 | return |
| 2162 | 2162 | $record->Environment()->canRestore() || // Ensure member can perform an action on the transfers env |
| 2163 | 2163 | $record->Environment()->canBackup() || |
@@ -2174,9 +2174,9 @@ discard block |
||
| 2174 | 2174 | * @return null|PaginatedList |
| 2175 | 2175 | */ |
| 2176 | 2176 | public function DeployHistory() { |
| 2177 | - if ($env = $this->getCurrentEnvironment()) { |
|
| 2177 | + if($env = $this->getCurrentEnvironment()) { |
|
| 2178 | 2178 | $history = $env->DeployHistory(); |
| 2179 | - if ($history->count() > 0) { |
|
| 2179 | + if($history->count() > 0) { |
|
| 2180 | 2180 | $pagination = new PaginatedList($history, $this->getRequest()); |
| 2181 | 2181 | $pagination->setPageLength(4); |
| 2182 | 2182 | return $pagination; |
@@ -2198,7 +2198,7 @@ discard block |
||
| 2198 | 2198 | $sendJSON = (strpos($this->getRequest()->getHeader('Accept'), 'application/json') !== false) |
| 2199 | 2199 | || $this->getRequest()->getExtension() == 'json'; |
| 2200 | 2200 | |
| 2201 | - if (!$sendJSON) { |
|
| 2201 | + if(!$sendJSON) { |
|
| 2202 | 2202 | $this->response->addHeader("Content-type", "text/plain"); |
| 2203 | 2203 | return $content; |
| 2204 | 2204 | } |
@@ -2217,7 +2217,7 @@ discard block |
||
| 2217 | 2217 | public function AmbientMenu() { |
| 2218 | 2218 | $list = new ArrayList(); |
| 2219 | 2219 | |
| 2220 | - if (Member::currentUserID()) { |
|
| 2220 | + if(Member::currentUserID()) { |
|
| 2221 | 2221 | $list->push(new ArrayData([ |
| 2222 | 2222 | 'Classes' => 'logout', |
| 2223 | 2223 | 'FaIcon' => 'sign-out', |
@@ -2238,10 +2238,10 @@ discard block |
||
| 2238 | 2238 | * @return bool |
| 2239 | 2239 | */ |
| 2240 | 2240 | public function canCreateProjects($member = null) { |
| 2241 | - if (!$member) { |
|
| 2241 | + if(!$member) { |
|
| 2242 | 2242 | $member = Member::currentUser(); |
| 2243 | 2243 | } |
| 2244 | - if (!$member) { |
|
| 2244 | + if(!$member) { |
|
| 2245 | 2245 | return false; |
| 2246 | 2246 | } |
| 2247 | 2247 | |
@@ -2249,28 +2249,28 @@ discard block |
||
| 2249 | 2249 | } |
| 2250 | 2250 | |
| 2251 | 2251 | protected function applyRedeploy(SS_HTTPRequest $request, &$data) { |
| 2252 | - if (!$request->getVar('redeploy')) { |
|
| 2252 | + if(!$request->getVar('redeploy')) { |
|
| 2253 | 2253 | return; |
| 2254 | 2254 | } |
| 2255 | 2255 | |
| 2256 | 2256 | $project = $this->getCurrentProject(); |
| 2257 | - if (!$project) { |
|
| 2257 | + if(!$project) { |
|
| 2258 | 2258 | return $this->project404Response(); |
| 2259 | 2259 | } |
| 2260 | 2260 | |
| 2261 | 2261 | // Performs canView permission check by limiting visible projects |
| 2262 | 2262 | $env = $this->getCurrentEnvironment($project); |
| 2263 | - if (!$env) { |
|
| 2263 | + if(!$env) { |
|
| 2264 | 2264 | return $this->environment404Response(); |
| 2265 | 2265 | } |
| 2266 | 2266 | |
| 2267 | 2267 | $current = $env->CurrentBuild(); |
| 2268 | - if ($current && $current->exists()) { |
|
| 2268 | + if($current && $current->exists()) { |
|
| 2269 | 2269 | $data['preselect_tab'] = 3; |
| 2270 | 2270 | $data['preselect_sha'] = $current->SHA; |
| 2271 | 2271 | } else { |
| 2272 | 2272 | $master = $project->DNBranchList()->byName('master'); |
| 2273 | - if ($master) { |
|
| 2273 | + if($master) { |
|
| 2274 | 2274 | $data['preselect_tab'] = 1; |
| 2275 | 2275 | $data['preselect_sha'] = $master->SHA(); |
| 2276 | 2276 | } |
@@ -2282,7 +2282,7 @@ discard block |
||
| 2282 | 2282 | */ |
| 2283 | 2283 | protected function project404Response() { |
| 2284 | 2284 | return new SS_HTTPResponse( |
| 2285 | - "Project '" . Convert::raw2xml($this->getRequest()->param('Project')) . "' not found.", |
|
| 2285 | + "Project '".Convert::raw2xml($this->getRequest()->param('Project'))."' not found.", |
|
| 2286 | 2286 | 404 |
| 2287 | 2287 | ); |
| 2288 | 2288 | } |
@@ -2292,7 +2292,7 @@ discard block |
||
| 2292 | 2292 | */ |
| 2293 | 2293 | protected function environment404Response() { |
| 2294 | 2294 | $envName = Convert::raw2xml($this->getRequest()->param('Environment')); |
| 2295 | - return new SS_HTTPResponse("Environment '" . $envName . "' not found.", 404); |
|
| 2295 | + return new SS_HTTPResponse("Environment '".$envName."' not found.", 404); |
|
| 2296 | 2296 | } |
| 2297 | 2297 | |
| 2298 | 2298 | /** |
@@ -2301,7 +2301,7 @@ discard block |
||
| 2301 | 2301 | * @param string $mode |
| 2302 | 2302 | */ |
| 2303 | 2303 | protected function validateSnapshotMode($mode) { |
| 2304 | - if (!in_array($mode, ['all', 'assets', 'db'])) { |
|
| 2304 | + if(!in_array($mode, ['all', 'assets', 'db'])) { |
|
| 2305 | 2305 | throw new LogicException('Invalid mode'); |
| 2306 | 2306 | } |
| 2307 | 2307 | } |
@@ -2315,12 +2315,12 @@ discard block |
||
| 2315 | 2315 | protected function getCustomisedViewSection($sectionName, $title = '', $data = []) { |
| 2316 | 2316 | // Performs canView permission check by limiting visible projects |
| 2317 | 2317 | $project = $this->getCurrentProject(); |
| 2318 | - if (!$project) { |
|
| 2318 | + if(!$project) { |
|
| 2319 | 2319 | return $this->project404Response(); |
| 2320 | 2320 | } |
| 2321 | 2321 | $data[$sectionName] = 1; |
| 2322 | 2322 | |
| 2323 | - if ($this !== '') { |
|
| 2323 | + if($this !== '') { |
|
| 2324 | 2324 | $data['Title'] = $title; |
| 2325 | 2325 | } |
| 2326 | 2326 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | return false; |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | - $key = $memberID . '-' . $this->EnvironmentID; |
|
| 232 | + $key = $memberID.'-'.$this->EnvironmentID; |
|
| 233 | 233 | if(!isset(self::$_cache_can_restore[$key])) { |
| 234 | 234 | self::$_cache_can_restore[$key] = $this->Environment()->canUploadArchive($member); |
| 235 | 235 | } |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | return false; |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - $key = $memberID . '-' . $this->EnvironmentID; |
|
| 253 | + $key = $memberID.'-'.$this->EnvironmentID; |
|
| 254 | 254 | if(!isset(self::$_cache_can_download[$key])) { |
| 255 | 255 | self::$_cache_can_download[$key] = $this->Environment()->canDownloadArchive($member); |
| 256 | 256 | } |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | // Extract database.sql.gz to <workingdir>/database.sql |
| 440 | - if(file_exists($workingDir . DIRECTORY_SEPARATOR . 'database.sql.gz')) { |
|
| 440 | + if(file_exists($workingDir.DIRECTORY_SEPARATOR.'database.sql.gz')) { |
|
| 441 | 441 | $process = new Process('gunzip database.sql.gz', $workingDir); |
| 442 | 442 | $process->setTimeout(3600); |
| 443 | 443 | $process->run(); |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | // Extract assets.tar.gz to <workingdir>/assets/ |
| 451 | - if(file_exists($workingDir . DIRECTORY_SEPARATOR . 'assets.tar.gz')) { |
|
| 451 | + if(file_exists($workingDir.DIRECTORY_SEPARATOR.'assets.tar.gz')) { |
|
| 452 | 452 | $process = new Process('tar xzf assets.tar.gz', $workingDir); |
| 453 | 453 | $process->setTimeout(3600); |
| 454 | 454 | $process->run(); |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | public static $cache = array(); |
| 8 | 8 | |
| 9 | 9 | public static function getIncludingBranches($commit) { |
| 10 | - $cacheKey = 'getIncludingBranches-' . $commit->getRepository()->getPath() . '-' . $commit->gethash(); |
|
| 10 | + $cacheKey = 'getIncludingBranches-'.$commit->getRepository()->getPath().'-'.$commit->gethash(); |
|
| 11 | 11 | if(!isset(self::$cache[$cacheKey])) { |
| 12 | 12 | self::$cache[$cacheKey] = $commit->getIncludingBranches(); |
| 13 | 13 | } |
@@ -55,7 +55,7 @@ |
||
| 55 | 55 | |
| 56 | 56 | public function Link() { |
| 57 | 57 | // Use a get-var for branch so that it can handle unsafe chars better |
| 58 | - return Controller::join_links($this->project->Link(), 'branch?name=' . urlencode($this->Name())); |
|
| 58 | + return Controller::join_links($this->project->Link(), 'branch?name='.urlencode($this->Name())); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | * @return string |
| 38 | 38 | */ |
| 39 | 39 | public function LogLink() { |
| 40 | - return $this->Link() . '/log'; |
|
| 40 | + return $this->Link().'/log'; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |