Merge branch '0.8.x' of git://gitorious.org/laconica/dev into 0.8.x

This commit is contained in:
Sarven Capadisli 2009-05-21 22:50:27 -04:00
commit 1e04e68044
10 changed files with 230 additions and 122 deletions

View File

@ -180,25 +180,14 @@ class NoticeListItem extends Widget
$this->showStart(); $this->showStart();
$this->showNotice(); $this->showNotice();
$this->showNoticeAttachments(); $this->showNoticeAttachments();
$this->showNoticeOptions();
$this->showNoticeInfo(); $this->showNoticeInfo();
$this->showNoticeOptions();
$this->showEnd(); $this->showEnd();
} }
function showNotice() function showNotice()
{ {
if(0) $this->out->elementStart('div', 'entry-title');
$this->out->elementStart('entry-title');
else
if ('shownotice' === $this->out->args['action']) {
$width = '85%';
} else {
$width = '90%';
}
$this->out->elementStart('div', array('class' => 'entry-title', 'style' => "float: left; width: $width;"));
$this->showAuthor(); $this->showAuthor();
$this->showContent(); $this->showContent();
$this->out->elementEnd('div'); $this->out->elementEnd('div');
@ -248,17 +237,7 @@ else
function showNoticeInfo() function showNoticeInfo()
{ {
if(0)
$this->out->elementStart('div', 'entry-content'); $this->out->elementStart('div', 'entry-content');
else
if ('shownotice' === $this->out->args['action']) {
$width = '85%';
} else {
$width = '90%';
}
$this->out->elementStart('div', array('class' => 'entry-content', 'style' => "float: left; width: $width;"));
$this->showNoticeLink(); $this->showNoticeLink();
$this->showNoticeSource(); $this->showNoticeSource();
$this->showContext(); $this->showContext();
@ -269,10 +248,7 @@ else
{ {
$user = common_current_user(); $user = common_current_user();
if ($user) { if ($user) {
if(0)
$this->out->elementStart('div', 'notice-options'); $this->out->elementStart('div', 'notice-options');
else
$this->out->elementStart('div', array('class' => 'notice-options', 'style' => 'float: right; width: 16%;'));
$this->showFaveForm(); $this->showFaveForm();
$this->showReplyLink(); $this->showReplyLink();
$this->showDeleteLink(); $this->showDeleteLink();

View File

@ -71,8 +71,6 @@ class FBCLoginGroupNav extends Widget
function show() function show()
{ {
common_debug('FBCLoginGroupNav');
$this->action->elementStart('dl', array('id' => 'site_nav_local_views')); $this->action->elementStart('dl', array('id' => 'site_nav_local_views'));
$this->action->element('dt', null, _('Local views')); $this->action->element('dt', null, _('Local views'));
$this->action->elementStart('dd'); $this->action->elementStart('dd');

View File

@ -50,7 +50,8 @@ class FBConnectauthAction extends Action
} }
} catch (Exception $e) { } catch (Exception $e) {
common_debug("Problem getting fbuid."); common_log(LOG_WARNING, 'Problem getting Facebook uid: ' .
$e->getMessage());
} }
return true; return true;
@ -124,34 +125,60 @@ class FBConnectauthAction extends Action
} }
$this->elementStart('form', array('method' => 'post', $this->elementStart('form', array('method' => 'post',
'id' => 'account_connect', 'id' => 'form_settings_facebook_connect',
'class' => 'form_settings',
'action' => common_local_url('FBConnectAuth'))); 'action' => common_local_url('FBConnectAuth')));
$this->hidden('token', common_session_token()); $this->elementStart('fieldset', array('id' => 'settings_facebook_connect_options'));
$this->element('h2', null, $this->element('legend', null, _('Connection options'));
_('Create new account')); $this->elementStart('ul', 'form_data');
$this->element('p', null, $this->elementStart('li');
_('Create a new user with this nickname.'));
$this->input('newname', _('New nickname'),
($this->username) ? $this->username : '',
_('1-64 lowercase letters or numbers, no punctuation or spaces'));
$this->elementStart('p');
$this->element('input', array('type' => 'checkbox', $this->element('input', array('type' => 'checkbox',
'id' => 'license', 'id' => 'license',
'class' => 'checkbox',
'name' => 'license', 'name' => 'license',
'value' => 'true')); 'value' => 'true'));
$this->elementStart('label', array('class' => 'checkbox', 'for' => 'license'));
$this->text(_('My text and files are available under ')); $this->text(_('My text and files are available under '));
$this->element('a', array('href' => common_config('license', 'url')), $this->element('a', array('href' => common_config('license', 'url')),
common_config('license', 'title')); common_config('license', 'title'));
$this->text(_(' except this private data: password, email address, IM address, phone number.')); $this->text(_(' except this private data: password, email address, IM address, phone number.'));
$this->elementEnd('p'); $this->elementEnd('label');
$this->elementEnd('li');
$this->elementEnd('ul');
$this->elementStart('fieldset');
$this->hidden('token', common_session_token());
$this->element('legend', null,
_('Create new account'));
$this->element('p', null,
_('Create a new user with this nickname.'));
$this->elementStart('ul', 'form_data');
$this->elementStart('li');
$this->input('newname', _('New nickname'),
($this->username) ? $this->username : '',
_('1-64 lowercase letters or numbers, no punctuation or spaces'));
$this->elementEnd('li');
$this->elementEnd('ul');
$this->submit('create', _('Create')); $this->submit('create', _('Create'));
$this->element('h2', null, $this->elementEnd('fieldset');
$this->elementStart('fieldset');
$this->element('legend', null,
_('Connect existing account')); _('Connect existing account'));
$this->element('p', null, $this->element('p', null,
_('If you already have an account, login with your username and password to connect it to your Facebook.')); _('If you already have an account, login with your username and password to connect it to your Facebook.'));
$this->elementStart('ul', 'form_data');
$this->elementStart('li');
$this->input('nickname', _('Existing nickname')); $this->input('nickname', _('Existing nickname'));
$this->elementEnd('li');
$this->elementStart('li');
$this->password('password', _('Password')); $this->password('password', _('Password'));
$this->elementEnd('li');
$this->elementEnd('ul');
$this->submit('connect', _('Connect')); $this->submit('connect', _('Connect'));
$this->elementEnd('fieldset');
$this->elementEnd('fieldset');
$this->elementEnd('form'); $this->elementEnd('form');
} }
@ -283,7 +310,7 @@ class FBConnectauthAction extends Action
} else { } else {
common_debug("no flink found for fbuid: $this->fbuid"); common_debug("No flink found for fbuid: $this->fbuid");
$this->showForm(null, $this->bestNewNickname()); $this->showForm(null, $this->bestNewNickname());
} }
@ -306,8 +333,6 @@ class FBConnectauthAction extends Action
function flinkUser($user_id, $fbuid) function flinkUser($user_id, $fbuid)
{ {
common_debug("flinkUser()");
$flink = new Foreign_link(); $flink = new Foreign_link();
$flink->user_id = $user_id; $flink->user_id = $user_id;
$flink->foreign_id = $fbuid; $flink->foreign_id = $fbuid;
@ -370,7 +395,10 @@ class FBConnectauthAction extends Action
// XXX: Consider moving this to lib/facebookutil.php // XXX: Consider moving this to lib/facebookutil.php
function getFacebookFields($fb_uid, $fields) { function getFacebookFields($fb_uid, $fields) {
try { try {
$infos = getFacebook()->api_client->users_getInfo($fb_uid, $fields);
$facebook = getFacebook();
$infos = $facebook->api_client->users_getInfo($fb_uid, $fields);
if (empty($infos)) { if (empty($infos)) {
return null; return null;
@ -378,8 +406,9 @@ class FBConnectauthAction extends Action
return reset($infos); return reset($infos);
} catch (Exception $e) { } catch (Exception $e) {
error_log("Failure in the api when requesting " . join(",", $fields) common_log(LOG_WARNING, "Facebook client failure when requesting " .
." on uid " . $fb_uid . " : ". $e->getMessage()); join(",", $fields) . " on uid " . $fb_uid .
" : ". $e->getMessage());
return null; return null;
} }
} }

View File

@ -0,0 +1,37 @@
/** Styles for Facebook logo and Facebook user profile avatar.
*
* @package Laconica
* @author Sarven Capadisli <csarven@controlyourself.ca>
* @copyright 2009 Control Yourself, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://laconi.ca/
*/
#site_nav_global_primary #nav_fb {
position:relative;
margin-left:18px;
margin-right:-7px;
}
#nav_fb .fb_profile_pic_rendered img {
position:relative;
top:3px;
left:0;
display:inline;
border:1px solid #3B5998;
padding:1px;
}
#nav_fb img {
position:absolute;
top:-13px;
left:-11px;
display:inline;
}
#settings_facebook_connect_options legend {
display:none;
}
#form_settings_facebook_connect fieldset fieldset legend {
display:block;
}

