Skip to content

Commit 599f476

Browse files
committed
Merge pull request #26 from VSEphpbb/fixes
Additional fixes and updates
2 parents a519ee2 + 2d9d0f2 commit 599f476

3 files changed

Lines changed: 31 additions & 3 deletions

File tree

controller/main.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use phpbb\config\config;
1717
use phpbb\controller\helper;
18+
use phpbb\exception\http_exception;
1819
use phpbb\request\request;
1920
use phpbb\skeleton\helper\packager;
2021
use phpbb\skeleton\helper\validator;
@@ -76,9 +77,15 @@ public function __construct(config $config, helper $helper, request $request, pa
7677
* Demo controller for route /skeleton
7778
*
7879
* @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
80+
* @throws http_exception
7981
*/
8082
public function handle()
8183
{
84+
if ($this->user->data['is_bot'])
85+
{
86+
throw new http_exception(403, 'NOT_AUTHORISED');
87+
}
88+
8289
if ($this->request->is_set_post('submit'))
8390
{
8491
try

helper/validator.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ public function __construct(user $user)
2525
$this->user = $user;
2626
}
2727

28+
public function validate_author_name($value)
29+
{
30+
if (strlen($value))
31+
{
32+
return $value;
33+
}
34+
35+
throw new \RuntimeException($this->user->lang('SKELETON_INVALID_AUTHOR_NAME'));
36+
}
37+
2838
public function validate_num_authors($value)
2939
{
3040
if (preg_match('#^\d+$#', $value) && $value > 0 && $value <= 20)
@@ -45,6 +55,16 @@ public function validate_extension_name($value)
4555
throw new \RuntimeException($this->user->lang('SKELETON_INVALID_EXTENSION_NAME'));
4656
}
4757

58+
public function validate_extension_display_name($value)
59+
{
60+
if (strlen($value))
61+
{
62+
return $value;
63+
}
64+
65+
throw new \RuntimeException($this->user->lang('SKELETON_INVALID_EXTENSION_NAME'));
66+
}
67+
4868
public function validate_extension_time($value)
4969
{
5070
if (preg_match('#^\d{4}\-\d{2}\-\d{2}$#', $value))

language/en/common.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,10 @@
9898
'SKELETON_TITLE_REQUIREMENT_INFO' => 'Requirements',
9999
'SKELETON_TITLE_COMPONENT_INFO' => 'Components',
100100

101+
'SKELETON_INVALID_AUTHOR_NAME' => 'The author name is required',
101102
'SKELETON_INVALID_EXTENSION_NAME' => 'The extension name you provided is invalid',
102103
'SKELETON_INVALID_EXTENSION_TIME' => 'The extension date you provided is invalid',
103-
'SKELETON_INVALID_EXTENSION_VERSION' => 'The extension version you provided is invalid',
104-
'SKELETON_INVALID_NUM_AUTHORS' => 'The number of authors you provided is invalid',
105-
'SKELETON_INVALID_VENDOR_NAME' => 'The vendor name you provided is invalid',
104+
'SKELETON_INVALID_EXTENSION_VERSION'=> 'The extension version you provided is invalid',
105+
'SKELETON_INVALID_NUM_AUTHORS' => 'The number of authors you provided is invalid',
106+
'SKELETON_INVALID_VENDOR_NAME' => 'The vendor name you provided is invalid',
106107
));

0 commit comments

Comments
 (0)