Merge branch '0.9.x' into location

This commit is contained in:
Evan Prodromou 2009-10-28 17:24:53 -04:00
commit b73d6d18ba
21 changed files with 677 additions and 510 deletions

2
.gitignore vendored
View File

@ -24,4 +24,4 @@ config-*.php
good-config.php good-config.php
lac08.log lac08.log
php.log php.log
.DS_Store

View File

@ -129,6 +129,9 @@ StartSubGroupNav: Showing the subscriptions group nav menu
EndSubGroupNav: At the end of the subscriptions group nav menu EndSubGroupNav: At the end of the subscriptions group nav menu
- $action: the current action - $action: the current action
StartInitializeRouter: Before the router instance has been initialized; good place to add routes
- $m: the Net_URL_Mapper that has just been set up
RouterInitialized: After the router instance has been initialized RouterInitialized: After the router instance has been initialized
- $m: the Net_URL_Mapper that has just been set up - $m: the Net_URL_Mapper that has just been set up

View File

@ -326,7 +326,7 @@ class EmailsettingsAction extends AccountSettingsAction
$this->showForm(_('Cannot normalize that email address')); $this->showForm(_('Cannot normalize that email address'));
return; return;
} }
if (!Validate::email($email, true)) { if (!Validate::email($email, common_config('email', 'check_domain'))) {
$this->showForm(_('Not a valid email address')); $this->showForm(_('Not a valid email address'));
return; return;
} else if ($user->email == $email) { } else if ($user->email == $email) {

View File

@ -68,7 +68,7 @@ class InviteAction extends CurrentUserDesignAction
foreach ($addresses as $email) { foreach ($addresses as $email) {
$email = trim($email); $email = trim($email);
if (!Validate::email($email, true)) { if (!Validate::email($email, common_config('email', 'check_domain'))) {
$this->showForm(sprintf(_('Invalid email address: %s'), $email)); $this->showForm(sprintf(_('Invalid email address: %s'), $email));
return; return;
} }

View File

@ -160,18 +160,12 @@ class NewnoticeAction extends Action
if (!$content) { if (!$content) {
$this->clientError(_('No content!')); $this->clientError(_('No content!'));
} else { return;
$content_shortened = common_shorten_links($content);
if (Notice::contentTooLong($content_shortened)) {
$this->clientError(sprintf(_('That\'s too long. '.
'Max notice size is %d chars.'),
Notice::maxContent()));
}
} }
$inter = new CommandInterpreter(); $inter = new CommandInterpreter();
$cmd = $inter->handle_command($user, $content_shortened); $cmd = $inter->handle_command($user, $content);
if ($cmd) { if ($cmd) {
if ($this->boolean('ajax')) { if ($this->boolean('ajax')) {
@ -182,6 +176,13 @@ class NewnoticeAction extends Action
return; return;
} }
$content_shortened = common_shorten_links($content);
if (Notice::contentTooLong($content_shortened)) {
$this->clientError(sprintf(_('That\'s too long. '.
'Max notice size is %d chars.'),
Notice::maxContent()));
}
$replyto = $this->trimmed('inreplyto'); $replyto = $this->trimmed('inreplyto');
#If an ID of 0 is wrongly passed here, it will cause a database error, #If an ID of 0 is wrongly passed here, it will cause a database error,
#so override it... #so override it...

View File

@ -191,7 +191,7 @@ class RegisterAction extends Action
if (!$this->boolean('license')) { if (!$this->boolean('license')) {
$this->showForm(_('You can\'t register if you don\'t '. $this->showForm(_('You can\'t register if you don\'t '.
'agree to the license.')); 'agree to the license.'));
} else if ($email && !Validate::email($email, true)) { } else if ($email && !Validate::email($email, common_config('email', 'check_domain'))) {
$this->showForm(_('Not a valid email address.')); $this->showForm(_('Not a valid email address.'));
} else if (!Validate::string($nickname, array('min_length' => 1, } else if (!Validate::string($nickname, array('min_length' => 1,
'max_length' => 64, 'max_length' => 64,

View File

@ -179,7 +179,7 @@ class Notice extends Memcached_DataObject
throw new ClientException(_('Problem saving notice. Too long.')); throw new ClientException(_('Problem saving notice. Too long.'));
} }
if (!$profile) { if (empty($profile)) {
throw new ClientException(_('Problem saving notice. Unknown user.')); throw new ClientException(_('Problem saving notice. Unknown user.'));
} }
@ -296,7 +296,6 @@ class Notice extends Memcached_DataObject
// XXX: do we need to change this for remote users? // XXX: do we need to change this for remote users?
$notice->saveReplies();
$notice->saveTags(); $notice->saveTags();
$notice->addToInboxes(); $notice->addToInboxes();
@ -334,11 +333,11 @@ class Notice extends Memcached_DataObject
static function checkDupes($profile_id, $content) { static function checkDupes($profile_id, $content) {
$profile = Profile::staticGet($profile_id); $profile = Profile::staticGet($profile_id);
if (!$profile) { if (empty($profile)) {
return false; return false;
} }
$notice = $profile->getNotices(0, NOTICE_CACHE_WINDOW); $notice = $profile->getNotices(0, NOTICE_CACHE_WINDOW);
if ($notice) { if (!empty($notice)) {
$last = 0; $last = 0;
while ($notice->fetch()) { while ($notice->fetch()) {
if (time() - strtotime($notice->created) >= common_config('site', 'dupelimit')) { if (time() - strtotime($notice->created) >= common_config('site', 'dupelimit')) {
@ -364,7 +363,7 @@ class Notice extends Memcached_DataObject
static function checkEditThrottle($profile_id) { static function checkEditThrottle($profile_id) {
$profile = Profile::staticGet($profile_id); $profile = Profile::staticGet($profile_id);
if (!$profile) { if (empty($profile)) {
return false; return false;
} }
# Get the Nth notice # Get the Nth notice
@ -685,7 +684,7 @@ class Notice extends Memcached_DataObject
$cache = common_memcache(); $cache = common_memcache();
if (!$cache) { if (empty($cache)) {
return Notice::getStreamDirect($qry, $offset, $limit, null, null, $order, null); return Notice::getStreamDirect($qry, $offset, $limit, null, null, $order, null);
} }
@ -746,7 +745,7 @@ class Notice extends Memcached_DataObject
# If there are no hits, just return the value # If there are no hits, just return the value
if (!$notice) { if (empty($notice)) {
return $notice; return $notice;
} }
@ -936,6 +935,18 @@ class Notice extends Memcached_DataObject
} }
} }
$recipients = $this->saveReplies();
foreach ($recipients as $recipient) {
if (!array_key_exists($recipient, $ni)) {
$recipientUser = User::staticGet('id', $recipient);
if (!empty($recipientUser)) {
$ni[$recipient] = NOTICE_INBOX_SOURCE_REPLY;
}
}
}
$cnt = 0; $cnt = 0;
$qryhdr = 'INSERT INTO notice_inbox (user_id, notice_id, source, created) VALUES '; $qryhdr = 'INSERT INTO notice_inbox (user_id, notice_id, source, created) VALUES ';
@ -1088,12 +1099,12 @@ class Notice extends Memcached_DataObject
for ($i=0; $i<count($names); $i++) { for ($i=0; $i<count($names); $i++) {
$nickname = $names[$i]; $nickname = $names[$i];
$recipient = common_relative_profile($sender, $nickname, $this->created); $recipient = common_relative_profile($sender, $nickname, $this->created);
if (!$recipient) { if (empty($recipient)) {
continue; continue;
} }
// Don't save replies from blocked profile to local user // Don't save replies from blocked profile to local user
$recipient_user = User::staticGet('id', $recipient->id); $recipient_user = User::staticGet('id', $recipient->id);
if ($recipient_user && $recipient_user->hasBlocked($sender)) { if (!empty($recipient_user) && $recipient_user->hasBlocked($sender)) {
continue; continue;
} }
$reply = new Reply(); $reply = new Reply();
@ -1104,7 +1115,7 @@ class Notice extends Memcached_DataObject
$last_error = &PEAR::getStaticProperty('DB_DataObject','lastError'); $last_error = &PEAR::getStaticProperty('DB_DataObject','lastError');
common_log(LOG_ERR, 'DB error inserting reply: ' . $last_error->message); common_log(LOG_ERR, 'DB error inserting reply: ' . $last_error->message);
common_server_error(sprintf(_('DB error inserting reply: %s'), $last_error->message)); common_server_error(sprintf(_('DB error inserting reply: %s'), $last_error->message));
return; return array();
} else { } else {
$replied[$recipient->id] = 1; $replied[$recipient->id] = 1;
} }
@ -1128,7 +1139,7 @@ class Notice extends Memcached_DataObject
$id = $reply->insert(); $id = $reply->insert();
if (!$id) { if (!$id) {
common_log_db_error($reply, 'INSERT', __FILE__); common_log_db_error($reply, 'INSERT', __FILE__);
return; return array();
} else { } else {
$replied[$recipient->id] = 1; $replied[$recipient->id] = 1;
} }
@ -1137,12 +1148,16 @@ class Notice extends Memcached_DataObject
} }
} }
foreach (array_keys($replied) as $recipient) { $recipientIds = array_keys($replied);
foreach ($recipientIds as $recipient) {
$user = User::staticGet('id', $recipient); $user = User::staticGet('id', $recipient);
if ($user) { if ($user) {
mail_notify_attn($user, $this); mail_notify_attn($user, $this);
} }
} }
return $recipientIds;
} }
function asAtomEntry($namespace=false, $source=false) function asAtomEntry($namespace=false, $source=false)

View File

@ -328,6 +328,7 @@ class User extends Memcached_DataObject
common_config('site', 'name'), common_config('site', 'name'),
$user->nickname), $user->nickname),
'system'); 'system');
common_broadcast_notice($notice);
} }
} }

View File

@ -104,6 +104,10 @@ $config['sphinx']['port'] = 3312;
// $config['site']['timezone'] = 'Pacific/Auckland'; // $config['site']['timezone'] = 'Pacific/Auckland';
// $config['site']['language'] = 'en_NZ'; // $config['site']['language'] = 'en_NZ';
// When validating user supplied email addresses, validate if the domain
// is running an SMTP server.
// $config['mail']['check_domain'] = true;
// Email info, used for all outbound email // Email info, used for all outbound email
// $config['mail']['notifyfrom'] = 'microblog@example.net'; // $config['mail']['notifyfrom'] = 'microblog@example.net';
// $config['mail']['domain'] = 'microblog.example.net'; // $config['mail']['domain'] = 'microblog.example.net';

View File

@ -73,7 +73,7 @@ class UntrackCommand extends UnimplementedCommand
} }
} }
class NudgeCommand extends UnimplementedCommand class NudgeCommand extends Command
{ {
var $other = null; var $other = null;
function __construct($user, $other) function __construct($user, $other)
@ -81,6 +81,26 @@ class NudgeCommand extends UnimplementedCommand
parent::__construct($user); parent::__construct($user);
$this->other = $other; $this->other = $other;
} }
function execute($channel)
{
$recipient = User::staticGet('nickname', $this->other);
if(! $recipient){
$channel->error($this->user, sprintf(_('Could not find a user with nickname %s'),
$this->other));
}else{
if ($recipient->id == $this->user->id) {
$channel->error($this->user, _('It does not make a lot of sense to nudge yourself!'));
}else{
if ($recipient->email && $recipient->emailnotifynudge) {
mail_notify_nudge($this->user, $recipient);
}
// XXX: notify by IM
// XXX: notify by SMS
$channel->output($this->user, sprintf(_('Nudge sent to %s'),
$recipient->nickname));
}
}
}
} }
class InviteCommand extends UnimplementedCommand class InviteCommand extends UnimplementedCommand
@ -124,18 +144,30 @@ class FavCommand extends Command
function execute($channel) function execute($channel)
{ {
if(substr($this->other,0,1)=='#'){
//favoriting a specific notice_id
$recipient = $notice = Notice::staticGet(substr($this->other,1));
common_relative_profile($this->user, common_canonical_nickname($this->other)); if (!$notice) {
$channel->error($this->user, _('Notice with that id does not exist'));
return;
}
$recipient = $notice->getProfile();
}else{
//favoriting a given user's last notice
if (!$recipient) { $recipient =
$channel->error($this->user, _('No such user.')); common_relative_profile($this->user, common_canonical_nickname($this->other));
return;
} if (!$recipient) {
$notice = $recipient->getCurrentNotice(); $channel->error($this->user, _('No such user.'));
if (!$notice) { return;
$channel->error($this->user, _('User has no last notice')); }
return; $notice = $recipient->getCurrentNotice();
if (!$notice) {
$channel->error($this->user, _('User has no last notice'));
return;
}
} }
$fave = Fave::addNew($this->user, $notice); $fave = Fave::addNew($this->user, $notice);
@ -347,6 +379,71 @@ class MessageCommand extends Command
} }
} }
class ReplyCommand extends Command
{
var $other = null;
var $text = null;
function __construct($user, $other, $text)
{
parent::__construct($user);
$this->other = $other;
$this->text = $text;
}
function execute($channel)
{
if(substr($this->other,0,1)=='#'){
//replying to a specific notice_id
$notice = Notice::staticGet(substr($this->other,1));
if (!$notice) {
$channel->error($this->user, _('Notice with that id does not exist'));
return;
}
$recipient = $notice->getProfile();
}else{
//replying to a given user's last notice
$recipient =
common_relative_profile($this->user, common_canonical_nickname($this->other));
if (!$recipient) {
$channel->error($this->user, _('No such user.'));
return;
}
$notice = $recipient->getCurrentNotice();
if (!$notice) {
$channel->error($this->user, _('User has no last notice'));
return;
}
}
$len = mb_strlen($this->text);
if ($len == 0) {
$channel->error($this->user, _('No content!'));
return;
}
$this->text = common_shorten_links($this->text);
if (Notice::contentTooLong($this->text)) {
$channel->error($this->user, sprintf(_('Notice too long - maximum is %d characters, you sent %d'),
Notice::maxContent(), mb_strlen($this->text)));
return;
}
$notice = Notice::saveNew($this->user->id, $this->text, $channel->source(), 1,
$notice->id);
if ($notice) {
$channel->output($this->user, sprintf(_('Reply to %s sent'), $recipient->nickname));
} else {
$channel->error($this->user, _('Error saving notice.'));
}
common_broadcast_notice($notice);
}
}
class GetCommand extends Command class GetCommand extends Command
{ {
@ -497,6 +594,9 @@ class HelpCommand extends Command
"get <nickname> - get last notice from user\n". "get <nickname> - get last notice from user\n".
"whois <nickname> - get profile info on user\n". "whois <nickname> - get profile info on user\n".
"fav <nickname> - add user's last notice as a 'fave'\n". "fav <nickname> - add user's last notice as a 'fave'\n".
"fav #<notice_id> - add notice with the given id as a 'fave'\n".
"reply #<notice_id> - reply to notice with a given id\n".
"reply <nickname> - reply to the last notice from user\n".
"join <group> - join group\n". "join <group> - join group\n".
"drop <group> - leave group\n". "drop <group> - leave group\n".
"stats - get your stats\n". "stats - get your stats\n".
@ -507,7 +607,7 @@ class HelpCommand extends Command
"last <nickname> - same as 'get'\n". "last <nickname> - same as 'get'\n".
"on <nickname> - not yet implemented.\n". "on <nickname> - not yet implemented.\n".
"off <nickname> - not yet implemented.\n". "off <nickname> - not yet implemented.\n".
"nudge <nickname> - not yet implemented.\n". "nudge <nickname> - remind a user to update.\n".
"invite <phone number> - not yet implemented.\n". "invite <phone number> - not yet implemented.\n".
"track <word> - not yet implemented.\n". "track <word> - not yet implemented.\n".
"untrack <word> - not yet implemented.\n". "untrack <word> - not yet implemented.\n".

View File

@ -134,6 +134,17 @@ class CommandInterpreter
} else { } else {
return new MessageCommand($user, $other, $extra); return new MessageCommand($user, $other, $extra);
} }
case 'r':
case 'reply':
if (!$arg) {
return null;
}
list($other, $extra) = $this->split_arg($arg);
if (!$extra) {
return null;
} else {
return new ReplyCommand($user, $other, $extra);
}
case 'whois': case 'whois':
if (!$arg) { if (!$arg) {
return null; return null;

View File

@ -84,7 +84,8 @@ $default =
'image' => 'http://i.creativecommons.org/l/by/3.0/80x15.png'), 'image' => 'http://i.creativecommons.org/l/by/3.0/80x15.png'),
'mail' => 'mail' =>
array('backend' => 'mail', array('backend' => 'mail',
'params' => null), 'params' => null,
'domain_check' => true),
'nickname' => 'nickname' =>
array('blacklist' => array(), array('blacklist' => array(),
'featured' => array()), 'featured' => array()),

