diff --git a/phplib/pledge.php b/phplib/pledge.php
index 0a51fbd3..8cdfac50 100644
--- a/phplib/pledge.php
+++ b/phplib/pledge.php
@@ -1358,12 +1358,15 @@ function pledge_draw_status_plaque($p, $params = array()) {
# n_columns: how many ul's should the list be returned as
# min_items_for_cols: don't bother breaking (just return one
) for this number of pledges or fewer
# ul_css_class: class to add to the tag(s), if any
+# open_pledges_only: true if only currently open pledges are wanted
#
-function pledge_get_ul_list_by_type($pledge_type, $n_columns=1, $min_items_for_cols=3, $ul_css_class="") {
- # global $pb_today; # in SQL maybe?: date >= '$pb_today' AND
- $pledges = pledge_get_list("
- pledge_type = '$pledge_type'
- ORDER BY ref_in_pledge_type", array('global'=>false,'main'=>true,'foreign'=>false));
+function pledge_get_ul_list_by_type($pledge_type, $n_columns=1, $min_items_for_cols=3, $ul_css_class="", $open_pledges_only=false) {
+ global $pb_today;
+ $where_clause = "pledge_type = '$pledge_type' ORDER BY ref_in_pledge_type";
+ if ($open_pledges_only) {
+ $where_clause = "date >= '$pb_today' AND " . $where_clause;
+ }
+ $pledges = pledge_get_list($where_clause, array('global'=>false,'main'=>true,'foreign'=>false));
$max_pledges_in_each_column = count($pledges) <= $min_items_for_cols?
count($pledges) : intval((count($pledges)+$n_columns-1)/$n_columns);
$ul_tag = "\n";
diff --git a/templates/barnet/index.php b/templates/barnet/index.php
index df8e49ee..0e6a01b9 100644
--- a/templates/barnet/index.php
+++ b/templates/barnet/index.php
@@ -5,6 +5,8 @@
// Copyright (c) 2010 UK Citizens Online Democracy. All rights reserved.
// Email: matthew@mysociety.org. WWW: http://www.mysociety.org
+// note: calls to pledge_get_ul_list_by_type on the *front* page should probably only
+// list open pledges, so set $open_pledges_only=true in the args
?>
Barnet PledgeBank is a site to get things done.
@@ -22,7 +24,7 @@
Sunday 3rd June 2012 provided at least 4 households agree to help organise it.
Sign up or start a pledge to arrange your party!
- print pledge_get_ul_list_by_type('diamondjubilee', 2); ?>
+ print pledge_get_ul_list_by_type('diamondjubilee', 2, 3, "", true); ?>
@@ -37,7 +39,7 @@
Barnet Council will support street adoption for 10 streets if at least six households in the street sign up to get involved:
sign up or start a pledge to adopt your street!
- print pledge_get_ul_list_by_type('adoptastreet', 2); ?>
+ print pledge_get_ul_list_by_type('adoptastreet', 2, 3, "", true); ?>