php_lib . "/common/format_utils.inc"; require_once $dotorg->php_lib . "/base/common/organization.inc"; require_once $dotorg->php_lib . "/base/workgroup/common/wg_traversal_tree.inc"; require_once $dotorg->php_lib . "/base/workgroup/common/evote.inc"; require_once $dotorg->php_lib . "/base/workgroup/common/dbclasses/o_time_zone.inc"; require_once $dotorg->php_lib . "/base/workgroup/common/wg_search.inc"; require_once $dotorg->php_lib . "/base/workgroup/common/dbclasses/o_wg_public.inc"; ////////////////////////////////////////////////////////////////////// // Ensure user input is clean (base/common/helpers.inc and // validate registered globals (base/common/validate.inc) ////////////////////////////////////////////////////////////////////// $my_sort_type_values = array('ASC', 'DESC'); $my_sort_field_values = array('ballot.name', 'ballot.close_date', 'workgroup.name', 'person.plname', 'd1.submission_date'); $_CLEAN['GET'] = clean($_GET); if (isset($_CLEAN['GET']['sort_field'])) { $sort_field = validateEnum($_CLEAN['GET']['sort_field'], $my_sort_field_values); } if (isset($_CLEAN['GET']['sort_type'])) { $sort_type = validateEnum($_CLEAN['GET']['sort_type'], $my_sort_type_values); } if (isset($_CLEAN['GET']['wg_abbrev'])) { $wg_abbrev = validateAbbrev($_CLEAN['GET']['wg_abbrev']); } if (isset($_CLEAN['GET']['page'])) { $page = validateInteger($_CLEAN['GET']['page']); } if (isset($_CLEAN['GET']['closed_within'])) { $closed_within = validateInteger($_CLEAN['GET']['closed_within']); } ////////////////////////////////////////////////////////////////////// // Declare form variables ////////////////////////////////////////////////////////////////////// if (!isset($wg_abbrev)) $wg_abbrev = ''; if (!isset($ballot_name)) $ballot_name = ''; if (!isset($workgroup_id)) $workgroup_id = 0; if (!isset($page)) $page = ''; if (!isset($sort_type)) $sort_type = ''; if (!isset($sort_field)) $sort_field = ''; if (!isset($closed_within)) $closed_within = ''; ////////////////////////////////////////////////////////////////////// // END OF VARIABLES ////////////////////////////////////////////////////////////////////// // For headers and footers $wg_public = new oWGPublic(); $self_url = rawurlencode($PHP_SELF); // Create person object for authenticated user $person = new oPerson(); $person_id = $person->populateFromLogin(); // Populate the current workgroup $workgroup = new oWorkGroup(); $workgroup_tbl = new oWorkGroupTable(); // If a wg abbreviation has been passed in, find the workgroup if (isset($wg_abbrev) && $wg_abbrev != '') { $found_workgroup = $workgroup_tbl->retrieveObject("abbreviation='$wg_abbrev'", $workgroup); if ($found_workgroup) { $workgroup_id = $workgroup->getValue('id'); $header = $workgroup->getPublicHeader(); $footer = $workgroup->getPublicFooter(); $group_name = $workgroup->getValue('name'); } else { $header = $wg_public->getHeader(); $footer = $wg_public->getFooter(); $group_name = 'Groups'; } } else { $header = $wg_public->getHeader(); $footer = $wg_public->getFooter(); $group_name = 'Groups'; } $header = 'file://'. $_SERVER["DOCUMENT_ROOT"] .'/committees/standard_html_header_nobc'; $footer = 'file://'. $_SERVER["DOCUMENT_ROOT"] .'/committees/standard_html_footer'; // This section includes the standard header $page_title = "$group_name Ballots"; include_remote_header($header, $page_title, 'workgroup'); print "

$page_title

"; // State passed along in the urls $current_semi_state = "closed_within=$closed_within&wg_abbrev=$wg_abbrev"; $current_full_state = $current_semi_state . "&sort_field=$sort_field&sort_type=$sort_type"; // Get all ballots shared with the general public $ballots_title = "Ballots"; $workgroup_ids = 0; $display_shared = false; $shared_with_wg_ids = array(9999); // get ballots shared with public if ($workgroup_id) { $originating_wg_ids = array($workgroup_id); } else { $originating_wg_ids = 0; } $display_wg_name = true; $eligible_only = false; $where_clause = ''; $and = ''; if ($ballot_name) { $where_clause .= " name like \"%$ballot_name%\""; $and = 'AND'; } if ($closed_within && is_numeric($closed_within)) { $time_zone = new oTimeZone(); // there's probably an easier way to get a gmt timestamp, but this one works :) $gmt_timestamp = $time_zone->convertServerTimeToGMT(); $now = date('Y-m-d H:i:00', $gmt_timestamp); $where_clause .= " $and DATE_ADD(close_date, INTERVAL $closed_within DAY) >= '$now'"; } if (!$sort_field) { $sort_field = 'ballot.close_date'; } if (!$sort_type) { $sort_type = 'desc'; } // GET HEADER NAMES AND SORT BUTTONS if ($sort_type == 'DESC') { $new_sort_type = 'ASC'; $new_sort_text = "ascending"; $button_img = "\"sort"; } else { $new_sort_type = 'DESC'; $button_img = "\"sort"; $new_sort_text = "descending"; } if ($sort_field == 'ballot.name') { $name_link = "Ballot Name $button_img"; } else { $name_link = "Ballot Name"; } if ($sort_field == 'ballot.close_date') { $close_date_link = "Close Date $button_img"; } else { $close_date_link = "Close Date"; } if ($sort_field == 'workgroup.name') { $workgroup_link = "Group $button_img"; } else { $workgroup_link = "Group"; } $num_per_page = 20; $order_by = "$sort_field $sort_type"; $ballot_state = ''; // get all ballots, open or closed $show_future = false; $num_ballots = getBallots($workgroup_ids, $display_shared, $shared_with_wg_ids, $originating_wg_ids, $ballot_state, 0, $order_by, true, $where_clause, $person_id, $eligible_only, '', true ); // PAGINATION NUMBERS $pagination = ''; $space = ''; if ($num_ballots > $num_per_page) { $pagination .= 'List paginated. View page: '; $num_pages = ceil($num_ballots / $num_per_page); for ($i = 0; $i < $num_pages; ++$i) { if ($page == 'all' || $page != $i) { $pagination .= $space ."". ($i + 1) .' '; } else { $pagination .= $space . ($i + 1) .' '; } $space = ' '; } if ($page != 'all') { $pagination .= " All (large)"; } else { $pagination .= ' All'; } print "

$pagination

"; } $limit_clause = ""; if ($page != 'all') { $start = $num_per_page * $page; $limit_clause .= " LIMIT $start,$num_per_page"; } $ballots = getBallots($workgroup_ids, $display_shared, $shared_with_wg_ids, $originating_wg_ids, $ballot_state, 0, $order_by, true, $where_clause, 0, false, $limit_clause, false ); printBallotList($ballots, $person_id, false, false, true, false, $name_link, $close_date_link, $workgroup_link, "ballot.php"); // This section includes the standard footer include_remote_footer($footer, 'workgroup');