123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- <?php
- if (!defined('STATUSNET')) {
-
-
- exit(1);
- }
- class GroupinboxAction extends GroupAction
- {
- var $gm;
-
- function prepare(array $args = [])
- {
- parent::prepare($args);
- $cur = common_current_user();
- if (empty($cur)) {
-
- throw new ClientException(_m('Only for logged-in users.'), 403);
- }
- $nicknameArg = $this->trimmed('nickname');
- $nickname = common_canonical_nickname($nicknameArg);
- if ($nickname != $nicknameArg) {
- $url = common_local_url('groupinbox', array('nickname' => $nickname));
- common_redirect($url);
- }
- $localGroup = Local_group::getKV('nickname', $nickname);
- if (empty($localGroup)) {
-
- throw new ClientException(_m('No such group.'), 404);
- }
- $this->group = User_group::getKV('id', $localGroup->group_id);
- if (empty($this->group)) {
-
- throw new ClientException(_m('No such group.'), 404);
- }
- if (!$cur->isMember($this->group)) {
-
- throw new ClientException(_m('Only for members.'), 403);
- }
- $this->page = $this->trimmed('page');
- if (!$this->page) {
- $this->page = 1;
- }
- $this->gm = Group_message::forGroup($this->group,
- ($this->page - 1) * MESSAGES_PER_PAGE,
- MESSAGES_PER_PAGE + 1);
- return true;
- }
- function showLocalNav()
- {
- $nav = new GroupNav($this, $this->group);
- $nav->show();
- }
- function showNoticeForm()
- {
- $form = new GroupMessageForm($this, $this->group);
- $form->show();
- }
- function showContent()
- {
- $gml = new GroupMessageList($this, $this->gm);
- $cnt = $gml->show();
- if ($cnt == 0) {
-
- $this->element('p', 'guide', _m('This group has not received any private messages.'));
- }
- $this->pagination($this->page > 1,
- $cnt > MESSAGES_PER_PAGE,
- $this->page,
- 'groupinbox',
- array('nickname' => $this->group->nickname));
- }
-
- function handle()
- {
- $this->showPage();
- }
-
- function isReadOnly($args)
- {
- return true;
- }
-
- function title()
- {
- $base = $this->group->getFancyName();
- if ($this->page == 1) {
-
- return sprintf(_m('%s group inbox'), $base);
- } else {
-
-
- return sprintf(_m('%1$s group inbox, page %2$d'),
- $base,
- $this->page);
- }
- }
-
- function showPageNotice()
- {
- $instr = $this->getInstructions();
- $output = common_markup_to_html($instr);
- $this->elementStart('div', 'instructions');
- $this->raw($output);
- $this->elementEnd('div');
- }
-
- function getInstructions()
- {
-
- return _m('This is the group inbox, which lists all incoming private messages for this group.');
- }
- }
|