Esempio n. 1
0
 /**
  * For initializing members of the class.
  *
  * @param array $argarray misc. arguments
  *
  * @return boolean true
  */
 function prepare($argarray)
 {
     parent::prepare($argarray);
     $cur = common_current_user();
     if (empty($cur)) {
         // TRANS: Client exception thrown when trying to view group inbox while not logged in.
         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)) {
         // TRANS: Client exception thrown when trying to view group inbox for non-existing group.
         throw new ClientException(_m('No such group.'), 404);
     }
     $this->group = User_group::getKV('id', $localGroup->group_id);
     if (empty($this->group)) {
         // TRANS: Client exception thrown when trying to view group inbox for non-existing group.
         throw new ClientException(_m('No such group.'), 404);
     }
     if (!$cur->isMember($this->group)) {
         // TRANS: Client exception thrown when trying to view group inbox while not a member.
         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 prepare($args)
 {
     parent::prepare($args);
     $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1;
     $nickname_arg = $this->arg('nickname');
     $nickname = common_canonical_nickname($nickname_arg);
     // Permanent redirect on non-canonical nickname
     if ($nickname_arg != $nickname) {
         $args = array('nickname' => $nickname);
         if ($this->page != 1) {
             $args['page'] = $this->page;
         }
         common_redirect(common_local_url('groupmembers', $args), 301);
         return false;
     }
     if (!$nickname) {
         // TRANS: Client error displayed when trying to view group members without providing a group nickname.
         $this->clientError(_('No nickname.'), 404);
         return false;
     }
     $local = Local_group::staticGet('nickname', $nickname);
     if (!$local) {
         // TRANS: Client error displayed when trying to view group members for a non-existing group.
         $this->clientError(_('No such group.'), 404);
         return false;
     }
     $this->group = User_group::staticGet('id', $local->group_id);
     if (!$this->group) {
         // TRANS: Client error displayed when trying to view group members for an object that is not a group.
         $this->clientError(_('No such group.'), 404);
         return false;
     }
     return true;
 }
Esempio n. 3
0
 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1;
     $nickname_arg = $this->arg('nickname');
     $nickname = common_canonical_nickname($nickname_arg);
     // Permanent redirect on non-canonical nickname
     if ($nickname_arg != $nickname) {
         $args = array('nickname' => $nickname);
         if ($this->page != 1) {
             $args['page'] = $this->page;
         }
         common_redirect(common_local_url('groupqueue', $args), 301);
     }
     if (!$nickname) {
         // TRANS: Client error displayed when trying to view group members without providing a group nickname.
         $this->clientError(_('No nickname.'), 404);
     }
     $local = Local_group::getKV('nickname', $nickname);
     if (!$local) {
         // TRANS: Client error displayed when trying to view group members for a non-existing group.
         $this->clientError(_('No such group.'), 404);
     }
     $this->group = User_group::getKV('id', $local->group_id);
     if (!$this->group) {
         // TRANS: Client error displayed when trying to view group members for an object that is not a group.
         $this->clientError(_('No such group.'), 404);
     }
     $cur = common_current_user();
     if (!$cur || !$cur->isAdmin($this->group)) {
         // TRANS: Client error displayed when trying to approve group applicants without being a group administrator.
         $this->clientError(_('Only the group admin may approve users.'));
     }
     return true;
 }
 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1;
     $nickname_arg = $this->arg('nickname');
     $nickname = common_canonical_nickname($nickname_arg);
     // Permanent redirect on non-canonical nickname
     if ($nickname_arg != $nickname) {
         $args = array('nickname' => $nickname);
         if ($this->page != 1) {
             $args['page'] = $this->page;
         }
         common_redirect(common_local_url('blockedfromgroup', $args), 301);
     }
     if (!$nickname) {
         // TRANS: Client error displayed when requesting a list of blocked users for a group without providing a group nickname.
         $this->clientError(_('No nickname.'), 404);
     }
     $local = Local_group::getKV('nickname', $nickname);
     if (!$local) {
         // TRANS: Client error displayed when requesting a list of blocked users for a non-local group.
         $this->clientError(_('No such group.'), 404);
     }
     $this->group = User_group::getKV('id', $local->group_id);
     if (!$this->group) {
         // TRANS: Client error displayed when requesting a list of blocked users for a non-existing group.
         $this->clientError(_('No such group.'), 404);
     }
     return true;
 }
Esempio n. 5
0
 /**
  * Prepare to run
  */
 function prepare($args)
 {
     parent::prepare($args);
     if (!common_logged_in()) {
         // TRANS: Client error displayed when trying to create a group while not logged in.
         $this->clientError(_('You must be logged in to create a group.'));
         return false;
     }
     $nickname_arg = $this->trimmed('nickname');
     $nickname = common_canonical_nickname($nickname_arg);
     // Permanent redirect on non-canonical nickname
     if ($nickname_arg != $nickname) {
         $args = array('nickname' => $nickname);
         common_redirect(common_local_url('grouplogo', $args), 301);
         return false;
     }
     if (!$nickname) {
         // TRANS: Client error displayed when trying to change group logo settings without providing a nickname.
         $this->clientError(_('No nickname.'), 404);
         return false;
     }
     $groupid = $this->trimmed('groupid');
     if ($groupid) {
         $this->group = User_group::staticGet('id', $groupid);
     } else {
         $local = Local_group::staticGet('nickname', $nickname);
         if ($local) {
             $this->group = User_group::staticGet('id', $local->group_id);
         }
     }
     if (!$this->group) {
         // TRANS: Client error displayed when trying to update logo settings for a non-existing group.
         $this->clientError(_('No such group.'), 404);
         return false;
     }
     $cur = common_current_user();
     if (!$cur->isAdmin($this->group)) {
         // TRANS: Client error displayed when trying to change group logo settings while not being a group admin.
         $this->clientError(_('You must be an admin to edit the group.'), 403);
         return false;
     }
     return true;
 }
 function prepare($args)
 {
     parent::prepare($args);
     $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1;
     return true;
 }
Esempio n. 7
0
 /**
  * Prepare the action
  *
  * Reads and validates arguments and instantiates the attributes.
  *
  * @param array $args $_REQUEST args
  *
  * @return boolean success flag
  */
 function prepare($args)
 {
     parent::prepare($args);
     $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1;
     $this->userProfile = Profile::current();
     $user = common_current_user();
     if (!empty($user) && $user->streamModeOnly()) {
         $stream = new GroupNoticeStream($this->group, $this->userProfile);
     } else {
         $stream = new ThreadingGroupNoticeStream($this->group, $this->userProfile);
     }
     $this->notice = $stream->getNotices(($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
     common_set_returnto($this->selfUrl());
     return true;
 }
Esempio n. 8
0
 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1;
     return true;
 }