/** * display form with filters and search field */ public function display_form() { ?> <form action="<?php echo BN; ?> " method="GET" class="filter"> <? // pass on all other parameters URI::hidden(['filter'=>null, 'search'=>null, 'page'=>null]); // filter if ($this->filters) { $this->display_select_filter(); } // search if ( $this->enable_search ) { ?> <input type="text" name="search" value="<?php echo $this->search; ?> " size="20"> <input type="submit" value="<?php echo _("search and filter"); ?> "> <? } else { ?> <input type="submit" value="<?php echo _("filter"); ?> "> <? } ?> <a href="<?php echo URI::strip(['filter', 'search']); ?> "><?php echo _("reset"); ?> </a> </form> <? }
/** * display Ngroup drop down menu */ public static function display_switch() { ?> <form method="GET" action="<? switch (BN) { // jump to proposals list if the same page doesn't show the equivalent content in other groups case "proposal.php": case "proposal_edit.php": case "draft.php": case "vote.php": case "vote_result.php": echo "proposals.php"; $hidden = false; break; default: echo BN; // pages with list and edit mode and content depending on the group case "periods.php": case "admin_areas.php": $hidden = array( 'ngroup' => null, // remove ngroup, because the new ngroup comes from the drop down menu 'id' => null // remove id to go back from edit to list mode ); } ?>"> <select name="ngroup" onchange="this.form.submit()" tabindex="2"> <? if (Login::$member) { $sql = "SELECT ngroup.*, member FROM ngroup LEFT JOIN member_ngroup ON member_ngroup.ngroup = ngroup.id AND member_ngroup.member = ".intval(Login::$member->id); } else { $sql = "SELECT * FROM ngroup"; } $sql .= " ORDER BY name"; $result = DB::query($sql); $ngroups = array(); while ( $ngroup = DB::fetch_object($result, "Ngroup") ) { $ngroups[] = $ngroup; } $ngroups = Ngroup::parent_sort_active($ngroups); // own ngroups if (Login::$member) { ?> <optgroup label="<?php echo _("own groups"); ?> "> <? foreach ($ngroups as $ngroup) { if (!$ngroup->member) continue; // save groups list of the logged in member Login::$ngroups[] = $ngroup->id; // use the first ngroup as default if ($_SESSION['ngroup']==0) $_SESSION['ngroup'] = $ngroup->id; ?> <option value="<?php echo $ngroup->id; ?> "<? if ($ngroup->id==$_SESSION['ngroup']) { ?> selected class="selected"<? } ?>>◆ <?php echo $ngroup->name; ?> </option> <? } ?> </optgroup> <? } // other ngroups ?> <optgroup label="<?php echo Login::$member ? _("other groups") : _("groups"); ?> "> <? foreach ($ngroups as $ngroup) { // save list of active groups Ngroup::$active_ngroups[] = $ngroup->id; if (Login::$member and $ngroup->member) continue; // use the first ngroup as default if ($_SESSION['ngroup']==0) $_SESSION['ngroup'] = $ngroup->id; ?> <option value="<?php echo $ngroup->id; ?> "<? if ($ngroup->id==$_SESSION['ngroup']) { ?> selected class="selected"<? } ?>>◇ <?php echo $ngroup->name; ?> </option> <? } ?> </optgroup> </select> <? // add the hidden fields after the drop down menu to have ngroup always in the first place of the GET parameters if ($hidden) URI::hidden($hidden); ?> </form> <? }