false ]);
case "changePassword": return UI::layout([ $this, 'changePasswordPostAction' ], [ 'showMenu' => false ]);
default: return UI::layout([ $this, 'nonExistsActionView' ], [ 'showMenu' => false ]);
}
}
function nonExistsActionView() {
UI::startTag('div', [ 'class' => "col-sm-6 col-sm-offset-3" ]);
UI::alert('danger', "Błąd formularza");
UI::endTag('div');
}
function showFormView() {
?>
"col-sm-6 col-sm-offset-3", 'style' => "margin-top:32px" ], [
"Wróć do ",
UI::h('a', [ 'href' => Router::getRoute('Menu')->getLink() ], "menu"),
]);
}
function changePasswordPostAction() {
try {
$oldPass = V::get('oldPass', '', $_POST);
$newPass = V::get('newPass', '', $_POST);
$newPassConfirm = V::get('newPassConfirm', '', $_POST);
if (!($oldPass && $newPass && ($newPass == $newPassConfirm))) throw new Exception("Błąd formularza");
if ($oldPass == $newPass) throw new Exception("Wprowadź inne hasło niż poprzednio");
$result = User::changePassword(User::getLogin(), $oldPass, $newPass);
echo UI::h('div', [ 'class' => "col-sm-6 col-sm-offset-3" ], [
($result)
? UI::h('div', [ 'class' => 'alert alert-success' ], "Pomyślnie zmieniono hasło")
: UI::h('div', [ 'class' => 'alert alert-warning' ], "Nie zmieniono hasła"),
'
',
"Wróć do ",
UI::h('a', [ 'href' => Router::getRoute('ChangePassword')->getLink() ], "zmiany hasła"),
" lub do ",
UI::h('a', [ 'href' => Router::getRoute('Menu')->getLink() ], "menu"),
]);
} catch (Exception $e) {
UI::startTag('div', [ 'class' => "col-sm-6 col-sm-offset-3" ]);
UI::alert('danger', $e->getMessage());
UI::endTag('div');
$this->showFormView();
}
}
}