]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/ModPlus/remoteprofileaction.php
8e2fcad284518ebb8c9b051f6391dade8426ef5e
[quix0rs-gnu-social.git] / plugins / ModPlus / remoteprofileaction.php
1 <?php
2 /*
3  * To change this template, choose Tools | Templates
4  * and open the template in the editor.
5  */
6
7 class RemoteProfileAction extends ShowstreamAction
8 {
9     function prepare($args)
10     {
11         OwnerDesignAction::prepare($args); // skip the ProfileAction code and replace it...
12
13         $id = $this->arg('id');
14         $this->user = false;
15         $this->profile = Profile::staticGet('id', $id);
16
17         if (!$this->profile) {
18             // TRANS: Error message displayed when referring to a user without a profile.
19             $this->serverError(_m('User has no profile.'));
20             return false;
21         }
22
23         $user = User::staticGet('id', $this->profile->id);
24         if ($user) {
25             // This is a local user -- send to their regular profile.
26             $url = common_local_url('showstream', array('nickname' => $user->nickname));
27             common_redirect($url);
28             return false;
29         }
30
31         $this->tag = $this->trimmed('tag');
32         $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
33         common_set_returnto($this->selfUrl());
34         return true;
35     }
36
37     function handle($args)
38     {
39         // skip yadis thingy
40         $this->showPage();
41     }
42
43     function title()
44     {
45         $base = $this->profile->getBestName();
46         $host = parse_url($this->profile->profileurl, PHP_URL_HOST);
47         // TRANS: Remote profile action page title.
48         // TRANS: %1$s is a username, %2$s is a hostname.
49         return sprintf(_m('%1$s on %2$s'), $base, $host);
50     }
51
52     /**
53      * Instead of showing notices, link to the original offsite profile.
54      */
55     function showNotices()
56     {
57         $url = $this->profile->profileurl;
58         $host = parse_url($url, PHP_URL_HOST);
59         $markdown = sprintf(
60                 // TRANS: Message on remote profile page.
61                 // TRANS: This message contains Markdown links in the form [description](link).
62                 // TRANS: %1$s is a profile nickname, %2$s is a hostname, %3$s is a URL.
63                 _m('This remote profile is registered on another site; see [%1$s\'s original profile page on %2$s](%3$s).'),
64                 $this->profile->nickname,
65                 $host,
66                 $url);
67         $html = common_markup_to_html($markdown);
68         $this->raw($html);
69
70         if ($this->profile->hasRole(Profile_role::SILENCED)) {
71             // TRANS: Message on blocked remote profile page.
72             $markdown = _m('Site moderators have silenced this profile, which prevents delivery of new messages to any users on this site.');
73             $this->raw(common_markup_to_html($markdown));
74         }
75     }
76
77     function getFeeds()
78     {
79         // none
80     }
81
82     /**
83      * Don't do various extra stuff, and also trim some things to avoid crawlers.
84      */
85     function extraHead()
86     {
87         $this->element('meta', array('name' => 'robots',
88                                      'content' => 'noindex,nofollow'));
89     }
90
91     function showLocalNav()
92     {
93         $nav = new PublicGroupNav($this);
94         $nav->show();
95     }
96
97     function showSections()
98     {
99         ProfileAction::showSections();
100         // skip tag cloud
101     }
102
103     function showStatistics()
104     {
105         // skip
106     }
107 }