Ejemplo n.º 1
0
function handle_get_user_list($type, $from, $data, $res)
{
    _update_users_claims($res, $from, false);
    _update_anons_to_pie($res, $from);
}
Ejemplo n.º 2
0
function handle_piece_mass_free($type, $from, $data, $res)
{
    global $connection;
    $from->need_level('admin');
    $indexes = $data['indexes'];
    $owners = array();
    $res->to_pie($from, info_msg("Mass slices update: free slices"));
    foreach ($indexes as $piece_index) {
        $piece_id = _find_piece_id($from, $piece_index);
        if (!pg_query($connection, 'UPDATE pieces SET owner = NULL WHERE id = ' . $piece_id)) {
            throw new Exception("Failed to free piece #" . $piece_index);
        }
        if (!pg_query($connection, 'DELETE FROM claims WHERE piece = ' . $piece_id)) {
            throw new Exception("Failed to remove claim for piece #" . $piece_index);
        }
        $res->to_pie($from, array('piece_owner', array("piece_index" => $piece_index, "owner" => "")));
        $res->to_pie($from, info_msg("%s has freed slice #%s", $from->nick(), $piece_index));
        _add_piece_info_log($res, $from, $piece_index, $piece_id, "Slice has been freed");
    }
    update_kml($from->pieid);
    _update_users_claims($res, $from, true);
    _update_pie_timestamp($from, $connection);
}