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'];