summaryrefslogtreecommitdiff
path: root/plugins/ModPlus/remoteprofileaction.php
blob: caa5e6fbf36037ada44fb388a10135e4d027978b (plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class RemoteProfileAction extends ShowstreamAction
{
    function prepare($args)
    {
        OwnerDesignAction::prepare($args); // skip the ProfileAction code and replace it...

        $id = $this->arg('id');
        $this->user = false;
        $this->profile = Profile::staticGet('id', $id);

        if (!$this->profile) {
            $this->serverError(_('User has no profile.'));
            return false;
        }

        $user = User::staticGet('id', $this->profile->id);
        if ($user) {
            // This is a local user -- send to their regular profile.
            $url = common_local_url('showstream', array('nickname' => $user->nickname));
            common_redirect($url);
            return false;
        }

        $this->tag = $this->trimmed('tag');
        $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
        common_set_returnto($this->selfUrl());
        return true;
    }

    function handle($args)
    {
        // skip yadis thingy
        $this->showPage();
    }

    function title()
    {
        // maybe fixed in 0.9.x
        if (!empty($this->profile->fullname)) {
            $base = $this->profile->fullname . ' (' . $this->profile->nickname . ') ';
        } else {
            $base = $this->profile->nickname;
        }
        $host = parse_url($this->profile->profileurl, PHP_URL_HOST);
        return sprintf(_m('%s on %s'), $base, $host);
    }

    /**
     * Instead of showing notices, link to the original offsite profile.
     */
    function showNotices()
    {
        $url = $this->profile->profileurl;
        $host = parse_url($url, PHP_URL_HOST);
        $markdown = sprintf(
                _m('This remote profile is registered on another site; see [%s\'s original profile page on %s](%s).'),
                $this->profile->nickname,
                $host,
                $url);
        $html = common_markup_to_html($markdown);
        $this->raw($html);

        if ($this->profile->hasRole(Profile_role::SILENCED)) {
            $markdown = _m('Site moderators have silenced this profile, which prevents delivery of new messages to any users on this site.');
            $this->raw(common_markup_to_html($markdown));
        }
    }

    function getFeeds()
    {
        // none
    }

    /**
     * Don't do various extra stuff, and also trim some things to avoid crawlers.
     */
    function extraHead()
    {
        $this->element('meta', array('name' => 'robots',
                                     'content' => 'noindex,nofollow'));
    }

    function showLocalNav()
    {
        $nav = new PublicGroupNav($this);
        $nav->show();
    }

    function showSections()
    {
        ProfileAction::showSections();
        // skip tag cloud
    }

    function showStatistics()
    {
        // skip
    }

}