View File

@ -40,7 +40,6 @@ require_once INSTALLDIR . '/plugins/FBConnect/FBConnectSettings.php';
require_once INSTALLDIR . '/plugins/FBConnect/FBCLoginGroupNav.php'; require_once INSTALLDIR . '/plugins/FBConnect/FBCLoginGroupNav.php';
require_once INSTALLDIR . '/plugins/FBConnect/FBCSettingsNav.php'; require_once INSTALLDIR . '/plugins/FBConnect/FBCSettingsNav.php';
/** /**
* Plugin to enable Facebook Connect * Plugin to enable Facebook Connect
* *
@ -53,7 +52,6 @@ require_once INSTALLDIR . '/plugins/FBConnect/FBCSettingsNav.php';
class FBConnectPlugin extends Plugin class FBConnectPlugin extends Plugin
{ {
function __construct() function __construct()
{ {
parent::__construct(); parent::__construct();
@ -84,7 +82,6 @@ class FBConnectPlugin extends Plugin
'media type you accept'), 406); 'media type you accept'), 406);
} }
header('Content-Type: '.$type); header('Content-Type: '.$type);
$action->extraHeaders(); $action->extraHeaders();
@ -95,18 +92,17 @@ class FBConnectPlugin extends Plugin
$language = $action->getLanguage(); $language = $action->getLanguage();
$action->elementStart('html', array('xmlns' => 'http://www.w3.org/1999/xhtml', $action->elementStart('html',
array('xmlns' => 'http://www.w3.org/1999/xhtml',
'xmlns:fb' => 'http://www.facebook.com/2008/fbml', 'xmlns:fb' => 'http://www.facebook.com/2008/fbml',
'xml:lang' => $language, 'xml:lang' => $language,
'lang' => $language)); 'lang' => $language));
return false; return false;
} }
function onEndShowLaconicaScripts($action) function onEndShowLaconicaScripts($action)
{ {
$action->element('script', $action->element('script',
array('type' => 'text/javascript', array('type' => 'text/javascript',
'src' => 'http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php'), 'src' => 'http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php'),
@ -134,38 +130,19 @@ class FBConnectPlugin extends Plugin
$action->raw($html); $action->raw($html);
} }
function onEndShowLaconicaStyles($action)
{
$action->element('link', array('rel' => 'stylesheet',
'type' => 'text/css',
'href' => common_path('plugins/FBConnect/FBConnectPlugin.css')));
}
function onStartPrimaryNav($action) function onStartPrimaryNav($action)
{ {
$user = common_current_user(); $user = common_current_user();
if ($user) { if ($user) {
$flink = Foreign_link::getByUserId($user->id, FACEBOOK_CONNECT_SERVICE);
if ($flink) {
$facebook = getFacebook();
if ($facebook->api_client->users_isAppUser($flink->foreign_id) ||
$facebook->api_client->added) {
// XXX: We need to replace this with a proper mini-icon and only after
// checing the FB Connect JavaScript lib method to see what the Connect
// status is. Checking Connect status looks to be impossible with the
// PHP client.
$action->elementStart('li');
$action->elementStart('fb:profile-pic', array('uid' => $flink->foreign_id,
'facebook-logo' => 'true',
'linked' => 'false',
'width' => 32,
'height' => 32));
$action->elementEnd('fb:profile-pic');
$action->elementEnd('li');
}
}
$action->menuItem(common_local_url('all', array('nickname' => $user->nickname)), $action->menuItem(common_local_url('all', array('nickname' => $user->nickname)),
_('Home'), _('Personal profile and friends timeline'), false, 'nav_home'); _('Home'), _('Personal profile and friends timeline'), false, 'nav_home');
$action->menuItem(common_local_url('profilesettings'), $action->menuItem(common_local_url('profilesettings'),
@ -183,8 +160,45 @@ class FBConnectPlugin extends Plugin
common_config('site', 'name')), common_config('site', 'name')),
false, 'nav_invitecontact'); false, 'nav_invitecontact');
$flink = Foreign_link::getByUserId($user->id, FACEBOOK_CONNECT_SERVICE);
$fbuid = 0;
if ($flink) {
try {
$facebook = getFacebook();
$fbuid = getFacebook()->get_loggedin_user();
} catch (Exception $e) {
common_log(LOG_WARNING,
'Problem getting Facebook client: ' .
$e->getMessage());
}
// Display Facebook Logged in indicator w/Facebook favicon
if ($fbuid > 0) {
$action->elementStart('li', array('id' => 'nav_fb'));
$action->elementStart('fb:profile-pic', array('uid' => $flink->foreign_id,
'linked' => 'false',
'width' => 16,
'height' => 16));
$action->elementEnd('fb:profile-pic');
$iconurl = common_path('/plugins/FBConnect/fbfavicon.ico');
$action->element('img', array('src' => $iconurl));
$action->elementEnd('li');
}
}
// Need to override the Logout link to make it do FB stuff // Need to override the Logout link to make it do FB stuff
if ($fbuid > 0) {
$logout_url = common_local_url('logout'); $logout_url = common_local_url('logout');
$title = _('Logout from the site'); $title = _('Logout from the site');
$text = _('Logout'); $text = _('Logout');
@ -195,6 +209,10 @@ class FBConnectPlugin extends Plugin
$action->raw($html); $action->raw($html);
} else {
$action->menuItem(common_local_url('logout'),
_('Logout'), _('Logout from the site'), false, 'nav_logout');
}
} }
else { else {
if (!common_config('site', 'closed')) { if (!common_config('site', 'closed')) {
@ -220,7 +238,7 @@ class FBConnectPlugin extends Plugin
$action_name = get_class($action); $action_name = get_class($action);
$login_actions = array('LoginAction', 'RegisterAction', $login_actions = array('LoginAction', 'RegisterAction',
'OpenidloginAction', 'FacebookStart'); 'OpenidloginAction', 'FBConnectLoginAction');
if (in_array($action_name, $login_actions)) { if (in_array($action_name, $login_actions)) {
$nav = new FBCLoginGroupNav($action); $nav = new FBCLoginGroupNav($action);
@ -240,6 +258,21 @@ class FBConnectPlugin extends Plugin
return true; return true;
} }
function onEndLogout($action)
{
try {
$facebook = getFacebook();
$fbuid = $facebook->get_loggedin_user();
if ($fbuid > 0) {
$facebook->logout(common_local_url('public'));
} }
} catch (Exception $e) {
common_log(LOG_WARNING, 'Could\'t logout of Facebook: ' .
$e->getMessage());
}
}
}

View File

@ -169,8 +169,18 @@ class FBConnectSettingsAction extends ConnectSettingsAction
return; return;
} }
try {
// XXX: not sure what exactly to do here
$facebook = getFacebook(); $facebook = getFacebook();
$facebook->logout(); $facebook->clear_cookie_state();
} catch (Exception $e) {
common_log(LOG_WARNING,
'Couldn\'t clear Facebook cookies: ' .
$e->getMessage());
}
$this->showForm(_('Facebook user disconnected.'), true); $this->showForm(_('Facebook user disconnected.'), true);

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -747,6 +747,13 @@ border-radius:4px;
-moz-border-radius:4px; -moz-border-radius:4px;
-webkit-border-radius:4px; -webkit-border-radius:4px;
} }
.notices .notices {
margin-top:7px;
margin-left:3%;
width:97%;
float:left;
}
/* NOTICES */ /* NOTICES */
#notices_primary { #notices_primary {

