]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/WebFinger/lib/webfingerresource.php
getAliases for Profile and Notice
[quix0rs-gnu-social.git] / plugins / WebFinger / lib / webfingerresource.php
1 <?php
2 /**
3  * WebFinger resource parent class
4  *
5  * @package   GNUsocial
6  * @author    Mikael Nordfeldth
7  * @copyright 2013 Free Software Foundation, Inc.
8  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
9  * @link      http://status.net/
10  */
11
12 abstract class WebFingerResource
13 {
14     protected $identities = array();
15
16     protected $object = null;
17     protected $type   = null;
18
19     public function __construct(Managed_DataObject $object)
20     {
21         $this->object = $object;
22     }
23
24     public function getObject()
25     {
26         if ($this->object === null) {
27             throw new ServerException('Object is not set');
28         }
29         return $this->object;
30     }
31
32     public function getAliases()
33     {
34         $aliases = $this->object->getAliases();
35
36         // Some sites have changed from http to https and still want
37         // (because remote sites look for it) verify that they are still
38         // the same identity as they were on HTTP. Should NOT be used if
39         // you've run HTTPS all the time!
40         if (common_config('webfinger', 'http_alias')) {
41             foreach ($aliases as $alias=>$id) {
42                 if (!strtolower(parse_url($alias, PHP_URL_SCHEME)) === 'https') {
43                     continue;
44                 }
45                 $aliases[preg_replace('/^https:/', 'http:', $alias, 1)] = $id;
46             }
47         }
48
49         // return a unique set of aliases by extracting only the keys
50         return array_keys($aliases);
51     }
52
53     abstract public function updateXRD(XML_XRD $xrd);
54 }