2010-03-04 04:20:04 +00:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* StatusNet - the distributed open-source microblogging tool
|
|
|
|
* Copyright (C) 2010, 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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2013-09-30 16:13:03 +01:00
|
|
|
* @package WebFingerPlugin
|
|
|
|
* @author James Walker <james@status.net>
|
|
|
|
* @author Mikael Nordfeldth <mmn@hethane.se>
|
2010-03-04 04:20:04 +00:00
|
|
|
*/
|
|
|
|
|
2013-09-30 16:13:03 +01:00
|
|
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
2010-03-04 04:20:04 +00:00
|
|
|
|
2013-09-30 16:13:03 +01:00
|
|
|
class OwnerxrdAction extends WebfingerAction
|
2010-03-04 04:20:04 +00:00
|
|
|
{
|
2013-09-30 16:13:03 +01:00
|
|
|
protected $defaultformat = 'xml';
|
2010-03-04 04:20:04 +00:00
|
|
|
|
2013-09-30 16:13:03 +01:00
|
|
|
protected function prepare(array $args=array())
|
2010-03-04 04:20:04 +00:00
|
|
|
{
|
2013-09-30 16:13:03 +01:00
|
|
|
$user = User::siteOwner();
|
2010-09-03 00:35:04 +01:00
|
|
|
|
2013-09-30 16:13:03 +01:00
|
|
|
$nick = common_canonical_nickname($user->nickname);
|
|
|
|
$args['resource'] = 'acct:' . $nick . '@' . common_config('site', 'server');
|
2010-03-04 04:20:04 +00:00
|
|
|
|
2013-09-30 16:13:03 +01:00
|
|
|
// We have now set $args['resource'] to the configured value, since
|
|
|
|
// only this local site configuration knows who the owner is!
|
|
|
|
parent::prepare($args);
|
2010-09-03 00:35:04 +01:00
|
|
|
|
2013-09-30 16:13:03 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function setXRD()
|
|
|
|
{
|
|
|
|
parent::setXRD();
|
2010-03-04 04:20:04 +00:00
|
|
|
|
|
|
|
// Check to see if a $config['webfinger']['owner'] has been set
|
2013-09-30 16:13:03 +01:00
|
|
|
// and then make sure 'subject' is set to that primary identity.
|
2010-03-04 04:20:04 +00:00
|
|
|
if ($owner = common_config('webfinger', 'owner')) {
|
2013-09-30 16:13:03 +01:00
|
|
|
$this->xrd->aliases[] = $this->xrd->subject;
|
2010-03-04 04:20:04 +00:00
|
|
|
$this->xrd->subject = Discovery::normalize($owner);
|
|
|
|
} else {
|
2013-09-30 16:13:03 +01:00
|
|
|
$this->xrd->subject = $this->resource;
|
2010-03-04 04:20:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|