View File

@ -175,10 +175,6 @@ background-image:url(../../base/images/icons/twotone/green/shield.gif);
} }
/* NOTICES */ /* NOTICES */
.notices li.over {
background-color:#fcfcfc;
}
.notice-options .notice_reply a, .notice-options .notice_reply a,
.notice-options form input.submit { .notice-options form input.submit {
background-color:transparent; background-color:transparent;
@ -214,6 +210,19 @@ font-family:sans-serif;
.notices li.hover { .notices li.hover {
background-color:#fcfcfc; background-color:#fcfcfc;
} }
.notices .notices {
background-color:rgba(200, 200, 200, 0.025);
}
.notices .notices .notices {
background-color:rgba(200, 200, 200, 0.050);
}
.notices .notices .notices .notices {
background-color:rgba(200, 200, 200, 0.075);
}
.notices .notices .notices .notices .notices {
background-color:rgba(200, 200, 200, 0.100);
}
/*END: NOTICES */ /*END: NOTICES */
#new_group a { #new_group a {

View File

@ -175,10 +175,6 @@ background-image:url(../../base/images/icons/twotone/green/shield.gif);
} }
/* NOTICES */ /* NOTICES */
.notices li.over {
background-color:#fcfcfc;
}
.notice-options .notice_reply a, .notice-options .notice_reply a,
.notice-options form input.submit { .notice-options form input.submit {
background-color:transparent; background-color:transparent;
@ -214,6 +210,19 @@ font-family:sans-serif;
.notices li.hover { .notices li.hover {
background-color:#fcfcfc; background-color:#fcfcfc;
} }
.notices .notices {
background-color:rgba(200, 200, 200, 0.025);
}
.notices .notices .notices {
background-color:rgba(200, 200, 200, 0.050);
}
.notices .notices .notices .notices {
background-color:rgba(200, 200, 200, 0.075);
}
.notices .notices .notices .notices .notices {
background-color:rgba(200, 200, 200, 0.100);
}
/*END: NOTICES */ /*END: NOTICES */
#new_group a { #new_group a {