Permalink
Browse files

pledge_get_ul_list_by_type now has open_pledges_only argument

  • Loading branch information...
1 parent f766c31 commit 384386850a834e6d5e2e241d0d54d2e417a8def0 @davewhiteland davewhiteland committed Mar 2, 2012
Showing with 12 additions and 7 deletions.
  1. +8 −5 phplib/pledge.php
  2. +4 −2 templates/barnet/index.php
View
@@ -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 <ul>) for this number of pledges or fewer
# ul_css_class: class to add to the <ul> 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 = "<ul" . ($ul_css_class? " class='$ul_css_class'":'') . ">\n";
@@ -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
?>
<h2>Barnet PledgeBank is a site to get things done.</h2>
@@ -22,7 +24,7 @@
Sunday 3rd&nbsp;June 2012 provided at least 4 households agree to help organise it.
Sign up or <a href="/type/diamondjubilee">start a pledge</a> to arrange your party!
</p>
- <? print pledge_get_ul_list_by_type('diamondjubilee', 2); ?>
+ <? print pledge_get_ul_list_by_type('diamondjubilee', 2, 3, "", true); ?>
<div style='clear:both;height:0.3em'></div>
</div>
@@ -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 <a href="/type/adoptastreet">start a pledge</a> to adopt your street!
</p>
- <? print pledge_get_ul_list_by_type('adoptastreet', 2); ?>
+ <? print pledge_get_ul_list_by_type('adoptastreet', 2, 3, "", true); ?>
<div style='clear:both;height:0.3em'></div>
</div>

0 comments on commit 3843868

Please sign in to comment.