Merge branch 'master' into 0.9.x
* master: (67 commits)
Ticket 2038: fix bad bug tracker link
Fix regression in group posting: bug introduced in commit 1319002e15
. Need to use actual profile object rather than an id on a variable that doesn't exist when checking blocks :D
Log database errors when saving notice_inbox entries
Drop the username from the log id for now; seems to trigger an error loop in some circumstances
request id on logs... pid + random id per web request + username + method + url
Add OpenID ini info back into statusnet.ini as a stopgap until we can
Some changes to the OpenID DataObjects to make them emit the exact same
OpenID plugin should set 'user_openid.display' as unique key
Remove relationship: user_openid.user_id -> user.id. I don't think this
Have OpenID plugin DataObjects emit their own .ini info
Revert "Allow plugin DB_DataObject classes to not have to use the .ini file by overriding keys(), table(), and sequenceKey() for them"
Catch and report exceptions from notice_to_omb_notice() instead of letting the OMB queue handler die.
Fix regression in remote subscription; added hasRole() shadow method on Remote_profile.
Fix fatal error on OMB subscription for first-timers
Remove annoying log msg
Drop error message on setlocale() failure; this is harmless, since we actually have a working locale set up.
Catch uncaught exception
Fixed bug where reply-sync bit wasn't getting saved
Forgot to render the nav menu when on FB Connect login tab
Facebook plugin no longer takes over Login and Connect settings nav menus
...
Conflicts:
db/08to09_pg.sql
db/statusnet_pg.sql
locale/pt_BR/LC_MESSAGES/statusnet.mo
plugins/Mapstraction/MapstractionPlugin.php
This commit is contained in:
commit
9dc888894b
@ -89,12 +89,16 @@ class FinishremotesubscribeAction extends Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
$remote = Remote_profile::staticGet('uri', $service->getListenerURI());
|
$remote = Remote_profile::staticGet('uri', $service->getListenerURI());
|
||||||
|
if ($remote) {
|
||||||
|
// Note remote profile may not have been saved yet.
|
||||||
|
// @fixme not convinced this is correct at all!
|
||||||
|
|
||||||
$profile = Profile::staticGet($remote->id);
|
$profile = Profile::staticGet($remote->id);
|
||||||
|
|
||||||
if ($user->hasBlocked($profile)) {
|
if ($user->hasBlocked($profile)) {
|
||||||
$this->clientError(_('That user has blocked you from subscribing.'));
|
$this->clientError(_('That user has blocked you from subscribing.'));
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perform the handling itself via libomb. */
|
/* Perform the handling itself via libomb. */
|
||||||
@ -122,6 +126,7 @@ class FinishremotesubscribeAction extends Action
|
|||||||
|
|
||||||
/* The service URLs are not accessible from datastore, so setting them
|
/* The service URLs are not accessible from datastore, so setting them
|
||||||
after insertion of the profile. */
|
after insertion of the profile. */
|
||||||
|
$remote = Remote_profile::staticGet('uri', $service->getListenerURI());
|
||||||
$orig_remote = clone($remote);
|
$orig_remote = clone($remote);
|
||||||
|
|
||||||
$remote->postnoticeurl =
|
$remote->postnoticeurl =
|
||||||
|
@ -79,8 +79,6 @@ class LoginAction extends Action
|
|||||||
$this->clientError(_('Already logged in.'));
|
$this->clientError(_('Already logged in.'));
|
||||||
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
$this->checkLogin();
|
$this->checkLogin();
|
||||||
} else if (isset($args['user_id']) && isset($args['token'])){
|
|
||||||
$this->checkLogin($args['user_id'],$args['token']);
|
|
||||||
} else {
|
} else {
|
||||||
common_ensure_session();
|
common_ensure_session();
|
||||||
$this->showForm();
|
$this->showForm();
|
||||||
@ -97,7 +95,7 @@ class LoginAction extends Action
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function checkLogin($user_id=null, $token=null)
|
function checkLogin()
|
||||||
{
|
{
|
||||||
if(isset($token) && isset($user_id)){
|
if(isset($token) && isset($user_id)){
|
||||||
//Token based login (from the LoginCommand)
|
//Token based login (from the LoginCommand)
|
||||||
@ -139,6 +137,11 @@ class LoginAction extends Action
|
|||||||
$user = common_check_user($nickname, $password);
|
$user = common_check_user($nickname, $password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$nickname = common_canonical_nickname($this->trimmed('nickname'));
|
||||||
|
$password = $this->arg('password');
|
||||||
|
|
||||||
|
$user = common_check_user($nickname, $password);
|
||||||
|
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
$this->showForm(_('Incorrect username or password.'));
|
$this->showForm(_('Incorrect username or password.'));
|
||||||
return;
|
return;
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Table Definition for group_alias
|
|
||||||
*
|
|
||||||
* StatusNet - the distributed open-source microblogging tool
|
|
||||||
* Copyright (C) 2009, StatusNet, Inc.
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
|
|
||||||
|
|
||||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
|
||||||
|
|
||||||
class Login_token extends Memcached_DataObject
|
|
||||||
{
|
|
||||||
###START_AUTOCODE
|
|
||||||
/* the code below is auto generated do not remove the above tag */
|
|
||||||
|
|
||||||
public $__table = 'login_token'; // table name
|
|
||||||
public $user_id; // int(4) primary_key not_null
|
|
||||||
public $token; // char(32) not_null
|
|
||||||
public $created; // datetime() not_null
|
|
||||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
|
||||||
|
|
||||||
/* Static get */
|
|
||||||
function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Login_token',$k,$v); }
|
|
||||||
|
|
||||||
/* the code above is auto generated do not remove the tag below */
|
|
||||||
###END_AUTOCODE
|
|
||||||
}
|
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
[avatar]
|
[avatar]
|
||||||
profile_id = 129
|
profile_id = 129
|
||||||
original = 17
|
original = 17
|
||||||
|
@ -73,12 +73,3 @@ create table location_namespace (
|
|||||||
modified timestamp comment 'date this record was modified'
|
modified timestamp comment 'date this record was modified'
|
||||||
|
|
||||||
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
|
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
|
||||||
|
|
||||||
create table login_token (
|
|
||||||
user_id integer not null comment 'user owning this token' references user (id),
|
|
||||||
token char(32) not null comment 'token useable for logging in',
|
|
||||||
created datetime not null comment 'date this record was created',
|
|
||||||
modified timestamp comment 'date this record was modified',
|
|
||||||
|
|
||||||
constraint primary key (user_id)
|
|
||||||
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
|
|
||||||
|
@ -39,15 +39,6 @@ create table profile_role (
|
|||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
create table login_token (
|
|
||||||
user_id integer not null /* comment 'user owning this token'*/ references "user" (id),
|
|
||||||
token char(32) not null /* comment 'token useable for logging in'*/,
|
|
||||||
created timestamp not null DEFAULT CURRENT_TIMESTAMP /* comment 'date this record was created'*/,
|
|
||||||
modified timestamp /* comment 'date this record was modified'*/,
|
|
||||||
|
|
||||||
primary key (user_id)
|
|
||||||
);
|
|
||||||
|
|
||||||
DROP index fave_user_id_idx;
|
DROP index fave_user_id_idx;
|
||||||
CREATE index fave_user_id_idx on fave (user_id,modified);
|
CREATE index fave_user_id_idx on fave (user_id,modified);
|
||||||
|
|
||||||
|
@ -575,13 +575,3 @@ create table location_namespace (
|
|||||||
modified timestamp comment 'date this record was modified'
|
modified timestamp comment 'date this record was modified'
|
||||||
|
|
||||||
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
|
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
|
||||||
|
|
||||||
create table login_token (
|
|
||||||
user_id integer not null comment 'user owning this token' references user (id),
|
|
||||||
token char(32) not null comment 'token useable for logging in',
|
|
||||||
created datetime not null comment 'date this record was created',
|
|
||||||
modified timestamp comment 'date this record was modified',
|
|
||||||
|
|
||||||
constraint primary key (user_id)
|
|
||||||
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
|
|
||||||
|
|
||||||
|
@ -571,13 +571,3 @@ create table profile_role (
|
|||||||
primary key (profile_id, role)
|
primary key (profile_id, role)
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
create table login_token (
|
|
||||||
user_id integer not null /* comment 'user owning this token'*/ references "user" (id),
|
|
||||||
token char(32) not null /* comment 'token useable for logging in'*/,
|
|
||||||
created timestamp not null DEFAULT CURRENT_TIMESTAMP /* comment 'date this record was created'*/,
|
|
||||||
modified timestamp /* comment 'date this record was modified'*/,
|
|
||||||
|
|
||||||
primary key (user_id)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
@ -579,32 +579,6 @@ class OnCommand extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoginCommand extends Command
|
|
||||||
{
|
|
||||||
function execute($channel)
|
|
||||||
{
|
|
||||||
$login_token = Login_token::staticGet('user_id',$this->user->id);
|
|
||||||
if($login_token){
|
|
||||||
$login_token->delete();
|
|
||||||
}
|
|
||||||
$login_token = new Login_token();
|
|
||||||
$login_token->user_id = $this->user->id;
|
|
||||||
$login_token->token = common_good_rand(16);
|
|
||||||
$login_token->created = common_sql_now();
|
|
||||||
$result = $login_token->insert();
|
|
||||||
if (!$result) {
|
|
||||||
common_log_db_error($login_token, 'INSERT', __FILE__);
|
|
||||||
$channel->error($this->user, sprintf(_('Could not create login token for %s'),
|
|
||||||
$this->user->nickname));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$channel->output($this->user,
|
|
||||||
sprintf(_('This link is useable only once, and is good for only 2 minutes: %s'),
|
|
||||||
common_local_url('login',
|
|
||||||
array('user_id'=>$login_token->user_id, 'token'=>$login_token->token))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class SubscriptionsCommand extends Command
|
class SubscriptionsCommand extends Command
|
||||||
{
|
{
|
||||||
function execute($channel)
|
function execute($channel)
|
||||||
@ -692,7 +666,6 @@ class HelpCommand extends Command
|
|||||||
"reply #<notice_id> - reply to notice with a given id\n".
|
"reply #<notice_id> - reply to notice with a given id\n".
|
||||||
"reply <nickname> - reply to the last notice from user\n".
|
"reply <nickname> - reply to the last notice from user\n".
|
||||||
"join <group> - join group\n".
|
"join <group> - join group\n".
|
||||||
"login - Get a link to login to the web interface\n".
|
|
||||||
"drop <group> - leave group\n".
|
"drop <group> - leave group\n".
|
||||||
"stats - get your stats\n".
|
"stats - get your stats\n".
|
||||||
"stop - same as 'off'\n".
|
"stop - same as 'off'\n".
|
||||||
|
@ -41,12 +41,6 @@ class CommandInterpreter
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new HelpCommand($user);
|
return new HelpCommand($user);
|
||||||
case 'login':
|
|
||||||
if ($arg) {
|
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return new LoginCommand($user);
|
|
||||||
}
|
|
||||||
case 'subscribers':
|
case 'subscribers':
|
||||||
if ($arg) {
|
if ($arg) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -176,7 +176,6 @@ 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)));
|
|
||||||
$xs->element('a', array('href' => $profile->profileurl),
|
$xs->element('a', array('href' => $profile->profileurl),
|
||||||
$profile->nickname);
|
$profile->nickname);
|
||||||
$xs->text(": ");
|
$xs->text(": ");
|
||||||
|
@ -88,8 +88,6 @@ class Router
|
|||||||
|
|
||||||
$m->connect('doc/:title', array('action' => 'doc'));
|
$m->connect('doc/:title', array('action' => 'doc'));
|
||||||
|
|
||||||
$m->connect('main/login?user_id=:user_id&token=:token', array('action'=>'login'), array('user_id'=> '[0-9]+', 'token'=>'.+'));
|
|
||||||
|
|
||||||
// main stuff is repetitive
|
// main stuff is repetitive
|
||||||
|
|
||||||
$main = array('login', 'logout', 'register', 'subscribe',
|
$main = array('login', 'logout', 'register', 'subscribe',
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
jQuery(document).ready(function($){
|
jQuery(document).ready(function($){
|
||||||
$('notices_primary').infinitescroll({
|
$('notices_primary').infinitescroll({
|
||||||
debug: true,
|
debug: false,
|
||||||
infiniteScroll : false,
|
infiniteScroll : false,
|
||||||
nextSelector : 'body#public li.nav_next a,'+
|
nextSelector : 'body#public li.nav_next a,'+
|
||||||
'body#all li.nav_next a,'+
|
'body#all li.nav_next a,'+
|
||||||
|
@ -110,6 +110,11 @@ class MapstractionPlugin extends Plugin
|
|||||||
function onEndShowScripts($action)
|
function onEndShowScripts($action)
|
||||||
{
|
{
|
||||||
$actionName = $action->trimmed('action');
|
$actionName = $action->trimmed('action');
|
||||||
|
// These are the ones that have maps on 'em
|
||||||
|
if (!in_array($actionName,
|
||||||
|
array('showstream', 'all', 'allmap', 'usermap'))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
switch ($this->provider)
|
switch ($this->provider)
|
||||||
{
|
{
|
||||||
@ -146,6 +151,39 @@ class MapstractionPlugin extends Plugin
|
|||||||
$action->raw(sprintf('var _provider = "%s";', $this->provider));
|
$action->raw(sprintf('var _provider = "%s";', $this->provider));
|
||||||
$action->elementEnd('script');
|
$action->elementEnd('script');
|
||||||
|
|
||||||
|
switch ($actionName) {
|
||||||
|
case 'usermap':
|
||||||
|
case 'showstream':
|
||||||
|
$notice = empty($action->tag)
|
||||||
|
? $action->user->getNotices(($action->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1)
|
||||||
|
: $action->user->getTaggedNotices($action->tag, ($action->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1, 0, 0, null);
|
||||||
|
break;
|
||||||
|
case 'all':
|
||||||
|
case 'allmap':
|
||||||
|
$cur = common_current_user();
|
||||||
|
if (!empty($cur) && $cur->id == $action->user->id) {
|
||||||
|
$notice = $action->user->noticeInbox(($action->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
|
||||||
|
} else {
|
||||||
|
$notice = $action->user->noticesWithFriends(($action->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$jsonArray = array();
|
||||||
|
|
||||||
|
while ($notice->fetch()) {
|
||||||
|
if (!empty($notice->lat) && !empty($notice->lon)) {
|
||||||
|
$jsonNotice = $this->noticeAsJson($notice);
|
||||||
|
$jsonArray[] = $jsonNotice;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$action->elementStart('script', array('type' => 'text/javascript'));
|
||||||
|
$action->raw('/*<![CDATA[*/'); // XHTML compat for Safari
|
||||||
|
$action->raw('var _notices = ' . json_encode($jsonArray));
|
||||||
|
$action->raw('/*]]>*/'); // XHTML compat for Safari
|
||||||
|
$action->elementEnd('script');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,4 +214,34 @@ class MapstractionPlugin extends Plugin
|
|||||||
|
|
||||||
$action->elementEnd('div');
|
$action->elementEnd('div');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function noticeAsJson($notice)
|
||||||
|
{
|
||||||
|
// FIXME: this code should be abstracted to a neutral third
|
||||||
|
// party, like Notice::asJson(). I'm not sure of the ethics
|
||||||
|
// of refactoring from within a plugin, so I'm just abusing
|
||||||
|
// the ApiAction method. Don't do this unless you're me!
|
||||||
|
|
||||||
|
require_once(INSTALLDIR.'/lib/api.php');
|
||||||
|
|
||||||
|
$act = new ApiAction('/dev/null');
|
||||||
|
|
||||||
|
$arr = $act->twitterStatusArray($notice, true);
|
||||||
|
$arr['url'] = $notice->bestUrl();
|
||||||
|
$arr['html'] = $notice->rendered;
|
||||||
|
$arr['source'] = $arr['source'];
|
||||||
|
|
||||||
|
if (!empty($notice->reply_to)) {
|
||||||
|
$reply_to = Notice::staticGet('id', $notice->reply_to);
|
||||||
|
if (!empty($reply_to)) {
|
||||||
|
$arr['in_reply_to_status_url'] = $reply_to->bestUrl();
|
||||||
|
}
|
||||||
|
$reply_to = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$profile = $notice->getProfile();
|
||||||
|
$arr['user']['profile_url'] = $profile->profileurl;
|
||||||
|
|
||||||
|
return $arr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
// Update the local timeline from a Meteor server
|
// Update the local timeline from a Meteor server
|
||||||
// XXX: If @a is subscribed to @b, @a should get @b's notices in @a's Personal timeline.
|
|
||||||
// Do Replies timeline.
|
|
||||||
|
|
||||||
var MeteorUpdater = function()
|
var MeteorUpdater = function()
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
define('PAGE_TYPE_PREFS',
|
define('PAGE_TYPE_PREFS_MOBILEPROFILE',
|
||||||
'application/vnd.wap.xhtml+xml, application/xhtml+xml, text/html;q=0.9');
|
'application/vnd.wap.xhtml+xml, application/xhtml+xml, text/html;q=0.9');
|
||||||
|
|
||||||
require_once INSTALLDIR.'/plugins/Mobile/WAP20Plugin.php';
|
require_once INSTALLDIR.'/plugins/Mobile/WAP20Plugin.php';
|
||||||
@ -159,8 +159,7 @@ class MobileProfilePlugin extends WAP20Plugin
|
|||||||
common_config('site', 'server'))) {
|
common_config('site', 'server'))) {
|
||||||
|
|
||||||
// FIXME: Redirect to equivalent page on mobile site instead
|
// FIXME: Redirect to equivalent page on mobile site instead
|
||||||
header("Location: ".$this->_common_path(''));
|
common_redirect($this->_common_path(''), 302);
|
||||||
exit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +172,7 @@ class MobileProfilePlugin extends WAP20Plugin
|
|||||||
$_SERVER['HTTP_ACCEPT'] : null;
|
$_SERVER['HTTP_ACCEPT'] : null;
|
||||||
|
|
||||||
$cp = common_accept_to_prefs($httpaccept);
|
$cp = common_accept_to_prefs($httpaccept);
|
||||||
$sp = common_accept_to_prefs(PAGE_TYPE_PREFS);
|
$sp = common_accept_to_prefs(PAGE_TYPE_PREFS_MOBILEPROFILE);
|
||||||
|
|
||||||
$type = common_negotiate_type($cp, $sp);
|
$type = common_negotiate_type($cp, $sp);
|
||||||
|
|
||||||
|
@ -281,6 +281,8 @@ RealtimeUpdate = {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#showstream .entity_profile').css({'width':'69%'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ class UserFlagPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
|
|
||||||
if (!empty($user)) {
|
if (!empty($user) && ($user->id != $profile->id)) {
|
||||||
|
|
||||||
$action->elementStart('li', 'entity_flag');
|
$action->elementStart('li', 'entity_flag');
|
||||||
|
|
||||||
|
@ -72,6 +72,28 @@ class FlagprofileAction extends ProfileFormAction
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle request
|
||||||
|
*
|
||||||
|
* Overriding the base Action's handle() here to deal check
|
||||||
|
* for Ajax and return an HXR response if necessary
|
||||||
|
*
|
||||||
|
* @param array $args $_REQUEST args; handled in prepare()
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function handle($args)
|
||||||
|
{
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
|
$this->handlePost();
|
||||||
|
if (!$this->boolean('ajax')) {
|
||||||
|
$this->returnToArgs();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle POST
|
* Handle POST
|
||||||
*
|
*
|
||||||
@ -97,6 +119,10 @@ class FlagprofileAction extends ProfileFormAction
|
|||||||
}
|
}
|
||||||
|
|
||||||
$ufp->free();
|
$ufp->free();
|
||||||
|
|
||||||
|
if ($this->boolean('ajax')) {
|
||||||
|
$this->ajaxResults();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ajaxResults() {
|
function ajaxResults() {
|
||||||
|
@ -47,6 +47,18 @@ require_once INSTALLDIR.'/lib/form.php';
|
|||||||
|
|
||||||
class FlagProfileForm extends ProfileActionForm
|
class FlagProfileForm extends ProfileActionForm
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* class of the form
|
||||||
|
* Action this form provides
|
||||||
|
*
|
||||||
|
* @return string class of the form
|
||||||
|
*/
|
||||||
|
|
||||||
|
function formClass()
|
||||||
|
{
|
||||||
|
return 'form_entity_flag';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action this form provides
|
* Action this form provides
|
||||||
*
|
*
|
||||||
|
128
scripts/updateavatarurl.php
Normal file
128
scripts/updateavatarurl.php
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* StatusNet - a distributed open-source microblogging tool
|
||||||
|
* Copyright (C) 2008, 2009, StatusNet, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
|
||||||
|
|
||||||
|
$shortoptions = 'i:n:a';
|
||||||
|
$longoptions = array('id=', 'nickname=', 'all');
|
||||||
|
|
||||||
|
$helptext = <<<END_OF_UPDATEAVATARURL_HELP
|
||||||
|
updateavatarurl.php [options]
|
||||||
|
update the URLs of all avatars in the system
|
||||||
|
|
||||||
|
-i --id ID of user to update
|
||||||
|
-n --nickname nickname of the user to update
|
||||||
|
-a --all update all
|
||||||
|
|
||||||
|
END_OF_UPDATEAVATARURL_HELP;
|
||||||
|
|
||||||
|
require_once INSTALLDIR.'/scripts/commandline.inc';
|
||||||
|
|
||||||
|
try {
|
||||||
|
$user = null;
|
||||||
|
|
||||||
|
if (have_option('i', 'id')) {
|
||||||
|
$id = get_option_value('i', 'id');
|
||||||
|
$user = User::staticGet('id', $id);
|
||||||
|
if (empty($user)) {
|
||||||
|
throw new Exception("Can't find user with id '$id'.");
|
||||||
|
}
|
||||||
|
updateAvatars($user);
|
||||||
|
} else if (have_option('n', 'nickname')) {
|
||||||
|
$nickname = get_option_value('n', 'nickname');
|
||||||
|
$user = User::staticGet('nickname', $nickname);
|
||||||
|
if (empty($user)) {
|
||||||
|
throw new Exception("Can't find user with nickname '$nickname'");
|
||||||
|
}
|
||||||
|
updateAvatars($user);
|
||||||
|
} else if (have_option('a', 'all')) {
|
||||||
|
$user = new User();
|
||||||
|
if ($user->find()) {
|
||||||
|
while ($user->fetch()) {
|
||||||
|
updateAvatars($user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Exception("You have to provide an ID or nickname or 'all'.");
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
print $e->getMessage()."\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateAvatars($user)
|
||||||
|
{
|
||||||
|
$touched = false;
|
||||||
|
|
||||||
|
if (!have_option('q', 'quiet')) {
|
||||||
|
print "Updating avatars for user '".$user->nickname."' (".$user->id.")...";
|
||||||
|
}
|
||||||
|
|
||||||
|
$avatar = new Avatar();
|
||||||
|
|
||||||
|
$avatar->profile_id = $user->id;
|
||||||
|
|
||||||
|
if (!$avatar->find()) {
|
||||||
|
if (have_option('v', 'verbose')) {
|
||||||
|
print "(none found)...";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
while ($avatar->fetch()) {
|
||||||
|
if (have_option('v', 'verbose')) {
|
||||||
|
if ($avatar->original) {
|
||||||
|
print "original...";
|
||||||
|
} else {
|
||||||
|
print $avatar->width."...";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$orig = clone($avatar);
|
||||||
|
|
||||||
|
$avatar->url = Avatar::url($avatar->filename);
|
||||||
|
|
||||||
|
if ($avatar->url != $orig->url) {
|
||||||
|
$sql =
|
||||||
|
"UPDATE avatar SET url = '" . $avatar->url . "' ".
|
||||||
|
"WHERE profile_id = " . $avatar->profile_id . " ".
|
||||||
|
"AND width = " . $avatar->width . " " .
|
||||||
|
"AND height = " . $avatar->height . " ";
|
||||||
|
|
||||||
|
if ($avatar->original) {
|
||||||
|
$sql .= "AND original = 1 ";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$avatar->query($sql)) {
|
||||||
|
throw new Exception("Can't update avatar for user " . $user->nickname . ".");
|
||||||
|
} else {
|
||||||
|
$touched = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($touched) {
|
||||||
|
$profile = $user->getProfile();
|
||||||
|
common_broadcast_profile($profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (have_option('v', 'verbose')) {
|
||||||
|
print "DONE.\n";
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user