Exemplo n.º 1
0
 public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams)
 {
     $csrf = false;
     if (isset($extraParams['t'])) {
         $csrf = true;
         unset($extraParams['t']);
     }
     // special params to banning
     if (!empty($data[Nobita_Teams_Banning::BANNING_ID_KEY])) {
         $banData = Nobita_Teams_Banning::getBanningParamsFromData($data);
         if ($banData) {
             $extraParams['team_id'] = $banData[0];
             $extraParams['type'] = $banData[1];
             $extraParams['user_id'] = $banData[2];
         }
         unset($data[Nobita_Teams_Banning::BANNING_ID_KEY]);
     }
     // comment extraData
     if (!empty($data['comment_type']) && !empty($data['team_id'])) {
         $extraParams['comment_type'] = $data['comment_type'];
         $extraParams['team_id'] = $data['team_id'];
         $extraParams[$data['comment_type'] . '_id'] = $data['post_id'];
     }
     if ($csrf) {
         // set csrf token into last params
         $extraParams['t'] = XenForo_Visitor::getInstance()->csrf_token_page;
     }
     $link = XenForo_Link::buildSubComponentLink($this->_subComponents, $outputPrefix, $action, $extension, $data);
     if (!$link) {
         $action = XenForo_Link::getPageNumberAsAction($action, $extraParams);
         if (is_array($data) && !empty($data['custom_url'])) {
             $link = XenForo_Link::buildBasicLinkWithStringParam($outputPrefix, $action, $extension, $data, 'custom_url');
         } else {
             if ($data && isset($data['team_title'])) {
                 $data['title'] = $data['team_title'];
             }
             $link = XenForo_Link::buildBasicLinkWithIntegerParam($outputPrefix, $action, $extension, $data, 'team_id', 'title');
         }
     }
     return $link;
 }
Exemplo n.º 2
0
 public function actionMembers()
 {
     list($team, $category) = $this->_getTeamHelper()->assertTeamValidAndViewable();
     if (!$this->_getTeamModel()->canViewTabAndContainer('members', $team, $category, $error)) {
         throw $this->getErrorOrNoPermissionResponseException($error);
     }
     $order = $this->_input->filterSingle('order', XenForo_Input::STRING);
     if (empty($order)) {
         $order = 'all';
     }
     $memberModel = $this->_getMemberModel();
     $banningModel = $this->_getBanningModel();
     $perPage = 20;
     $page = max(1, $this->_input->filterSingle('page', XenForo_Input::UINT));
     $conditions = array();
     $fetchOptions = array();
     static $break = false;
     switch ($order) {
         case 'admins':
             $conditions['position'] = $this->_getMemberGroupModel()->getStaffIds();
             break;
         case 'alphabetical':
             $conditions['member_state'] = 'accept';
             $fetchOptions = array_merge($fetchOptions, array('order' => 'alphabetical', 'page' => $page, 'perPage' => $perPage));
             break;
         case 'date':
             $conditions['member_state'] = 'accept';
             $fetchOptions = array_merge($fetchOptions, array('order' => 'date', 'direction' => 'desc', 'page' => $page, 'perPage' => $perPage));
             break;
         case 'blocked':
             if (!$banningModel->canViewBannedUsers($team, $category, $error)) {
                 throw $this->getErrorOrNoPermissionResponseException($error);
             }
             // get all
             $members = $banningModel->getAllBanningActiveForTeam($team['team_id']);
             foreach ($members as &$user) {
                 $user['banUser'] = array('user_id' => $user['ban_user_id'], 'username' => $user['ban_username']);
                 Nobita_Teams_Banning::generateBanningUniqueId($user, 'ban_list');
             }
             $break = true;
             $totalMembers = 0;
         default:
             $conditions['member_state'] = 'accept';
             $fetchOptions = array_merge($fetchOptions, array('page' => $page, 'perPage' => $perPage));
             break;
     }
     if ($break === false) {
         $members = $memberModel->getMembersByTeamId($team['team_id'], $conditions, $fetchOptions);
         $totalMembers = $memberModel->countMembersInTeam($team['team_id'], $conditions);
         foreach ($members as &$user) {
             $user = $memberModel->prepareMember($user, $team);
         }
     }
     $pageRoute = TEAM_ROUTE_PREFIX . '/members';
     $pageParams = array('order' => $order);
     $this->canonicalizePageNumber($page, $perPage, $totalMembers, $pageRoute);
     $viewParams = array('team' => $team, 'members' => $members, 'page' => $page, 'perPage' => $perPage, 'totalMembers' => $totalMembers, 'pageRoute' => $pageRoute, 'pageParams' => $pageParams, 'canAssign' => $memberModel->assertPermissionActionViewable($team, "canAssign"), 'order' => $order, 'disableAdminQuery' => true, 'canEditBanned' => $banningModel->canBanUser($team, $category));
     return $this->_getTeamViewWrapper('members', $team, $category, $this->responseView('Nobita_Teams_ViewPublic_Team_Member', 'Team_member', $viewParams));
 }
