@@ -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 | */ |
@@ -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 | } |
@@ -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); |
@@ -91,7 +91,7 @@ |
||
91 | 91 | $files = glob($dir . '/*.tar.gz'); |
92 | 92 | if(sizeof($files) > $count) { |
93 | 93 | usort($files, function($a, $b) { |
94 | - return filemtime($a) > filemtime($b); |
|
94 | + return filemtime($a) > filemtime($b); |
|
95 | 95 | }); |
96 | 96 | |
97 | 97 | for($i=0;$i<sizeof($files)-$count;$i++) { |
@@ -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; |
@@ -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 | */ |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | } |
33 | 33 | |
34 | 34 | // Check validity of commit |
35 | - if (!preg_match('/^[a-f0-9]{40}$/', $sha)) { |
|
35 | + if(!preg_match('/^[a-f0-9]{40}$/', $sha)) { |
|
36 | 36 | $this->validationError( |
37 | 37 | $field, |
38 | 38 | "Invalid release SHA: " . Convert::raw2xml($sha), |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | ->setAttribute('onclick', |
144 | 144 | "return confirm('This will begin a release pipeline, but with the following exclusions:\\n" . |
145 | 145 | " - No messages will be sent\\n" . |
146 | - " - No capistrano actions will be invoked\\n". |
|
146 | + " - No capistrano actions will be invoked\\n" . |
|
147 | 147 | " - No deployments or snapshots will be created.');" |
148 | 148 | ) |
149 | 149 | ); |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | FormAction::create('doDeploy', "Direct deployment (bypass pipeline)") |
154 | 154 | ->addExtraClass('btn btn-warning') |
155 | 155 | ->setAttribute('onclick', |
156 | - "return confirm('This will start a direct deployment, bypassing the pipeline ". |
|
156 | + "return confirm('This will start a direct deployment, bypassing the pipeline " . |
|
157 | 157 | "process in place.\\n\\nAre you sure this is necessary?');" |
158 | 158 | ) |
159 | 159 | ); |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | foreach($project->DNBranchList() as $branch) { |
189 | 189 | $sha = $branch->SHA(); |
190 | 190 | $name = $branch->Name(); |
191 | - $branches[$sha . '-' . $name] = $name . ' (' . substr($sha,0,8) . ', ' . $branch->LastUpdated()->TimeDiff() . ' old)'; |
|
191 | + $branches[$sha . '-' . $name] = $name . ' (' . substr($sha, 0, 8) . ', ' . $branch->LastUpdated()->TimeDiff() . ' old)'; |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | // Tags |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | foreach($project->DNTagList()->setLimit(null) as $tag) { |
197 | 197 | $sha = $tag->SHA(); |
198 | 198 | $name = $tag->Name(); |
199 | - $tags[$sha . '-' . $tag] = $name . ' (' . substr($sha,0,8) . ', ' . $tag->Created()->TimeDiff() . ' old)'; |
|
199 | + $tags[$sha . '-' . $tag] = $name . ' (' . substr($sha, 0, 8) . ', ' . $tag->Created()->TimeDiff() . ' old)'; |
|
200 | 200 | } |
201 | 201 | $tags = array_reverse($tags); |
202 | 202 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | $redeploy[$envName] = array(); |
211 | 211 | } |
212 | 212 | if(!isset($redeploy[$envName][$sha])) { |
213 | - $redeploy[$envName][$sha] = substr($sha,0,8) . ' (deployed ' . $deploy->obj('LastEdited')->Ago() . ')'; |
|
213 | + $redeploy[$envName][$sha] = substr($sha, 0, 8) . ' (deployed ' . $deploy->obj('LastEdited')->Ago() . ')'; |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | } |
@@ -268,11 +268,11 @@ discard block |
||
268 | 268 | protected function buildPipelineField($commits) { |
269 | 269 | // Get filtered commits |
270 | 270 | $filteredCommits = array(); |
271 | - foreach ($commits as $commit) { |
|
271 | + foreach($commits as $commit) { |
|
272 | 272 | $title = sprintf( |
273 | 273 | "%s (%s, %s old)", |
274 | 274 | $commit->Message, |
275 | - substr($commit->SHA,0,8), |
|
275 | + substr($commit->SHA, 0, 8), |
|
276 | 276 | $commit->dbObject('Created')->TimeDiff() |
277 | 277 | ); |
278 | 278 | $filteredCommits[$commit->SHA] = $title; |
@@ -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,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); |
@@ -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 |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | /** |
98 | 98 | * Return the used quota in MB. |
99 | 99 | * |
100 | - * @param mixed $round Number of decimal places to round to |
|
101 | - * @return string|int The used quota size in MB |
|
100 | + * @param integer $round Number of decimal places to round to |
|
101 | + * @return double The used quota size in MB |
|
102 | 102 | */ |
103 | 103 | public function getUsedQuotaMB($round = 2) { |
104 | 104 | $size = 0; |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * Return all archives which are "manual upload requests", |
222 | 222 | * meaning they don't have a file attached to them (yet). |
223 | 223 | * |
224 | - * @return ArrayList |
|
224 | + * @return DataList |
|
225 | 225 | */ |
226 | 226 | public function PendingManualUploadDataArchives() { |
227 | 227 | return $this->DataArchives()->filter('ArchiveFileID', null); |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | * Setup a gridfield for the environment configs |
566 | 566 | * |
567 | 567 | * @param FieldList $fields |
568 | - * @param $environments |
|
568 | + * @param FormField $environments |
|
569 | 569 | * @return void |
570 | 570 | */ |
571 | 571 | protected function setEnvironmentFields(&$fields, $environments) { |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * @return array |
239 | 239 | */ |
240 | 240 | public function getProcessEnv() { |
241 | - if (file_exists($this->getPrivateKeyPath())) { |
|
241 | + if(file_exists($this->getPrivateKeyPath())) { |
|
242 | 242 | // Key-pair is available, use it. |
243 | 243 | $processEnv = array( |
244 | 244 | 'IDENT_KEY' => $this->getPrivateKeyPath(), |
@@ -324,21 +324,21 @@ discard block |
||
324 | 324 | * Returns a map of envrionment name to build name |
325 | 325 | */ |
326 | 326 | public function currentBuilds() { |
327 | - if(!isset(self::$relation_cache['currentBuilds.'.$this->ID])) { |
|
327 | + if(!isset(self::$relation_cache['currentBuilds.' . $this->ID])) { |
|
328 | 328 | $currentBuilds = array(); |
329 | 329 | foreach($this->Environments() as $env) { |
330 | 330 | $currentBuilds[$env->Name] = $env->CurrentBuild(); |
331 | 331 | } |
332 | - self::$relation_cache['currentBuilds.'.$this->ID] = $currentBuilds; |
|
332 | + self::$relation_cache['currentBuilds.' . $this->ID] = $currentBuilds; |
|
333 | 333 | } |
334 | - return self::$relation_cache['currentBuilds.'.$this->ID]; |
|
334 | + return self::$relation_cache['currentBuilds.' . $this->ID]; |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | /** |
338 | 338 | * |
339 | 339 | * @return string |
340 | 340 | */ |
341 | - public function Link($action='') { |
|
341 | + public function Link($action = '') { |
|
342 | 342 | return Controller::join_links("naut", "project", $this->Name, $action); |
343 | 343 | } |
344 | 344 | |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | * @return boolean |
418 | 418 | */ |
419 | 419 | public function projectFolderExists() { |
420 | - if(file_exists($this->DNData()->getEnvironmentDir().'/'.$this->Name)) { |
|
420 | + if(file_exists($this->DNData()->getEnvironmentDir() . '/' . $this->Name)) { |
|
421 | 421 | return true; |
422 | 422 | } |
423 | 423 | return false; |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | * @return bool |
429 | 429 | */ |
430 | 430 | public function repoExists() { |
431 | - return file_exists(DEPLOYNAUT_LOCAL_VCS_PATH . '/' . $this->Name.'/HEAD'); |
|
431 | + return file_exists(DEPLOYNAUT_LOCAL_VCS_PATH . '/' . $this->Name . '/HEAD'); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | /** |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | protected function checkProjectPath() { |
469 | 469 | // Create the project capistrano folder |
470 | 470 | if($this->CreateEnvFolder && !file_exists($this->getProjectFolderPath())) { |
471 | - mkdir($this->DNData()->getEnvironmentDir().'/'.$this->Name); |
|
471 | + mkdir($this->DNData()->getEnvironmentDir() . '/' . $this->Name); |
|
472 | 472 | } |
473 | 473 | } |
474 | 474 | |
@@ -477,10 +477,10 @@ discard block |
||
477 | 477 | */ |
478 | 478 | protected function checkCVSPath() { |
479 | 479 | $changedFields = $this->getChangedFields(true, 2); |
480 | - if (!$this->CVSPath) { |
|
480 | + if(!$this->CVSPath) { |
|
481 | 481 | return; |
482 | 482 | } |
483 | - if (isset($changedFields['CVSPath']) || isset($changedFields['Name'])) { |
|
483 | + if(isset($changedFields['CVSPath']) || isset($changedFields['Name'])) { |
|
484 | 484 | $this->cloneRepo(); |
485 | 485 | } |
486 | 486 | } |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | public function getPublicKey() { |
512 | 512 | $key = $this->getPublicKeyPath(); |
513 | 513 | |
514 | - if (file_exists($key)) { |
|
514 | + if(file_exists($key)) { |
|
515 | 515 | return file_get_contents($key); |
516 | 516 | } |
517 | 517 | } |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | */ |
593 | 593 | public function getRepositoryURL() { |
594 | 594 | $showUrl = Config::inst()->get($this->class, 'show_repository_url'); |
595 | - if ($showUrl) { |
|
595 | + if($showUrl) { |
|
596 | 596 | return $this->CVSPath; |
597 | 597 | } |
598 | 598 | } |
@@ -602,6 +602,6 @@ discard block |
||
602 | 602 | * @return string |
603 | 603 | */ |
604 | 604 | protected function getProjectFolderPath() { |
605 | - return $this->DNData()->getEnvironmentDir().'/'.$this->Name; |
|
605 | + return $this->DNData()->getEnvironmentDir() . '/' . $this->Name; |
|
606 | 606 | } |
607 | 607 | } |
@@ -181,9 +181,13 @@ discard block |
||
181 | 181 | * @return boolean |
182 | 182 | */ |
183 | 183 | public function canView($member = null) { |
184 | - if(!$member) $member = Member::currentUser(); |
|
184 | + if(!$member) { |
|
185 | + $member = Member::currentUser(); |
|
186 | + } |
|
185 | 187 | |
186 | - if(Permission::checkMember($member, 'ADMIN')) return true; |
|
188 | + if(Permission::checkMember($member, 'ADMIN')) { |
|
189 | + return true; |
|
190 | + } |
|
187 | 191 | |
188 | 192 | return $member->inGroups($this->Viewers()); |
189 | 193 | } |
@@ -553,7 +557,9 @@ discard block |
||
553 | 557 | */ |
554 | 558 | public function getKeyDir() { |
555 | 559 | $keyDir = $this->DNData()->getKeyDir(); |
556 | - if(!$keyDir) return null; |
|
560 | + if(!$keyDir) { |
|
561 | + return null; |
|
562 | + } |
|
557 | 563 | |
558 | 564 | $filter = FileNameFilter::create(); |
559 | 565 | $name = $filter->filter($this->Name); |
@@ -55,7 +55,6 @@ discard block |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | - * @param int $limit - defaults to the ten lates |
|
59 | 58 | * @return array() |
60 | 59 | */ |
61 | 60 | protected function getReferences() { |
@@ -106,6 +105,7 @@ discard block |
||
106 | 105 | |
107 | 106 | /** |
108 | 107 | * Find a build in this set by hash. |
108 | + * @param string $hash |
|
109 | 109 | */ |
110 | 110 | public function byName($hash) { |
111 | 111 | if($this->loaded == false) { |
@@ -61,7 +61,9 @@ discard block |
||
61 | 61 | protected function getReferences() { |
62 | 62 | $repository = new Gitonomy\Git\Repository($this->project->LocalCVSPath); |
63 | 63 | if($this->getTags) { |
64 | - if($this->reference) throw new LogicException("Can't have \$reference and \$getTags both set"); |
|
64 | + if($this->reference) { |
|
65 | + throw new LogicException("Can't have \$reference and \$getTags both set"); |
|
66 | + } |
|
65 | 67 | $log = $repository->getReferences()->getTags(); |
66 | 68 | |
67 | 69 | } else if($this->reference) { |
@@ -140,7 +142,9 @@ discard block |
||
140 | 142 | $this->loaded = true; |
141 | 143 | } |
142 | 144 | foreach($this->items as $i => $item) { |
143 | - if(is_array($item)) $this->items[$i] = new ArrayData($item); |
|
145 | + if(is_array($item)) { |
|
146 | + $this->items[$i] = new ArrayData($item); |
|
147 | + } |
|
144 | 148 | } |
145 | 149 | return new ArrayIterator($this->items); |
146 | 150 | } |
@@ -22,7 +22,6 @@ |
||
22 | 22 | ); |
23 | 23 | |
24 | 24 | /** |
25 | - * @param Gitonomy\Git\Commit $commit |
|
26 | 25 | * @param DNProject $project |
27 | 26 | * @param DNData $data |
28 | 27 | */ |