We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 8e0508da authored by Zach Copley's avatar Zach Copley

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

parents cdab8d55 da532bae
avatar/*
files/*
_darcs/*
logs/*
config.php
.htaccess
httpd.conf
*.tmproj
dataobject.ini
*~
......@@ -10,3 +12,4 @@ dataobject.ini
*.orig
*.rej
.#*
*.swp
......@@ -83,7 +83,7 @@ class FinishopenidloginAction extends Action
function showContent()
{
if ($this->message_text) {
if (!empty($this->message_text)) {
$this->element('p', null, $this->message);
return;
}
......@@ -232,7 +232,8 @@ class FinishopenidloginAction extends Action
return;
}
if ($sreg['country']) {
$location = '';
if (!empty($sreg['country'])) {
if ($sreg['postcode']) {
# XXX: use postcode to get city and region
# 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'];
} else {
$fullname = '';
}
if ($sreg['email'] && Validate::email($sreg['email'], true)) {
if (!empty($sreg['email']) && Validate::email($sreg['email'], true)) {
$email = $sreg['email'];
} else {
$email = '';
}
# XXX: add language
......@@ -328,7 +333,7 @@ class FinishopenidloginAction extends Action
# Try the passed-in nickname
if ($sreg['nickname']) {
if (!empty($sreg['nickname'])) {
$nickname = $this->nicknamize($sreg['nickname']);
if ($this->isNewNickname($nickname)) {
return $nickname;
......@@ -337,7 +342,7 @@ class FinishopenidloginAction extends Action
# Try the full name
if ($sreg['fullname']) {
if (!empty($sreg['fullname'])) {
$fullname = $this->nicknamize($sreg['fullname']);
if ($this->isNewNickname($fullname)) {
return $fullname;
......
......@@ -111,13 +111,13 @@ class groupRssAction extends Rss10Action
{
$group = $this->group;
if (is_null($group)) {
return null;
}
$notice = $group->getNotices(0, ($limit == 0) ? NOTICES_PER_PAGE : $limit);
while ($notice->fetch()) {
$notices[] = clone($notice);
}
......@@ -141,13 +141,4 @@ class groupRssAction extends Rss10Action
{
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);
}
}
......@@ -108,13 +108,15 @@ class LoginAction extends Action
$nickname = common_canonical_nickname($this->trimmed('nickname'));
$password = $this->arg('password');
if (!common_check_user($nickname, $password)) {
$user = common_check_user($nickname, $password);
if (!$user) {
$this->showForm(_('Incorrect username or password.'));
return;
}
// success!
if (!common_set_user($nickname)) {
if (!common_set_user($user)) {
$this->serverError(_('Error setting user.'));
return;
}
......
......@@ -135,7 +135,8 @@ class TagotherAction extends Action
'id' => 'form_tag_user',
'class' => 'form_settings',
'name' => 'tagother',
'action' => $this->selfUrl()));
'action' => common_local_url('tagother', array('id' => $this->profile->id))));
$this->elementStart('fieldset');
$this->element('legend', null, _('Tag user'));
$this->hidden('token', common_session_token());
......
......@@ -204,7 +204,7 @@ class TwitapistatusesAction extends TwitterapiAction
# FriendFeed's SUP protocol
# 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);
# XXX: since
......
......@@ -46,13 +46,13 @@ class UserrssAction extends Rss10Action
{
$user = $this->user;
if (is_null($user)) {
return null;
}
$notice = $user->getNotices(0, ($limit == 0) ? NOTICES_PER_PAGE : $limit);
while ($notice->fetch()) {
$notices[] = clone($notice);
}
......@@ -87,10 +87,10 @@ class UserrssAction extends Rss10Action
}
# override parent to add X-SUP-ID URL
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);
parent::initRss($limit);
}
......@@ -100,4 +100,3 @@ class UserrssAction extends Rss10Action
return true;
}
}
......@@ -183,16 +183,16 @@ class User extends Memcached_DataObject
$profile->nickname = $nickname;
$profile->profileurl = common_profile_url($nickname);
if ($fullname) {
if (!empty($fullname)) {
$profile->fullname = $fullname;
}
if ($homepage) {
if (!empty($homepage)) {
$profile->homepage = $homepage;
}
if ($bio) {
if (!empty($bio)) {
$profile->bio = $bio;
}
if ($location) {
if (!empty($location)) {
$profile->location = $location;
}
......@@ -200,7 +200,7 @@ class User extends Memcached_DataObject
$id = $profile->insert();
if (!$id) {
if (empty($id)) {
common_log_db_error($profile, 'INSERT', __FILE__);
return false;
}
......@@ -210,13 +210,13 @@ class User extends Memcached_DataObject
$user->id = $id;
$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);
}
# Users who respond to invite email have proven their ownership of that address
if ($code) {
if (!empty($code)) {
$invite = Invitation::staticGet($code);
if ($invite && $invite->address && $invite->address_type == 'email' && $invite->address == $email) {
$user->email = $invite->address;
......@@ -253,7 +253,7 @@ class User extends Memcached_DataObject
return false;
}
if ($email && !$user->email) {
if (!empty($email) && !$user->email) {
$confirm = new Confirm_address();
$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();
}
......
......@@ -27,12 +27,13 @@ $action = null;
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'];
} else if ($_SERVER['PATH_INFO']) {
} else if (array_key_exists('PATH_INFO', $_SERVER)) {
return $_SERVER['PATH_INFO'];
} else {
return $req['p'];
return null;
}
}
......@@ -115,8 +116,8 @@ function main()
// XXX: find somewhere for this little block to live
if ($config['db']['mirror'] && $action_obj->isReadOnly()) {
if (is_array($config['db']['mirror'])) {
if (common_config('db', 'mirror') && $action_obj->isReadOnly()) {
if (is_array(common_config('db', 'mirror'))) {
// "load balancing", ha ha
$k = array_rand($config['db']['mirror']);
......
......@@ -151,7 +151,7 @@ class GroupList extends Widget
# 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();
}
......
......@@ -96,7 +96,7 @@ class NoticeSection extends Section
$this->out->elementStart('p', 'entry-content');
$this->out->raw($notice->rendered);
$this->out->elementEnd('p');
if ($notice->value) {
if (!empty($notice->value)) {
$this->out->elementStart('p');
$this->out->text($notice->value);
$this->out->elementEnd('p');
......
......@@ -239,7 +239,7 @@ function omb_broadcast_profile($profile)
while ($sub->fetch()) {
$rp = Remote_profile::staticGet('id', $sub->subscriber);
if ($rp) {
if (!$updated[$rp->updateprofileurl]) {
if (!array_key_exists($rp->updateprofileurl, $updated)) {
if (omb_update_profile($profile, $rp, $sub)) {
$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__);
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__);
$subscription->delete();
return false;
......
......@@ -64,6 +64,9 @@ function oid_set_last($openid_url)
function oid_get_last()
{
if (empty($_COOKIE[OPENID_COOKIE_KEY])) {
return null;
}
$openid_url = $_COOKIE[OPENID_COOKIE_KEY];
if ($openid_url && strlen($openid_url) > 0) {
return $openid_url;
......
......@@ -31,8 +31,6 @@ if (!defined('LACONICA')) {
exit(1);
}
define('NOTICES_PER_SECTION', 5);
/**
* Base class for sections showing lists of notices
*
......
......@@ -34,8 +34,6 @@ if (!defined('LACONICA')) {
require_once INSTALLDIR.'/lib/widget.php';
define('PROFILES_PER_PAGE', 20);
/**
* Widget to show a list of profiles
*
......
......@@ -47,7 +47,7 @@ require_once 'Net/URL/Mapper.php';
class Router
{
static $m = null;
var $m = null;
static $inst = null;
static function get()
......@@ -98,12 +98,14 @@ class Router
$main = array('login', 'logout', 'register', 'subscribe',
'unsubscribe', 'confirmaddress', 'recoverpassword',
'invite', 'favor', 'disfavor', 'sup',
'tagother', 'block');
'block');
foreach ($main as $a) {
$m->connect('main/'.$a, array('action' => $a));
}
$m->connect('main/tagother/:id', array('action' => 'tagother'));
// these take a code
foreach (array('register', 'confirmaddress', 'recoverpassword') as $c) {
......@@ -370,7 +372,7 @@ class Router
return $match;
}
function build($action, $args=null, $fragment=null)
function build($action, $args=null, $params=null, $fragment=null)
{
$action_arg = array('action' => $action);
......@@ -380,6 +382,6 @@ class Router
$args = $action_arg;
}
return $this->m->generate($args, null, $fragment);
return $this->m->generate($args, $params, $fragment);
}
}
\ No newline at end of file
......@@ -79,10 +79,11 @@ class SearchAction extends Action
function showTop($arr=null)
{
$error = null;
if ($arr) {
$error = $arr[1];
}
if ($error) {
if (!empty($error)) {
$this->element('p', 'error', $error);
} else {
$instr = $this->getInstructions();
......
......@@ -705,10 +705,10 @@ function common_relative_profile($sender, $nickname, $dt=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();
$path = $r->build($action, $args, $fragment);
$path = $r->build($action, $args, $params, $fragment);
if ($path) {
}
if (common_config('site','fancy')) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment