Beispiel #1
0
        global $sql_names;
        global $sql_select, $sql_from, $sql_where;
        global $sql_fud_names, $sql_fud_select, $sql_fud_from, $sql_fud_where;
        global $sql_type_select, $sql_type_from, $sql_type_where;
        $sql_fetch = " from" . "  (select " . $sql_select . $sql_fud_select . $sql_type_select . "    from " . $sql_from . $sql_fud_from . $sql_type_from . "    where " . $sql_where . $sql_fud_where . $sql_type_where . "    order by i.referendum) as v" . " where " . $search;
        $sql = "select count(*) from (select distinct on (referendum) referendum " . $sql_fetch . " group by referendum) as r";
        $row = pg_fetch_row(pg_query($dbconn, $sql)) or die('Could query: ' . pg_last_error());
        $len = (int) $row[0];
        $sql = "select * " . $sql_fetch . " order by " . $order;
        " limit " . ($start + $pagelen);
        $rows = pg_query($dbconn, $sql) or die('Could query: ' . pg_last_error());
        pg_result_seek($rows, $start);
        $v = array();
        while ($row = pg_fetch_row($rows)) {
            $row = array_combine($sql_names, $row);
            $row['expanded'] = in_array($row['referendum'], $expanded_referendums);
            if (!isset($v[count($v) - 1]) || $v[count($v) - 1]['referendum'] != $row['referendum']) {
                $v[] = $row;
            } else {
                if (!isset($v[count($v) - 1]['subrows'])) {
                    $v[count($v) - 1]['subrows'] = array($v[count($v) - 1]);
                }
                $v[count($v) - 1]['subrows'][] = $row;
            }
        }
        return array('len' => $len, 'referendums' => $v);
    }
    $info = fetch_referendums(0, $referendum_page_start, $referendum_page_len, searchToSql($referendum_search), sortToSql($referendums_sort));
    $referendums_len = $info['len'];
    $referendums = $info['referendums'];
}
Beispiel #2
0
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
*/
if (in_array('usermanagement', $_SESSION['privs'])) {
    $sql_names = array('id', 'username', 'givenname', 'surname', 'vote_enabled', 'usermanagement_enabled');
    $sql_fetch = " from" . "  (select" . "     u.id," . "     u.username," . "     u.givenname," . "     u.surname," . "     exists (select * from user_enabled_now as e, user_enabled_type as t where e.user = u.id and e.type = t.id and t.name = 'vote') as vote_enabled," . "     exists (select * from user_enabled_now as e, user_enabled_type as t where e.user = u.id and e.type = t.id and t.name = 'usermanagement') as usermanagement_enabled" . "    from \"user\" as u" . "    order by u.id, u.username, u.givenname, u.surname) as u" . " where " . searchToSql($users_search);
    $sql = "select count(*)" . $sql_fetch;
    $row = pg_fetch_row(pg_query($dbconn, $sql)) or die('Could query: ' . pg_last_error());
    $users_len = (int) $row[0];
    $sql = "select * " . $sql_fetch . " order by " . sortToSql($users_sort);
    " limit " . ($users_page_start + $users_page_len);
    $rows = pg_query($dbconn, $sql) or die('Could query: ' . pg_last_error());
    pg_result_seek($rows, $users_page_start);
    $users = array();
    while ($row = pg_fetch_row($rows)) {
        $row = array_combine($sql_names, $row);
        $users[] = $row;
    }
}
Beispiel #3
0
your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
*/
if (in_array('view', $_SESSION['privs']) && $_GET['view'] == 'searchreferendumsglobal') {
    $sql_names = array('path', 'referendums');
    $user = 1;
    if (isset($_SESSION['user'])) {
        $user = $_SESSION['user'];
    }
    $sql_fetch = " from" . "  (select path, count(*) as referendums " . "    from referendum_info" . "    where \"user\" = '{$user}' and " . searchToSql($globalreferendum_search) . "    group by path) as v";
    $sql = "select count(*)" . $sql_fetch;
    $row = pg_fetch_row(pg_query($dbconn, $sql)) or die('Could query: ' . pg_last_error());
    $globalreferendums_len = (int) $row[0];
    $sql = "select * " . $sql_fetch . " order by " . sortToSql($globalreferendums_sort);
    " limit " . ($globalreferendum_page_start + $globalreferendum_page_len);
    $rows = pg_query($dbconn, $sql) or die('Could query: ' . pg_last_error());
    pg_result_seek($rows, $globalreferendum_page_start);
    $globalreferendums = array();
    while ($row = pg_fetch_row($rows)) {
        $globalreferendums[] = array_combine($sql_names, $row);
    }
}