'S3 framework function
Designed to be called when a user is created through:
- registration
Does the following:
- Stores the user\'s email & profile image in auth_user_temp
to be added to their person record when created on approval
@ToDo: If these fields are implemented with the InlineForms functionality,
this function may become redundant'

def s3_user_register_onaccept(self, form):

    db = current.db
    s3db = current.s3db
    session = current.session
    utable = self.settings.table_user
    temptable = s3db.auth_user_temp
    form_vars = form.vars
    user_id = form_vars.id
    if (not user_id):
        return None
    if (not form_vars.utc_offset):
        db((utable.id == user_id)).update(utc_offset=session.s3.utc_offset)
    record = dict(user_id=user_id)
    home = form_vars.home
    if home:
        record['home'] = home
    mobile = form_vars.mobile
    if mobile:
        record['mobile'] = mobile
    image = form_vars.image
    if ((image != None) and hasattr(image, 'file')):
        source_file = image.file
        original_filename = image.filename
        field = temptable.image
        newfilename = field.store(source_file, original_filename, field.uploadfolder)
        if isinstance(field.uploadfield, str):
            form_vars[field.uploadfield] = source_file.read()
        record['image'] = newfilename
    if (len(record) > 1):
        temptable.update_or_insert(**record)
