JOIN groupmembers g USING (uid)
JOIN channel_group_flags gf USING (gid)
JOIN channel_flags f USING (flag)
-WHERE u.hostmask ILIKE $1 AND channel = $2 AND f.name = ANY($3);
+WHERE uid = $1 AND channel = $2 AND f.name = ANY($3);
};
if ($c->check_user_roles(qw/irc_masterop/)){
$mode = substr $access[0], 0,1;
}else{
- ($mode) = $c->model->selectrow_array($mode,undef,$c->host,$c->channel,\@access);
+ ($mode) = $c->model->selectrow_array($mode,undef,$c->uid,$c->channel,\@access);
}
if ($mode){
$c->command(mode => $c->channel, "$mod$mode", $msg);
if ($channel && $c->check_user_roles('irc_masterinvite')){
push @channels,$channel;
}else{
- my @access = ('auto_invite');
- push @access, 'invite' if $channel;
+ my @access = ('i');
+ push @access, 'I' if $channel;
my $channels = $c->model->prepare(q{
SELECT DISTINCT channel FROM users u
JOIN groupmembers g USING (uid)
JOIN channel_group_flags gf USING (gid)
- JOIN channel_flags f USING (flag)
-WHERE u.hostmask ILIKE $1 AND COALESCE(channel = $2,TRUE)
- AND (f.name = ANY($3) )
+WHERE uid = $1 AND COALESCE(channel = $2,TRUE)
+ AND (flag = ANY($3) )
});
- $channels->execute($c->host,$channel,\@access);
+ $channels->execute($c->uid,$channel,\@access);
while (my ($channel) = $channels->fetchrow()){
push @channels,$channel;
}
my $password = generate_random_string 10;
my $update = $dbh->do(q{
UPDATE users SET password = MD5( ? )
-WHERE hostmask ILIKE ? AND password =''
- },undef,$password,$c->host);
+WHERE uid ? AND password =''
+ },undef,$password,$c->uid);
if ($update > 0){
$c->reply("Password set to: $password (you can change it on webbie)");
}else{
$dbh->begin_work;
my $rows = $dbh->do(q{
-UPDATE calls SET dc = (SELECT uid FROM users WHERE hostmask ILIKE $1)
+UPDATE calls SET dc = $1
,status = $3
WHERE call = $2
- },undef,$c->host,$id,$status);
+ },undef,$c->uid,$id,$status);
if ($rows == 1){
$c->reply("Setting status on call $id to $status");
$c->def_log($id , "Changed status: [B]$status [/B]");
{
my ($self,$c,$msg) = @_;
my $f;
- my $nick = $c->host;
+ my $nick = $c->uid;
if ($msg =~ /(\S+)/ && $c->check_user_roles(qw/irc_points_others/)){
$nick = $1;
$f = $c->model->prepare(q{
}else{
$f = $c->model->prepare(q{
SELECT username, attack_points, defense_points, scan_points, humor_points
-FROM users WHERE hostmask ILIKE ?
+FROM users WHERE uid = ?
});
}
$f->execute($nick);
}, undef, $1);
}else{
$user = $dbh->selectrow_hashref(q{
-SELECT uid,username FROM users WHERE hostmask ILIKE ?
- }, undef, $c->host);
+SELECT uid,username FROM users WHERE uid = ?
+ }, undef, $c->uid);
}
if ($user){
my $unread = $dbh->selectrow_hashref(q{SELECT * FROM unread_posts($1)},undef,$user->{uid});
my ($avalue,$ascore) = $c->model->selectrow_array(q{
SELECT value,score FROM current_planet_stats
-WHERE pid = (SELECT pid FROM users WHERE hostmask ILIKE ?)
- }, undef, $c->host);
+WHERE pid = (SELECT pid FROM users WHERE uid = ?)
+ }, undef, $c->uid);
my ($tvalue,$tscore,$tsize) = $c->model->selectrow_array(q{
SELECT value,score,size FROM current_planet_stats
WHERE x = ? AND y = ? and z = ?
my ($value,$score) = $c->model->selectrow_array(q{
SELECT value,score FROM planet_stats WHERE tick = $2 AND
- pid = (SELECT pid FROM users WHERE hostmask ILIKE $1)
- }, undef, $c->host,$tick);
+ pid = (SELECT pid FROM users WHERE uid = $1)
+ }, undef, $c->uid,$tick);
unless ($value){
$c->reply("You don't have a planet registered.");
return;
$n = $n-1;
if (exists $FILE[$n]){
my ($uid,$username) = $c->model->selectrow_array(q{
-SELECT uid,username FROM users where hostmask ILIKE ?
- },undef,$c->host);
+SELECT uid,username FROM users where uid = ?
+ },undef,$c->uid);
my $text = $FILE[$n];
push @OLDFILE,"Removed by $username ($uid): $text";
}
my $sms = $dbh->prepare(q{
INSERT INTO sms (uid,number,message)
-VALUES((SELECT uid FROM users WHERE hostmask ilike $1),$2,$3)
+VALUES($1,$2,$3)
RETURNING id
});
- $sms->execute($c->host,$number,$message);
+ $sms->execute($c->uid,$number,$message);
my ($id) = $sms->fetchrow_array;
$c->reply("Message added to queue, you can see the status with: .smsstatus $id");
}
}else{
my $req = $c->model->prepare(q{
SELECT * FROM scan_requests
-WHERE uid = (SELECT uid FROM users WHERE hostmask ILIKE $1)
+WHERE uid = $1
AND pid = $2 AND type = $3 AND NOT sent
});
- $req->execute($c->host,$planet,$type);
+ $req->execute($c->uid,$planet,$type);
my $id;
if(my $scan = $req->fetchrow_hashref){
}else{
$req = $c->model->prepare(q{
INSERT INTO scan_requests (uid,nick,pid,type)
-VALUES((SELECT uid FROM users WHERE hostmask ILIKE $1),$2,$3,$4) RETURNING (id)
+VALUES($1,$2,$3,$4) RETURNING (id)
});
- $req->execute($c->host,$c->nick,$planet,$type);
+ $req->execute($c->uid,$c->nick,$planet,$type);
$id = $req->fetchrow;
}
if ($id){
- $c->message(privmsg =>$c->disp->targets->{scans}
+ $c->message(privmsg => $c->disp->targets->{scan}
,"<b>$id</b> http://game.planetarion.com/waves.pl?id=$typeid&x=$x&y=$y&z=$z"
. " ($x:$y:$z $type) | <".$c->nick."> $msg"
);
INSERT INTO scans (scan_id,tick,groupscan,uid) VALUES (LOWER($1),tick(),$2,COALESCE($3,-1))
});
my $user = $dbh->selectrow_hashref(q{SELECT uid,username, scan_points, tick()
- FROM users WHERE hostmask ILIKE ? },undef,$c->host);
+ FROM users WHERE uid = ? },undef,$c->uid);
my $groupscans = 0;
my $scans = 0;
eval {
my $host = "$pnick.users.netgamers.org";
my ($username,$hostname,$p_nick) = $dbh->selectrow_array(q{
SELECT username, hostmask,pnick
-FROM users WHERE username ILIKE ? OR hostmask ILIKE ? OR pnick ILIKE ?
+FROM users WHERE username = $1 OR hostmask = $2 OR pnick = $3
},undef,$nick,$host,$pnick);
if (defined $username){
if($@){
if ($@ =~ /duplicate key value violates unique constraint/){
my ($username, $hostname) = $dbh->selectrow_array(q{
-SELECT username,hostmask FROM users WHERE hostmask ILIKE $1
+SELECT username,hostmask FROM users WHERE hostmask = $1
},undef,$host);
$c->reply("<c04>Problem</c>, <b>$username</b> already uses host <b>$hostname</b>.");
}else{
if($@){
if ($@ =~ /duplicate key value violates unique constraint/){
my ($username, $hostname, $pnick) = $dbh->selectrow_array(q{
-SELECT username,hostmask,pnick FROM users WHERE hostmask ILIKE $1 OR pnick ILIKE $2
+SELECT username,hostmask,pnick FROM users WHERE hostmask = $1 OR pnick = $2
},undef,$hostname, $pnick);
$c->reply("<c04>Problem</c>, <b>$username</b> already uses host <b>$hostname</b> and pnick <b>$pnick</b>.");
}else{
lazy_build => 1
);
+has uid => (
+ is => 'ro',
+ isa => 'Int',
+ lazy_build => 1
+);
+
has disp => (
is => 'ro',
isa => 'Object',
my ($c,$planet, $message) = @_;
my $log = $c->model->prepare_cached(q{
INSERT INTO forum_posts (ftid,uid,message) VALUES(
- (SELECT ftid FROM planets WHERE pid = $3)
- ,(SELECT uid FROM users WHERE hostmask ILIKE $1)
- ,$2)
+ (SELECT ftid FROM planets WHERE pid = $3),$1,$2)
});
- $log->execute($c->host,$message,$planet);
+ $log->execute($c->uid,$message,$planet);
}
sub def_log {
my ($c,$call, $message) = @_;
my $log = $c->model->prepare(q{
INSERT INTO forum_posts (ftid,uid,message) VALUES(
- (SELECT ftid FROM calls WHERE call = $3)
- ,(SELECT uid FROM users WHERE hostmask ILIKE $1),$2)
+ (SELECT ftid FROM calls WHERE call = $3),$1,$2)
});
- $log->execute($c->host,$message,$call);
+ $log->execute($c->uid,$message,$call);
}
sub _build_roles {
my $query = $self->model->prepare(q{
SELECT role FROM group_roles
WHERE gid IN (SELECT gid FROM groupmembers JOIN users USING (uid)
- WHERE hostmask ILIKE $1)
+ WHERE hostmask = $1)
});
$query->execute($self->host);
return Set::Object->new(@roles);
}
+sub _build_uid {
+ my ($self) = @_;
+
+ my $query = $self->model->prepare(q{
+SELECT uid FROM users
+WHERE hostmask = $1
+ });
+ $query->execute($self->host);
+
+ if (my ($uid) = $query->fetchrow_array){
+ $query->finish;
+ return $uid;
+ }
+ return -4;
+}
1;