123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- <?php
- if (!defined('GNUSOCIAL')) { exit(1); }
- require_once INSTALLDIR.'/lib/noticelist.php';
- class ShownoticeAction extends ManagedAction
- {
-
- var $notice = null;
-
- var $profile = null;
-
- var $avatar = null;
-
- protected function prepare(array $args=array())
- {
- parent::prepare($args);
- if ($this->boolean('ajax')) {
- StatusNet::setApi(true);
- }
- $this->notice = $this->getNotice();
- if (!$this->notice->inScope($this->scoped)) {
-
- throw new ClientException(_('Access restricted.'), 403);
- }
- $this->profile = $this->notice->getProfile();
- if (!$this->profile instanceof Profile) {
-
- $this->serverError(_('Notice has no profile.'), 500);
- }
- try {
- $this->user = $this->profile->getUser();
- } catch (NoSuchUserException $e) {
-
- $this->user = null;
- }
- try {
- $this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
- } catch (Exception $e) {
- $this->avatar = null;
- }
- return true;
- }
-
- protected function getNotice()
- {
- $id = $this->arg('notice');
- $notice = Notice::getKV('id', $id);
- if ($notice instanceof Notice) {
-
- return $notice;
- }
-
- $deleted = Deleted_notice::getKV('id', $id);
- if ($deleted instanceof Deleted_notice) {
-
- $this->clientError(_('Notice deleted.'), 410);
- }
-
- $this->clientError(_('No such notice.'), 404);
- }
-
- function isReadOnly($args)
- {
- return true;
- }
-
- function lastModified()
- {
- return max(strtotime($this->notice->modified),
- strtotime($this->profile->modified),
- ($this->avatar) ? strtotime($this->avatar->modified) : 0);
- }
-
- function etag()
- {
- $avtime = ($this->avatar) ?
- strtotime($this->avatar->modified) : 0;
- return 'W/"' . implode(':', array($this->arg('action'),
- common_user_cache_hash(),
- common_language(),
- $this->notice->id,
- strtotime($this->notice->created),
- strtotime($this->profile->modified),
- $avtime)) . '"';
- }
-
- function title()
- {
- return $this->notice->getTitle();
- }
-
- function showContent()
- {
- $this->elementStart('ol', array('class' => 'notices xoxo'));
- $nli = new NoticeListItem($this->notice, $this);
- $nli->show();
- $this->elementEnd('ol');
- }
-
- function showPageNoticeBlock()
- {
- }
-
- function showAside() {
- }
-
- function extraHead()
- {
- $user = User::getKV($this->profile->id);
- if (!$user instanceof User) {
- return;
- }
- if ($user->emailmicroid && $user->email && $this->notice->uri) {
- $id = new Microid('mailto:'. $user->email,
- $this->notice->uri);
- $this->element('meta', array('name' => 'microid',
- 'content' => $id->toString()));
- }
-
- $avatarUrl = $this->profile->avatarUrl(AVATAR_PROFILE_SIZE);
- $this->element('meta', array('property' => 'og:image',
- 'content' => $avatarUrl));
- $this->element('meta', array('property' => 'og:description',
- 'content' => $this->notice->content));
- }
- }
|