@@ -41,7 +41,7 @@ |
||
| 41 | 41 | /** |
| 42 | 42 | * |
| 43 | 43 | * @param SS_HTTPRequest $request |
| 44 | - * @return string |
|
| 44 | + * @return SS_HTTPResponse |
|
| 45 | 45 | */ |
| 46 | 46 | public function listProjects(SS_HTTPRequest $request) { |
| 47 | 47 | $response = array( |
@@ -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())) { |
@@ -300,6 +300,7 @@ |
||
| 300 | 300 | /** |
| 301 | 301 | * Utility function for triggering the db rebuild and flush. |
| 302 | 302 | * Also cleans up and generates new error pages. |
| 303 | + * @param DeploynautLogFile $log |
|
| 303 | 304 | */ |
| 304 | 305 | public function rebuild(DNEnvironment $environment, $log) { |
| 305 | 306 | $name = $environment->getFullName(); |
@@ -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. |
@@ -10,6 +10,7 @@ discard block |
||
| 10 | 10 | * @param DeploynautLogFile $log |
| 11 | 11 | * @param DNProject $project |
| 12 | 12 | * @param type $leaveMaintenancePage |
| 13 | + * @return void |
|
| 13 | 14 | */ |
| 14 | 15 | public function deploy(DNEnvironment $environment, $sha, DeploynautLogFile $log, DNProject $project, $leaveMaintenancePage = false); |
| 15 | 16 | |
@@ -19,6 +20,7 @@ discard block |
||
| 19 | 20 | * |
| 20 | 21 | * @param DNDataTransfer $dataTransfer |
| 21 | 22 | * @param DeploynautLogFile $log |
| 23 | + * @return void |
|
| 22 | 24 | */ |
| 23 | 25 | public function dataTransfer(DNDataTransfer $dataTransfer, DeploynautLogFile $log); |
| 24 | 26 | |
@@ -28,6 +30,7 @@ discard block |
||
| 28 | 30 | * @param DNEnvironment $environment |
| 29 | 31 | * @param DeploynautLogFile $log |
| 30 | 32 | * @param DNProject $project |
| 33 | + * @return void |
|
| 31 | 34 | */ |
| 32 | 35 | public function enableMaintenance(DNEnvironment $environment, DeploynautLogFile $log, DNProject $project); |
| 33 | 36 | |
@@ -37,6 +40,7 @@ discard block |
||
| 37 | 40 | * @param DNEnvironment $environment |
| 38 | 41 | * @param DeploynautLogFile $log |
| 39 | 42 | * @param DNProject $project |
| 43 | + * @return void |
|
| 40 | 44 | */ |
| 41 | 45 | public function disableMaintenance(DNEnvironment $environment, DeploynautLogFile $log, DNProject $project); |
| 42 | 46 | |
@@ -46,6 +50,7 @@ discard block |
||
| 46 | 50 | * @param DNEnvironment $environment |
| 47 | 51 | * @param DeploynautLogFile $log |
| 48 | 52 | * @param DNProject $project |
| 53 | + * @return void |
|
| 49 | 54 | */ |
| 50 | 55 | public function ping(DNEnvironment $environment, DeploynautLogFile $log, DNProject $project); |
| 51 | 56 | |
@@ -13,8 +13,9 @@ |
||
| 13 | 13 | /** |
| 14 | 14 | * Generate the package file, saving to the given location |
| 15 | 15 | * |
| 16 | - * @param $baseDir string The base directory of the project, checked out from git. |
|
| 16 | + * @param string $baseDir string The base directory of the project, checked out from git. |
|
| 17 | 17 | * @param $outputFilename string The filename to write to. |
| 18 | + * @param string $sha |
|
| 18 | 19 | * |
| 19 | 20 | * @return boolean True on success |
| 20 | 21 | */ |
@@ -72,7 +72,7 @@ |
||
| 72 | 72 | /** |
| 73 | 73 | * Take the identifier an make it safe to use as a directory name. |
| 74 | 74 | * |
| 75 | - * @param string $identfiier The unsanitised directory name. |
|
| 75 | + * @param string $identifier The unsanitised directory name. |
|
| 76 | 76 | */ |
| 77 | 77 | protected function sanitiseDirName($identifier) { |
| 78 | 78 | $safe = preg_replace('/[^A-Za-z0-9_-]/', '', $identifier); |
@@ -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; |
@@ -18,6 +18,7 @@ discard block |
||
| 18 | 18 | * Validate a commit sha |
| 19 | 19 | * |
| 20 | 20 | * @param string $sha |
| 21 | + * @param string $field |
|
| 21 | 22 | * @return boolean |
| 22 | 23 | */ |
| 23 | 24 | protected function validateCommit($sha, $field) { |
@@ -100,6 +101,10 @@ discard block |
||
| 100 | 101 | */ |
| 101 | 102 | class DeployForm extends Form { |
| 102 | 103 | |
| 104 | + /** |
|
| 105 | + * @param DNRoot $controller |
|
| 106 | + * @param string $name |
|
| 107 | + */ |
|
| 103 | 108 | public function __construct($controller, $name, DNEnvironment $environment, DNProject $project) { |
| 104 | 109 | if($environment->HasPipelineSupport()) { |
| 105 | 110 | // Determine if commits are filtered |
@@ -261,7 +266,6 @@ discard block |
||
| 261 | 266 | /** |
| 262 | 267 | * Generate fields necessary to select from a filtered commit list |
| 263 | 268 | * |
| 264 | - * @param DNEnvironment $environment |
|
| 265 | 269 | * @param DataList $commits List of commits |
| 266 | 270 | * @return FormField |
| 267 | 271 | */ |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | /** |
| 162 | 162 | * Action |
| 163 | 163 | * |
| 164 | - * @return string - HTML |
|
| 164 | + * @return HTMLText - HTML |
|
| 165 | 165 | */ |
| 166 | 166 | public function projects(SS_HTTPRequest $request) { |
| 167 | 167 | // Performs canView permission check by limiting visible projects in DNProjectsList() call. |
@@ -854,6 +854,7 @@ discard block |
||
| 854 | 854 | } |
| 855 | 855 | |
| 856 | 856 | /** |
| 857 | + * @param SS_HTTPRequest $request |
|
| 857 | 858 | * @return Form |
| 858 | 859 | */ |
| 859 | 860 | public function getDataTransferForm($request) { |
@@ -1189,6 +1190,8 @@ discard block |
||
| 1189 | 1190 | |
| 1190 | 1191 | /** |
| 1191 | 1192 | * Build snapshot move form. |
| 1193 | + * @param SS_HTTPRequest $request |
|
| 1194 | + * @param DataObject $dataArchive |
|
| 1192 | 1195 | */ |
| 1193 | 1196 | public function getMoveForm($request, $dataArchive = null) { |
| 1194 | 1197 | $dataArchive = $dataArchive ? $dataArchive : DNDataArchive::get()->byId($request->requestVar('DataArchiveID')); |
@@ -1330,7 +1333,7 @@ discard block |
||
| 1330 | 1333 | * TODO To be replaced with a method that just returns the list of archives this {@link Member} has access to. |
| 1331 | 1334 | * |
| 1332 | 1335 | * @param Member $member The {@link Member} to check (or null to check the currently logged in Member) |
| 1333 | - * @return boolean true if $member has access to upload or download to at least one {@link DNEnvironment}. |
|
| 1336 | + * @return boolean|null true if $member has access to upload or download to at least one {@link DNEnvironment}. |
|
| 1334 | 1337 | */ |
| 1335 | 1338 | public function CanViewArchives(Member $member = null) { |
| 1336 | 1339 | if(!$member) $member = Member::currentUser(); |
@@ -1357,7 +1360,7 @@ discard block |
||
| 1357 | 1360 | } |
| 1358 | 1361 | |
| 1359 | 1362 | /** |
| 1360 | - * @return ArrayList The list of all archive files that can be accessed by the currently logged-in {@link Member} |
|
| 1363 | + * @return PaginatedList The list of all archive files that can be accessed by the currently logged-in {@link Member} |
|
| 1361 | 1364 | */ |
| 1362 | 1365 | public function CompleteDataArchives() { |
| 1363 | 1366 | $project = $this->getCurrentProject(); |
@@ -1375,7 +1378,7 @@ discard block |
||
| 1375 | 1378 | } |
| 1376 | 1379 | |
| 1377 | 1380 | /** |
| 1378 | - * @return ArrayList The list of "pending" data archives which are waiting for a file |
|
| 1381 | + * @return PaginatedList The list of "pending" data archives which are waiting for a file |
|
| 1379 | 1382 | * to be delivered offline by post, and manually uploaded into the system. |
| 1380 | 1383 | */ |
| 1381 | 1384 | public function PendingDataArchives() { |
@@ -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); |
@@ -84,7 +84,7 @@ |
||
| 84 | 84 | * |
| 85 | 85 | * @param PipelineStep $source Client step |
| 86 | 86 | * @param string $from |
| 87 | - * @param string|Member $to |
|
| 87 | + * @param string $to |
|
| 88 | 88 | * @param string $subject |
| 89 | 89 | * @param string $body |
| 90 | 90 | */ |
@@ -75,7 +75,9 @@ |
||
| 75 | 75 | * @param string $body |
| 76 | 76 | */ |
| 77 | 77 | protected function sendMessageTo($source, $from, $to, $subject, $body) { |
| 78 | - if($to instanceof Member) $to = $to->Email; |
|
| 78 | + if($to instanceof Member) { |
|
| 79 | + $to = $to->Email; |
|
| 80 | + } |
|
| 79 | 81 | $this->sendViaEmail($source, $from, $to, $subject, $body); |
| 80 | 82 | } |
| 81 | 83 | |
@@ -919,6 +919,9 @@ |
||
| 919 | 919 | $fields->insertAfter($createConfigField, 'noDeployConfig'); |
| 920 | 920 | } |
| 921 | 921 | |
| 922 | + /** |
|
| 923 | + * @param FieldList $fields |
|
| 924 | + */ |
|
| 922 | 925 | protected function setPipelineConfigurationFields($fields) { |
| 923 | 926 | if(!$this->config()->get('allow_web_editing')) { |
| 924 | 927 | return; |
@@ -192,7 +192,9 @@ discard block |
||
| 192 | 192 | // Multiple choices, use our choice if it's legal, otherwise default to the first item on the list |
| 193 | 193 | default: |
| 194 | 194 | $backend = $this->BackendIdentifier; |
| 195 | - if(!in_array($backend, $backends)) $backend = $backends[0]; |
|
| 195 | + if(!in_array($backend, $backends)) { |
|
| 196 | + $backend = $backends[0]; |
|
| 197 | + } |
|
| 196 | 198 | } |
| 197 | 199 | |
| 198 | 200 | return Injector::inst()->get($backend); |
@@ -304,10 +306,17 @@ discard block |
||
| 304 | 306 | * @return boolean |
| 305 | 307 | */ |
| 306 | 308 | public function canView($member = null) { |
| 307 | - if(!$member) $member = Member::currentUser(); |
|
| 308 | - if(!$member) return false; // Must be logged in to check permissions |
|
| 309 | + if(!$member) { |
|
| 310 | + $member = Member::currentUser(); |
|
| 311 | + } |
|
| 312 | + if(!$member) { |
|
| 313 | + return false; |
|
| 314 | + } |
|
| 315 | + // Must be logged in to check permissions |
|
| 309 | 316 | |
| 310 | - if(Permission::checkMember($member, 'ADMIN')) return true; |
|
| 317 | + if(Permission::checkMember($member, 'ADMIN')) { |
|
| 318 | + return true; |
|
| 319 | + } |
|
| 311 | 320 | |
| 312 | 321 | // if no Viewers or ViewerGroups defined, fallback to DNProject::canView permissions |
| 313 | 322 | if($this->Viewers()->exists() || $this->ViewerGroups()->exists()) { |
@@ -325,10 +334,17 @@ discard block |
||
| 325 | 334 | * @return boolean |
| 326 | 335 | */ |
| 327 | 336 | public function canDeploy($member = null) { |
| 328 | - if(!$member) $member = Member::currentUser(); |
|
| 329 | - if(!$member) return false; // Must be logged in to check permissions |
|
| 337 | + if(!$member) { |
|
| 338 | + $member = Member::currentUser(); |
|
| 339 | + } |
|
| 340 | + if(!$member) { |
|
| 341 | + return false; |
|
| 342 | + } |
|
| 343 | + // Must be logged in to check permissions |
|
| 330 | 344 | |
| 331 | - if(Permission::checkMember($member, 'ADMIN')) return true; |
|
| 345 | + if(Permission::checkMember($member, 'ADMIN')) { |
|
| 346 | + return true; |
|
| 347 | + } |
|
| 332 | 348 | |
| 333 | 349 | return $this->Deployers()->byID($member->ID) |
| 334 | 350 | || $member->inGroups($this->DeployerGroups()); |
@@ -342,10 +358,17 @@ discard block |
||
| 342 | 358 | * @return boolean true if $member can restore, and false if they can't. |
| 343 | 359 | */ |
| 344 | 360 | public function canRestore($member = null) { |
| 345 | - if(!$member) $member = Member::currentUser(); |
|
| 346 | - if(!$member) return false; // Must be logged in to check permissions |
|
| 361 | + if(!$member) { |
|
| 362 | + $member = Member::currentUser(); |
|
| 363 | + } |
|
| 364 | + if(!$member) { |
|
| 365 | + return false; |
|
| 366 | + } |
|
| 367 | + // Must be logged in to check permissions |
|
| 347 | 368 | |
| 348 | - if(Permission::checkMember($member, 'ADMIN')) return true; |
|
| 369 | + if(Permission::checkMember($member, 'ADMIN')) { |
|
| 370 | + return true; |
|
| 371 | + } |
|
| 349 | 372 | |
| 350 | 373 | return $this->CanRestoreMembers()->byID($member->ID) |
| 351 | 374 | || $member->inGroups($this->CanRestoreGroups()); |
@@ -360,12 +383,21 @@ discard block |
||
| 360 | 383 | */ |
| 361 | 384 | public function canBackup($member = null) { |
| 362 | 385 | $project = $this->Project(); |
| 363 | - if($project->HasDiskQuota() && $project->HasExceededDiskQuota()) return false; |
|
| 386 | + if($project->HasDiskQuota() && $project->HasExceededDiskQuota()) { |
|
| 387 | + return false; |
|
| 388 | + } |
|
| 364 | 389 | |
| 365 | - if(!$member) $member = Member::currentUser(); |
|
| 366 | - if(!$member) return false; // Must be logged in to check permissions |
|
| 390 | + if(!$member) { |
|
| 391 | + $member = Member::currentUser(); |
|
| 392 | + } |
|
| 393 | + if(!$member) { |
|
| 394 | + return false; |
|
| 395 | + } |
|
| 396 | + // Must be logged in to check permissions |
|
| 367 | 397 | |
| 368 | - if(Permission::checkMember($member, 'ADMIN')) return true; |
|
| 398 | + if(Permission::checkMember($member, 'ADMIN')) { |
|
| 399 | + return true; |
|
| 400 | + } |
|
| 369 | 401 | |
| 370 | 402 | return $this->CanBackupMembers()->byID($member->ID) |
| 371 | 403 | || $member->inGroups($this->CanBackupGroups()); |
@@ -384,12 +416,21 @@ discard block |
||
| 384 | 416 | */ |
| 385 | 417 | public function canUploadArchive($member = null) { |
| 386 | 418 | $project = $this->Project(); |
| 387 | - if($project->HasDiskQuota() && $project->HasExceededDiskQuota()) return false; |
|
| 419 | + if($project->HasDiskQuota() && $project->HasExceededDiskQuota()) { |
|
| 420 | + return false; |
|
| 421 | + } |
|
| 388 | 422 | |
| 389 | - if(!$member) $member = Member::currentUser(); |
|
| 390 | - if(!$member) return false; // Must be logged in to check permissions |
|
| 423 | + if(!$member) { |
|
| 424 | + $member = Member::currentUser(); |
|
| 425 | + } |
|
| 426 | + if(!$member) { |
|
| 427 | + return false; |
|
| 428 | + } |
|
| 429 | + // Must be logged in to check permissions |
|
| 391 | 430 | |
| 392 | - if(Permission::checkMember($member, 'ADMIN')) return true; |
|
| 431 | + if(Permission::checkMember($member, 'ADMIN')) { |
|
| 432 | + return true; |
|
| 433 | + } |
|
| 393 | 434 | |
| 394 | 435 | return $this->ArchiveUploaders()->byID($member->ID) |
| 395 | 436 | || $member->inGroups($this->ArchiveUploaderGroups()); |
@@ -403,10 +444,17 @@ discard block |
||
| 403 | 444 | * @return boolean true if $member can download archives from this environment, false if they can't. |
| 404 | 445 | */ |
| 405 | 446 | public function canDownloadArchive($member = null) { |
| 406 | - if(!$member) $member = Member::currentUser(); |
|
| 407 | - if(!$member) return false; // Must be logged in to check permissions |
|
| 447 | + if(!$member) { |
|
| 448 | + $member = Member::currentUser(); |
|
| 449 | + } |
|
| 450 | + if(!$member) { |
|
| 451 | + return false; |
|
| 452 | + } |
|
| 453 | + // Must be logged in to check permissions |
|
| 408 | 454 | |
| 409 | - if(Permission::checkMember($member, 'ADMIN')) return true; |
|
| 455 | + if(Permission::checkMember($member, 'ADMIN')) { |
|
| 456 | + return true; |
|
| 457 | + } |
|
| 410 | 458 | return $this->ArchiveDownloaders()->byID($member->ID) |
| 411 | 459 | || $member->inGroups($this->ArchiveDownloaderGroups()); |
| 412 | 460 | } |
@@ -418,10 +466,16 @@ discard block |
||
| 418 | 466 | * @return boolean |
| 419 | 467 | */ |
| 420 | 468 | public function canAbort($member = null) { |
| 421 | - if(!$member) $member = Member::currentUser(); |
|
| 422 | - if(!$member) return false; |
|
| 469 | + if(!$member) { |
|
| 470 | + $member = Member::currentUser(); |
|
| 471 | + } |
|
| 472 | + if(!$member) { |
|
| 473 | + return false; |
|
| 474 | + } |
|
| 423 | 475 | |
| 424 | - if(Permission::checkMember($member, 'ADMIN')) return true; |
|
| 476 | + if(Permission::checkMember($member, 'ADMIN')) { |
|
| 477 | + return true; |
|
| 478 | + } |
|
| 425 | 479 | |
| 426 | 480 | return $this->PipelineCancellers()->byID($member->ID) |
| 427 | 481 | || $member->inGroups($this->PipelineCancellerGroups()); |
@@ -434,10 +488,16 @@ discard block |
||
| 434 | 488 | * @return boolean |
| 435 | 489 | */ |
| 436 | 490 | public function canApprove($member = null) { |
| 437 | - if(!$member) $member = Member::currentUser(); |
|
| 438 | - if(!$member) return false; |
|
| 491 | + if(!$member) { |
|
| 492 | + $member = Member::currentUser(); |
|
| 493 | + } |
|
| 494 | + if(!$member) { |
|
| 495 | + return false; |
|
| 496 | + } |
|
| 439 | 497 | |
| 440 | - if(Permission::checkMember($member, 'ADMIN')) return true; |
|
| 498 | + if(Permission::checkMember($member, 'ADMIN')) { |
|
| 499 | + return true; |
|
| 500 | + } |
|
| 441 | 501 | return $this->PipelineApprovers()->byID($member->ID) |
| 442 | 502 | || $member->inGroups($this->PipelineApproverGroups()); |
| 443 | 503 | } |
@@ -450,10 +510,17 @@ discard block |
||
| 450 | 510 | * @return boolean true if $member can delete archives from this environment, false if they can't. |
| 451 | 511 | */ |
| 452 | 512 | public function canDeleteArchive($member = null) { |
| 453 | - if(!$member) $member = Member::currentUser(); |
|
| 454 | - if(!$member) return false; // Must be logged in to check permissions |
|
| 513 | + if(!$member) { |
|
| 514 | + $member = Member::currentUser(); |
|
| 515 | + } |
|
| 516 | + if(!$member) { |
|
| 517 | + return false; |
|
| 518 | + } |
|
| 519 | + // Must be logged in to check permissions |
|
| 455 | 520 | |
| 456 | - if(Permission::checkMember($member, 'ADMIN')) return true; |
|
| 521 | + if(Permission::checkMember($member, 'ADMIN')) { |
|
| 522 | + return true; |
|
| 523 | + } |
|
| 457 | 524 | |
| 458 | 525 | return $this->ArchiveDeleters()->byID($member->ID) |
| 459 | 526 | || $member->inGroups($this->ArchiveDeleterGroups()); |
@@ -973,7 +1040,9 @@ discard block |
||
| 973 | 1040 | * Write the deployment config file to filesystem |
| 974 | 1041 | */ |
| 975 | 1042 | protected function writeConfigFile() { |
| 976 | - if(!$this->config()->get('allow_web_editing')) return; |
|
| 1043 | + if(!$this->config()->get('allow_web_editing')) { |
|
| 1044 | + return; |
|
| 1045 | + } |
|
| 977 | 1046 | |
| 978 | 1047 | // Create a basic new environment config from a template |
| 979 | 1048 | if( !$this->envFileExists() |
@@ -991,7 +1060,9 @@ discard block |
||
| 991 | 1060 | * Write the pipeline config file to filesystem |
| 992 | 1061 | */ |
| 993 | 1062 | protected function writePipelineFile() { |
| 994 | - if(!$this->config()->get('allow_web_editing')) return; |
|
| 1063 | + if(!$this->config()->get('allow_web_editing')) { |
|
| 1064 | + return; |
|
| 1065 | + } |
|
| 995 | 1066 | $path = $this->getPipelineFilename(); |
| 996 | 1067 | if($this->PipelineConfig) { |
| 997 | 1068 | // Update file |
@@ -1058,9 +1129,13 @@ discard block |
||
| 1058 | 1129 | */ |
| 1059 | 1130 | public function getPipelineFilename() { |
| 1060 | 1131 | $name = $this->getConfigFilename(); |
| 1061 | - if(!$name) return null; |
|
| 1132 | + if(!$name) { |
|
| 1133 | + return null; |
|
| 1134 | + } |
|
| 1062 | 1135 | $path = pathinfo($name); |
| 1063 | - if($path) return $path['dirname'] . '/' . $path['filename'] . '.yml'; |
|
| 1136 | + if($path) { |
|
| 1137 | + return $path['dirname'] . '/' . $path['filename'] . '.yml'; |
|
| 1138 | + } |
|
| 1064 | 1139 | } |
| 1065 | 1140 | |
| 1066 | 1141 | /** |
@@ -1086,7 +1161,9 @@ discard block |
||
| 1086 | 1161 | */ |
| 1087 | 1162 | public static function array_to_viewabledata($array) { |
| 1088 | 1163 | // Don't transform non-arrays |
| 1089 | - if(!is_array($array)) return $array; |
|
| 1164 | + if(!is_array($array)) { |
|
| 1165 | + return $array; |
|
| 1166 | + } |
|
| 1090 | 1167 | |
| 1091 | 1168 | // Figure out whether this is indexed or associative |
| 1092 | 1169 | $keys = array_keys($array); |
@@ -1119,17 +1196,23 @@ discard block |
||
| 1119 | 1196 | public function getDependentFilteredCommits() { |
| 1120 | 1197 | // check if this environment depends on another environemnt |
| 1121 | 1198 | $dependsOnEnv = $this->DependsOnEnvironment(); |
| 1122 | - if(empty($dependsOnEnv)) return null; |
|
| 1199 | + if(empty($dependsOnEnv)) { |
|
| 1200 | + return null; |
|
| 1201 | + } |
|
| 1123 | 1202 | |
| 1124 | 1203 | // Check if there is a filter |
| 1125 | 1204 | $config = $this->GenericPipelineConfig(); |
| 1126 | 1205 | $filter = isset($config->PipelineConfig->FilteredCommits) |
| 1127 | 1206 | ? $config->PipelineConfig->FilteredCommits |
| 1128 | 1207 | : null; |
| 1129 | - if (empty($filter)) return null; |
|
| 1208 | + if (empty($filter)) { |
|
| 1209 | + return null; |
|
| 1210 | + } |
|
| 1130 | 1211 | |
| 1131 | 1212 | // Create and execute filter |
| 1132 | - if (!class_exists($filter)) throw new Exception(sprintf("Class %s does not exist", $filter)); |
|
| 1213 | + if (!class_exists($filter)) { |
|
| 1214 | + throw new Exception(sprintf("Class %s does not exist", $filter)); |
|
| 1215 | + } |
|
| 1133 | 1216 | $commitClass = $filter::create(); |
| 1134 | 1217 | // setup the environment to check for commits |
| 1135 | 1218 | $commitClass->env = $dependsOnEnv; |