Exemplo n.º 3
0
 public function prepareComment(array $comment, array $postOrEvent, array $team, array $viewingUser = null)
 {
     $this->standardizeViewingUserReference($viewingUser);
     $comment['canDelete'] = $this->canDeleteComment($comment, $postOrEvent, $team, $null, $viewingUser);
     $comment['canEdit'] = $this->canEditComment($comment, $postOrEvent, $team, $null, $viewingUser);
     $comment['canLike'] = $this->canLikeComment($comment, $team, $team, $null, $viewingUser);
     $comment['likeUsers'] = unserialize($comment['like_users']);
     $removeFields = array();
     if (array_key_exists('commenter_user_id', $comment)) {
         $comment['comment_user'] = array('user_id' => $comment['commenter_user_id'], 'username' => $comment['commenter_username'], 'avatar_date' => $comment['commenter_avatar_date'], 'gender' => $comment['commenter_gender'], 'gravatar' => $comment['commenter_gravatar']);
         $removeFields = array_merge($removeFields, array('commenter_user_id', 'commenter_username', 'commenter_avatar_date', 'commenter_gender', 'commenter_gravatar'));
     }
     $comment = $this->getModelFromCache('Nobita_Teams_Model_Banning')->prepareContent($comment, $team, $team, $null, $viewingUser);
     Nobita_Teams_Array::removeKeys($comment, $removeFields);
     Nobita_Teams_Banning::generateBanningUniqueId($comment, 'comment');
     return $comment;
 }
Exemplo n.º 4
0
 public function preparePost(array $post, array $team, array $category, $viewingUser = null)
 {
     $this->standardizeViewingUserReference($viewingUser);
     if (!isset($post['canInlineMod'])) {
         $this->addInlineModOptionToPost($post, $team, $category, $viewingUser);
     }
     $post['canReport'] = $this->getModelFromCache('XenForo_Model_User')->canReportContent();
     $post['canDelete'] = $this->canDeletePost($post, $team, $category, $null, $viewingUser);
     $post['canApprove'] = $this->canApproveUnapprove($post, $team, $category, $null, $viewingUser);
     $post['canEdit'] = $this->canEditPost($post, $team, $category, $null, $viewingUser);
     $post['canComment'] = $this->canCommentOnPost($post, $team, $category, $null, $viewingUser);
     $post['canLike'] = $this->canLikePost($post, $team, $category, $null, $viewingUser);
     $post['canSticky'] = $this->canStickyOrUnstickyPost($post, $team, $category, $null, $viewingUser);
     if ($post['likes']) {
         $post['likeUsers'] = unserialize($post['like_users']);
     }
     $post = $this->getModelFromCache('Nobita_Teams_Model_Banning')->prepareContent($post, $team, $category, $null, $viewingUser);
     $post['isModerated'] = $this->isModerated($post, $team);
     if (!empty($post['delete_date'])) {
         $post['deleteInfo'] = array('user_id' => $post['delete_user_id'], 'username' => $post['delete_username'], 'date' => $post['delete_date'], 'reason' => $post['delete_reason']);
     }
     if ($post['system_posting']) {
         $post['message'] = Nobita_Teams_Setup::helperSystemPost($post);
     }
     Nobita_Teams_Banning::generateBanningUniqueId($post, 'post');
     return $post;
 }