Committer: ailyin
LJINT-411 (Additional logout link)U trunk/cgi-bin/LJ/PartnerSite.pm A trunk/htdocs/gadgets/loginstatus.bml A trunk/templates/Identity/LoginStatus.tmpl
Modified: trunk/cgi-bin/LJ/PartnerSite.pm =================================================================== --- trunk/cgi-bin/LJ/PartnerSite.pm 2011-02-18 10:21:34 UTC (rev 10080) +++ trunk/cgi-bin/LJ/PartnerSite.pm 2011-02-18 10:28:39 UTC (rev 10081) @@ -888,6 +888,7 @@ 'page' => $load_comments_struct->{'out_page'}, 'journal' => $journal->username, 'auth_token' => $auth_token, + 'logged_in' => $remote ? 1 : 0, }; } Added: trunk/htdocs/gadgets/loginstatus.bml =================================================================== --- trunk/htdocs/gadgets/loginstatus.bml (rev 0) +++ trunk/htdocs/gadgets/loginstatus.bml 2011-02-18 10:28:39 UTC (rev 10081) @@ -0,0 +1,62 @@ +<?_code +{ + use strict; + use warnings; + + use LJ::PartnerSite; + + my $api_key = LJ::Request->get_param('rsk'); + my $domain = LJ::Request->get_param('domain'); + + ## convert remote-site key to lj.com's community + my $partner = LJ::PartnerSite->find_by_api_key($api_key); + return 'unknown key' + unless $partner; + + unless ( $partner->is_domain_trusted($domain) ) { + return 'this domain doesn\'t belong to this partner'; + } + + $partner->request_logcom_resources; + + my $journal = $partner->journal; + + my $js_check_domain = $partner->domain_check_js( + { + 'mode' => 'logcom', + 'partner_domain' => $domain, + } + ); + + my $remote = LJ::get_remote(); + + return '' unless $remote; + + LJ::need_res(qw( stc/partners/login.css )); + + my $remote_sessid = $remote->session->id; + + my $thispage = "$LJ::SITEROOT/gadgets/loginstatus.bml?" + . LJ::Request->args; + + my $logout_url = "$LJ::SITEROOT/gadgets/logout.bml?" . + 'returnto=' . LJ::eurl($thispage) . '&' . + 'sessid=' . $remote_sessid; + + my $template = LJ::HTML::Template->new( + { use_expr => 1 }, # force HTML::Template::Pro with Expr support + filename => "$ENV{'LJHOME'}/templates/Identity/LoginStatus.tmpl", + ); + + die "Can't open template: $!" + unless $template; + + $template->param( + 'js_check_domain' => $js_check_domain, + 'partner_remote_ljuser' => $partner->ljuser_html($remote), + 'logout_url' => $logout_url, + ); + + return $template->output; +} +_code?> \ No newline at end of file Added: trunk/templates/Identity/LoginStatus.tmpl =================================================================== --- trunk/templates/Identity/LoginStatus.tmpl (rev 0) +++ trunk/templates/Identity/LoginStatus.tmpl 2011-02-18 10:28:39 UTC (rev 10081) @@ -0,0 +1,15 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <title>index :: Дерево комментариев</title> + + <TMPL_VAR lj_res_includes> +</head> +<body> + <TMPL_VAR js_check_domain> + + <TMPL_VAR partner_remote_ljuser> + <span class="lj3-logout">(<a href="<TMPL_VAR logout_url>"><TMPL_VAR expr="ml('/logout.bml.logout.head')"></a>)</span> +</body> +</html>