Example #1
0
function compo_rate_rate($cid, $uid)
{
    global $compo;
    $cat = get_category($cid);
    $topurl = get_bloginfo("url");
    $k = "compo-{$cid}-cats";
    $cats = get_option($k);
    $action = isset($_REQUEST["compo_action"]) ? $_REQUEST["compo_action"] : "default";
    $user = wp_get_current_user();
    if ($user->ID == $uid) {
        //         echo "<p>You don't get to rate your own entry, silly!</p>";
        compo_trophy($uid);
        return;
    }
    if ($action == "submit") {
        $e = array();
        foreach (explode(",", $cats) as $k) {
            $v = $_REQUEST[$k];
            if (strlen($v)) {
                $e[$k] = max(1, min(5, intval($v)));
            }
        }
        compo_query("delete from {$compo["rate.table"]} where cid = ? and from_uid = ? and to_uid = ?", array($cid, $user->ID, $uid));
        compo_query("insert into {$compo["rate.table"]} (cid,from_uid,to_uid,data,comment) values (?,?,?,?,?)", array($cid, $user->ID, $uid, serialize($e), $_REQUEST["comment"]));
        compo_calc($cid, $uid);
        //         return;
        //         echo "<p><b>Ratings saved.</b></p>";
        header("Location: {$topurl}/category/{$cat->slug}/");
        die;
    }
    echo "<h3>Rate this entry</h3>";
    echo "<p>Rate on a 1-5 scale where 1 is lowest and 5 is highest.  Mark n/a if the category is not applicable to the entry, or you are not able to rate that category.</p>";
    echo "<form method=post action='{$_SERVER['REQUEST_URI']}'>";
    echo "<input type='hidden' name='compo_action' value='submit'>";
    echo "<table>";
    $r = compo_query("select * from {$compo["rate.table"]} where cid = ? and from_uid = ? and to_uid = ?", array($cid, $user->ID, $uid));
    $ee = $r[0];
    //     print_r($ee);
    $e = count($r) ? unserialize($ee["data"]) : array();
    foreach (explode(",", $cats) as $k) {
        echo "<tr>";
        echo "<th>" . ucfirst($k);
        echo "<td>";
        $v = isset($e[$k]) ? $e[$k] : "";
        compo_select($k, array("" => "n/a", "5" => "5", "4" => "4", "3" => "3", "2" => "2", "1" => "1"), $v);
    }
    echo "</table>";
    echo "<p>Comments:<br><textarea cols=50 rows=5 name='comment'>" . htmlentities($ee["comment"]) . "</textarea></p>";
    echo "<input type='submit' value='Save'>";
    echo "</form>";
}
Example #2
0
        ?>
's Trophies</h2>
		<?php 
    }
    ?>
<div class="ld-post post" id="trophies">
	<div class="body">
<?php 
    if (is_author() && is_category()) {
        $uid = get_query_var("author");
        $auth = get_userdata($uid);
        $mylink = get_option('home') . "/author/{$auth->user_nicename}/?compo_action=form";
        echo "<form method=post action='{$mylink}'><input type='submit' value='Award a trophy!'></form>";
        compo_rate(get_query_var("cat"), get_query_var("author"));
    } elseif (is_author()) {
        compo_trophy(get_query_var("author"));
    } elseif (is_category()) {
        compo_results(get_query_var("cat"));
    }
    ?>
	</div>
</div>

 	  <?php 
    /* If this is a category archive */
    if (is_category()) {
        ?>
		<h2 class="pagetitle">Archive for the &#8216;<?php 
        single_cat_title();
        ?>
&#8217; Category</h2>