Merge branch 'testing' of git@gitorious.org:statusnet/mainline into testing
This commit is contained in:
commit
4aa82f75ed
@ -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;
|
||||||
|
@ -145,7 +145,7 @@ class SubscribeAction extends Action
|
|||||||
$this->element('title', null, _('Subscribed'));
|
$this->element('title', null, _('Subscribed'));
|
||||||
$this->elementEnd('head');
|
$this->elementEnd('head');
|
||||||
$this->elementStart('body');
|
$this->elementStart('body');
|
||||||
$unsubscribe = new UnsubscribeForm($this, $this->other->getProfile());
|
$unsubscribe = new UnsubscribeForm($this, $this->other);
|
||||||
$unsubscribe->show();
|
$unsubscribe->show();
|
||||||
$this->elementEnd('body');
|
$this->elementEnd('body');
|
||||||
$this->elementEnd('html');
|
$this->elementEnd('html');
|
||||||
|
@ -121,6 +121,9 @@ class Notice extends Memcached_DataObject
|
|||||||
$result = parent::delete();
|
$result = parent::delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract #hashtags from this notice's content and save them to the database.
|
||||||
|
*/
|
||||||
function saveTags()
|
function saveTags()
|
||||||
{
|
{
|
||||||
/* extract all #hastags */
|
/* extract all #hastags */
|
||||||
@ -129,14 +132,22 @@ class Notice extends Memcached_DataObject
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Add them to the database */
|
||||||
|
return $this->saveKnownTags($match[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Record the given set of hash tags in the db for this notice.
|
||||||
|
* Given tag strings will be normalized and checked for dupes.
|
||||||
|
*/
|
||||||
|
function saveKnownTags($hashtags)
|
||||||
|
{
|
||||||
//turn each into their canonical tag
|
//turn each into their canonical tag
|
||||||
//this is needed to remove dupes before saving e.g. #hash.tag = #hashtag
|
//this is needed to remove dupes before saving e.g. #hash.tag = #hashtag
|
||||||
$hashtags = array();
|
for($i=0; $i<count($hashtags); $i++) {
|
||||||
for($i=0; $i<count($match[1]); $i++) {
|
$hashtags[$i] = common_canonical_tag($hashtags[$i]);
|
||||||
$hashtags[] = common_canonical_tag($match[1][$i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add them to the database */
|
|
||||||
foreach(array_unique($hashtags) as $hashtag) {
|
foreach(array_unique($hashtags) as $hashtag) {
|
||||||
/* elide characters we don't want in the tag */
|
/* elide characters we don't want in the tag */
|
||||||
$this->saveTag($hashtag);
|
$this->saveTag($hashtag);
|
||||||
@ -145,6 +156,10 @@ class Notice extends Memcached_DataObject
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Record a single hash tag as associated with this notice.
|
||||||
|
* Tag format and uniqueness must be validated by caller.
|
||||||
|
*/
|
||||||
function saveTag($hashtag)
|
function saveTag($hashtag)
|
||||||
{
|
{
|
||||||
$tag = new Notice_tag();
|
$tag = new Notice_tag();
|
||||||
@ -194,6 +209,8 @@ class Notice extends Memcached_DataObject
|
|||||||
* place of extracting @-replies from content.
|
* place of extracting @-replies from content.
|
||||||
* array 'groups' list of group IDs to deliver to, in place of
|
* array 'groups' list of group IDs to deliver to, in place of
|
||||||
* extracting ! tags from content
|
* extracting ! tags from content
|
||||||
|
* array 'tags' list of hashtag strings to save with the notice
|
||||||
|
* in place of extracting # tags from content
|
||||||
* @fixme tag override
|
* @fixme tag override
|
||||||
*
|
*
|
||||||
* @return Notice
|
* @return Notice
|
||||||
@ -343,6 +360,8 @@ class Notice extends Memcached_DataObject
|
|||||||
|
|
||||||
$notice->blowOnInsert();
|
$notice->blowOnInsert();
|
||||||
|
|
||||||
|
// Save per-notice metadata...
|
||||||
|
|
||||||
if (isset($replies)) {
|
if (isset($replies)) {
|
||||||
$notice->saveKnownReplies($replies);
|
$notice->saveKnownReplies($replies);
|
||||||
} else {
|
} else {
|
||||||
@ -355,6 +374,16 @@ class Notice extends Memcached_DataObject
|
|||||||
$notice->saveGroups();
|
$notice->saveGroups();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($tags)) {
|
||||||
|
$notice->saveKnownTags($tags);
|
||||||
|
} else {
|
||||||
|
$notice->saveTags();
|
||||||
|
}
|
||||||
|
|
||||||
|
// @fixme pass in data for URLs too?
|
||||||
|
$notice->saveUrls();
|
||||||
|
|
||||||
|
// Prepare inbox delivery, may be queued to background.
|
||||||
$notice->distribute();
|
$notice->distribute();
|
||||||
|
|
||||||
return $notice;
|
return $notice;
|
||||||
|
@ -399,25 +399,41 @@ class User_group extends Memcached_DataObject
|
|||||||
return $xs->getString();
|
return $xs->getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an XML string fragment with group information as an
|
||||||
|
* Activity Streams <activity:subject> element.
|
||||||
|
*
|
||||||
|
* Assumes that 'activity' namespace has been previously defined.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function asActivitySubject()
|
function asActivitySubject()
|
||||||
{
|
{
|
||||||
$xs = new XMLStringer(true);
|
return $this->asActivityNoun('subject');
|
||||||
|
}
|
||||||
|
|
||||||
$xs->elementStart('activity:subject');
|
/**
|
||||||
$xs->element('activity:object', null, 'http://activitystrea.ms/schema/1.0/group');
|
* Returns an XML string fragment with group information as an
|
||||||
$xs->element('id', null, $this->permalink());
|
* Activity Streams noun object with the given element type.
|
||||||
$xs->element('title', null, $this->getBestName());
|
*
|
||||||
$xs->element(
|
* Assumes that 'activity', 'georss', and 'poco' namespace has been
|
||||||
'link', array(
|
* previously defined.
|
||||||
'rel' => 'avatar',
|
*
|
||||||
'href' => empty($this->homepage_logo)
|
* @param string $element one of 'actor', 'subject', 'object', 'target'
|
||||||
? User_group::defaultLogo(AVATAR_PROFILE_SIZE)
|
*
|
||||||
: $this->homepage_logo
|
* @return string
|
||||||
)
|
*/
|
||||||
);
|
function asActivityNoun($element)
|
||||||
$xs->elementEnd('activity:subject');
|
{
|
||||||
|
$noun = ActivityObject::fromGroup($this);
|
||||||
|
return $noun->asString('activity:' . $element);
|
||||||
|
}
|
||||||
|
|
||||||
return $xs->getString();
|
function getAvatar()
|
||||||
|
{
|
||||||
|
return empty($this->homepage_logo)
|
||||||
|
? User_group::defaultLogo(AVATAR_PROFILE_SIZE)
|
||||||
|
: $this->homepage_logo;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function register($fields) {
|
static function register($fields) {
|
||||||
|
17
db/local_group.sql
Normal file
17
db/local_group.sql
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
alter table user_group
|
||||||
|
add uri varchar(255) unique key comment 'universal identifier',
|
||||||
|
add mainpage varchar(255) comment 'page for group info to link to',
|
||||||
|
drop index nickname;
|
||||||
|
|
||||||
|
create table local_group (
|
||||||
|
|
||||||
|
group_id integer primary key comment 'group represented' references user_group (id),
|
||||||
|
nickname varchar(64) unique key comment 'group represented',
|
||||||
|
|
||||||
|
created datetime not null comment 'date this record was created',
|
||||||
|
modified timestamp comment 'date this record was modified'
|
||||||
|
|
||||||
|
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
|
||||||
|
|
||||||
|
insert into local_group (group_id, nickname, created, modified)
|
||||||
|
select id, nickname, created, modified from user_group;
|
127
lib/activity.php
127
lib/activity.php
@ -223,6 +223,37 @@ class PoCo
|
|||||||
return $poco;
|
return $poco;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fromGroup($group)
|
||||||
|
{
|
||||||
|
if (empty($group)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$poco = new PoCo();
|
||||||
|
|
||||||
|
$poco->preferredUsername = $group->nickname;
|
||||||
|
$poco->displayName = $group->getBestName();
|
||||||
|
|
||||||
|
$poco->note = $group->description;
|
||||||
|
|
||||||
|
$paddy = new PoCoAddress();
|
||||||
|
$paddy->formatted = $group->location;
|
||||||
|
$poco->address = $paddy;
|
||||||
|
|
||||||
|
if (!empty($group->homepage)) {
|
||||||
|
array_push(
|
||||||
|
$poco->urls,
|
||||||
|
new PoCoURL(
|
||||||
|
'homepage',
|
||||||
|
$group->homepage,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $poco;
|
||||||
|
}
|
||||||
|
|
||||||
function getPrimaryURL()
|
function getPrimaryURL()
|
||||||
{
|
{
|
||||||
foreach ($this->urls as $url) {
|
foreach ($this->urls as $url) {
|
||||||
@ -610,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;
|
||||||
@ -621,6 +655,21 @@ class ActivityObject
|
|||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static function fromGroup($group)
|
||||||
|
{
|
||||||
|
$object = new ActivityObject();
|
||||||
|
|
||||||
|
$object->type = ActivityObject::GROUP;
|
||||||
|
$object->id = $group->getUri();
|
||||||
|
$object->title = $group->getBestName();
|
||||||
|
$object->link = $group->getUri();
|
||||||
|
$object->avatar = $group->getAvatar();
|
||||||
|
|
||||||
|
$object->poco = PoCo::fromGroup($group);
|
||||||
|
|
||||||
|
return $object;
|
||||||
|
}
|
||||||
|
|
||||||
function asString($tag='activity:object')
|
function asString($tag='activity:object')
|
||||||
{
|
{
|
||||||
$xs = new XMLStringer(true);
|
$xs = new XMLStringer(true);
|
||||||
@ -656,15 +705,26 @@ class ActivityObject
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->type == ActivityObject::PERSON
|
if ($this->type == ActivityObject::PERSON) {
|
||||||
|| $this->type == ActivityObject::GROUP) {
|
|
||||||
$xs->element(
|
$xs->element(
|
||||||
'link', array(
|
'link', array(
|
||||||
'type' => empty($this->avatar) ? 'image/png' : $this->avatar->mediatype,
|
'type' => empty($this->avatar) ? 'image/png' : $this->avatar->mediatype,
|
||||||
'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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// XXX: Gotta figure out mime-type! Gar.
|
||||||
|
|
||||||
|
if ($this->type == ActivityObject::GROUP) {
|
||||||
|
$xs->element(
|
||||||
|
'link', array(
|
||||||
|
'rel' => 'avatar',
|
||||||
|
'href' => $this->avatar
|
||||||
),
|
),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
@ -859,6 +919,7 @@ class Activity
|
|||||||
public $content; // HTML content of activity
|
public $content; // HTML content of activity
|
||||||
public $id; // ID of the activity
|
public $id; // ID of the activity
|
||||||
public $title; // title of the activity
|
public $title; // title of the activity
|
||||||
|
public $categories = array(); // list of AtomCategory objects
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns a regular old Atom <entry> into a magical activity
|
* Turns a regular old Atom <entry> into a magical activity
|
||||||
@ -947,6 +1008,14 @@ class Activity
|
|||||||
$this->summary = ActivityUtils::childContent($entry, 'summary');
|
$this->summary = ActivityUtils::childContent($entry, 'summary');
|
||||||
$this->id = ActivityUtils::childContent($entry, 'id');
|
$this->id = ActivityUtils::childContent($entry, 'id');
|
||||||
$this->content = ActivityUtils::getContent($entry);
|
$this->content = ActivityUtils::getContent($entry);
|
||||||
|
|
||||||
|
$catEls = $entry->getElementsByTagNameNS(self::ATOM, 'category');
|
||||||
|
if ($catEls) {
|
||||||
|
for ($i = 0; $i < $catEls->length; $i++) {
|
||||||
|
$catEl = $catEls->item($i);
|
||||||
|
$this->categories[] = new AtomCategory($catEl);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1011,6 +1080,10 @@ class Activity
|
|||||||
$xs->raw($this->target->asString('activity:target'));
|
$xs->raw($this->target->asString('activity:target'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($this->categories as $cat) {
|
||||||
|
$xs->raw($cat->asString());
|
||||||
|
}
|
||||||
|
|
||||||
$xs->elementEnd('entry');
|
$xs->elementEnd('entry');
|
||||||
|
|
||||||
return $xs->getString();
|
return $xs->getString();
|
||||||
@ -1021,3 +1094,49 @@ class Activity
|
|||||||
return ActivityUtils::child($element, $tag, $namespace);
|
return ActivityUtils::child($element, $tag, $namespace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class AtomCategory
|
||||||
|
{
|
||||||
|
public $term;
|
||||||
|
public $scheme;
|
||||||
|
public $label;
|
||||||
|
|
||||||
|
function __construct($element=null)
|
||||||
|
{
|
||||||
|
if ($element && $element->attributes) {
|
||||||
|
$this->term = $this->extract($element, 'term');
|
||||||
|
$this->scheme = $this->extract($element, 'scheme');
|
||||||
|
$this->label = $this->extract($element, 'label');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function extract($element, $attrib)
|
||||||
|
{
|
||||||
|
$node = $element->attributes->getNamedItemNS(Activity::ATOM, $attrib);
|
||||||
|
if ($node) {
|
||||||
|
return trim($node->textContent);
|
||||||
|
}
|
||||||
|
$node = $element->attributes->getNamedItem($attrib);
|
||||||
|
if ($node) {
|
||||||
|
return trim($node->textContent);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function asString()
|
||||||
|
{
|
||||||
|
$attribs = array();
|
||||||
|
if ($this->term !== null) {
|
||||||
|
$attribs['term'] = $this->term;
|
||||||
|
}
|
||||||
|
if ($this->scheme !== null) {
|
||||||
|
$attribs['scheme'] = $this->scheme;
|
||||||
|
}
|
||||||
|
if ($this->label !== null) {
|
||||||
|
$attribs['label'] = $this->label;
|
||||||
|
}
|
||||||
|
$xs = new XMLStringer();
|
||||||
|
$xs->element('category', $attribs);
|
||||||
|
return $xs->asString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -62,24 +62,12 @@ class DistribQueueHandler
|
|||||||
{
|
{
|
||||||
// XXX: do we need to change this for remote users?
|
// XXX: do we need to change this for remote users?
|
||||||
|
|
||||||
try {
|
|
||||||
$notice->saveTags();
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$this->logit($notice, $e);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$notice->addToInboxes();
|
$notice->addToInboxes();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->logit($notice, $e);
|
$this->logit($notice, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
$notice->saveUrls();
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$this->logit($notice, $e);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Event::handle('EndNoticeSave', array($notice));
|
Event::handle('EndNoticeSave', array($notice));
|
||||||
// Enqueue for other handlers
|
// Enqueue for other handlers
|
||||||
|
@ -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) {
|
||||||
|
@ -134,7 +134,7 @@ function common_check_user($nickname, $password)
|
|||||||
$authenticatedUser = false;
|
$authenticatedUser = false;
|
||||||
|
|
||||||
if (Event::handle('StartCheckPassword', array($nickname, $password, &$authenticatedUser))) {
|
if (Event::handle('StartCheckPassword', array($nickname, $password, &$authenticatedUser))) {
|
||||||
$user = User::staticGet('nickname', $nickname);
|
$user = User::staticGet('nickname', common_canonical_nickname($nickname));
|
||||||
if (!empty($user)) {
|
if (!empty($user)) {
|
||||||
if (!empty($password)) { // never allow login with blank password
|
if (!empty($password)) { // never allow login with blank password
|
||||||
if (0 == strcmp(common_munge_password($password, $user->id),
|
if (0 == strcmp(common_munge_password($password, $user->id),
|
||||||
|
@ -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 {
|
||||||
@ -638,7 +641,9 @@ class Ostatus_profile extends Memcached_DataObject
|
|||||||
'uri' => $sourceUri,
|
'uri' => $sourceUri,
|
||||||
'rendered' => $rendered,
|
'rendered' => $rendered,
|
||||||
'replies' => array(),
|
'replies' => array(),
|
||||||
'groups' => array());
|
'groups' => array(),
|
||||||
|
'tags' => array());
|
||||||
|
|
||||||
|
|
||||||
// Check for optional attributes...
|
// Check for optional attributes...
|
||||||
|
|
||||||
@ -673,6 +678,16 @@ class Ostatus_profile extends Memcached_DataObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Atom categories <-> hashtags
|
||||||
|
foreach ($activity->categories as $cat) {
|
||||||
|
if ($cat->term) {
|
||||||
|
$term = common_canonical_tag($cat->term);
|
||||||
|
if ($term) {
|
||||||
|
$options['tags'][] = $term;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$saved = Notice::saveNew($oprofile->profile_id,
|
$saved = Notice::saveNew($oprofile->profile_id,
|
||||||
$content,
|
$content,
|
||||||
@ -1083,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) {
|
||||||
@ -1092,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);
|
||||||
|
|
||||||
@ -1171,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