commit 3c4dc62cbcbfbfa09e5923a300988ae6b1bb795b from: Tracey Emery date: Fri May 13 16:42:24 2022 UTC finish edit company code commit - 9a2a2e446d93f4d99e18c113e55ac5fd10a23805 commit + 3c4dc62cbcbfbfa09e5923a300988ae6b1bb795b blob - 7418fa0ea05584d877bae7189fcf0f883a42ebb4 blob + 132a7f73e9bce65b3c2796a979ba73e335ddb8d5 --- module/Securitx/src/Controller/SecuritxController.php +++ module/Securitx/src/Controller/SecuritxController.php @@ -163,6 +163,7 @@ ret: } if ($_GET) { $companies = ''; + $id = ''; if (array_key_exists('add', $_GET)) { $form = new CompanyForm(); $action = "add"; @@ -170,6 +171,8 @@ ret: $form = new CompanyEditForm(); $companies = $this->company_table->fetchAll(); $action = "edit"; + if (array_key_exists('id', $_GET)) + $id = $_GET['id']; } else if (array_key_exists('delete', $_GET)) { $form = new CompanyDeleteForm(); $companies = $this->company_table->fetchAll(); @@ -190,37 +193,95 @@ ret: 'valid_domain' => '', 'valid_phone' => '', 'companies' => $companies, + 'company' => '', ]); } $company = new Company(); - if ($action != "delete") + if ($action == "add") $form->setInputFilter($company->getInputFilter()); - $form->setData($request->getPost()); - if (!$form->isValid()) { + if ($action == "add" || $action == "delete") { + $form->setData($request->getPost()); + if (!$form->isValid()) { + return new ViewModel([ + 'member' => $member, + 'action' => $action, + 'exists' => '', + 'form' => $form, + 'completed' => false, + 'valid_domain' => '', + 'valid_phone' => '', + ]); + } + + $company->exchangeArray($form->getData()); + $count = $this->company_table->getShortCount( + $company->short + ); + + if ($count) { + return new ViewModel([ + 'member' => $member, + 'action' => $action, + 'exists' => 'Short name already exists', + 'form' => $form, + 'completed' => false, + 'valid_domain' => '', + 'valid_phone' => '', + ]); + } + $domain = $this->company_table->getDomainCount( + $company->domain + ); + if ($domain) { + return new ViewModel([ + 'member' => $member, + 'action' => $action, + 'exists' => '', + 'form' => $form, + 'completed' => false, + 'valid_domain' => 'Domain already exists', + 'valid_phone' => '', + ]); + } + } + if ($action == "edit" && $id) { + $form->setInputFilter($company->getInputFilter()); + $form->setData($request->getPost()); + if (!$form->isValid()) { + return new ViewModel([ + 'member' => $member, + 'action' => $action, + 'form' => $form, + 'completed' => false, + 'valid_domain' => '', + 'valid_phone' => '', + 'company' => $ce, + ]); + } + + $company->exchangeArray($form->getData()); + $this->company_table->saveCompany($company); return new ViewModel([ 'member' => $member, - 'action' => $action, - 'exists' => '', - 'form' => $form, - 'completed' => false, - 'valid_domain' => '', - 'valid_phone' => '', + 'action' => 'edited', + 'completed' => true, ]); - } - - $company->exchangeArray($form->getData()); - $count = $this->company_table->getShortCount( - $company->short); - - if ($count) { + } else if ($action == "edit" && !$id) { + $form->setData($request->getPost()); + $form->isValid(); + $company->exchangeArray($form->getData()); + $ce = $this->company_table->getCompany( + $company->company_id + ); + $form = new CompanyEditForm(); return new ViewModel([ 'member' => $member, 'action' => $action, - 'exists' => 'Short name already exists', 'form' => $form, 'completed' => false, 'valid_domain' => '', 'valid_phone' => '', + 'company' => $ce, ]); } if ($action == "delete") { blob - 1103f6b13f7976ac83ac5e2d82a74a9730a3f3de blob + e5f3c1721559fff43644b4dbcd0581ad7bb19a91 --- module/Securitx/src/Form/CompanyEditForm.php +++ module/Securitx/src/Form/CompanyEditForm.php @@ -5,7 +5,7 @@ use Laminas\Captcha; use Laminas\Form\Form; use Laminas\Form\Element; -class CompanyForm extends Form { +class CompanyEditForm extends Form { public function __construct($name = null) { parent::__construct($name); @@ -17,13 +17,6 @@ class CompanyForm extends Form { ], ]); $this->add([ - 'name' => 'short', - 'type' => 'text', - 'options' => [ - 'label' => 'Two Letter Short Name', - ], - ]); - $this->add([ 'name' => 'domain', 'type' => 'text', 'options' => [ @@ -59,6 +52,13 @@ class CompanyForm extends Form { ], ]); $this->add([ + 'name' => 'short', + 'type' => Element\Hidden::class, + 'attributes' => [ + 'value' => '', + ], + ]); + $this->add([ 'name' => 'submit', 'type' => 'submit', 'attributes' => [ blob - e6027752d4dce42d191004527811471dc7a6e6a5 blob + 2f17095928e078a5206f7637bb099c9a436e15d3 --- module/Securitx/src/Model/CompanyTable.php +++ module/Securitx/src/Model/CompanyTable.php @@ -25,6 +25,9 @@ class CompanyTable { } return $row; } + public function getDomainCount($id) { + return $this->tableGateway->select(['domain' => $id])->count(); + } public function getShortCount($id) { return $this->tableGateway->select(['short' => $id])->count(); } @@ -47,11 +50,11 @@ class CompanyTable { } try { - $this->getMember($id); + $this->getCompany($id); } catch (RuntimeException $e) { return; } - $this->tableGateway->update($data, ['id' => $id]); + $this->tableGateway->update($data, ['company_id' => $id]); } } blob - 9806c07e801dea21c277413aeee58a88492dc697 blob + 8f0ca03f69439afd110415f76be0fd45019fc756 --- module/Securitx/view/securitx/cdownload/cdownload.phtml +++ module/Securitx/view/securitx/cdownload/cdownload.phtml @@ -15,7 +15,7 @@ use Securitx\Model\Downloads;

Hello, .
You've reached your SecuritX company file downloader!
Links are good for five days.

-
+
File Name
File Sent Date
blob - 37c9fb7cb3108cce4a438d776c6c6a85279f3791 blob + 5e7e2cbff3a8ef26f65ac89b75bbbece640beb30 --- module/Securitx/view/securitx/companies/companies.phtml +++ module/Securitx/view/securitx/companies/companies.phtml @@ -6,17 +6,19 @@

Hello, first ?>.
The company has been .

-
+
-

Hello, first ?>.
Here, you can a company.
The primary company can not be deleted.

+

Hello, first ?>.
Here, you can a company. + +
The primary company can not be deleted.

+ +
-
- form()->closeTag(); goto done; } + if ($action == "edit" && !$company) { + $co_opts = array(); + foreach ($companies as $company) { + $co_opt = [ + 'value' => $company->company_id, + 'label' => $this->escapeHtml($company->name), + ]; + array_push($co_opts, $co_opt); + } + $company_id = $form->get('company_id'); + $company_id->setAttribute('class', 'form-control'); + $company_id->setAttribute('placeholder', 'Select Company'); + $company_id->setValueOptions($co_opts); + + $submit = $form->get('submit'); + $submit->setAttribute('class', 'btn btn-primary'); + + $form->setAttribute('action', $this->url('securitx', [ + 'action' => 'companies', + 'id' => $member->u_key, + ], + [ + 'query' => [ + $action => '', + ] + ])); + echo $this->form()->openTag($form); +?> +
+ formLabel($company_id) ?> + formElement($company_id) ?> + formElementErrors()->render($company_id, + ['class' => 'help-block']) ?> +
+
+ +
+formSubmit($form->get('submit')); + echo $this->form()->closeTag(); + goto done; + } else if ($action == "edit" && $company->company_id) { + $short = $form->get('short'); + $short->setValue($company->short); + + $name = $form->get('name'); + $name->setAttribute('class', 'form-control'); + $name->setAttribute('placeholder', 'Company Name'); + $name->setValue($company->name); + + $domain = $form->get('domain'); + $domain->setAttribute('class', 'form-control'); + $domain->setAttribute('placeholder', 'Email Domain'); + $domain->setValue($company->domain); + + $phone = $form->get('phone'); + $phone->setAttribute('class', 'form-control'); + $phone->setAttribute('placeholder', 'Phone Number'); + $phone->setValue($company->phone); + + $downloads = $form->get('downloads'); + $downloads->setAttribute('class', 'form-control'); + $downloads->setAttribute('placeholder', + 'Enable Browser Downloads'); + $downloads->setValue($company->downloads); + + $submit = $form->get('submit'); + $submit->setAttribute('class', 'btn btn-primary'); + + $form->setAttribute('action', $this->url('securitx', [ + 'action' => 'companies', + 'id' => $member->u_key, + ], + [ + 'query' => [ + $action => '', + 'id' => $company->company_id, + ] + ])); + $form->prepare(); + + echo $this->form()->openTag($form); + echo $this->formHidden($short); +?> + +
+ formLabel($name) ?> + formElement($name) ?> + formElementErrors()->render($name, + ['class' => 'help-block']) ?> +
+ +
+ formLabel($phone) ?> + formElement($phone) ?> + formElementErrors()->render($phone, + ['class' => 'help-block']) ?> +

+
+ +
+ formLabel($domain) ?> + formElement($domain) ?> + formElementErrors()->render($domain, + ['class' => 'help-block']) ?> +

+
+ +
+ formLabel($downloads) ?> (if you plan to enable automatic file handling via other scripting, do not enable this) +
+ formElement($downloads) ?> + formElementErrors()->render($downloads, + ['class' => 'help-block']) ?> +
+
+ +formSubmit($form->get('submit')); + echo $this->form()->closeTag(); + goto done; + } $name = $form->get('name'); $name->setAttribute('class', 'form-control'); $name->setAttribute('placeholder', 'Company Name'); blob - 3f2487be3a7010284db8a726537cd99bd33566a7 blob + 302f656a1b9c99a3b2cd83d19e73ac65cae9e2e2 --- module/Securitx/view/securitx/download/download.phtml +++ module/Securitx/view/securitx/download/download.phtml @@ -15,7 +15,7 @@ use Securitx\Model\Downloads;

Hello, .
You've reached your SecuritX personal file downloader!
Links are good for five days.

-
+
File Name
File Sent Date
blob - 2375891ec92be1086873be5697898796956afefa blob + fbb705e735be3d7676aa85cd858a60b9dbb25304 --- module/Securitx/view/securitx/forgot/forgot.phtml +++ module/Securitx/view/securitx/forgot/forgot.phtml @@ -11,7 +11,7 @@

Enter your email address and your home link will be emailed to you.

-
+
get('email'); $email->setAttribute('class', 'form-control'); blob - ddcbd9e94688b0e3690d1932ba1863e217bd2f6a blob + 2358cf3647372e5347bc2749044c62b0ac099c9d --- module/Securitx/view/securitx/home/home.phtml +++ module/Securitx/view/securitx/home/home.phtml @@ -47,7 +47,7 @@

Edit my profile »

*/--> -
+

is_admin == 0) { blob - a0afcda7386bfd42594f70d17d213fed7cc020b3 blob + ca8157b0ee1949932c6b1293d4f3006e74569203 --- module/Securitx/view/securitx/index/index.phtml +++ module/Securitx/view/securitx/index/index.phtml @@ -18,7 +18,7 @@

Before the site becomes available, the new administrator account must be verified.
Please click the link in the verification email.

-
+
get('name'); $name->setAttribute('class', 'form-control'); blob - ead1c1482d613b09d41d6e5d513e851dc65fff99 blob + 70c1f986a1626aa7fd830aa79b4dfe4ae8be4850 --- module/Securitx/view/securitx/invite/invite.phtml +++ module/Securitx/view/securitx/invite/invite.phtml @@ -16,7 +16,7 @@ $this->headTitle('SecuritX: Request');

Invite a member

Please fill out and submit the request form below.
They will receive a validation email to activate their account.
You will receive an email once they validate their membership.

-
+
headTitle('SecuritX: Request');

Please fill out and submit the request form below. You will receive a validation email to activate your account.

-
+
MB.
A maximum of files may be selected for upload. -
+
Hello, first ?>.
Please enter the code that was emailed to you.
If you have not received the email, check your Junk folder.

-
+
get('code'); $code->setAttribute('class', 'form-control'); blob - 4d41979bc4c88668e25f86994c9e8325fd9f2fea blob + 2213bd16003a089b78190209e41f679c095302b6 --- module/Securitx/view/securitx/upload/upload.phtml +++ module/Securitx/view/securitx/upload/upload.phtml @@ -9,7 +9,7 @@ Combined filesize of selected documents may not exceed MB.
A maximum of files may be selected for upload. -
+
get('submit'); $submit->setAttribute('class', 'btn btn-primary'); blob - 8ab63b4b628d45d39b22cba4889eeb2df8f70161 blob + c20c889688a1f505ff35b7adefc029d47609b760 --- module/Securitx/view/securitx/user/user.phtml +++ module/Securitx/view/securitx/user/user.phtml @@ -6,5 +6,5 @@

Congratulations! You've reached your SecuritX user editor!

-
+