# You must use a tab-size of 4 spaces to edit this file.
---
zenario_user__details:
    priv: _PRIV_VIEW_USER
    key:
        id: ""
        parent_id: ''
        email_on_load: ''
    identifier:
        css_class: user
        label: User ID
    tabs:
        details:
            label: Details
            edit_mode:
                priv: _PRIV_EDIT_USER
                enabled: Yes
            notices:
                password_expired:
                    show: false
                    message: This user's password has expired. Reset their password to give the user more time to login.
                    type: warning
            fields:
                email_grouping:
                    dataset_label: '[Email grouping]'
                    type: grouping
                    name: email_grouping
                email:
                    grouping: email_grouping
                    label: "Email:"
                    type: text
                    onblur: |
                        var emailOnLoad = zenarioAB.tuix.key.email_on_load;
                        var emailNow = $(zenarioAB.get('email'));
                        var emailVerifiedStatus = $('.email_status');
                        
                        if (emailNow && emailOnLoad) {
                            emailNow = emailNow.val();
                            if ((emailNow != emailOnLoad) && emailVerifiedStatus) {
                                emailVerifiedStatus.remove();
                            }
                        }
                email_verified:
                    grouping: email_grouping
                    #This field is only used for storing the value.
                    label: "Email address verified"
                    type: checkbox
                    hidden: true
                salutation:
                    label: "Salutation:"
                    type: text
                    allow_admin_to_change_visibility: true
                first_name:
                    label: "First name:"
                    type: text
                last_name:
                    label: "Last name:"
                    type: text
                status:
                    label: "Status:"
                    type: radios
                    values: 
                        contact: 
                            ord: 1
                            label: Contact
                        pending: 
                            ord: 2
                            label: Extranet user (pending)
                        active: 
                            ord: 3
                            label: Extranet user (active)
                        suspended: 
                            ord: 4
                            label: Extranet user (suspended)
                    redraw_onchange: true
                    side_note: |
                        Choose "Contact" for a record of someone whose details you store, whom you may email, or export their details. They won't be able to log in.<br /><br />Choose "Extranet user" for someone whose details you store, and who may also log into an extranet area, so long as their account is "active".
                linked_countries:
                    visible_if: |
                        zenarioAB.value('status', 'details')
                        && zenarioAB.value('status', 'details') != 'contact'
                        && zenarioA.siteSettings.users_use_linked_countries
                    label: "Country-based permissions:"
                    pick_items:
                        path: zenario__languages/panels/countries/refiners/active////
                        min_path: zenario__languages/panels/countries
                        max_path: zenario__languages/panels/countries
                        target_path: zenario__languages/panels/countries
                        multiple_select: true
                        select_phrase: Select countries...
                        nothing_selected_phrase: No countries selected
                
                screen_name_grouping:
                    dataset_label: '[Screen name grouping]'
                    type: grouping
                    name: screen_name_grouping
                
                screen_name: 
                    grouping: screen_name_grouping
                    label: "Screen name:"
                    type: text
                    visible_if: |
                        zenarioAB.value('status', 'details')
                        && zenarioAB.value('status', 'details') != 'contact'
                        && zenarioA.siteSettings.user_use_screen_name
                    maxlength: 50
                    note_below: "When suggesting a screen name, the first namd and/or last name will be used. If neither is provided, the suggestion may be blank. Please note: the suggested screen name may not be unique. If it is not, we recommend adding numbers at the end of it."
                    
                suggest_screen_name:
                    grouping: screen_name_grouping
                    same_row: true
                    visible_if: |
                        zenarioAB.value('status', 'details')
                        && zenarioAB.value('status', 'details') != 'contact'
                        && zenarioA.siteSettings.user_use_screen_name
                    dataset_label: '[Suggest screen name button]'
                    snippet:
                        html: |
                            <input type="button" value="Suggest" onclick="
                                zenario.ajax(
                                    'zenario/admin/quick_ajax.php',
                                    {screen_name_suggestion: 1, first_name: zenarioAB.get('first_name').value, last_name: zenarioAB.get('last_name').value, email: zenarioAB.get('email').value},
                                    false, false
                                ).after(function(screen_name) {
                                    var screen_name_field;
                                    if (screen_name_field = zenarioAB.get('screen_name')) {
                                        screen_name_field.value = screen_name;
                                    }
                                });
                            "/>
                screen_name_confirmed:
                    grouping: screen_name_grouping
                    label: 'Screen name chosen or accepted by user'
                    type: checkbox
                    visible_if: |
                        zenarioAB.tuix.key.id
                        && zenarioAB.value('status', 'details')
                        && zenarioAB.value('status', 'details') != 'contact'
                        && zenarioA.siteSettings.user_use_screen_name
                    readonly: true 
                    side_note: "If unchecked the screen name has been automatically generated with no user input."
                
                
                password_grouping:
                    dataset_label: '[Password grouping]'
                    type: grouping
                    name: password_grouping
                
                activation_grouping:
                    dataset_label: '[Account creation grouping]'
                    type: grouping
                    name: activation_grouping
                
                password_when_editing:
                    grouping: password_grouping
                    label: "Password:"
                    snippet:
                        html: "[[change_password_link]]"
                    note_below: "Passwords are 1-way encrypted. They can be changed but not read from the database"
                    visible_if: |
                        zenarioAB.tuix.key.id
                        && zenarioAB.value('status', 'details')
                        && zenarioAB.value('status', 'details') != 'contact'
                password:
                    grouping: password_grouping
                    label: "Password:"
                    type: password
                    visible_if: |
                        !zenarioAB.tuix.key.id
                        && zenarioAB.value('status', 'details')
                        && zenarioAB.value('status', 'details') != 'contact'
                    
                    # This is a little hack to try and stop Google Chrome auto-filling a username and password in here
                    # http://stackoverflow.com/questions/15738259/disabling-chrome-autofill
                    autocomplete: "off_yes_really_i_want_this_off"
                    oninput: |
                        var adminFacing = true;
                        zenarioP.updatePasswordNotifier(
                            zenarioAB.get('password'),
                            {
                                min_extranet_user_password_length: zenarioAB.tuix.key.min_extranet_user_password_length,
                                min_extranet_user_password_score: zenarioAB.tuix.key.min_extranet_user_password_score
                            },
                            '#zenario_password_message',
                            adminFacing
                        );
                        
                    pre_field_html: |
                        <input type="text" name="dummy_username" autocomplete="off_yes_really_i_want_this_off" tabindex="-1" style="
                            position: fixed;
                            top: -1000px;
                            width: 1px;
                            height: 1px;
                        "/>
                        <input type="password" name="dummy_password" autocomplete="off_yes_really_i_want_this_off" tabindex="-1" style="
                            position: fixed;
                            top: -1000px;
                            width: 1px;
                            height: 1px;
                        "/>
                
                reveal_password:
                    grouping: password_grouping
                    same_row: true
                    visible_if: |
                        !zenarioAB.tuix.key.id
                        && zenarioAB.value('status', 'details')
                        && zenarioAB.value('status', 'details') != 'contact'
                    value: Reveal
                    dataset_label: '[Reveal password button]'
                    type: toggle
                    onclick: |
                        var fields = zenarioAB.tuix.tabs.details.fields,
                            passwordEl = zenarioAB.get('password'),
                            passwordField = fields.password,
                            revealEl = zenarioAB.get('reveal_password'),
                            revealField = fields.reveal_password,
                            previouslyPressed = zenarioAB.value('reveal_password', 'details');
                    
                        if (passwordEl && revealEl) {
                            passwordEl.type = 
                            passwordField.type =
                                previouslyPressed? 'password' : 'text';
                            
                            revealEl.value =
                            revealField.current_value =
                                previouslyPressed? 'Reveal' : 'Hide';
                        }
                suggest_password:
                    grouping: password_grouping
                    same_row: true
                    visible_if: |
                        !zenarioAB.tuix.key.id
                        && zenarioAB.value('status', 'details')
                        && zenarioAB.value('status', 'details') != 'contact'
                    dataset_label: '[Suggest password button]'
                    snippet:
                        html: |
                            <input type="button" value="Suggest" onclick="
                                zenario.ajax('zenario/admin/quick_ajax.php', {password_suggestion: 1}, false, false).after(function(password) {
                                    var passwordEl;
                                    if (passwordEl = zenarioAB.get('password')) {
                                        passwordEl.value = password;
                                    }
                                
                                    $(zenarioAB.get('password')).trigger('oninput');
                                });
                            "/>
                
                
                password_message:
                    grouping: password_grouping
                    indent: 1
                    dataset_label: '[Password validation message]'
                    visible_if: |
                        !zenarioAB.tuix.key.id
                        && zenarioAB.value('status', 'details')
                        && zenarioAB.value('status', 'details') != 'contact'
                    post_field_html: |
                        <div>
                            <span id="zenario_password_message" class="title_red">Password does not match the requirements</span>
                        </div>
                password_needs_changing:
                    grouping: password_grouping
                    priv: _PRIV_EDIT_USER
                    visible_if: |
                        !zenarioAB.tuix.key.id
                        && zenarioAB.value('status', 'details')
                        && zenarioAB.value('status', 'details') != 'contact'
                    label: "Must change password on next login"
                    type: checkbox
                    side_note: "When the extranet user next logs in to the site, they will be asked to change their password before they can access the extranet area."
                terms_and_conditions_accepted:
                    visible_if: |
                        zenarioAB.value('status', 'details')
                    label: "Has accepted terms and conditions"
                    note_below: "This indicates if the user or contact has accepted the site's terms and conditions (recorded in the consent log when a user/contact signs up themself). If using Newsletters in Zenario, they will only be sent to recipients where this is checked."
                    type: checkbox
                send_activation_email_to_user:
                    grouping: activation_grouping
                    label: 'Send "account created" email to user'
                    type: checkbox
                    side_note: "Send an email to the user with their login details and a link to the login page."
                    visible_if: |
                        zenarioAB.value('status', 'details')
                        && zenarioAB.value('status', 'details') != 'contact'
                    format_onchange: Yes
                    hidden: true
                email_to_send:
                    grouping: activation_grouping
                    label: 'Activation email template:'
                    indent: 1
                    pick_items:
                        path: zenario__email_template_manager/panels/email_templates
                        min_path: zenario__email_template_manager/panels/email_templates
                        max_path: zenario__email_template_manager/panels/email_templates
                        target_path: zenario__email_template_manager/panels/email_templates
                        select_phrase: Select email template...
                        hide_remove_button: Yes
                    validation:
                        required_if_not_hidden: Please select an email template
                    visible_if: |
                        zenarioAB.value('send_activation_email_to_user', 'details')
                    side_note: >
                        An email based on the selected email template will be sent
                        to the user.
                    hidden: true
                    #The note_below is added in PHP.
        groups:
            label: Groups
            edit_mode:
                priv: _PRIV_EDIT_USER
                enabled: true
            fields:
                no_groups_created:
                    hidden: true
                    snippet:
                        html: |
                            No groups have been created on this tab. [[link_start]]Create groups...[[link_end]]
                    dataset_label: '[Warning message about groups]'
        dates:
            visible_if: |
                zenarioAB.tuix.key.id
            label: Dates/History
            ord: 999999
            fields:
                last_login: 
                    visible_if: |
                        zenarioAB.value('status', 'details') != 'contact'
                    label: "Last login:"
                    type: DateTime
                    change_month_and_year: true
                    readonly: true
                    show_as_a_span: true
                last_profile_update_in_frontend: 
                    visible_if: |
                        zenarioAB.value('status', 'details') != 'contact'
                    label: "Profile last updated:"
                    type: DateTime
                    change_month_and_year: true
                    readonly: true
                    show_as_a_span: true
                suspended_date: 
                    visible_if: |
                        zenarioAB.value('status', 'details') == 'suspended'
                    label: "Date suspended:"
                    type: DateTime
                    change_month_and_year: true
                    readonly: true
                    show_as_a_span: true
                consents_log:
                    label: 'Consents log:'
                    snippet:
                        html: 'No consents recorded for this user.'
