Merge branch 'testing' of gitorious.org:statusnet/mainline into testing
* 'testing' of gitorious.org:statusnet/mainline: Not sure how this ended up in wrong-cased dir... OStatus: fix remote groups to work with new user_groups/local_groups split. Conflicts: classes/User_group.php
This commit is contained in:
commit
bac959ad46
|
@ -62,30 +62,33 @@ class JoingroupAction extends Action
|
||||||
}
|
}
|
||||||
|
|
||||||
$nickname_arg = $this->trimmed('nickname');
|
$nickname_arg = $this->trimmed('nickname');
|
||||||
$nickname = common_canonical_nickname($nickname_arg);
|
$id = intval($this->arg('id'));
|
||||||
|
if ($id) {
|
||||||
|
$this->group = User_group::staticGet('id', $id);
|
||||||
|
} else if ($nickname_arg) {
|
||||||
|
$nickname = common_canonical_nickname($nickname_arg);
|
||||||
|
|
||||||
// Permanent redirect on non-canonical nickname
|
// Permanent redirect on non-canonical nickname
|
||||||
|
|
||||||
if ($nickname_arg != $nickname) {
|
if ($nickname_arg != $nickname) {
|
||||||
$args = array('nickname' => $nickname);
|
$args = array('nickname' => $nickname);
|
||||||
common_redirect(common_local_url('joingroup', $args), 301);
|
common_redirect(common_local_url('leavegroup', $args), 301);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$local = Local_group::staticGet('nickname', $nickname);
|
||||||
|
|
||||||
|
if (!$local) {
|
||||||
|
$this->clientError(_('No such group.'), 404);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->group = User_group::staticGet('id', $local->group_id);
|
||||||
|
} else {
|
||||||
|
$this->clientError(_('No nickname or ID.'), 404);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$nickname) {
|
|
||||||
$this->clientError(_('No nickname.'), 404);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$local = Local_group::staticGet('nickname', $nickname);
|
|
||||||
|
|
||||||
if (!$local) {
|
|
||||||
$this->clientError(_('No such group.'), 404);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->group = User_group::staticGet('id', $local->group_id);
|
|
||||||
|
|
||||||
if (!$this->group) {
|
if (!$this->group) {
|
||||||
$this->clientError(_('No such group.'), 404);
|
$this->clientError(_('No such group.'), 404);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -62,30 +62,33 @@ class LeavegroupAction extends Action
|
||||||
}
|
}
|
||||||
|
|
||||||
$nickname_arg = $this->trimmed('nickname');
|
$nickname_arg = $this->trimmed('nickname');
|
||||||
$nickname = common_canonical_nickname($nickname_arg);
|
$id = intval($this->arg('id'));
|
||||||
|
if ($id) {
|
||||||
|
$this->group = User_group::staticGet('id', $id);
|
||||||
|
} else if ($nickname_arg) {
|
||||||
|
$nickname = common_canonical_nickname($nickname_arg);
|
||||||
|
|
||||||
// Permanent redirect on non-canonical nickname
|
// Permanent redirect on non-canonical nickname
|
||||||
|
|
||||||
if ($nickname_arg != $nickname) {
|
if ($nickname_arg != $nickname) {
|
||||||
$args = array('nickname' => $nickname);
|
$args = array('nickname' => $nickname);
|
||||||
common_redirect(common_local_url('leavegroup', $args), 301);
|
common_redirect(common_local_url('leavegroup', $args), 301);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$local = Local_group::staticGet('nickname', $nickname);
|
||||||
|
|
||||||
|
if (!$local) {
|
||||||
|
$this->clientError(_('No such group.'), 404);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->group = User_group::staticGet('id', $local->group_id);
|
||||||
|
} else {
|
||||||
|
$this->clientError(_('No nickname or ID.'), 404);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$nickname) {
|
|
||||||
$this->clientError(_('No nickname.'), 404);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$local = Local_group::staticGet('nickname', $nickname);
|
|
||||||
|
|
||||||
if (!$local) {
|
|
||||||
$this->clientError(_('No such group.'), 404);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->group = User_group::staticGet('id', $local->group_id);
|
|
||||||
|
|
||||||
if (!$this->group) {
|
if (!$this->group) {
|
||||||
$this->clientError(_('No such group.'), 404);
|
$this->clientError(_('No such group.'), 404);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -641,7 +641,10 @@ class ActivityObject
|
||||||
$object->id = $profile->getUri();
|
$object->id = $profile->getUri();
|
||||||
$object->title = $profile->getBestName();
|
$object->title = $profile->getBestName();
|
||||||
$object->link = $profile->profileurl;
|
$object->link = $profile->profileurl;
|
||||||
$object->avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
||||||
|
if ($avatar) {
|
||||||
|
$object->avatar = $avatar->displayUrl();
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($profile->lat) && isset($profile->lon)) {
|
if (isset($profile->lat) && isset($profile->lon)) {
|
||||||
$object->geopoint = (float)$profile->lat . ' ' . (float)$profile->lon;
|
$object->geopoint = (float)$profile->lat . ' ' . (float)$profile->lon;
|
||||||
|
@ -709,7 +712,7 @@ class ActivityObject
|
||||||
'rel' => 'avatar',
|
'rel' => 'avatar',
|
||||||
'href' => empty($this->avatar)
|
'href' => empty($this->avatar)
|
||||||
? Avatar::defaultImage(AVATAR_PROFILE_SIZE)
|
? Avatar::defaultImage(AVATAR_PROFILE_SIZE)
|
||||||
: $this->avatar->displayUrl()
|
: $this->avatar
|
||||||
),
|
),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
|
|
@ -100,7 +100,7 @@ class JoinForm extends Form
|
||||||
function action()
|
function action()
|
||||||
{
|
{
|
||||||
return common_local_url('joingroup',
|
return common_local_url('joingroup',
|
||||||
array('nickname' => $this->group->nickname));
|
array('id' => $this->group->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -100,7 +100,7 @@ class LeaveForm extends Form
|
||||||
function action()
|
function action()
|
||||||
{
|
{
|
||||||
return common_local_url('leavegroup',
|
return common_local_url('leavegroup',
|
||||||
array('nickname' => $this->group->nickname));
|
array('id' => $this->group->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -247,6 +247,9 @@ class Router
|
||||||
$m->connect('group/:nickname/'.$v,
|
$m->connect('group/:nickname/'.$v,
|
||||||
array('action' => $v.'group'),
|
array('action' => $v.'group'),
|
||||||
array('nickname' => '[a-zA-Z0-9]+'));
|
array('nickname' => '[a-zA-Z0-9]+'));
|
||||||
|
$m->connect('group/:id/id/'.$v,
|
||||||
|
array('action' => $v.'group'),
|
||||||
|
array('id' => '[0-9]+'));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (array('members', 'logo', 'rss', 'designsettings') as $n) {
|
foreach (array('members', 'logo', 'rss', 'designsettings') as $n) {
|
||||||
|
|
|
@ -333,10 +333,18 @@ class OStatusSubAction extends Action
|
||||||
$group = $this->oprofile->localGroup();
|
$group = $this->oprofile->localGroup();
|
||||||
if ($user->isMember($group)) {
|
if ($user->isMember($group)) {
|
||||||
$this->showForm(_m('Already a member!'));
|
$this->showForm(_m('Already a member!'));
|
||||||
} elseif (Group_member::join($this->oprofile->group_id, $user->id)) {
|
return;
|
||||||
$this->successGroup();
|
}
|
||||||
|
if (Event::handle('StartJoinGroup', array($group, $user))) {
|
||||||
|
$ok = Group_member::join($this->oprofile->group_id, $user->id);
|
||||||
|
if ($ok) {
|
||||||
|
Event::handle('EndJoinGroup', array($group, $user));
|
||||||
|
$this->successGroup();
|
||||||
|
} else {
|
||||||
|
$this->showForm(_m('Remote group join failed!'));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->showForm(_m('Remote group join failed!'));
|
$this->showForm(_m('Remote group join aborted!'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$local = $this->oprofile->localProfile();
|
$local = $this->oprofile->localProfile();
|
||||||
|
|
|
@ -162,7 +162,7 @@ class Ostatus_profile extends Memcached_DataObject
|
||||||
'jpg' => 'image/jpeg',
|
'jpg' => 'image/jpeg',
|
||||||
'jpeg' => 'image/jpeg',
|
'jpeg' => 'image/jpeg',
|
||||||
'gif' => 'image/gif');
|
'gif' => 'image/gif');
|
||||||
$extension = pathinfo(parse_url($avatarHref, PHP_URL_PATH), PATHINFO_EXTENSION);
|
$extension = pathinfo(parse_url($object->avatar, PHP_URL_PATH), PATHINFO_EXTENSION);
|
||||||
if (isset($map[$extension])) {
|
if (isset($map[$extension])) {
|
||||||
// @fixme this ain't used/saved yet
|
// @fixme this ain't used/saved yet
|
||||||
$object->avatarType = $map[$extension];
|
$object->avatarType = $map[$extension];
|
||||||
|
@ -332,6 +332,9 @@ class Ostatus_profile extends Memcached_DataObject
|
||||||
*/
|
*/
|
||||||
public function unsubscribe() {
|
public function unsubscribe() {
|
||||||
$feedsub = FeedSub::staticGet('uri', $this->feeduri);
|
$feedsub = FeedSub::staticGet('uri', $this->feeduri);
|
||||||
|
if (!$feedsub) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if ($feedsub->sub_state == 'active') {
|
if ($feedsub->sub_state == 'active') {
|
||||||
return $feedsub->unsubscribe();
|
return $feedsub->unsubscribe();
|
||||||
} else if ($feedsub->sub_state == '' || $feedsub->sub_state == 'inactive' || $feedsub->sub_state == 'unsubscribe') {
|
} else if ($feedsub->sub_state == '' || $feedsub->sub_state == 'inactive' || $feedsub->sub_state == 'unsubscribe') {
|
||||||
|
@ -356,7 +359,7 @@ class Ostatus_profile extends Memcached_DataObject
|
||||||
$count = $this->localProfile()->subscriberCount();
|
$count = $this->localProfile()->subscriberCount();
|
||||||
}
|
}
|
||||||
if ($count == 0) {
|
if ($count == 0) {
|
||||||
common_log(LOG_INFO, "Unsubscribing from now-unused remote feed $oprofile->feeduri");
|
common_log(LOG_INFO, "Unsubscribing from now-unused remote feed $this->feeduri");
|
||||||
$this->unsubscribe();
|
$this->unsubscribe();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1095,8 +1098,8 @@ class Ostatus_profile extends Memcached_DataObject
|
||||||
|
|
||||||
if ($object->type == ActivityObject::PERSON) {
|
if ($object->type == ActivityObject::PERSON) {
|
||||||
$profile = new Profile();
|
$profile = new Profile();
|
||||||
|
$profile->created = common_sql_now();
|
||||||
self::updateProfile($profile, $object, $hints);
|
self::updateProfile($profile, $object, $hints);
|
||||||
$profile->created = common_sql_now();
|
|
||||||
|
|
||||||
$oprofile->profile_id = $profile->insert();
|
$oprofile->profile_id = $profile->insert();
|
||||||
if (!$oprofile->profile_id) {
|
if (!$oprofile->profile_id) {
|
||||||
|
@ -1104,6 +1107,7 @@ class Ostatus_profile extends Memcached_DataObject
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$group = new User_group();
|
$group = new User_group();
|
||||||
|
$group->uri = $homeuri;
|
||||||
$group->created = common_sql_now();
|
$group->created = common_sql_now();
|
||||||
self::updateGroup($group, $object, $hints);
|
self::updateGroup($group, $object, $hints);
|
||||||
|
|
||||||
|
@ -1183,19 +1187,19 @@ class Ostatus_profile extends Memcached_DataObject
|
||||||
{
|
{
|
||||||
$orig = clone($group);
|
$orig = clone($group);
|
||||||
|
|
||||||
// @fixme need to make nick unique etc *hack hack*
|
|
||||||
$group->nickname = self::getActivityObjectNickname($object, $hints);
|
$group->nickname = self::getActivityObjectNickname($object, $hints);
|
||||||
$group->fullname = $object->title;
|
$group->fullname = $object->title;
|
||||||
|
|
||||||
// @fixme no canonical profileurl; using homepage instead for now
|
if (!empty($object->link)) {
|
||||||
$group->homepage = $object->id;
|
$group->mainpage = $object->link;
|
||||||
|
} else if (array_key_exists('profileurl', $hints)) {
|
||||||
|
$group->mainpage = $hints['profileurl'];
|
||||||
|
}
|
||||||
|
|
||||||
// @fixme homepage
|
|
||||||
// @fixme bio
|
|
||||||
// @fixme tags/categories
|
|
||||||
// @fixme location?
|
|
||||||
// @todo tags from categories
|
// @todo tags from categories
|
||||||
// @todo lat/lon/location?
|
$group->description = self::getActivityObjectBio($object, $hints);
|
||||||
|
$group->location = self::getActivityObjectLocation($object, $hints);
|
||||||
|
$group->homepage = self::getActivityObjectHomepage($object, $hints);
|
||||||
|
|
||||||
if ($group->id) {
|
if ($group->id) {
|
||||||
common_log(LOG_DEBUG, "Updating OStatus group $group->id from remote info $object->id: " . var_export($object, true) . var_export($hints, true));
|
common_log(LOG_DEBUG, "Updating OStatus group $group->id from remote info $object->id: " . var_export($object, true) . var_export($hints, true));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user