{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 .= "
"; 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?>