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

This commit is contained in:
Zach Copley 2009-02-22 17:03:41 -08:00
commit 8e0508dad3
18 changed files with 63 additions and 57 deletions

3
.gitignore vendored
View File

@ -1,8 +1,10 @@
avatar/* avatar/*
files/* files/*
_darcs/* _darcs/*
logs/*
config.php config.php
.htaccess .htaccess
httpd.conf
*.tmproj *.tmproj
dataobject.ini dataobject.ini
*~ *~
@ -10,3 +12,4 @@ dataobject.ini
*.orig *.orig
*.rej *.rej
.#* .#*
*.swp

View File

@ -83,7 +83,7 @@ class FinishopenidloginAction extends Action
function showContent() function showContent()
{ {
if ($this->message_text) { if (!empty($this->message_text)) {
$this->element('p', null, $this->message); $this->element('p', null, $this->message);
return; return;
} }
@ -232,7 +232,8 @@ class FinishopenidloginAction extends Action
return; return;
} }
if ($sreg['country']) { $location = '';
if (!empty($sreg['country'])) {
if ($sreg['postcode']) { if ($sreg['postcode']) {
# XXX: use postcode to get city and region # XXX: use postcode to get city and region
# XXX: also, store postcode somewhere -- it's valuable! # XXX: also, store postcode somewhere -- it's valuable!
@ -242,12 +243,16 @@ class FinishopenidloginAction extends Action
} }
} }
if ($sreg['fullname'] && mb_strlen($sreg['fullname']) <= 255) { if (!empty($sreg['fullname']) && mb_strlen($sreg['fullname']) <= 255) {
$fullname = $sreg['fullname']; $fullname = $sreg['fullname'];
} else {
$fullname = '';
} }
if ($sreg['email'] && Validate::email($sreg['email'], true)) { if (!empty($sreg['email']) && Validate::email($sreg['email'], true)) {
$email = $sreg['email']; $email = $sreg['email'];
} else {
$email = '';
} }
# XXX: add language # XXX: add language
@ -328,7 +333,7 @@ class FinishopenidloginAction extends Action
# Try the passed-in nickname # Try the passed-in nickname
if ($sreg['nickname']) { if (!empty($sreg['nickname'])) {
$nickname = $this->nicknamize($sreg['nickname']); $nickname = $this->nicknamize($sreg['nickname']);
if ($this->isNewNickname($nickname)) { if ($this->isNewNickname($nickname)) {
return $nickname; return $nickname;
@ -337,7 +342,7 @@ class FinishopenidloginAction extends Action
# Try the full name # Try the full name
if ($sreg['fullname']) { if (!empty($sreg['fullname'])) {
$fullname = $this->nicknamize($sreg['fullname']); $fullname = $this->nicknamize($sreg['fullname']);
if ($this->isNewNickname($fullname)) { if ($this->isNewNickname($fullname)) {
return $fullname; return $fullname;

View File

@ -141,13 +141,4 @@ class groupRssAction extends Rss10Action
{ {
return $this->group->homepage_logo; return $this->group->homepage_logo;
} }
# override parent to add X-SUP-ID URL
function initRss($limit=0)
{
$url = common_local_url('sup', null, $this->group->id);
header('X-SUP-ID: '.$url);
parent::initRss($limit);
}
} }

View File

@ -108,13 +108,15 @@ class LoginAction extends Action
$nickname = common_canonical_nickname($this->trimmed('nickname')); $nickname = common_canonical_nickname($this->trimmed('nickname'));
$password = $this->arg('password'); $password = $this->arg('password');
if (!common_check_user($nickname, $password)) { $user = common_check_user($nickname, $password);
if (!$user) {
$this->showForm(_('Incorrect username or password.')); $this->showForm(_('Incorrect username or password.'));
return; return;
} }
// success! // success!
if (!common_set_user($nickname)) { if (!common_set_user($user)) {
$this->serverError(_('Error setting user.')); $this->serverError(_('Error setting user.'));
return; return;
} }

View File

@ -135,7 +135,8 @@ class TagotherAction extends Action
'id' => 'form_tag_user', 'id' => 'form_tag_user',
'class' => 'form_settings', 'class' => 'form_settings',
'name' => 'tagother', 'name' => 'tagother',
'action' => $this->selfUrl())); 'action' => common_local_url('tagother', array('id' => $this->profile->id))));
$this->elementStart('fieldset'); $this->elementStart('fieldset');
$this->element('legend', null, _('Tag user')); $this->element('legend', null, _('Tag user'));
$this->hidden('token', common_session_token()); $this->hidden('token', common_session_token());

View File

@ -204,7 +204,7 @@ class TwitapistatusesAction extends TwitterapiAction
# FriendFeed's SUP protocol # FriendFeed's SUP protocol
# Also added RSS and Atom feeds # Also added RSS and Atom feeds
$suplink = common_local_url('sup', null, $user->id); $suplink = common_local_url('sup', null, null, $user->id);
header('X-SUP-ID: '.$suplink); header('X-SUP-ID: '.$suplink);
# XXX: since # XXX: since

View File

@ -90,7 +90,7 @@ class UserrssAction extends Rss10Action
function initRss($limit=0) function initRss($limit=0)
{ {
$url = common_local_url('sup', null, $this->user->id); $url = common_local_url('sup', null, null, $this->user->id);
header('X-SUP-ID: '.$url); header('X-SUP-ID: '.$url);
parent::initRss($limit); parent::initRss($limit);
} }
@ -100,4 +100,3 @@ class UserrssAction extends Rss10Action
return true; return true;
} }
} }

View File

@ -183,16 +183,16 @@ class User extends Memcached_DataObject
$profile->nickname = $nickname; $profile->nickname = $nickname;
$profile->profileurl = common_profile_url($nickname); $profile->profileurl = common_profile_url($nickname);
if ($fullname) { if (!empty($fullname)) {
$profile->fullname = $fullname; $profile->fullname = $fullname;
} }
if ($homepage) { if (!empty($homepage)) {
$profile->homepage = $homepage; $profile->homepage = $homepage;
} }
if ($bio) { if (!empty($bio)) {
$profile->bio = $bio; $profile->bio = $bio;
} }
if ($location) { if (!empty($location)) {
$profile->location = $location; $profile->location = $location;
} }
@ -200,7 +200,7 @@ class User extends Memcached_DataObject
$id = $profile->insert(); $id = $profile->insert();
if (!$id) { if (empty($id)) {
common_log_db_error($profile, 'INSERT', __FILE__); common_log_db_error($profile, 'INSERT', __FILE__);
return false; return false;
} }
@ -210,13 +210,13 @@ class User extends Memcached_DataObject
$user->id = $id; $user->id = $id;
$user->nickname = $nickname; $user->nickname = $nickname;
if ($password) { # may not have a password for OpenID users if (!empty($password)) { # may not have a password for OpenID users
$user->password = common_munge_password($password, $id); $user->password = common_munge_password($password, $id);
} }
# Users who respond to invite email have proven their ownership of that address # Users who respond to invite email have proven their ownership of that address
if ($code) { if (!empty($code)) {
$invite = Invitation::staticGet($code); $invite = Invitation::staticGet($code);
if ($invite && $invite->address && $invite->address_type == 'email' && $invite->address == $email) { if ($invite && $invite->address && $invite->address_type == 'email' && $invite->address == $email) {
$user->email = $invite->address; $user->email = $invite->address;
@ -253,7 +253,7 @@ class User extends Memcached_DataObject
return false; return false;
} }
if ($email && !$user->email) { if (!empty($email) && !$user->email) {
$confirm = new Confirm_address(); $confirm = new Confirm_address();
$confirm->code = common_confirmation_code(128); $confirm->code = common_confirmation_code(128);
@ -268,7 +268,7 @@ class User extends Memcached_DataObject
} }
} }
if ($code && $user->email) { if (!empty($code) && $user->email) {
$user->emailChanged(); $user->emailChanged();
} }

View File

@ -27,12 +27,13 @@ $action = null;
function getPath($req) function getPath($req)
{ {
if (common_config('site', 'fancy')) { if ((common_config('site', 'fancy') || !array_key_exists('PATH_INFO', $_SERVER))
&& array_key_exists('p', $req)) {
return $req['p']; return $req['p'];
} else if ($_SERVER['PATH_INFO']) { } else if (array_key_exists('PATH_INFO', $_SERVER)) {
return $_SERVER['PATH_INFO']; return $_SERVER['PATH_INFO'];
} else { } else {
return $req['p']; return null;
} }
} }
@ -115,8 +116,8 @@ function main()
// XXX: find somewhere for this little block to live // XXX: find somewhere for this little block to live
if ($config['db']['mirror'] && $action_obj->isReadOnly()) { if (common_config('db', 'mirror') && $action_obj->isReadOnly()) {
if (is_array($config['db']['mirror'])) { if (is_array(common_config('db', 'mirror'))) {
// "load balancing", ha ha // "load balancing", ha ha
$k = array_rand($config['db']['mirror']); $k = array_rand($config['db']['mirror']);

View File

@ -151,7 +151,7 @@ class GroupList extends Widget
# If we're on a list with an owner (subscriptions or subscribers)... # If we're on a list with an owner (subscriptions or subscribers)...
if ($user && $user->id == $this->owner->id) { if (!empty($user) && !empty($this->owner) && $user->id == $this->owner->id) {
$this->showOwnerControls(); $this->showOwnerControls();
} }

View File

@ -96,7 +96,7 @@ class NoticeSection extends Section
$this->out->elementStart('p', 'entry-content'); $this->out->elementStart('p', 'entry-content');
$this->out->raw($notice->rendered); $this->out->raw($notice->rendered);
$this->out->elementEnd('p'); $this->out->elementEnd('p');
if ($notice->value) { if (!empty($notice->value)) {
$this->out->elementStart('p'); $this->out->elementStart('p');
$this->out->text($notice->value); $this->out->text($notice->value);
$this->out->elementEnd('p'); $this->out->elementEnd('p');

View File

@ -239,7 +239,7 @@ function omb_broadcast_profile($profile)
while ($sub->fetch()) { while ($sub->fetch()) {
$rp = Remote_profile::staticGet('id', $sub->subscriber); $rp = Remote_profile::staticGet('id', $sub->subscriber);
if ($rp) { if ($rp) {
if (!$updated[$rp->updateprofileurl]) { if (!array_key_exists($rp->updateprofileurl, $updated)) {
if (omb_update_profile($profile, $rp, $sub)) { if (omb_update_profile($profile, $rp, $sub)) {
$updated[$rp->updateprofileurl] = true; $updated[$rp->updateprofileurl] = true;
} }
@ -295,7 +295,9 @@ function omb_update_profile($profile, $remote_profile, $subscription)
common_debug('Got HTTP result "'.print_r($result,true).'"', __FILE__); common_debug('Got HTTP result "'.print_r($result,true).'"', __FILE__);
if ($result->status == 403) { # not authorized, don't send again if (empty($result) || $result) {
common_debug("Unable to contact " . $req->get_normalized_http_url());
} else if ($result->status == 403) { # not authorized, don't send again
common_debug('403 result, deleting subscription', __FILE__); common_debug('403 result, deleting subscription', __FILE__);
$subscription->delete(); $subscription->delete();
return false; return false;

View File

@ -64,6 +64,9 @@ function oid_set_last($openid_url)
function oid_get_last() function oid_get_last()
{ {
if (empty($_COOKIE[OPENID_COOKIE_KEY])) {
return null;
}
$openid_url = $_COOKIE[OPENID_COOKIE_KEY]; $openid_url = $_COOKIE[OPENID_COOKIE_KEY];
if ($openid_url && strlen($openid_url) > 0) { if ($openid_url && strlen($openid_url) > 0) {
return $openid_url; return $openid_url;

View File

@ -31,8 +31,6 @@ if (!defined('LACONICA')) {
exit(1); exit(1);
} }
define('NOTICES_PER_SECTION', 5);
/** /**
* Base class for sections showing lists of notices * Base class for sections showing lists of notices
* *

View File

@ -34,8 +34,6 @@ if (!defined('LACONICA')) {
require_once INSTALLDIR.'/lib/widget.php'; require_once INSTALLDIR.'/lib/widget.php';
define('PROFILES_PER_PAGE', 20);
/** /**
* Widget to show a list of profiles * Widget to show a list of profiles
* *

View File

@ -47,7 +47,7 @@ require_once 'Net/URL/Mapper.php';
class Router class Router
{ {
static $m = null; var $m = null;
static $inst = null; static $inst = null;
static function get() static function get()
@ -98,12 +98,14 @@ class Router
$main = array('login', 'logout', 'register', 'subscribe', $main = array('login', 'logout', 'register', 'subscribe',
'unsubscribe', 'confirmaddress', 'recoverpassword', 'unsubscribe', 'confirmaddress', 'recoverpassword',
'invite', 'favor', 'disfavor', 'sup', 'invite', 'favor', 'disfavor', 'sup',
'tagother', 'block'); 'block');
foreach ($main as $a) { foreach ($main as $a) {
$m->connect('main/'.$a, array('action' => $a)); $m->connect('main/'.$a, array('action' => $a));
} }
$m->connect('main/tagother/:id', array('action' => 'tagother'));
// these take a code // these take a code
foreach (array('register', 'confirmaddress', 'recoverpassword') as $c) { foreach (array('register', 'confirmaddress', 'recoverpassword') as $c) {
@ -370,7 +372,7 @@ class Router
return $match; return $match;
} }
function build($action, $args=null, $fragment=null) function build($action, $args=null, $params=null, $fragment=null)
{ {
$action_arg = array('action' => $action); $action_arg = array('action' => $action);
@ -380,6 +382,6 @@ class Router
$args = $action_arg; $args = $action_arg;
} }
return $this->m->generate($args, null, $fragment); return $this->m->generate($args, $params, $fragment);
} }
} }

View File

@ -79,10 +79,11 @@ class SearchAction extends Action
function showTop($arr=null) function showTop($arr=null)
{ {
$error = null;
if ($arr) { if ($arr) {
$error = $arr[1]; $error = $arr[1];
} }
if ($error) { if (!empty($error)) {
$this->element('p', 'error', $error); $this->element('p', 'error', $error);
} else { } else {
$instr = $this->getInstructions(); $instr = $this->getInstructions();

View File

@ -705,10 +705,10 @@ function common_relative_profile($sender, $nickname, $dt=null)
return null; return null;
} }
function common_local_url($action, $args=null, $fragment=null) function common_local_url($action, $args=null, $params=null, $fragment=null)
{ {
$r = Router::get(); $r = Router::get();
$path = $r->build($action, $args, $fragment); $path = $r->build($action, $args, $params, $fragment);
if ($path) { if ($path) {
} }
if (common_config('site','fancy')) { if (common_config('site','fancy')) {