-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolidUserProfile.php
More file actions
52 lines (45 loc) · 1.69 KB
/
SolidUserProfile.php
File metadata and controls
52 lines (45 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
namespace Pdsinterop\PhpSolid\Routes;
use Pdsinterop\PhpSolid\User;
use Pdsinterop\PhpSolid\Util;
class SolidUserProfile {
public static function respondToProfile() {
$serverName = Util::getServerName();
[$idPart, $rest] = explode(".", $serverName, 2);
$userId = preg_replace("/^id-/", "", $idPart);
$user = User::getUserById($userId);
if (!isset($user['storage']) || !$user['storage']) {
$user['storage'] = "https://storage-" . $userId . "." . BASEDOMAIN . "/";
}
if (is_array($user['storage'])) { // empty array is already handled
$user['storage'] = array_values($user['storage'])[0]; // FIXME: Handle multiple storage pods
}
if (!isset($user['issuer'])) {
$user['issuer'] = BASEURL;
}
$profile = <<<"EOF"
@prefix : <#>.
@prefix acl: <http://www.w3.org/ns/auth/acl#>.
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
@prefix ldp: <http://www.w3.org/ns/ldp#>.
@prefix schema: <http://schema.org/>.
@prefix solid: <http://www.w3.org/ns/solid/terms#>.
@prefix space: <http://www.w3.org/ns/pim/space#>.
@prefix vcard: <http://www.w3.org/2006/vcard/ns#>.
@prefix pro: <./>.
@prefix inbox: <{$user['storage']}inbox/>.
<> a foaf:PersonalProfileDocument; foaf:maker :me; foaf:primaryTopic :me.
:me
a schema:Person, foaf:Person;
ldp:inbox inbox:;
space:preferencesFile <{$user['storage']}settings/preferences.ttl>;
space:storage <{$user['storage']}>;
solid:account <{$user['storage']}>;
solid:oidcIssuer <{$user['issuer']}>;
solid:privateTypeIndex <{$user['storage']}settings/privateTypeIndex.ttl>;
solid:publicTypeIndex <{$user['storage']}settings/publicTypeIndex.ttl>.
EOF;
header('Content-Type: text/turtle');
echo $profile;
}
}