{userid}; $body = ""; LJ::set_active_crumb('addfriends'); unless ($remote) { $title = $ML{'.error1.title'}; $body = ""; return; } unless ($user && $userid) { $title = $ML{'Error'}; $body = $ML{'.error2.text'}; return; } if ($FORM{'mode'} eq "add") { unless (LJ::did_post()) { $title = $ML{'Error'}; $body = " p?>"; return; } unless ($remote->{'userid'} == $FORM{'remid'}) { $title = $ML{'Error'}; $body = ""; return; } my $gmask = 1; foreach my $bit (1..30) { next unless $FORM{"bit_$bit"}; $gmask |= (1 << $bit); } my $req = { "user" => $remote->{'user'}, "mode" => "editfriends", "ver" => $LJ::PROTOCOL_VER, }; if ($FORM{'action:delete'}) { $req->{"editfriend_delete_$user"} = 1; } else { $req->{"editfriend_add_1_user"} = $user; $req->{"editfriend_add_1_fg"} = $FORM{'editfriend_add_1_fg'}; $req->{"editfriend_add_1_bg"} = $FORM{'editfriend_add_1_bg'}; $req->{"editfriend_add_1_groupmask"} = $gmask; } my %res = (); LJ::do_request($req, \%res, { "noauth" => 1, "userid" => $remote->{'userid'} } ); if ($res{'success'} eq "OK") { if ($FORM{'action:delete'}) { $title = $ML{'.remove.title'}; $body = "$user, 'ljuser' => LJ::ljuser($u), 'url'=>"$LJ::SITEROOT/users/$remote->{'user'}/friends"}) . " p?>"; } else { $title = $ML{'.add.title'}; $body = " $user, 'ljuser' => LJ::ljuser($u), 'url' => "$LJ::SITEROOT/users/$remote->{'user'}/friends", }) . " p?>"; } } else { $title = $ML{'Error'}; $body = ""; } return; } # check to see if user is already a friend. # TAG:fr:bml_friends_add:check_is_friend my $dbr = LJ::get_db_reader(); $sth = $dbr->prepare("SELECT * FROM friends WHERE userid=$remote->{'userid'} AND friendid=$userid"); $sth->execute; my $fr = $sth->fetchrow_hashref; if ($fr) { $title .= $ML{'.error3.title'}; $body .= "$user}) . " p?>"; } else { # was this a syndicated add? if ($u->{journaltype} eq 'Y') { $title = $ML{'.confirm.syn.title'}; $body .= " $user }) . " h1?>"; } else { $title .= $ML{'.confirm.title'}; $body .= " $user }) . " h1?>"; } $body .= " $user }) . " p?>"; } $body .= "
"; $body .= LJ::html_hidden(mode => 'add', user => $user, remid => $remote->{userid}); if ($fr) { $body .= "
"; $body .= " -
"; } else { $body .= "
$user}) . "\">
"; } ## let them pick friend groups $body .= "
"; my $err; my $greq = LJ::Protocol::do_request("getfriendgroups", { 'username' => $remote->{'user'}, 'ver' => $LJ::PROTOCOL_VER, }, \$err, { 'noauth' => 1 }); if (@{$greq->{'friendgroups'}}) { foreach my $g (@{$greq->{'friendgroups'}}) { my $ck = ($fr && ($fr->{'groupmask'} & (1 << $g->{'id'}))) ? "checked='1'" : ""; # by default, newly added friends are in default view unless unchecked $ck = "checked='1'" if (! $fr && $g->{'name'} eq "Default View"); $body .= " "; $body .= LJ::ehtml($g->{'name'}) . "
\n"; } } else { $body .= "$ML{'.groups.nogroup'}"; } $body .= "
"; ## let them pick the colors $body .= "$user}) . " p?>"; $ret = ""; $ret .= "

\n"; my @color = (); LJ::load_codes({ "color" => \@color }); my $sel = $fr || { 'fgcolor' => hex '000000', 'bgcolor' => hex 'FFFFFF', }; $ret .= ""; $ret .= "\n"; $ret .= "\n"; $ret .= "\n"; $ret .= "
$ML{'.colors.fg'}$ML{'.colors.bg'}
\n"; ### color swatch my $col = 0; $ret .= "

"; foreach (@color) { if ($col==0) { $ret .= "\n"; } $col++; my $ecolor = LJ::ehtml($_->{'item'}); $ret .= "\n"; if ($col==23) { $ret .= "\n"; $col==0; } } if ($col) { $ret .= "\n"; $col==0; } $ret .= "
{'code'}>\"$ecolor\"
\n"; $ret .= "$ML{'.colors.hover'}"; $ret .= "

\n"; $body .= $ret; $body .= "
"; return; _code?> body=> page?> link: htdocs/login.bml, htdocs/create.bml, htdocs/friends/edit.bml, htdocs/users img: htdocs/img/dot.gif post: htdocs/friends/add.bml _c?>