From e332e1a7e7a15c4e2a98ab8c7e79aab72e1981b2 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Tue, 3 Dec 2019 11:02:52 +0100 Subject: [PATCH] app/forms/UserSettings.php: adding a admin flag. --- app/forms/UserSettings.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/forms/UserSettings.php b/app/forms/UserSettings.php index c003f67..bd6d4d0 100644 --- a/app/forms/UserSettings.php +++ b/app/forms/UserSettings.php @@ -36,6 +36,18 @@ use Phalcon\Validation\Validator\Callback as CallbackValidator, class UserSettings extends FormBase { + /** + * @var bool + */ + protected $_admin; + + public function __construct(UserModel $user = null, bool $admin = false) + { + $this->_admin = $admin; + + parent::__construct($user); + } + public function initialize() { $this->setValidation(new \Phalcon\Validation()); @@ -118,7 +130,7 @@ class UserSettings extends FormBase $current_pw = $this->getEntity()->getPassword(); // Current - if (strlen($current_pw) > 0) { + if ($this->_admin === false && strlen($current_pw) > 0) { $current = new Password('passwordCurrent', array( 'class' => 'form-control', )); @@ -143,7 +155,7 @@ class UserSettings extends FormBase // Validation $validation = $this->getValidation(); - if (strlen($current_pw) > 0) { + if ($this->_admin === false && strlen($current_pw) > 0) { $validation->add('passwordCurrent', new CallbackValidator([ 'callback' => function($data) { $new_pw = $data['passwordNew'];