md5_email( $email ), "ranker_email" => $email ); $db = db_connect(); if ( ! pg_insert( $db, "rankers", $ranker ) ) { return FALSE; } db_disconnect($db); return TRUE; } function ranker_email_message( $email ) { global $foss4g_name; global $foss4g_url; global $foss4g_year; global $num_to_be_accepted; global $deadline; $message = "Thank you for helping to review the presentations for $foss4g_name!\n"; $message .= "Please click on the link below to open up your review session.\n\n"; $message .= " http://" . $_SERVER["SERVER_NAME"] . dirname($_SERVER["REQUEST_URI"]) . "/rank.php?ranksession=" . md5_email( $email ) . "\n\n"; $message .= "The scoring system is simple:\n\n"; $message .= " 0 = I am not interested in this presentation.\n"; $message .= " 1 = I have some interest in seeing this presentation.\n"; $message .= " 2 = I am very interested in seeing this presentation!\n\n"; $message .= "Note that the default score is zero, so you only have to\n"; $message .= "score those presentations that interest you.\n\n"; $message .= "About $num_to_be_accepted presentations will be selected.\n\n"; $message .= "The committee will be choosing the program starting $deadline, so\n"; $message .= "you must have your scores in before then to make a\n"; $message .= "difference!\n\n"; $message .= "Happy scoring!\n\n"; $message .= "$foss4g_name $foss4g_year Program Committee\n"; $message .= "$foss4g_url \n\n"; return $message; } function escByteA($binData) { /** * \134 = 92 = backslash, \000 = 00 = NULL, \047 = 39 = Single Quote * * str_replace() replaces the searches array in order. Therefore, we must * process the 'backslash' character first. If we process it last, it'll * replace all the escaped backslashes from the other searches that came * before. */ $search = array(chr(92), chr(0), chr(39)); $replace = array('\\\134', '\\\000', '\\\047'); $binData = str_replace($search, $replace, $binData); return $binData; //echo "
$binData
"; //exit; } function abstract_rank( $ranking ) { // $ranking = array( [abstract_id, ranker_id, ranking_ip, ranking_value] ) $db = db_connect(); $ranking = pg_convert($db, "rankings", $ranking); $abstract_id = $ranking["abstract_id"]; $ranking_ip = $ranking["ranking_ip"]; $ranker_id = $ranking["ranker_id"]; $ranking_value = $ranking["ranking_value"]; pg_query("begin") or db_die( "abstract_rank" ); $rv = pg_query( "update rankings set ranking_value = $ranking_value where abstract_id = $abstract_id and ranker_id = $ranker_id"); if ( ! pg_affected_rows($rv) ) { $rv = pg_query( "insert into rankings ( abstract_id, ranking_ip, ranker_id, ranking_value ) values ( $abstract_id, $ranking_ip, $ranker_id, $ranking_value )"); } pg_query("commit") or db_die( "abstract_rank" ); db_disconnect($db); return TRUE; } function last_changed_timestamp( $table ) { $db = db_connect(); $table = pg_escape_string( $table ); $sql = "select date_part('epoch',table_timestamp) as table_timestamp from last_changed where table_name = '$table'"; $result = pg_query($db, $sql) or db_die( "last_changed_timestamp" ); if (!$result) db_die("last_changed_timestamp"); $rv = pg_fetch_result($result, 0, 0); db_disconnect($db); return $rv; } function abstract_id_query($query) { $sql = "select abstract_id from abstracts where abstract_tsearch @@ to_tsquery('$query')"; $db = db_connect(); $result = pg_query($db, $sql) or db_die( "abstract_id_query" ); if (!$result) db_die("abstract_id_query_result"); $rv = array(); while ( $row = pg_fetch_assoc($result) ) { array_push($rv, $row["abstract_id"]); } db_disconnect($db); return $rv; } function print_abstract_ranks_full($result) { $i = 0; print "FOSS4G Presentations"; while ( $r = pg_fetch_assoc($result) ) { $i++; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
" . $i . "ID:" . $r["abstract_id"] . "" . $r["abstract_title"] . "
"; print $r["ranking"] . " / " . $r["interest"] . " / " . $r["interest_pct"] . " / " . $r["interest_high_pct"]; print ""; print $r["presenter"] . ", " . $r["presenter_organization"]; print "
"; print nl2br($r["abstract_description"]); print "
"; print "

"; } print ""; return TRUE; } function print_abstract_ranks($output_type) { $minranks = 10; $sql = "select abstracts.abstract_id, abstract_title, abstract_summary, abstract_description, ranking, interest, interest_high, round(100 * interest::float4/count) || '%' as interest_pct, round(100 * interest_high::float4 / (0.01+interest::float4)) || '%' as interest_high_pct, presenter, presenter_organization from (SELECT DISTINCT ON (abstract_id) abstract_id, abstract_title, abstract_summary, abstract_description, presenter_name as presenter, presenter_organization FROM abstracts LEFT JOIN presenters USING (abstract_id)) as abstracts, (select sum(ranking_value) as ranking, sum(case when ranking_value > 0 then 1 else 0 end) as interest, sum(case when ranking_value = 2 then 1 else 0 end) as interest_high, abstract_id from rankings, (select count(*) as count, ranker_id from rankings group by ranker_id) as rankers where rankings.ranker_id = rankers.ranker_id and rankers.count > $minranks group by abstract_id) as ranks, (select count(*) as count from (select ranker_id, count(*) as c from rankings group by ranker_id) as counts where c > $minranks) as rankers where abstracts.abstract_id = ranks.abstract_id order by ranking desc, interest desc"; $db = db_connect(); $result = pg_query($db, $sql) or db_die( "abstract_list_ranked_summary_query" ); if (!$result) db_die("abstract_list_ranked_result"); if ( $output_type == "summary" ) { print_abstract_ranks_summary($result); } elseif ( $output_type == "tsv" ) { print_abstract_ranks_tsv($result); } else { print_abstract_ranks_full($result); } db_disconnect($db); return TRUE; } function print_abstract_ranks_summary($result) { print "FOSS4G Presentations"; print ""; print ""; $i = 0; while ( $r = pg_fetch_assoc($result) ) { $i++; print ""; print ""; print ""; print ""; print ""; print ""; print ""; } print "
#IDR/I/%TitlePresenter
$i" . $r["abstract_id"] . "" . $r["ranking"] . "/" . $r["interest"] . "/" . $r["interest_pct"] . "/" . $r["interest_high_pct"] . "" . $r["abstract_title"] . "" . $r["presenter"] . ", " . $r["presenter_organization"] . "
"; print ""; print "

Explanation of numbers: First number ('ranking') is sum(scores). Second number ('interest') is sum(scores>0?1:0). Third number ('interest percent') is # of non-zero votes for this abstract divided by total number of votes recorded for all abstracts. Fourth number ('high interest percent') is # of 2 votes for this abstract compared to the # of 1 votes for this abstract.

"; return TRUE; } function print_abstract_ranks_tsv($result) { print "rank\tabstract_id\tranking\tinterest\tinterest_pct\tinterest_high_pct\tabstract_title\tpresenter_name\tpresenter_organization\turl\n"; $i = 0; while ( $r = pg_fetch_assoc($result) ) { $i++; print $i . "\t"; print $r["abstract_id"] . "\t"; print $r["ranking"] . "\t"; print $r["interest"] . "\t"; print $r["interest_pct"] . "\t"; print $r["interest_high_pct"] . "\t"; print $r["abstract_title"] . "\t"; print $r["presenter"] . "\t"; print $r["presenter_organization"] . "\t"; print "http://community-review.foss4g.org/rank.php?abstract_id=" . $r["abstract_id"] . "\n"; } return TRUE; } function abstract_list_session( $session ) { $db = db_connect(); $session = pg_escape_string( $session ); $sql = "SELECT distinct on (abstract_id) abstract_id, abstract_title, abstract_summary, abstract_description, ranking_value, presenter_name, presenter_organization FROM abstracts LEFT JOIN (SELECT ranking_value, abstract_id FROM rankings WHERE ranker_id = '$session') as rankings USING ( abstract_id ) left join (SELECT * FROM presenters ORDER BY presenter_id) as presenters using (abstract_id) WHERE abstract_status = 1; "; $result = pg_query($db, $sql) or db_die( "abstract_array_query" ); if (!$result) db_die("abstract_array_result"); $rv = array(); while ( $row = pg_fetch_assoc($result) ) { array_push($rv, $row); } db_disconnect($db); return $rv; } function abstract_get( $abstract_id, $session ) { $db = db_connect(); $rv = array(); $abstract_id = pg_escape_string( $abstract_id ); $session = pg_escape_string($session); $sql = "SELECT * FROM abstracts where abstract_id = '$abstract_id'"; $result = pg_query($db, $sql) or db_die( "abstract_get_query" ); if ($result) $rv["abstract"] = pg_fetch_assoc($result, 0); else return FALSE; $sql = "SELECT * FROM presenters where abstract_id = '$abstract_id' order by presenter_id"; $result = pg_query($db, $sql) or db_die( "abstract_get_query" ); $presenters = array(); if ($result) { while ( $row = pg_fetch_assoc($result) ) { array_push($presenters, $row); } } $rv["presenters"] = $presenters; $sql = "SELECT * FROM rankings where abstract_id = '$abstract_id' and ranker_id = '$session'"; $result = pg_query($db, $sql) or db_die( "abstract_get_query_3" ); if ($result && pg_num_rows($result) > 0) $rv["ranking"] = pg_fetch_assoc($result, 0); else $rv["ranking"] = FALSE; db_disconnect($db); return $rv; } function session_sort( $a, $b ) { global $global_session; $a = md5($global_session + $a["abstract_id"]); $b = md5($global_session + $b["abstract_id"]); if( $a == $b ) { return 0; } return ($a < $b) ? -1 : 1; } function html_abstract_list( $session ) { global $global_session; $global_session = $session; $abstracts = abstract_list_session( $session ); usort($abstracts, "session_sort"); $count = 0; $rankcount = 0; $ids = array(); foreach ( $abstracts as $a ) { $count++; if ( $a["ranking_value"] > 0 ) { $rankcount++; } $alternate = $count % 2; $abstract_id = $a["abstract_id"]; array_push($ids, $abstract_id); $abstract_description = strip_tags($a['abstract_description'], '
      • '); print "\n"; print "
        \n"; print "

        "; html_ranking_stars( $abstract_id, $a["ranking_value"] ); print $a["abstract_title"]; print "

        \n"; print "
        \n"; # print "

        More...

        \n"; # The descriptions are markdown, hence might contain several paragraphs print $abstract_description . "\n"; print "
        \n"; print "
        \n"; print "
        \n"; print "\n\n"; } print ""; return $rankcount; } function html_abstract_full_text( $abstract_id, $session ) { $a = abstract_get( $abstract_id, $session ); print "

        Less...

        "; # print "
          \n"; # foreach ( $a["presenters"] as $p ) { # print "
        • "; # print $p["presenter_name"]; # if( $p["presenter_department"] ) { # echo sprintf(", %s", $p["presenter_department"]); # } # if( $p["presenter_organization"] ) { # if( $p["presenter_organization_url"] ) { # echo sprintf(", %s", $p["presenter_organization_url"], $p["presenter_organization"]); # } else { # echo sprintf(", %s", $p["presenter_organization"]); # } # } # print "
        • "; # } # print "
        \n"; print "

        " . nl2br(htmlspecialchars($a["abstract"]["abstract_description"])) . "

        \n"; print "

        Keywords: " . nl2br(htmlspecialchars($a["abstract"]["abstract_keywords"])) . "

        \n"; } function html_abstracts_accepted($where) { //$abstracts = abstract_list("WHERE abstract_status = 3 ORDER BY abstract_timestamp"); $abstracts = abstract_list("WHERE $where ORDER BY ranking DESC"); print "
        \n"; print "
          \n"; foreach ( $abstracts as $a ) { $abstract_id = $a["abstract_id"]; print "
        • "; print ""; print $a["abstract_title"]; print ""; print "
          "; print $a["presenter"] . ", " . $a["presenter_organization"]; print ""; print "
        • \n"; } print "
        \n"; print "
        \n"; } function html_ranking_stars( $abstract_id, $ranking_value ) { $current = $ranking_value * 1; for ( $i = 0; $i < 3; $i++ ) { $i == $current ? $j = 1 : $j = 0; print "\n"; } } function session_get() { global $cookie_name; if( isset( $_COOKIE[$cookie_name] ) ) { return $_COOKIE[$cookie_name]; } if( isset( $_GET["ranksession"] ) ) { $session = $_GET["ranksession"]; setcookie( $cookie_name, $session, time() + 365 * 24 * 60 * 60 ); return $session; } return FALSE; } ?>