Habari\AdminUsersHandler::validate_edit_user PHP Method

validate_edit_user() public method

Validation for when a user is edited
public validate_edit_user ( $unused, FormControlSubmit $control, FormUI $form ) : array
$unused
$control FormControlSubmit The Apply button
$form FormUI The editing form
return array An empty array if there are no errors, or strings describing the error.
    public function validate_edit_user($unused, $control, $form)
    {
        $errors = array();
        $self = $form->edit_user->value == User::identify()->id;
        if ($self) {
            if (!User::identify()->can('manage_users') && !User::identify()->can('manage_self')) {
                $errors[] = _t('You have insufficient permissions to manage your own user account.');
            }
        } else {
            if (!User::identify()->can('manage_users')) {
                $errors[] = _t('You have insufficient permissions to manage users.');
            }
        }
        return $errors;
    }