Exemplo n.º 1
0
function select_with_pagintation($fields, $table, $conditions, $order, $countfields, $link)
{
    global $page;
    $count = db_rows_count($table, $conditions, $countfields, $link);
    prepare_pagination($count);
    if ($count) {
        $p = $page['pagination'];
        $limit = $p['limit'];
        $page['pagination.items'] = select_multi_assoc(db_build_select($fields, $table, $conditions, $order) . " " . $limit, $link);
    } else {
        $page['pagination.items'] = false;
    }
}
Exemplo n.º 2
0
function setup_redirect_links($threadid, $token)
{
    global $page, $mibewroot, $settings, $mysqlprefix;
    loadsettings();
    $link = connect();
    $operatorscount = db_rows_count("{$mysqlprefix}chatoperator", array(), "", $link);
    $groupscount = 0;
    $groups = array();
    if ($settings['enablegroups'] == "1") {
        foreach (get_groups($link, true) as $group) {
            if ($group['inumofagents'] == 0) {
                continue;
            }
            $groups[] = $group;
        }
        $groupscount = count($groups);
    }
    prepare_pagination(max($operatorscount, $groupscount), 8);
    $p = $page['pagination'];
    $limit = $p['limit'];
    $operators = select_multi_assoc(db_build_select("operatorid, vclogin, vclocalename, vccommonname, istatus, (unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time", "{$mysqlprefix}chatoperator", array(), "order by vclogin " . $limit), $link);
    $groups = array_slice($groups, $p['start'], $p['end'] - $p['start']);
    mysql_close($link);
    $agent_list = "";
    $params = array('thread' => $threadid, 'token' => $token);
    foreach ($operators as $agent) {
        $params['nextAgent'] = $agent['operatorid'];
        $status = $agent['time'] < $settings['online_timeout'] ? $agent['istatus'] == 0 ? getlocal("char.redirect.operator.online_suff") : getlocal("char.redirect.operator.away_suff") : "";
        $agent_list .= "<li><a href=\"" . add_params($mibewroot . "/operator/redirect.php", $params) . "\" title=\"" . safe_htmlspecialchars(topage(get_operator_name($agent))) . "\">" . safe_htmlspecialchars(topage(get_operator_name($agent))) . "</a> {$status}</li>";
    }
    $page['redirectToAgent'] = $agent_list;
    $group_list = "";
    if ($settings['enablegroups'] == "1") {
        $params = array('thread' => $threadid, 'token' => $token);
        foreach ($groups as $group) {
            $params['nextGroup'] = $group['groupid'];
            $status = $group['ilastseen'] !== NULL && $group['ilastseen'] < $settings['online_timeout'] ? getlocal("char.redirect.operator.online_suff") : ($group['ilastseenaway'] !== NULL && $group['ilastseenaway'] < $settings['online_timeout'] ? getlocal("char.redirect.operator.away_suff") : "");
            $group_list .= "<li><a href=\"" . add_params($mibewroot . "/operator/redirect.php", $params) . "\" title=\"" . safe_htmlspecialchars(topage(get_group_name($group))) . "\">" . safe_htmlspecialchars(topage(get_group_name($group))) . "</a> {$status}</li>";
        }
    }
    $page['redirectToGroup'] = $group_list;
}