commit - 9a2a2e446d93f4d99e18c113e55ac5fd10a23805
commit + 3c4dc62cbcbfbfa09e5923a300988ae6b1bb795b
blob - 7418fa0ea05584d877bae7189fcf0f883a42ebb4
blob + 132a7f73e9bce65b3c2796a979ba73e335ddb8d5
--- module/Securitx/src/Controller/SecuritxController.php
+++ module/Securitx/src/Controller/SecuritxController.php
}
if ($_GET) {
$companies = '';
+ $id = '';
if (array_key_exists('add', $_GET)) {
$form = new CompanyForm();
$action = "add";
$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();
'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
use Laminas\Form\Form;
use Laminas\Form\Element;
-class CompanyForm extends Form {
+class CompanyEditForm extends Form {
public function __construct($name = null) {
parent::__construct($name);
],
]);
$this->add([
- 'name' => 'short',
- 'type' => 'text',
- 'options' => [
- 'label' => 'Two Letter Short Name',
- ],
- ]);
- $this->add([
'name' => 'domain',
'type' => 'text',
'options' => [
],
]);
$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
}
return $row;
}
+ public function getDomainCount($id) {
+ return $this->tableGateway->select(['domain' => $id])->count();
+ }
public function getShortCount($id) {
return $this->tableGateway->select(['short' => $id])->count();
}
}
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
<p>Hello, <?= $first ?>.<br />
You've reached your SecuritX company file downloader!<br />
Links are good for five days.</p>
- <hr class="my-4">
+ <hr class="my-4" \>
<div class="downloads">
<div class="dfilem">File Name</div>
<div class="mdatem">File Sent Date</div>
blob - 37c9fb7cb3108cce4a438d776c6c6a85279f3791
blob + 5e7e2cbff3a8ef26f65ac89b75bbbece640beb30
--- module/Securitx/view/securitx/companies/companies.phtml
+++ module/Securitx/view/securitx/companies/companies.phtml
<?php if ($completed) { ?>
<p>Hello, <?= $member->first ?>.<br />The company has been <?= $action ?>.</p>
- <hr class="my-4">
+ <hr class="my-4" \>
<?php
goto done;
}
?>
- <p>Hello, <?= $member->first ?>.<br />Here, you can <?= $action ?> a company.<br />The primary company can not be deleted.</p>
+ <p>Hello, <?= $member->first ?>.<br />Here, you can <?= $action ?> a company.
+<?php if ($action == "delete") { ?>
+ <br />The primary company can not be deleted.</p>
+<?php } ?>
+ <hr class="my-4" \>
- <hr class="my-4">
-
<?php
if ($action == "delete") {
$cnt = 0;
echo $this->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);
+?>
+ <div class="form-group">
+ <?= $this->formLabel($company_id) ?>
+ <?= $this->formElement($company_id) ?>
+ <?= $this->formElementErrors()->render($company_id,
+ ['class' => 'help-block']) ?>
+ </div>
+ <div class="form-group">
+ <span style="color: red; font-weight: bold">
+ </div>
+<?php
+ echo $this->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);
+?>
+ <input type="hidden" name="company_id" value="<?=$company->company_id ?>" \>
+ <div class="form-group">
+ <?= $this->formLabel($name) ?>
+ <?= $this->formElement($name) ?>
+ <?= $this->formElementErrors()->render($name,
+ ['class' => 'help-block']) ?>
+ </div>
+
+ <div class="form-group">
+ <?= $this->formLabel($phone) ?>
+ <?= $this->formElement($phone) ?>
+ <?= $this->formElementErrors()->render($phone,
+ ['class' => 'help-block']) ?>
+ <p style="color: red"><?= $valid_phone ?></p>
+ </div>
+
+ <div class="form-group">
+ <?= $this->formLabel($domain) ?>
+ <?= $this->formElement($domain) ?>
+ <?= $this->formElementErrors()->render($domain,
+ ['class' => 'help-block']) ?>
+ <p style="color: red"><?= $valid_domain ?></p>
+ </div>
+
+ <div class="form-group">
+ <?= $this->formLabel($downloads) ?> (if you plan to enable automatic file handling via other scripting, do not enable this)
+ <div class="form-group-left">
+ <?= $this->formElement($downloads) ?>
+ <?= $this->formElementErrors()->render($downloads,
+ ['class' => 'help-block']) ?>
+ </div>
+ </div>
+
+<?php
+ echo $this->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
<p>Hello, <?= $first ?>.<br />
You've reached your SecuritX personal file downloader!<br />
Links are good for five days.</p>
- <hr class="my-4">
+ <hr class="my-4" \>
<div class="downloads">
<div class="dfilem">File Name</div>
<div class="mdatem">File Sent Date</div>
blob - 2375891ec92be1086873be5697898796956afefa
blob + fbb705e735be3d7676aa85cd858a60b9dbb25304
--- module/Securitx/view/securitx/forgot/forgot.phtml
+++ module/Securitx/view/securitx/forgot/forgot.phtml
<p>Enter your email address and your home link will be emailed to you.</p>
<?php } ?>
- <hr class="my-4">
+ <hr class="my-4" \>
<?php
$email = $form->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
<p><a class="btn btn-secondary btn-lg" href="/securitx/user/<?= $member->u_key ?>">Edit my profile »</a></p>
*/-->
- <hr class="my-4">
+ <hr class="my-4" \>
<p>
<?php
if ($has_domain && $member->is_admin == 0) {
blob - a0afcda7386bfd42594f70d17d213fed7cc020b3
blob + ca8157b0ee1949932c6b1293d4f3006e74569203
--- module/Securitx/view/securitx/index/index.phtml
+++ module/Securitx/view/securitx/index/index.phtml
<p>Before the site becomes available, the new administrator account must be verified.
<br />Please click the link in the verification email.</p>
<?php return; } ?>
- <hr class="my-4">
+ <hr class="my-4" \>
<?php if (!$company) {
$name = $form->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
<h1 class="display-4">Invite a member</h1>
<p>Please fill out and submit the request form below.<br />They will receive a validation email to activate their account.<br />You will receive an email once they validate their membership.</p>
- <hr class="my-4">
+ <hr class="my-4" \>
<?php
$co_opts = array();
foreach ($companies as $company) {
blob - 6b56350c5232dc426030515b76a7c6e15283684c
blob + 4f48c4a1a007f2cba5a4df77846f7f8d157dc2d7
--- module/Securitx/view/securitx/request/request.phtml
+++ module/Securitx/view/securitx/request/request.phtml
<p>Please fill out and submit the request form below. You will receive a validation email to activate your account.</p>
- <hr class="my-4">
+ <hr class="my-4" \>
<?php
$co_opts = array();
foreach ($companies as $company) {
blob - 49f3bf45a5d00a3e71830ead595384483bab10ab
blob + f7f7b312f1c953b926024358a4d560f1a20410b4
--- module/Securitx/view/securitx/send/send.phtml
+++ module/Securitx/view/securitx/send/send.phtml
Combined filesize of selected documents may not exceed <b><?= $limit ?> MB</b>.<br />
A maximum of <?= ini_get('max_file_uploads') ?> files may be selected for upload.
- <hr class="my-4">
+ <hr class="my-4" \>
<?php
$m_opts = array();
$m_count = 0;
blob - 33a6d29a80debd79d84c0dad57e8b1c26b69bd8c
blob + a068a5723148bc77b38ce3bcbce25e85cc748e7e
--- module/Securitx/view/securitx/twofa/twofa.phtml
+++ module/Securitx/view/securitx/twofa/twofa.phtml
<p>Hello, <?= $member->first ?>.<br />Please enter the code that was emailed to you.<br />If you have not received the email, check your Junk folder.</p>
- <hr class="my-4">
+ <hr class="my-4" \>
<?php
$code = $form->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
Combined filesize of selected documents may not exceed <b><?= $limit ?> MB</b>.<br />
A maximum of <?= ini_get('max_file_uploads') ?> files may be selected for upload.
- <hr class="my-4">
+ <hr class="my-4" \>
<?php
$submit = $form->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
<p>Congratulations! You've reached your SecuritX user editor!</p>
- <hr class="my-4">
+ <hr class="my-4" \>
</div>