Verified Commit 542309da authored by dockx thibault's avatar dockx thibault
Browse files

:sparkles: Feat(Reminder) - Logic of error handling

error handling and tpl updates
Showing with 34 additions and 23 deletions
+34 -23
...@@ -58,6 +58,8 @@ class reminderFrontEnd extends standAlonePage ...@@ -58,6 +58,8 @@ class reminderFrontEnd extends standAlonePage
function execute () function execute ()
{ {
global $error_collector; global $error_collector;
$success = FALSE;
$error = FALSE;
if (!empty($_POST)) { if (!empty($_POST)) {
$this->sanitizeInputs(); $this->sanitizeInputs();
...@@ -72,25 +74,31 @@ class reminderFrontEnd extends standAlonePage ...@@ -72,25 +74,31 @@ class reminderFrontEnd extends standAlonePage
// Verify if uid is set (thanks to post) and verify token validity. // Verify if uid is set (thanks to post) and verify token validity.
if (!empty($this->uid)) { if (!empty($this->uid)) {
// verification of token // verification of token
if ($this->checkToken($this->token)) { if (!$this->checkToken($this->token)) {
$this->message[] = "Token is valid and not expired."; $this->message[] = "Error, data received are incorrect!";
} else { } else {
$this->message[] = "Token is not valid or expired."; $success = TRUE;
} }
} }
if (!empty($this->message)) { if (!empty($this->message)) {
msg_dialog::displayChecks($this->message); msg_dialog::displayChecks($this->message);
$success = FALSE; $error = TRUE;
} }
// Initialize smarty and pass the status of potential error ?? // Initialize smarty and pass the status of potential error ??
$this->initSmarty($success); $this->initSmarty($success, $error);
} }
private function initSmarty ($success) /**
* @param bool $success
* @param bool $error
* @return void
* Note : success allows to display certain part of the tpl '<div>' element.
*/
private function initSmarty (bool $success, bool $error)
{ {
$smarty = get_smarty(); $smarty = get_smarty();
...@@ -112,6 +120,8 @@ class reminderFrontEnd extends standAlonePage ...@@ -112,6 +120,8 @@ class reminderFrontEnd extends standAlonePage
$smarty->assign('version', FD_VERSION); $smarty->assign('version', FD_VERSION);
$smarty->assign('activated', $this->activated); $smarty->assign('activated', $this->activated);
$smarty->assign('success', $success);
$smarty->assign('error', $error);
$smarty->assign('taskName', $this->task['name']); $smarty->assign('taskName', $this->task['name']);
$smarty->assign('token', $this->token); $smarty->assign('token', $this->token);
$smarty->display(get_template_path('taskReminder.tpl')); $smarty->display(get_template_path('taskReminder.tpl'));
......
...@@ -16,24 +16,25 @@ ...@@ -16,24 +16,25 @@
{t}Reminder - Account prolongation{/t} {t}Reminder - Account prolongation{/t}
</p> </p>
</div> </div>
{if !$success && !$error}
<div style="text-align: center;">
<label for="login">
<img class="center" src="geticon.php?context=types&amp;icon=user&amp;size=48" alt="{t}Username{/t}" title="{t}Username{/t}"/>&nbsp;
</label>
<input type="text" name="login" placeholder="{t}Enter your ID{/t}" required />
<br />
<div style="text-align: center;"> <!-- Hidden fields for taskName and token from $_GET -->
<label for="login"> <input type="hidden" name="taskName" value="{$taskName}" />
<img class="center" src="geticon.php?context=types&amp;icon=user&amp;size=48" alt="{t}Username{/t}" title="{t}Username{/t}"/>&nbsp; <input type="hidden" name="token" value="{$token}" />
</label> </div>
<input type="text" name="login" placeholder="{t}Enter your ID{/t}" required />
<br />
<!-- Hidden fields for taskName and token from $_GET --> <div id="window-footer" class="plugbottom">
<input type="hidden" name="taskName" value="{$taskName}" /> <div>
<input type="hidden" name="token" value="{$token}" /> <input type="submit" name="apply" value="{t}Submit{/t}" title="{t}Click here to prolonged your account.{/t}"/>
</div> </div>
</div>
<div id="window-footer" class="plugbottom"> {/if}
<div>
<input type="submit" name="apply" value="{t}Submit{/t}" title="{t}Click here to prolonged your account.{/t}"/>
</div>
</div>
</form> </form>
<div id="window-content"> <div id="window-content">
...@@ -47,7 +48,7 @@ ...@@ -47,7 +48,7 @@
{else if $error} {else if $error}
<div class="error"> <div class="error">
<img class="center" src="geticon.php?context=status&amp;icon=task-failure&amp;size=16" alt="{t}Error{/t}" title="{t}Error{/t}">&nbsp; <img class="center" src="geticon.php?context=status&amp;icon=task-failure&amp;size=16" alt="{t}Error{/t}" title="{t}Error{/t}">&nbsp;
<b>{t}An unexpected error occurred{/t}</b> <b>{t}Error, data received are invalid!{/t}</b>
</div> </div>
{/if} {/if}
<br/> <br/>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment