@@ -49,7 +49,7 @@ |
||
| 49 | 49 | 'projects' => array(), |
| 50 | 50 | ); |
| 51 | 51 | |
| 52 | - if($request->httpMethod() != 'GET') return $this->message('API not found', 404);; |
|
| 52 | + if($request->httpMethod() != 'GET') return $this->message('API not found', 404); ; |
|
| 53 | 53 | |
| 54 | 54 | foreach(DNProject::get() as $item) { |
| 55 | 55 | if($item->canView($this->getMember())) { |
@@ -49,7 +49,10 @@ |
||
| 49 | 49 | 'projects' => array(), |
| 50 | 50 | ); |
| 51 | 51 | |
| 52 | - if($request->httpMethod() != 'GET') return $this->message('API not found', 404);; |
|
| 52 | + if($request->httpMethod() != 'GET') { |
|
| 53 | + return $this->message('API not found', 404); |
|
| 54 | + } |
|
| 55 | + ; |
|
| 53 | 56 | |
| 54 | 57 | foreach(DNProject::get() as $item) { |
| 55 | 58 | if($item->canView($this->getMember())) { |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | "href" => "$href/deploy", |
| 39 | 39 | "type" => "application/json", |
| 40 | 40 | "fields" => array( |
| 41 | - array( "name" => "release", "type" => "text" ), |
|
| 41 | + array("name" => "release", "type" => "text"), |
|
| 42 | 42 | ), |
| 43 | 43 | ) |
| 44 | 44 | ) |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | $ping->write(); |
| 127 | 127 | $ping->start(); |
| 128 | 128 | |
| 129 | - $location = Director::absoluteBaseURL().$this->Link().'/ping/'.$ping->ID; |
|
| 129 | + $location = Director::absoluteBaseURL() . $this->Link() . '/ping/' . $ping->ID; |
|
| 130 | 130 | $output = array( |
| 131 | 131 | 'message' => 'Ping queued as job ' . $ping->ResqueToken, |
| 132 | 132 | 'href' => $location, |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | $deploy->SHA = $reqBody['release']; |
| 181 | 181 | $deploy->write(); |
| 182 | 182 | $deploy->start(); |
| 183 | - $location = Director::absoluteBaseURL().$this->Link().'/deploy/'.$deploy->ID; |
|
| 183 | + $location = Director::absoluteBaseURL() . $this->Link() . '/deploy/' . $deploy->ID; |
|
| 184 | 184 | $output = array( |
| 185 | 185 | 'message' => 'Deploy queued as job ' . $deploy->ResqueToken, |
| 186 | 186 | 'href' => $location, |
@@ -119,7 +119,7 @@ |
||
| 119 | 119 | * @return SS_HTTPResponse |
| 120 | 120 | */ |
| 121 | 121 | protected function message($message, $statusCode) { |
| 122 | - $response = $this->getAPIResponse(array( |
|
| 122 | + $response = $this->getAPIResponse(array( |
|
| 123 | 123 | 'message' => $message, |
| 124 | 124 | 'statusCode' => $statusCode |
| 125 | 125 | )); |
@@ -97,7 +97,7 @@ |
||
| 97 | 97 | $fetch->write(); |
| 98 | 98 | $fetch->start(); |
| 99 | 99 | |
| 100 | - $location = Director::absoluteBaseURL().$this->Link().'/fetch/'.$fetch->ID; |
|
| 100 | + $location = Director::absoluteBaseURL() . $this->Link() . '/fetch/' . $fetch->ID; |
|
| 101 | 101 | $output = array( |
| 102 | 102 | 'message' => 'Ping queued as job ' . $fetch->ResqueToken, |
| 103 | 103 | 'href' => $location, |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | $env = $environment->Project()->getProcessEnv(); |
| 178 | 178 | |
| 179 | 179 | if(!$args) $args = array(); |
| 180 | - $args['history_path'] = realpath(DEPLOYNAUT_LOG_PATH.'/'); |
|
| 180 | + $args['history_path'] = realpath(DEPLOYNAUT_LOG_PATH . '/'); |
|
| 181 | 181 | |
| 182 | 182 | // Inject env string directly into the command. |
| 183 | 183 | // Capistrano doesn't like the $process->setEnv($env) we'd normally do below. |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | |
| 192 | 192 | $data = DNData::inst(); |
| 193 | 193 | // Generate a capfile from a template |
| 194 | - $capTemplate = file_get_contents(BASE_PATH.'/deploynaut/Capfile.template'); |
|
| 194 | + $capTemplate = file_get_contents(BASE_PATH . '/deploynaut/Capfile.template'); |
|
| 195 | 195 | $cap = str_replace( |
| 196 | 196 | array('<config root>', '<ssh key>', '<base path>'), |
| 197 | 197 | array($data->getEnvironmentDir(), DEPLOYNAUT_SSH_KEY, BASE_PATH), |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | if(defined('DEPLOYNAUT_CAPFILE')) { |
| 202 | 202 | $capFile = DEPLOYNAUT_CAPFILE; |
| 203 | 203 | } else { |
| 204 | - $capFile = ASSETS_PATH.'/Capfile'; |
|
| 204 | + $capFile = ASSETS_PATH . '/Capfile'; |
|
| 205 | 205 | } |
| 206 | 206 | file_put_contents($capFile, $cap); |
| 207 | 207 | |
@@ -176,7 +176,9 @@ |
||
| 176 | 176 | $name = $environment->getFullName(); |
| 177 | 177 | $env = $environment->Project()->getProcessEnv(); |
| 178 | 178 | |
| 179 | - if(!$args) $args = array(); |
|
| 179 | + if(!$args) { |
|
| 180 | + $args = array(); |
|
| 181 | + } |
|
| 180 | 182 | $args['history_path'] = realpath(DEPLOYNAUT_LOG_PATH.'/'); |
| 181 | 183 | |
| 182 | 184 | // Inject env string directly into the command. |
@@ -53,7 +53,7 @@ |
||
| 53 | 53 | |
| 54 | 54 | // Default, cacheless implementation |
| 55 | 55 | } else { |
| 56 | - $filename = TEMP_FOLDER .'/' . $sha . '.tar.gz'; |
|
| 56 | + $filename = TEMP_FOLDER . '/' . $sha . '.tar.gz'; |
|
| 57 | 57 | if($this->generatePackage($sha, $repositoryDir, $outputFilename, $log)) { |
| 58 | 58 | return $filename; |
| 59 | 59 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | public function getIdentifier() { |
| 27 | 27 | // If the build script changes, don't re-use cached items |
| 28 | - return substr(sha1($this->buildScript),0,8); |
|
| 28 | + return substr(sha1($this->buildScript), 0, 8); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | protected function executeProcesses($processes, DeploynautLogFile $log) { |
| 74 | 74 | foreach($processes as $process) { |
| 75 | - $process->mustRun(function ($type, $buffer) use($log) { |
|
| 75 | + $process->mustRun(function($type, $buffer) use($log) { |
|
| 76 | 76 | $log->write($buffer); |
| 77 | 77 | }); |
| 78 | 78 | } |
@@ -33,7 +33,9 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | public function generatePackage($sha, $baseDir, $outputFilename, DeploynautLogFile $log) { |
| 35 | 35 | $tempPath = TEMP_FOLDER . "/" . str_replace(".tar.gz", "", basename($outputFilename)); |
| 36 | - if(!file_exists($tempPath)) mkdir($tempPath); |
|
| 36 | + if(!file_exists($tempPath)) { |
|
| 37 | + mkdir($tempPath); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | // Execute these in sequence until there's a failure |
| 39 | 41 | $processes = array( |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | return $filename; |
| 62 | 62 | |
| 63 | 63 | } else { |
| 64 | - if($this->cacheSize) $this->reduceDirSizeTo($buildPath, $this->cacheSize-1, $log); |
|
| 64 | + if($this->cacheSize) $this->reduceDirSizeTo($buildPath, $this->cacheSize - 1, $log); |
|
| 65 | 65 | |
| 66 | 66 | if($generator->generatePackage($sha, $repositoryDir, $filename, $log)) { |
| 67 | 67 | return $filename; |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | return filemtime($a) > filemtime($b); |
| 95 | 95 | }); |
| 96 | 96 | |
| 97 | - for($i=0;$i<sizeof($files)-$count;$i++) { |
|
| 97 | + for($i = 0; $i < sizeof($files) - $count; $i++) { |
|
| 98 | 98 | $log->write("Removing " . $files[$i] . " from package cache"); |
| 99 | 99 | unlink($files[$i]); |
| 100 | 100 | } |
@@ -41,16 +41,22 @@ discard block |
||
| 41 | 41 | * @param DeploynautLogFile $log The log to write status output to, including package-generation commands |
| 42 | 42 | */ |
| 43 | 43 | public function getPackageFilename(PackageGenerator $generator, $identifier, $sha, $repositoryDir, DeploynautLogFile $log) { |
| 44 | - if(!$this->baseDir) throw new \LogicException("Can't use PackageCache without setting BaseDir"); |
|
| 44 | + if(!$this->baseDir) { |
|
| 45 | + throw new \LogicException("Can't use PackageCache without setting BaseDir"); |
|
| 46 | + } |
|
| 45 | 47 | |
| 46 | 48 | $buildPath = $this->baseDir . '/' . $this->sanitiseDirName($identifier); |
| 47 | 49 | $filename = "$buildPath/$sha.tar.gz"; |
| 48 | 50 | |
| 49 | 51 | if(!file_exists($this->baseDir)) { |
| 50 | - if(!mkdir($this->baseDir)) throw new \LogicException("Can't create base dir {$this->baseDir}"); |
|
| 52 | + if(!mkdir($this->baseDir)) { |
|
| 53 | + throw new \LogicException("Can't create base dir {$this->baseDir}"); |
|
| 54 | + } |
|
| 51 | 55 | } |
| 52 | 56 | if(!file_exists($buildPath)) { |
| 53 | - if(!mkdir($buildPath)) throw new \LogicException("Can't create build path $buildPath"); |
|
| 57 | + if(!mkdir($buildPath)) { |
|
| 58 | + throw new \LogicException("Can't create build path $buildPath"); |
|
| 59 | + } |
|
| 54 | 60 | } |
| 55 | 61 | |
| 56 | 62 | if(file_exists($filename)) { |
@@ -61,7 +67,9 @@ discard block |
||
| 61 | 67 | return $filename; |
| 62 | 68 | |
| 63 | 69 | } else { |
| 64 | - if($this->cacheSize) $this->reduceDirSizeTo($buildPath, $this->cacheSize-1, $log); |
|
| 70 | + if($this->cacheSize) { |
|
| 71 | + $this->reduceDirSizeTo($buildPath, $this->cacheSize-1, $log); |
|
| 72 | + } |
|
| 65 | 73 | |
| 66 | 74 | if($generator->generatePackage($sha, $repositoryDir, $filename, $log)) { |
| 67 | 75 | return $filename; |
@@ -107,11 +107,11 @@ discard block |
||
| 107 | 107 | * @return boolean |
| 108 | 108 | */ |
| 109 | 109 | public static function FlagSnapshotsEnabled() { |
| 110 | - if (defined('FLAG_SNAPSHOTS_ENABLED') && FLAG_SNAPSHOTS_ENABLED) return true; |
|
| 111 | - if (defined('FLAG_SNAPSHOTS_ENABLED_FOR_MEMBERS') && FLAG_SNAPSHOTS_ENABLED_FOR_MEMBERS) { |
|
| 110 | + if(defined('FLAG_SNAPSHOTS_ENABLED') && FLAG_SNAPSHOTS_ENABLED) return true; |
|
| 111 | + if(defined('FLAG_SNAPSHOTS_ENABLED_FOR_MEMBERS') && FLAG_SNAPSHOTS_ENABLED_FOR_MEMBERS) { |
|
| 112 | 112 | $allowedMembers = explode(';', FLAG_SNAPSHOTS_ENABLED_FOR_MEMBERS); |
| 113 | 113 | $member = Member::currentUser(); |
| 114 | - if ($allowedMembers && $member && in_array($member->Email, $allowedMembers)) return true; |
|
| 114 | + if($allowedMembers && $member && in_array($member->Email, $allowedMembers)) return true; |
|
| 115 | 115 | } |
| 116 | 116 | return false; |
| 117 | 117 | } |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | ) |
| 139 | 139 | ); |
| 140 | 140 | |
| 141 | - Requirements::css(FRAMEWORK_ADMIN_DIR .'/thirdparty/chosen/chosen/chosen.css'); |
|
| 141 | + Requirements::css(FRAMEWORK_ADMIN_DIR . '/thirdparty/chosen/chosen/chosen.css'); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | // Framing an environment as a "group of people with download access" |
| 266 | 266 | // makes more sense to the user here, while still allowing us to enforce |
| 267 | 267 | // environment specific restrictions on downloading the file later on. |
| 268 | - $envs = $project->DNEnvironmentList()->filterByCallback(function($item) {return $item->canUploadArchive();}); |
|
| 268 | + $envs = $project->DNEnvironmentList()->filterByCallback(function($item) {return $item->canUploadArchive(); }); |
|
| 269 | 269 | $envsMap = array(); |
| 270 | 270 | foreach($envs as $env) { |
| 271 | 271 | $envsMap[$env->ID] = $env->Name; |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | $form->disableSecurityToken(); |
| 294 | 294 | $form->addExtraClass('fields-wide'); |
| 295 | 295 | // Tweak the action so it plays well with our fake URL structure. |
| 296 | - $form->setFormAction($project->Link().'/UploadSnapshotForm'); |
|
| 296 | + $form->setFormAction($project->Link() . '/UploadSnapshotForm'); |
|
| 297 | 297 | |
| 298 | 298 | return $form; |
| 299 | 299 | } |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | // Framing an environment as a "group of people with download access" |
| 413 | 413 | // makes more sense to the user here, while still allowing us to enforce |
| 414 | 414 | // environment specific restrictions on downloading the file later on. |
| 415 | - $envs = $project->DNEnvironmentList()->filterByCallback(function($item) {return $item->canUploadArchive();}); |
|
| 415 | + $envs = $project->DNEnvironmentList()->filterByCallback(function($item) {return $item->canUploadArchive(); }); |
|
| 416 | 416 | $envsMap = array(); |
| 417 | 417 | foreach($envs as $env) { |
| 418 | 418 | $envsMap[$env->ID] = $env->Name; |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | $form->disableSecurityToken(); |
| 435 | 435 | $form->addExtraClass('fields-wide'); |
| 436 | 436 | // Tweak the action so it plays well with our fake URL structure. |
| 437 | - $form->setFormAction($project->Link().'/PostSnapshotForm'); |
|
| 437 | + $form->setFormAction($project->Link() . '/PostSnapshotForm'); |
|
| 438 | 438 | |
| 439 | 439 | return $form; |
| 440 | 440 | } |
@@ -446,7 +446,7 @@ discard block |
||
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | $validEnvs = $project->DNEnvironmentList() |
| 449 | - ->filterByCallback(function($item) {return $item->canUploadArchive();}); |
|
| 449 | + ->filterByCallback(function($item) {return $item->canUploadArchive(); }); |
|
| 450 | 450 | |
| 451 | 451 | // Validate $data['EnvironmentID'] by checking against $validEnvs. |
| 452 | 452 | $environment = $validEnvs->find('ID', $data['EnvironmentID']); |
@@ -745,7 +745,7 @@ discard block |
||
| 745 | 745 | $form = new DeployForm($this, 'DeployForm', $environment, $project); |
| 746 | 746 | |
| 747 | 747 | // Tweak the action so it plays well with our fake URL structure. |
| 748 | - $form->setFormAction($request->getURL().'/DeployForm'); |
|
| 748 | + $form->setFormAction($request->getURL() . '/DeployForm'); |
|
| 749 | 749 | return $form; |
| 750 | 750 | } |
| 751 | 751 | |
@@ -859,7 +859,7 @@ discard block |
||
| 859 | 859 | public function getDataTransferForm($request) { |
| 860 | 860 | // Performs canView permission check by limiting visible projects |
| 861 | 861 | $envs = $this->getCurrentProject()->DNEnvironmentList() |
| 862 | - ->filterByCallback(function($item) {return $item->canBackup();}); |
|
| 862 | + ->filterByCallback(function($item) {return $item->canBackup(); }); |
|
| 863 | 863 | if(!$envs) { |
| 864 | 864 | return new SS_HTTPResponse("Environment '" . Convert::raw2xml($request->latestParam('Environment')) . "' not found.", 404); |
| 865 | 865 | } |
@@ -876,7 +876,7 @@ discard block |
||
| 876 | 876 | FormAction::create('doDataTransfer', 'Create')->addExtraClass('btn') |
| 877 | 877 | ) |
| 878 | 878 | ); |
| 879 | - $form->setFormAction($request->getURL().'/DataTransferForm'); |
|
| 879 | + $form->setFormAction($request->getURL() . '/DataTransferForm'); |
|
| 880 | 880 | |
| 881 | 881 | return $form; |
| 882 | 882 | } |
@@ -892,12 +892,12 @@ discard block |
||
| 892 | 892 | $dataArchive = null; |
| 893 | 893 | |
| 894 | 894 | // Validate direction. |
| 895 | - if ($data['Direction']=='get') { |
|
| 895 | + if($data['Direction'] == 'get') { |
|
| 896 | 896 | $validEnvs = $this->getCurrentProject()->DNEnvironmentList() |
| 897 | - ->filterByCallback(function($item) {return $item->canBackup();}); |
|
| 898 | - } else if ($data['Direction']=='push') { |
|
| 897 | + ->filterByCallback(function($item) {return $item->canBackup(); }); |
|
| 898 | + } else if($data['Direction'] == 'push') { |
|
| 899 | 899 | $validEnvs = $this->getCurrentProject()->DNEnvironmentList() |
| 900 | - ->filterByCallback(function($item) {return $item->canRestore();}); |
|
| 900 | + ->filterByCallback(function($item) {return $item->canRestore(); }); |
|
| 901 | 901 | } else { |
| 902 | 902 | throw new LogicException('Invalid direction'); |
| 903 | 903 | } |
@@ -909,7 +909,7 @@ discard block |
||
| 909 | 909 | } |
| 910 | 910 | |
| 911 | 911 | // Validate mode. |
| 912 | - if (!in_array($data['Mode'], array('all', 'assets', 'db'))) { |
|
| 912 | + if(!in_array($data['Mode'], array('all', 'assets', 'db'))) { |
|
| 913 | 913 | throw new LogicException('Invalid mode'); |
| 914 | 914 | } |
| 915 | 915 | |
@@ -1022,7 +1022,7 @@ discard block |
||
| 1022 | 1022 | // Performs canView permission check by limiting visible projects |
| 1023 | 1023 | $project = $this->getCurrentProject(); |
| 1024 | 1024 | $envs = $project->DNEnvironmentList() |
| 1025 | - ->filterByCallback(function($item) {return $item->canRestore();}); |
|
| 1025 | + ->filterByCallback(function($item) {return $item->canRestore(); }); |
|
| 1026 | 1026 | |
| 1027 | 1027 | if(!$envs) { |
| 1028 | 1028 | return new SS_HTTPResponse("Environment '" . Convert::raw2xml($request->latestParam('Environment')) . "' not found.", 404); |
@@ -107,11 +107,15 @@ discard block |
||
| 107 | 107 | * @return boolean |
| 108 | 108 | */ |
| 109 | 109 | public static function FlagSnapshotsEnabled() { |
| 110 | - if (defined('FLAG_SNAPSHOTS_ENABLED') && FLAG_SNAPSHOTS_ENABLED) return true; |
|
| 110 | + if (defined('FLAG_SNAPSHOTS_ENABLED') && FLAG_SNAPSHOTS_ENABLED) { |
|
| 111 | + return true; |
|
| 112 | + } |
|
| 111 | 113 | if (defined('FLAG_SNAPSHOTS_ENABLED_FOR_MEMBERS') && FLAG_SNAPSHOTS_ENABLED_FOR_MEMBERS) { |
| 112 | 114 | $allowedMembers = explode(';', FLAG_SNAPSHOTS_ENABLED_FOR_MEMBERS); |
| 113 | 115 | $member = Member::currentUser(); |
| 114 | - if ($allowedMembers && $member && in_array($member->Email, $allowedMembers)) return true; |
|
| 116 | + if ($allowedMembers && $member && in_array($member->Email, $allowedMembers)) { |
|
| 117 | + return true; |
|
| 118 | + } |
|
| 115 | 119 | } |
| 116 | 120 | return false; |
| 117 | 121 | } |
@@ -655,14 +659,22 @@ discard block |
||
| 655 | 659 | $params = $request->params(); |
| 656 | 660 | $pipeline = Pipeline::get()->byID($params['Identifier']); |
| 657 | 661 | |
| 658 | - if(!$pipeline || !$pipeline->ID || !$pipeline->Environment()) throw new SS_HTTPResponse_Exception('Pipeline not found', 404); |
|
| 659 | - if(!$pipeline->Environment()->canView()) return Security::permissionFailure(); |
|
| 662 | + if(!$pipeline || !$pipeline->ID || !$pipeline->Environment()) { |
|
| 663 | + throw new SS_HTTPResponse_Exception('Pipeline not found', 404); |
|
| 664 | + } |
|
| 665 | + if(!$pipeline->Environment()->canView()) { |
|
| 666 | + return Security::permissionFailure(); |
|
| 667 | + } |
|
| 660 | 668 | |
| 661 | 669 | $environment = $pipeline->Environment(); |
| 662 | 670 | $project = $pipeline->Environment()->Project(); |
| 663 | 671 | |
| 664 | - if($environment->Name != $params['Environment']) throw new LogicException("Environment in URL doesn't match this pipeline"); |
|
| 665 | - if($project->Name != $params['Project']) throw new LogicException("Project in URL doesn't match this pipeline"); |
|
| 672 | + if($environment->Name != $params['Environment']) { |
|
| 673 | + throw new LogicException("Environment in URL doesn't match this pipeline"); |
|
| 674 | + } |
|
| 675 | + if($project->Name != $params['Project']) { |
|
| 676 | + throw new LogicException("Project in URL doesn't match this pipeline"); |
|
| 677 | + } |
|
| 666 | 678 | |
| 667 | 679 | // Delegate to sub-requesthandler |
| 668 | 680 | return PipelineController::create($this, $pipeline); |
@@ -795,14 +807,22 @@ discard block |
||
| 795 | 807 | $params = $request->params(); |
| 796 | 808 | $deployment = DNDeployment::get()->byId($params['Identifier']); |
| 797 | 809 | |
| 798 | - if(!$deployment || !$deployment->ID) throw new SS_HTTPResponse_Exception('Deployment not found', 404); |
|
| 799 | - if(!$deployment->canView()) return Security::permissionFailure(); |
|
| 810 | + if(!$deployment || !$deployment->ID) { |
|
| 811 | + throw new SS_HTTPResponse_Exception('Deployment not found', 404); |
|
| 812 | + } |
|
| 813 | + if(!$deployment->canView()) { |
|
| 814 | + return Security::permissionFailure(); |
|
| 815 | + } |
|
| 800 | 816 | |
| 801 | 817 | $environment = $deployment->Environment(); |
| 802 | 818 | $project = $environment->Project(); |
| 803 | 819 | |
| 804 | - if($environment->Name != $params['Environment']) throw new LogicException("Environment in URL doesn't match this deploy"); |
|
| 805 | - if($project->Name != $params['Project']) throw new LogicException("Project in URL doesn't match this deploy"); |
|
| 820 | + if($environment->Name != $params['Environment']) { |
|
| 821 | + throw new LogicException("Environment in URL doesn't match this deploy"); |
|
| 822 | + } |
|
| 823 | + if($project->Name != $params['Project']) { |
|
| 824 | + throw new LogicException("Project in URL doesn't match this deploy"); |
|
| 825 | + } |
|
| 806 | 826 | |
| 807 | 827 | return $this->customise(new ArrayData(array( |
| 808 | 828 | 'Deployment' => $deployment, |
@@ -818,14 +838,22 @@ discard block |
||
| 818 | 838 | $params = $request->params(); |
| 819 | 839 | $deployment = DNDeployment::get()->byId($params['Identifier']); |
| 820 | 840 | |
| 821 | - if(!$deployment || !$deployment->ID) throw new SS_HTTPResponse_Exception('Deployment not found', 404); |
|
| 822 | - if(!$deployment->canView()) return Security::permissionFailure(); |
|
| 841 | + if(!$deployment || !$deployment->ID) { |
|
| 842 | + throw new SS_HTTPResponse_Exception('Deployment not found', 404); |
|
| 843 | + } |
|
| 844 | + if(!$deployment->canView()) { |
|
| 845 | + return Security::permissionFailure(); |
|
| 846 | + } |
|
| 823 | 847 | |
| 824 | 848 | $environment = $deployment->Environment(); |
| 825 | 849 | $project = $environment->Project(); |
| 826 | 850 | |
| 827 | - if($environment->Name != $params['Environment']) throw new LogicException("Environment in URL doesn't match this deploy"); |
|
| 828 | - if($project->Name != $params['Project']) throw new LogicException("Project in URL doesn't match this deploy"); |
|
| 851 | + if($environment->Name != $params['Environment']) { |
|
| 852 | + throw new LogicException("Environment in URL doesn't match this deploy"); |
|
| 853 | + } |
|
| 854 | + if($project->Name != $params['Project']) { |
|
| 855 | + throw new LogicException("Project in URL doesn't match this deploy"); |
|
| 856 | + } |
|
| 829 | 857 | |
| 830 | 858 | $log = $deployment->log(); |
| 831 | 859 | if($log->exists()) { |
@@ -950,13 +978,19 @@ discard block |
||
| 950 | 978 | $params = $request->params(); |
| 951 | 979 | $transfer = DNDataTransfer::get()->byId($params['Identifier']); |
| 952 | 980 | |
| 953 | - if(!$transfer || !$transfer->ID) throw new SS_HTTPResponse_Exception('Transfer not found', 404); |
|
| 954 | - if(!$transfer->canView()) return Security::permissionFailure(); |
|
| 981 | + if(!$transfer || !$transfer->ID) { |
|
| 982 | + throw new SS_HTTPResponse_Exception('Transfer not found', 404); |
|
| 983 | + } |
|
| 984 | + if(!$transfer->canView()) { |
|
| 985 | + return Security::permissionFailure(); |
|
| 986 | + } |
|
| 955 | 987 | |
| 956 | 988 | $environment = $transfer->Environment(); |
| 957 | 989 | $project = $environment->Project(); |
| 958 | 990 | |
| 959 | - if($project->Name != $params['Project']) throw new LogicException("Project in URL doesn't match this deploy"); |
|
| 991 | + if($project->Name != $params['Project']) { |
|
| 992 | + throw new LogicException("Project in URL doesn't match this deploy"); |
|
| 993 | + } |
|
| 960 | 994 | |
| 961 | 995 | return $this->customise(new ArrayData(array( |
| 962 | 996 | 'Transfer' => $transfer, |
@@ -973,13 +1007,19 @@ discard block |
||
| 973 | 1007 | $params = $request->params(); |
| 974 | 1008 | $transfer = DNDataTransfer::get()->byId($params['Identifier']); |
| 975 | 1009 | |
| 976 | - if(!$transfer || !$transfer->ID) throw new SS_HTTPResponse_Exception('Transfer not found', 404); |
|
| 977 | - if(!$transfer->canView()) return Security::permissionFailure(); |
|
| 1010 | + if(!$transfer || !$transfer->ID) { |
|
| 1011 | + throw new SS_HTTPResponse_Exception('Transfer not found', 404); |
|
| 1012 | + } |
|
| 1013 | + if(!$transfer->canView()) { |
|
| 1014 | + return Security::permissionFailure(); |
|
| 1015 | + } |
|
| 978 | 1016 | |
| 979 | 1017 | $environment = $transfer->Environment(); |
| 980 | 1018 | $project = $environment->Project(); |
| 981 | 1019 | |
| 982 | - if($project->Name != $params['Project']) throw new LogicException("Project in URL doesn't match this deploy"); |
|
| 1020 | + if($project->Name != $params['Project']) { |
|
| 1021 | + throw new LogicException("Project in URL doesn't match this deploy"); |
|
| 1022 | + } |
|
| 983 | 1023 | |
| 984 | 1024 | $log = $transfer->log(); |
| 985 | 1025 | if($log->exists()) { |
@@ -1318,7 +1358,9 @@ discard block |
||
| 1318 | 1358 | * @return DNEnvironment |
| 1319 | 1359 | */ |
| 1320 | 1360 | protected function getCurrentEnvironment($project = null) { |
| 1321 | - if(!$project) $project = $this->getCurrentProject(); |
|
| 1361 | + if(!$project) { |
|
| 1362 | + $project = $this->getCurrentProject(); |
|
| 1363 | + } |
|
| 1322 | 1364 | return $project->DNEnvironmentList()->filter('Name', $this->getRequest()->latestParam('Environment'))->First(); |
| 1323 | 1365 | } |
| 1324 | 1366 | |
@@ -1333,12 +1375,18 @@ discard block |
||
| 1333 | 1375 | * @return boolean true if $member has access to upload or download to at least one {@link DNEnvironment}. |
| 1334 | 1376 | */ |
| 1335 | 1377 | public function CanViewArchives(Member $member = null) { |
| 1336 | - if(!$member) $member = Member::currentUser(); |
|
| 1378 | + if(!$member) { |
|
| 1379 | + $member = Member::currentUser(); |
|
| 1380 | + } |
|
| 1337 | 1381 | |
| 1338 | - if(Permission::checkMember($member, 'ADMIN')) return true; |
|
| 1382 | + if(Permission::checkMember($member, 'ADMIN')) { |
|
| 1383 | + return true; |
|
| 1384 | + } |
|
| 1339 | 1385 | |
| 1340 | 1386 | $allProjects = $this->DNProjectList(); |
| 1341 | - if(!$allProjects) return false; |
|
| 1387 | + if(!$allProjects) { |
|
| 1388 | + return false; |
|
| 1389 | + } |
|
| 1342 | 1390 | |
| 1343 | 1391 | foreach($allProjects as $project) { |
| 1344 | 1392 | if($project->Environments()) { |
@@ -1383,7 +1431,9 @@ discard block |
||
| 1383 | 1431 | $archives = new ArrayList(); |
| 1384 | 1432 | foreach($project->DNEnvironmentList() as $env) { |
| 1385 | 1433 | foreach($env->DataArchives() as $archive) { |
| 1386 | - if($archive->canView() && $archive->isPending()) $archives->push($archive); |
|
| 1434 | + if($archive->canView() && $archive->isPending()) { |
|
| 1435 | + $archives->push($archive); |
|
| 1436 | + } |
|
| 1387 | 1437 | } |
| 1388 | 1438 | } |
| 1389 | 1439 | return new PaginatedList($archives->sort("Created", "DESC"), $this->request); |