View File

@ -176,6 +176,7 @@ function jabber_format_entry($profile, $notice)
$xs = new XMLStringer(); $xs = new XMLStringer();
$xs->elementStart('html', array('xmlns' => 'http://jabber.org/protocol/xhtml-im')); $xs->elementStart('html', array('xmlns' => 'http://jabber.org/protocol/xhtml-im'));
$xs->elementStart('body', array('xmlns' => 'http://www.w3.org/1999/xhtml')); $xs->elementStart('body', array('xmlns' => 'http://www.w3.org/1999/xhtml'));
$xs->element("img", array('src'=> $profile->avatarUrl(AVATAR_MINI_SIZE) , 'alt' => $profile->nickname));
$xs->element('a', array('href' => $profile->profileurl), $xs->element('a', array('href' => $profile->profileurl),
$profile->nickname); $profile->nickname);
$xs->text(": "); $xs->text(": ");
@ -184,6 +185,11 @@ function jabber_format_entry($profile, $notice)
} else { } else {
$xs->raw(common_render_content($notice->content, $notice)); $xs->raw(common_render_content($notice->content, $notice));
} }
$xs->raw(" ");
$xs->element('a', array(
'href'=>common_local_url('conversation',
array('id' => $notice->conversation)).'#notice-'.$notice->id
),sprintf(_('notice id: %s'),$notice->id));
$xs->elementEnd('body'); $xs->elementEnd('body');
$xs->elementEnd('html'); $xs->elementEnd('html');

