Exemplo n.º 1
0
/**
 * NBA Member Directory
 *
 * @author Jordan Pakrosnis
 */
function nba_do_member_directory()
{
    //=============================//
    //  CONFIG SEARCH VALS & META  //
    //=============================//
    $search_vals = nba_get_search_vals();
    //======================================================//
    //  DIVISIONS, DIVISION STATES, TEACHING LEVELS CONFIG  //
    //======================================================//
    //-- GET DIVISIONS --//
    //   Needed for checking chair
    $divisions = nba_get_divisions();
    //-- STATE OR DIVISION CHAIR? --//
    if ($divisions['current_user']['state_chair'] || $divisions['current_user']['division_chair']) {
        $is_chair = true;
    } else {
        $is_chair = false;
    }
    //-- SELECTED DIVISION STATES --//
    //   Get if searching by division is enabled & searched & form is submitted
    if ($search_vals['do_search'] && $search_vals['division_name'] != 'all' && $search_vals['division_name'] != 'disabled') {
        $division_states = array();
        // foreach           in the  searched division's     states    as State      Chair ID
        foreach ($divisions[$search_vals['division_name']]['states'] as $state => $chair) {
            $division_states[] = nba_format_state($state, 'abbr');
        }
    } else {
        $division_states = '';
    }
    // if division_name isn't default
    //-- TEACHING LEVELS --//
    $teaching_levels = array('none' => 'None', 'elementary' => 'Elementary', 'middle-school' => 'Middle School', 'junior-high-school' => 'Junior High School', 'high-school' => 'High School', 'college-university' => 'College / University', 'community' => 'Community', 'military' => 'Military', 'other' => 'Other');
    //=======================================//
    //  COUNT TOTAL USERS (SESSION CONTROL)  //
    //=======================================//
    nba_total_results($search_vals, $division_states);
    //-- WRAPPER --//
    echo '<section class="nba-member-directory clearfix">';
    //-- INIT PAGINATION --//
    if ($search_vals['do_search']) {
        $pagination = nba_get_pagination($search_vals, $division_states);
    }
    //===============//
    //  SEARCH FORM  //
    //===============//
    nba_member_directory_search_form($search_vals, $divisions, $teaching_levels, $is_chair);
    if ($search_vals['do_search']) {
        //======================================//
        //  GET & DISPLAY RESULTS & PAGINATION  //
        //======================================//
        $results = nba_do_member_directory_search($search_vals, $division_states, $pagination['users_per_page'], $pagination['offset']);
        //-- RESULTS FOUND --//
        if ($results) {
            nba_display_member_directory_results($results, $divisions, $teaching_levels);
            nba_do_pagination($pagination);
        } else {
            echo '<div class="directory-none-found">';
            echo '<h3>There are no members that match your search.</h3>';
            echo '<div>';
            // .directory-none-found
        }
        // None Found
    }
    // if do_search
    // Close Wrapper
    echo '</section>';
}
/**
 * NATIONAL BAND ASSOCIATION
 * Register The [state-chairs] Shortcode
 *
 * @author Jordan Pakrosnis
 * @since 1.0.0
 * @package NBA
 */
function nba_shortcode_state_chairs($atts)
{
    //-- VARIABLES --//
    $output = '';
    $divisions = '';
    //-- ATTRIBUTES --//
    $a = shortcode_atts(array('heading' => 'State Chairs', 'email' => true), $atts);
    //-- CONFIGURE DIVISIONS --//
    $divisions = nba_get_divisions();
    unset($divisions['current_user']);
    unset($divisions['all_states']);
    // No Divisions
    if (!$divisions) {
        return false;
    }
    // Wrapper
    $output .= '<section class="state-chairs">';
    //-- HEADING --//
    $output .= '<h2>' . $a['heading'] . '</h2>';
    //======================//
    //  MAIN DIVISION LOOP  //
    //======================//
    foreach ($divisions as $label => $division) {
        // Tabby Tab
        $output .= '[tabby title="' . $label . '"]';
        // Unordered List
        $output .= '<ul class="states">';
        //-- STATE LOOP --//
        foreach ($division['states'] as $state => $chair) {
            // START LI
            $output .= '<li>';
            // State Name
            $output .= '<span class="state-name">' . $state . '</span> ';
            // State Chair
            if ($chair) {
                // If ID provided (non-manual, integer)
                if (is_numeric($chair)) {
                    // Get Meta
                    $name = get_user_meta($chair, 'first_name', true) . ' ' . get_user_meta($chair, 'last_name', true);
                    $email = get_user_meta($chair, 'mepr_directory_email', true);
                } else {
                    $name = $chair;
                    $email = null;
                }
                if ($name) {
                    $output .= '<span class="chair-name">';
                    if ($email && $a['email']) {
                        $output .= '<a href="mailto:' . $email . '" target="_BLANK">' . $name . '</a>';
                    } else {
                        $output .= $name;
                    }
                    $output .= '</span>';
                }
                // if $name
            } else {
                $output .= '<span class="chair-name tba">TBA</span>';
            }
            $output .= '</li>';
        }
        // foreach state
        $output .= '</ul>';
    }
    // foreach division
    // End Tabby
    $output .= '[tabbyending]';
    $output .= '</section>';
    // .state-chairs
    //-- RETURN SHORTCODE --//
    return do_shortcode($output);
}