'Onaccept callback
Update any User record associated with this person'

@staticmethod
def pr_person_onaccept(form):

    db = current.db
    s3db = current.s3db
    form_vars = form.vars
    person_id = form_vars.id
    ptable = s3db.pr_person
    ltable = s3db.pr_person_user
    utable = current.auth.settings.table_user
    query = (((ptable.id == person_id) & (ltable.pe_id == ptable.pe_id)) & (utable.id == ltable.user_id))
    user = db(query).select(utable.id, utable.first_name, utable.last_name, limitby=(0, 1)).first()
    if user:
        middle_as_last = current.deployment_settings.get_L10n_mandatory_middlename()
        if middle_as_last:
            if (form_vars.first_name and ((user.first_name != form_vars.first_name) or (user.last_name != form_vars.middle_name))):
                query = (utable.id == user.id)
                db(query).update(first_name=form_vars.first_name, last_name=form_vars.middle_name)
        elif (form_vars.first_name and ((user.first_name != form_vars.first_name) or (user.last_name != form_vars.last_name))):
            query = (utable.id == user.id)
            db(query).update(first_name=form_vars.first_name, last_name=form_vars.last_name)