File diff suppressed because it is too large Load Diff

View File

@ -83,8 +83,8 @@ class FacebookAction extends Action
function showStylesheets() function showStylesheets()
{ {
$this->cssLink('css/display.css', 'base'); $this->cssLink('css/display.css', 'base');
$this->cssLink('css/display.css',null,'screen, projection, tv'); $this->cssLink('css/display.css', null, 'screen, projection, tv');
$this->cssLink('css/facebookapp.css', 'base'); $this->cssLink('plugins/Facebook/facebookapp.css');
} }
function showScripts() function showScripts()

View File

@ -5,8 +5,8 @@ font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif;
#wrap { #wrap {
background-color:#F0F2F5; background-color:#F0F2F5;
padding-left:18px; padding-left:1.795%;
padding-right:18px; padding-right:1.795%;
width:auto; width:auto;
} }
@ -15,8 +15,16 @@ h1,h2,h3,h4,h5,h6 {
color:#000; color:#000;
} }
#header {
width:131%;
}
#content { #content {
width:95%; width:92.7%;
}
#aside_primary {
display:none;
} }
#site_nav_local_views a { #site_nav_local_views a {
@ -26,6 +34,16 @@ background-color:#D0DFE7;
background-color:#FAFBFC; background-color:#FAFBFC;
} }
#form_notice .form_note + label,
#form_notice #notice_data-attach {
display:none;
}
#form_notice #notice_action-submit {
height:47px !important;
}
span.facebook-button { span.facebook-button {
border: 2px solid #aaa; border: 2px solid #aaa;
padding: 3px; padding: 3px;

View File

@ -105,6 +105,7 @@ class FacebookinviteAction extends FacebookAction
$multi_params = array('showborder' => 'false'); $multi_params = array('showborder' => 'false');
$multi_params['actiontext'] = $actiontext; $multi_params['actiontext'] = $actiontext;
$multi_params['bypass'] = 'cancel'; $multi_params['bypass'] = 'cancel';
$multi_params['cols'] = 4;
// Get a list of users who are already using the app for exclusion // Get a list of users who are already using the app for exclusion
$exclude_ids = $this->facebook->api_client->friends_getAppUsers(); $exclude_ids = $this->facebook->api_client->friends_getAppUsers();

View File

@ -150,11 +150,15 @@ class OpenIDPlugin extends Plugin
* @return void * @return void
*/ */
function onEndHeadChildren($action) function onEndShowHeadElements($action)
{ {
// for client side of OpenID authentication if ($action->trimmed('action') == 'public') {
$action->element('meta', array('http-equiv' => 'X-XRDS-Location', // for client side of OpenID authentication
'content' => common_local_url('publicxrds'))); $action->element('meta', array('http-equiv' => 'X-XRDS-Location',
'content' => common_local_url('publicxrds')));
}
return true;
} }
/** /**

View File

@ -265,7 +265,7 @@ class FinishopenidloginAction extends Action
$fullname = ''; $fullname = '';
} }
if (!empty($sreg['email']) && Validate::email($sreg['email'], true)) { if (!empty($sreg['email']) && Validate::email($sreg['email'], common_config('email', 'check_domain'))) {
$email = $sreg['email']; $email = $sreg['email'];
} else { } else {
$email = ''; $email = '';

View File

@ -241,7 +241,7 @@ function oid_update_user(&$user, &$sreg)
$orig_user = clone($user); $orig_user = clone($user);
if ($sreg['email'] && Validate::email($sreg['email'], true)) { if ($sreg['email'] && Validate::email($sreg['email'], common_config('email', 'check_domain'))) {
$user->email = $sreg['email']; $user->email = $sreg['email'];
} }

View File

@ -18,7 +18,7 @@ font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
font-size:1em; font-size:1em;
} }
address { address {
margin-right:5.8%; margin-right:5.7%;
} }
input, textarea, select, option { input, textarea, select, option {