function widget($args, $instance)
    {
        extract($args);
        echo $before_widget;
        if ($instance['title']) {
            echo $before_title . apply_filters('widget_title', $instance['title']) . $after_title;
        }
        $user_limit = $instance['user_limit'];
        $user_tp = $instance['user_tp'];
        global $wpdb;
        if ($user_tp == "both") {
            $inr = '';
            $whr = '';
        }
        if ($user_tp == "service_provider") {
            $inr = "INNER JOIN {$wpdb->usermeta} m ON m.user_id = users.ID ";
            $whr = "m.meta_key = 'wp_capabilities' AND m.meta_value LIKE '%service_provider%' AND";
        }
        if ($user_tp == "service_contractor") {
            $inr = "INNER JOIN {$wpdb->usermeta} m ON m.user_id = users.ID ";
            $whr = "m.meta_key = 'wp_capabilities' AND m.meta_value LIKE '%business_owner%' AND";
        }
        //$widget_id = $args['widget_id'];
        if (empty($user_limit)) {
            $user_limit = 5;
        }
        $querystr = "\r\n\t\t\t\t\tSELECT users.user_email email,users.ID UID, users.user_registered dt, users.user_login username, ratings.touser uid, \r\n\t\t\t\t\tAVG(ratings.grade) rate FROM " . $wpdb->prefix . "project_ratings ratings, {$wpdb->users} users \r\n\t\t\t\t\t" . $inr . " where " . $whr . "\t\t\t\t\r\n\t\t\t\t\tusers.ID=ratings.touser \r\n\t\t\t\t\tgroup by ratings.touser order by rate DESC LIMIT {$user_limit}";
        $r = $wpdb->get_results($querystr);
        if (count($r) == 0) {
            echo __('No rated users yet.', 'ProjectTheme');
        } else {
            echo '<table width="100%">';
            foreach ($r as $row) {
                $hash = md5(strtolower(trim($row->email)));
                $dt = date_i18n("jS \\of F, Y", strtotime($row->dt));
                echo '<tr>';
                echo '<td width="20%"><a href="' . ProjectTheme_get_user_profile_link($row->UID) . '"><img class="image_class"
						src="' . ProjectTheme_get_avatar($row->UID, 40, 40) . '" width="40" /></a></td>';
                echo '<td><b><a href="' . ProjectTheme_get_user_profile_link($row->UID) . '">' . $row->username . '</a></b><br/>
						 ' . sprintf(__('Joined on: %s', 'ProjectTheme'), $dt) . '
						<br/>' . ProjectTheme_get_project_stars(floor($row->rate / 2)) . '
						</td>';
                echo '</tr>';
            }
            echo '</table>';
        }
        echo $after_widget;
    }
Exemple #2
0
        echo '<th><b>' . __('Price', 'ProjectTheme') . '</b></th>';
        echo '<th><b>' . __('Rating', 'ProjectTheme') . '</b></th>';
        echo '</tr>';
        foreach ($r as $row) {
            $post = $row->pid;
            $post = get_post($post);
            $bid = projectTheme_get_winner_bid($row->pid);
            $user = get_userdata($row->fromuser);
            echo '<tr>';
            echo '<th><img class="img_class" src="' . ProjectTheme_get_first_post_image($row->pid, 42, 42) . '" 
                                alt="' . $post->post_title . '" width="42" /></th>';
            echo '<th><a href="' . get_permalink($row->pid) . '">' . $post->post_title . '</a></th>';
            echo '<th><a href="' . ProjectTheme_get_user_profile_link($user->user_login) . '">' . $user->user_login . '</a></th>';
            echo '<th>' . date('d-M-Y H:i:s', get_post_meta($row->pid, 'closed_date', true)) . '</th>';
            echo '<th>' . projectTheme_get_show_price($bid->bid) . '</th>';
            echo '<th>' . ProjectTheme_get_project_stars(floor($row->grade / 2)) . ' (' . floor($row->grade / 2) . '/5)</th>';
            echo '</tr>';
            echo '<tr>';
            echo '<th></th>';
            echo '<th colspan="5"><b>' . __('Comment', 'ProjectTheme') . ':</b> ' . $row->comment . '</th>';
            echo '</tr>';
            echo '<tr><th colspan="6"><hr color="#eee" /></th></tr>';
        }
        echo '</table>';
    } else {
        _e("There are no reviews to be awarded.", "ProjectTheme");
    }
    ?>
                
                
				<!-- ####### -->
Exemple #3
0
function ProjectTheme_project_get_star_rating2($uid)
{
    global $wpdb;
    $s = "select grade from " . $wpdb->prefix . "project_ratings where touser='******' AND awarded='1'";
    $r = $wpdb->get_results($s);
    $i = 0;
    $s = 0;
    if (count($r) == 0) {
        return __('(No rating)', 'ProjectTheme');
    } else {
        foreach ($r as $row) {
            $i++;
            $s = $s + $row->grade;
        }
    }
    $rating = round($s / $i / 2, 0);
    $rating2 = round($s / $i / 2, 1);
    return ProjectTheme_get_project_stars($rating) . "<br/>(" . $rating2 . "/5) " . sprintf(__("on %s rating(s)", "ProjectTheme"), $i);
}