Skip to content
This repository has been archived by the owner on Jun 26, 2018. It is now read-only.

Commit

Permalink
pledge_get_ul_list_by_type now has open_pledges_only argument
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Whiteland committed Mar 2, 2012
1 parent f766c31 commit 3843868
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
13 changes: 8 additions & 5 deletions phplib/pledge.php
Expand Up @@ -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";
Expand Down
6 changes: 4 additions & 2 deletions templates/barnet/index.php
Expand Up @@ -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>
Expand All @@ -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>

Expand All @@ -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>

Expand Down

0 comments on commit 3843868

Please sign in to comment.