X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fxrdaction.php;h=6cca80d93e5593428687899365d9800fb5d2fb78;hb=0d487a1ea000b327cfaa5a2632e9a2a9fa61f23c;hp=43826b32bb88c88216ecc9f34d680d490a785429;hpb=76946ea5a3636479d713f64471e86643936bc540;p=quix0rs-gnu-social.git diff --git a/lib/xrdaction.php b/lib/xrdaction.php index 43826b32bb..6cca80d93e 100644 --- a/lib/xrdaction.php +++ b/lib/xrdaction.php @@ -31,7 +31,7 @@ class XrdAction extends Action const PROFILEPAGE = 'http://webfinger.net/rel/profile-page'; const UPDATESFROM = 'http://schemas.google.com/g/2010#updates-from'; const HCARD = 'http://microformats.org/profile/hcard'; - + public $uri; public $user; @@ -53,64 +53,79 @@ class XrdAction extends Action $xrd->subject = self::normalize($this->uri); } - if (Event::handle('StartXrdActionAliases', array(&$xrd, $this->user))) { - - // Possible aliases for the user - - $uris = array($this->user->uri, $profile->profileurl); - - // FIXME: Webfinger generation code should live somewhere on its own - - $path = common_config('site', 'path'); - - if (empty($path)) { - $uris[] = sprintf('acct:%s@%s', $nick, common_config('site', 'server')); - } - - foreach ($uris as $uri) { - if ($uri != $xrd->subject) { - $xrd->alias[] = $uri; - } - } - - Event::handle('EndXrdActionAliases', array(&$xrd, $this->user)); - } - - if (Event::handle('StartXrdActionLinks', array(&$xrd, $this->user))) { - - $xrd->links[] = array('rel' => self::PROFILEPAGE, - 'type' => 'text/html', - 'href' => $profile->profileurl); - - // hCard - $xrd->links[] = array('rel' => self::HCARD, - 'type' => 'text/html', - 'href' => common_local_url('hcard', array('nickname' => $nick))); - - // XFN - $xrd->links[] = array('rel' => 'http://gmpg.org/xfn/11', - 'type' => 'text/html', - 'href' => $profile->profileurl); - // FOAF - $xrd->links[] = array('rel' => 'describedby', - 'type' => 'application/rdf+xml', - 'href' => common_local_url('foaf', - array('nickname' => $nick))); - - - Event::handle('EndXrdActionLinks', array(&$xrd, $this->user)); - } - + if (Event::handle('StartXrdActionAliases', array(&$xrd, $this->user))) { + + // Possible aliases for the user + + $uris = array($this->user->uri, $profile->profileurl); + + // FIXME: Webfinger generation code should live somewhere on its own + + $path = common_config('site', 'path'); + + if (empty($path)) { + $uris[] = sprintf('acct:%s@%s', $nick, common_config('site', 'server')); + } + + foreach ($uris as $uri) { + if ($uri != $xrd->subject) { + $xrd->alias[] = $uri; + } + } + + Event::handle('EndXrdActionAliases', array(&$xrd, $this->user)); + } + + if (Event::handle('StartXrdActionLinks', array(&$xrd, $this->user))) { + + $xrd->links[] = array('rel' => self::PROFILEPAGE, + 'type' => 'text/html', + 'href' => $profile->profileurl); + + // XFN + $xrd->links[] = array('rel' => 'http://gmpg.org/xfn/11', + 'type' => 'text/html', + 'href' => $profile->profileurl); + // FOAF + $xrd->links[] = array('rel' => 'describedby', + 'type' => 'application/rdf+xml', + 'href' => common_local_url('foaf', + array('nickname' => $nick))); + + $xrd->links[] = array('rel' => 'http://apinamespace.org/atom', + 'type' => 'application/atomsvc+xml', + 'href' => common_local_url('ApiAtomService', array('id' => $nick)), + 'property' => array(array('type' => 'http://apinamespace.org/atom/username', + 'value' => $nick))); + + if (common_config('site', 'fancy')) { + $apiRoot = common_path('api/', true); + } else { + $apiRoot = common_path('index.php/api/', true); + } + + $xrd->links[] = array('rel' => 'http://apinamespace.org/twitter', + 'href' => $apiRoot, + 'property' => array(array('type' => 'http://apinamespace.org/twitter/username', + 'value' => $nick))); + + Event::handle('EndXrdActionLinks', array(&$xrd, $this->user)); + } + + if (common_config('discovery', 'cors')) { + header('Access-Control-Allow-Origin: *'); + } header('Content-type: application/xrd+xml'); + print $xrd->toXML(); } - + /** * Given a "user id" make sure it's normalized to either a webfinger * acct: uri or a profile HTTP URL. */ - + public static function normalize($user_id) { if (substr($user_id, 0, 5) == 'http:' || @@ -132,4 +147,16 @@ class XrdAction extends Action return (substr($uri, 0, 5) == 'acct:'); } + + /** + * Is this action read-only? + * + * @param array $args other arguments + * + * @return boolean is read only action? + */ + function isReadOnly($args) + { + return true; + } }