<?php

require_once(dirname(__FILE__) . '/dao.php');
$context = array();
$context['theme'] = get_template_directory_uri();
$context['url'] = home_url();
$current_user = wp_get_current_user();
$current_user_id = $current_user->ID;
if ($current_user_id == 0) {
    $context['message'] = '请先登录';
} else {
    $role = $current_user->roles[0];
    $user_role = '';
    $result = null;
    switch ($role) {
        case 'contributor':
            $result = dao::search_view_house_by_user_id($current_user_id);
            break;
        case 'editor':
            $result = dao::search_view_house_by_consultant_id($current_user_id);
            break;
    }
    if ($result) {
        $context['result'] = $result;
    } else {
        $context['message'] = 'not found';
    }
}

Timber::render('list.html', $context);

?>