Merge branch 'master' of git@gitorious.org:statusnet/mainline into testing
This commit is contained in:
commit
1de7badd78
@ -41,6 +41,7 @@ class Foreign_user extends Memcached_DataObject
|
|||||||
|
|
||||||
function updateKeys(&$orig)
|
function updateKeys(&$orig)
|
||||||
{
|
{
|
||||||
|
$this->_connect();
|
||||||
$parts = array();
|
$parts = array();
|
||||||
foreach (array('id', 'service', 'uri', 'nickname') as $k) {
|
foreach (array('id', 'service', 'uri', 'nickname') as $k) {
|
||||||
if (strcmp($this->$k, $orig->$k) != 0) {
|
if (strcmp($this->$k, $orig->$k) != 0) {
|
||||||
|
@ -75,7 +75,11 @@ class User extends Memcached_DataObject
|
|||||||
|
|
||||||
function getProfile()
|
function getProfile()
|
||||||
{
|
{
|
||||||
return Profile::staticGet('id', $this->id);
|
$profile = Profile::staticGet('id', $this->id);
|
||||||
|
if (empty($profile)) {
|
||||||
|
throw new UserNoProfileException($this);
|
||||||
|
}
|
||||||
|
return $profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isSubscribed($other)
|
function isSubscribed($other)
|
||||||
@ -87,6 +91,7 @@ class User extends Memcached_DataObject
|
|||||||
|
|
||||||
function updateKeys(&$orig)
|
function updateKeys(&$orig)
|
||||||
{
|
{
|
||||||
|
$this->_connect();
|
||||||
$parts = array();
|
$parts = array();
|
||||||
foreach (array('nickname', 'email', 'jabber', 'incomingemail', 'sms', 'carrier', 'smsemail', 'language', 'timezone') as $k) {
|
foreach (array('nickname', 'email', 'jabber', 'incomingemail', 'sms', 'carrier', 'smsemail', 'language', 'timezone') as $k) {
|
||||||
if (strcmp($this->$k, $orig->$k) != 0) {
|
if (strcmp($this->$k, $orig->$k) != 0) {
|
||||||
@ -140,9 +145,6 @@ class User extends Memcached_DataObject
|
|||||||
function getCurrentNotice()
|
function getCurrentNotice()
|
||||||
{
|
{
|
||||||
$profile = $this->getProfile();
|
$profile = $this->getProfile();
|
||||||
if (!$profile) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return $profile->getCurrentNotice();
|
return $profile->getCurrentNotice();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -470,21 +472,13 @@ class User extends Memcached_DataObject
|
|||||||
|
|
||||||
function getTaggedNotices($tag, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) {
|
function getTaggedNotices($tag, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) {
|
||||||
$profile = $this->getProfile();
|
$profile = $this->getProfile();
|
||||||
if (!$profile) {
|
return $profile->getTaggedNotices($tag, $offset, $limit, $since_id, $before_id);
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return $profile->getTaggedNotices($tag, $offset, $limit, $since_id, $before_id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNotices($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
|
function getNotices($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
|
||||||
{
|
{
|
||||||
$profile = $this->getProfile();
|
$profile = $this->getProfile();
|
||||||
if (!$profile) {
|
return $profile->getNotices($offset, $limit, $since_id, $before_id);
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return $profile->getNotices($offset, $limit, $since_id, $before_id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function favoriteNotices($offset=0, $limit=NOTICES_PER_PAGE, $own=false)
|
function favoriteNotices($offset=0, $limit=NOTICES_PER_PAGE, $own=false)
|
||||||
@ -625,14 +619,12 @@ class User extends Memcached_DataObject
|
|||||||
function getSubscriptions($offset=0, $limit=null)
|
function getSubscriptions($offset=0, $limit=null)
|
||||||
{
|
{
|
||||||
$profile = $this->getProfile();
|
$profile = $this->getProfile();
|
||||||
assert(!empty($profile));
|
|
||||||
return $profile->getSubscriptions($offset, $limit);
|
return $profile->getSubscriptions($offset, $limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSubscribers($offset=0, $limit=null)
|
function getSubscribers($offset=0, $limit=null)
|
||||||
{
|
{
|
||||||
$profile = $this->getProfile();
|
$profile = $this->getProfile();
|
||||||
assert(!empty($profile));
|
|
||||||
return $profile->getSubscribers($offset, $limit);
|
return $profile->getSubscribers($offset, $limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -696,9 +688,7 @@ class User extends Memcached_DataObject
|
|||||||
function delete()
|
function delete()
|
||||||
{
|
{
|
||||||
$profile = $this->getProfile();
|
$profile = $this->getProfile();
|
||||||
if ($profile) {
|
$profile->delete();
|
||||||
$profile->delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
$related = array('Fave',
|
$related = array('Fave',
|
||||||
'Confirm_address',
|
'Confirm_address',
|
||||||
|
74
lib/usernoprofileexception.php
Normal file
74
lib/usernoprofileexception.php
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* StatusNet, the distributed open-source microblogging tool
|
||||||
|
*
|
||||||
|
* class for an exception when the user profile is missing
|
||||||
|
*
|
||||||
|
* PHP version 5
|
||||||
|
*
|
||||||
|
* LICENCE: 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/>.
|
||||||
|
*
|
||||||
|
* @category Exception
|
||||||
|
* @package StatusNet
|
||||||
|
* @author Evan Prodromou <evan@status.net>
|
||||||
|
* @copyright 2010 StatusNet, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||||
|
* @link http://status.net/
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('STATUSNET')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class for an exception when the user profile is missing
|
||||||
|
*
|
||||||
|
* @category Exception
|
||||||
|
* @package StatusNet
|
||||||
|
* @author Evan Prodromou <evan@status.net>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||||
|
* @link http://status.net/
|
||||||
|
*/
|
||||||
|
|
||||||
|
class UserNoProfileException extends ServerException
|
||||||
|
{
|
||||||
|
var $user = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* constructor
|
||||||
|
*
|
||||||
|
* @param User $user User that's missing a profile
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function __construct($user)
|
||||||
|
{
|
||||||
|
$this->user = $user;
|
||||||
|
|
||||||
|
$message = sprintf(_("User %s (%d) has no profile record."),
|
||||||
|
$user->nickname, $user->id);
|
||||||
|
|
||||||
|
parent::__construct($message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accessor for user
|
||||||
|
*
|
||||||
|
* @return User the user that triggered this exception
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function getUser()
|
||||||
|
{
|
||||||
|
return $this->user;
|
||||||
|
}
|
||||||
|
}
|
@ -56,7 +56,12 @@ try {
|
|||||||
$user = new User();
|
$user = new User();
|
||||||
if ($user->find()) {
|
if ($user->find()) {
|
||||||
while ($user->fetch()) {
|
while ($user->fetch()) {
|
||||||
updateOStatus($user);
|
try {
|
||||||
|
updateOStatus($user);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
common_log(LOG_NOTICE, "Couldn't convert OMB subscriptions ".
|
||||||
|
"for {$user->nickname} to OStatus: " . $e->getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -107,8 +112,8 @@ function updateOStatus($user)
|
|||||||
if (!have_option('q', 'quiet')) {
|
if (!have_option('q', 'quiet')) {
|
||||||
echo "Converting...";
|
echo "Converting...";
|
||||||
}
|
}
|
||||||
Subscription::cancel($up, $rp);
|
|
||||||
Subscription::start($up, $op->localProfile());
|
Subscription::start($up, $op->localProfile());
|
||||||
|
Subscription::cancel($up, $rp);
|
||||||
if (!have_option('q', 'quiet')) {
|
if (!have_option('q', 'quiet')) {
|
||||||
echo "done.\n";
|
echo "done.\n";
|
||||||
}
|
}
|
||||||
@ -118,8 +123,7 @@ function updateOStatus($user)
|
|||||||
if (!have_option('q', 'quiet')) {
|
if (!have_option('q', 'quiet')) {
|
||||||
echo "fail.\n";
|
echo "fail.\n";
|
||||||
}
|
}
|
||||||
continue;
|
common_log(LOG_NOTICE, "Couldn't convert OMB subscription (" . $up->nickname . ", " . $rp->nickname .
|
||||||
common_log(LOG_WARNING, "Couldn't convert OMB subscription (" . $up->nickname . ", " . $rp->nickname .
|
|
||||||
") to OStatus: " . $e->getMessage());
|
") to OStatus: " . $e->getMessage());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user