/** * @httpMethod GET * @path /{userName} */ public function doProfile() { if ($this->user->hasRight('profile_view')) { $account = $this->getAccount(); if (!$account instanceof Account\Record) { throw new Exception('Invalid user'); } $this->template->assign('account', $account); // check whether remote profile if ($account->status == Account\Record::REMOTE) { Base::setResponseCode(301); header('Location: ' . $account->profileUrl); exit; } // add path $this->path->add($account->name, $this->page->getUrl() . '/' . $account->name); // get activities $activities = $this->getActivities($account); $this->template->assign('activities', $activities); // options $url = $this->config['psx_url'] . '/' . $this->config['psx_dispatch'] . 'api/user/friend'; $options = new Option(__CLASS__, $this->registry, $this->user, $this->page); if (!$this->user->isAnonymous() && !$this->user->hasFriend($account)) { $options->add('profile_view', 'Add as friend', 'javascript:amun.services.profile.friendshipRequest(' . $this->user->getId() . ', ' . $account->id . ', \'' . $url . '\', this)'); } $options->load(array($this->page, $account)); $this->template->assign('options', $options); // template $this->htmlCss->add('profile'); $this->htmlJs->add('amun'); $this->htmlJs->add('profile'); $this->htmlContent->add(Html\Content::META, Atom\Writer::link('Activity', $this->config['psx_url'] . '/' . $this->config['psx_dispatch'] . 'api/my/activity/' . $account->id . '?format=atom')); $this->htmlContent->add(Html\Content::META, '<link rel="alternate" type="application/stream+json" href="' . $this->config['psx_url'] . '/' . $this->config['psx_dispatch'] . 'api/user/activity/' . $account->id . '?format=jas" />'); $this->htmlContent->add(Html\Content::META, '<link rel="meta" type="application/rdf+xml" title="FOAF" href="' . $this->config['psx_url'] . '/' . $this->config['psx_dispatch'] . 'api/my/foaf/' . $account->name . '" />'); $this->htmlContent->add(Html\Content::META, '<link rel="profile" type="html/text" href="' . $account->profileUrl . '" />'); } else { throw new Exception('Access not allowed'); } }
private function getForum() { $result = $this->getHandler()->getOneById($this->id, array(), Sql::FETCH_OBJECT); if (empty($result)) { throw new Exception('Invalid forum id'); } $this->id = $result->id; // redirect to correct url if (empty($this->title) || strcasecmp($this->title, $result->urlTitle) !== 0) { Base::setResponseCode(301); header('Location: ' . $this->page->getUrl() . '/view/' . $result->id . '/' . $result->urlTitle); exit; } return $result; }