Skip to content

Commit

Permalink
Merge pull request #14 from YWatchman/master
Browse files Browse the repository at this point in the history
Hotfixed DPA status request
  • Loading branch information
WilliamDEdwards authored Nov 18, 2018
2 parents 9326696 + 03566d4 commit cb9f004
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 31 deletions.
25 changes: 15 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Description

[![Codacy Badge](https://api.codacy.com/project/badge/Grade/a52ad6881cbd428ba76deba69bd572de)](https://app.codacy.com/app/ik/HostFact-Verwerkersovereenkomst?utm_source=github.com&utm_medium=referral&utm_content=YWatchman/HostFact-Verwerkersovereenkomst&utm_campaign=Badge_Grade_Dashboard)

This HostFact plugin does three things:

- your debtors are able to agree to your DPA (verwerkersovereenkomst) in the HostFact `klantenpaneel`;
Expand Down Expand Up @@ -41,22 +43,26 @@ This HostFact plugin does three things:

*Let op: als er geen PDF is geüpload naar de map 'docs' en/of opgegeven in het configuratiebestand, dan zien debiteuren in het `klantenpaneel` een bericht dat de DPA binnenkort getekend kan worden.*

<!--# Optional: Ask debtors to sign
# Optional: Ask debtors to sign
Asking debtors to accept the DPA plugin throughout the HostFact `klantenpaneel`:

![Asking debtors to accept](https://i.imgur.com/LX3OR9A.png)

You can use the following code in your custom/views/header.phtml to show a message to all debtors that haven't signed the DPA yet in the `klantenpaneel`. Below code will check if the debtor has agreed to the DPA yet, and if not, a message will be shown.

*Note*: this code is not working at the moment, because it relies on some variables only passed by HostFact in the `dpa` view. Will try to fix...
<?php
$dpa = new Dpa\Dpa_Model();
require_once(CUSTOMPATH . '/plugins/dpa/config.php');
require_once(CUSTOMPATH . '/plugins/dpa/models/dpa_model.php');

if ($dpa->debtorDPAStatus() == '' && strpos($_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'], __('dpa', 'url', 'dpa')) == false) {
echo '<div class="alert alert-warning" role="alert"><p>'.__('dpa not accepted').' <a href="/klantenpaneel/'.__('dpa', 'url', 'dpa').'/">'.__('accept').'</a></p></div>';
}
?>-->
$dpa = new \Dpa\Dpa_Model();
global $config;
?>

<?php if ($dpa->debtorDPAStatus($config)): ?>
<div class="box box-warning">
Your content
</div>
<?php endif; ?>

# Delete DPA preference (for testing)

Expand All @@ -67,5 +73,4 @@ If you're testing and you need to delete the custom field value for a debtor, yo
Replace {DEBTORID} with the debtor ID (NOT the debtor code) and {FIELDID} with the same field ID that you set in the config.

# Known bug

When a user resets their password and logs in after doing so, the message above (under "Optional: Ask debtors to sign") is not shown, and the module says that the DPA has already been signed for that account. That is because the custom field for that debtor is created and we only check if the custom field was created; not what it contains. I'm not aware of any good method to fix that, currently.
~~When a user resets their password and logs in after doing so, the message above (under "Optional: Ask debtors to sign") is not shown, and the module says that the DPA has already been signed for that account. That is because the custom field for that debtor is created and we only check if the custom field was created; not what it contains. I'm not aware of any good method to fix that, currently.~~
2 changes: 1 addition & 1 deletion klantenpaneel/custom/plugins/dpa/config.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php

global $config;
$config = array();

// Custom field code ('Veldcode', not the name)
Expand Down
36 changes: 16 additions & 20 deletions klantenpaneel/custom/plugins/dpa/models/dpa_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ public function isActivated()
if (file_exists(CUSTOMPATH . '/plugins/dpa/docs/' . $this->config['pdffile'])) {
return true;
}
else {
return false;
}
return false;
}

// No config input entered.
Expand Down Expand Up @@ -79,7 +77,7 @@ public function getCurrentDebtor()
*
* @return boolean
*/
public function sendEmail($debtorid) {
public function sendEmail($debtorid) {
$debtorParams = array(
'Identifier' => $debtorid,
'TemplateID' => $this->config['templateid'],
Expand All @@ -90,9 +88,7 @@ public function sendEmail($debtorid) {
if ($response['status'] == "success") {
return true;
}
else {
return false;
}
return false;
}

/**
Expand Down Expand Up @@ -133,26 +129,26 @@ public function updatePreference() {
}

// Error processing signing.
else {
return false;
}
return false;
}

/**
* Retrieve debtor DPA info.
*
* @return string
*/
public function debtorDPAStatus() {
* Retrieve debtor DPA info.
* Hotfix by YWatchman <[email protected]>
*
* @return string
*/
public function debtorDPAStatus($config = null)
{
$debtor = $this->getCurrentDebtor();
$response = $this->APIRequest('debtor', 'show', array('Identifier' => $debtor));

// If custom field is filled, debtor agreed already
if (isset($response['debtor']['CustomFields'][$this->config['fieldname']]) && $response['debtor']['CustomFields'][$this->config['fieldname']] != "") {
$this->config = $config != null ? $config : $this->config;

// If custom field is filled, debtor agreed already
if ( isset($response['debtor']['CustomFields'][$this->config['fieldname']]) && $response['debtor']['CustomFields'][$this->config['fieldname']] != "" ) {
return $response['debtor']['CustomFields'][$this->config['fieldname']];
}
else {
return '';
}
return '';
}
}

0 comments on commit cb9f004

Please sign in to comment.