Пример #1
0
 public function prepareApiDataForCategory(array $category)
 {
     $publicKeys = array('node_id' => 'category_id', 'title' => 'category_title', 'description' => 'category_description');
     $data = bdApi_Data_Helper_Core::filter($category, $publicKeys);
     $data['links'] = array('permalink' => XenForo_Link::buildPublicLink('categories', $category), 'detail' => bdApi_Data_Helper_Core::safeBuildApiLink('categories', $category), 'sub-categories' => bdApi_Data_Helper_Core::safeBuildApiLink('categories', array(), array('parent_category_id' => $category['node_id'])), 'sub-forums' => bdApi_Data_Helper_Core::safeBuildApiLink('forums', array(), array('parent_category_id' => $category['node_id'])));
     $data['permissions'] = array('view' => $this->canViewCategory($category), 'edit' => XenForo_Visitor::getInstance()->hasAdminPermission('node'), 'delete' => XenForo_Visitor::getInstance()->hasAdminPermission('node'));
     return $data;
 }
Пример #2
0
 public function prepareApiDataForPage(array $page)
 {
     $publicKeys = array('node_id' => 'page_id', 'title' => 'page_title', 'description' => 'page_description', 'view_count' => 'page_view_count');
     $data = bdApi_Data_Helper_Core::filter($page, $publicKeys);
     $data['links'] = array('permalink' => XenForo_Link::buildPublicLink('pages', $page), 'detail' => bdApi_Data_Helper_Core::safeBuildApiLink('pages', $page), 'sub-pages' => bdApi_Data_Helper_Core::safeBuildApiLink('pages', array(), array('parent_page_id' => $page['node_id'])));
     $data['permissions'] = array('view' => $this->canViewPage($page), 'edit' => XenForo_Visitor::getInstance()->hasAdminPermission('node'), 'delete' => XenForo_Visitor::getInstance()->hasAdminPermission('node'));
     return $data;
 }
Пример #3
0
 public function prepareApiDataForComment(array $comment, array $profilePost, array $user)
 {
     $comment = $this->prepareProfilePostComment($comment, $profilePost, $user);
     $publicKeys = array('profile_post_comment_id' => 'comment_id', 'profile_post_id' => 'profile_post_id', 'user_id' => 'comment_user_id', 'username' => 'comment_username', 'comment_date' => 'comment_create_date', 'message' => 'comment_body');
     $data = bdApi_Data_Helper_Core::filter($comment, $publicKeys);
     $data['timeline_user_id'] = $profilePost['profile_user_id'];
     $data['links'] = array('detail' => bdApi_Data_Helper_Core::safeBuildApiLink('profile-posts/comments', $profilePost, array('comment_id' => $comment['profile_post_comment_id'])), 'profile_post' => bdApi_Data_Helper_Core::safeBuildApiLink('profile-posts', $profilePost), 'timeline' => bdApi_Data_Helper_Core::safeBuildApiLink('users/timeline', $user), 'timeline_user' => bdApi_Data_Helper_Core::safeBuildApiLink('users', $user), 'poster' => bdApi_Data_Helper_Core::safeBuildApiLink('users', $comment), 'poster_avatar' => XenForo_Template_Helper_Core::callHelper('avatar', array($comment, 'm', false, true)));
     $data['permissions'] = array('view' => $this->canViewProfilePost($profilePost, $user), 'delete' => $this->canDeleteProfilePostComment($comment, $profilePost, $user));
     return $data;
 }
Пример #4
0
 public function prepareApiDataForLinkForum(array $linkForum)
 {
     $publicKeys = array('node_id' => 'link_id', 'title' => 'link_title', 'description' => 'link_description');
     $data = bdApi_Data_Helper_Core::filter($linkForum, $publicKeys);
     if (!empty($linkForum['link_url'])) {
         $linkUrl = $linkForum['link_url'];
     } else {
         $linkUrl = XenForo_Link::buildPublicLink('link-forums', $linkForum);
     }
     $data['links']['target'] = $linkUrl;
     $data['permissions'] = array('view' => $this->canViewLinkForum($linkForum), 'edit' => XenForo_Visitor::getInstance()->hasAdminPermission('node'), 'delete' => XenForo_Visitor::getInstance()->hasAdminPermission('node'));
     return $data;
 }
Пример #5
0
 public function prepareApiDataForPoll(array $poll, $canVote)
 {
     $poll = $this->preparePoll($poll, $canVote);
     $publicKeys = array('poll_id' => 'poll_id', 'question' => 'poll_question', 'voter_count' => 'poll_vote_count', 'max_votes' => 'poll_max_votes', 'open' => 'poll_is_open', 'hasVoted' => 'poll_is_voted');
     $data = bdApi_Data_Helper_Core::filter($poll, $publicKeys);
     $data['responses'] = array();
     foreach ($poll['responses'] as $responseId => $response) {
         $responseData = array('response_id' => $responseId, 'response_answer' => $response['response']);
         if (!empty($data['poll_is_voted'])) {
             $responseData['response_is_voted'] = $response['hasVoted'];
         }
         $data['responses'][] = $responseData;
     }
     $data['permissions'] = array('vote' => $poll['canVote'], 'result' => $poll['canViewResults']);
     return $data;
 }
Пример #6
0
 public function prepareApiDataForForum(array $forum)
 {
     if (!empty($forum['node_permission_cache'])) {
         XenForo_Visitor::getInstance()->setNodePermissions($forum['node_id'], $forum['node_permission_cache']);
     }
     $publicKeys = array('node_id' => 'forum_id', 'title' => 'forum_title', 'description' => 'forum_description', 'discussion_count' => 'forum_thread_count', 'message_count' => 'forum_post_count');
     $data = bdApi_Data_Helper_Core::filter($forum, $publicKeys);
     $data['links'] = array('permalink' => XenForo_Link::buildPublicLink('forums', $forum), 'detail' => bdApi_Data_Helper_Core::safeBuildApiLink('forums', $forum), 'sub-categories' => bdApi_Data_Helper_Core::safeBuildApiLink('categories', array(), array('parent_forum_id' => $forum['node_id'])), 'sub-forums' => bdApi_Data_Helper_Core::safeBuildApiLink('forums', array(), array('parent_forum_id' => $forum['node_id'])), 'threads' => bdApi_Data_Helper_Core::safeBuildApiLink('threads', array(), array('forum_id' => $forum['node_id'])));
     $data['permissions'] = array('view' => $this->canViewForum($forum), 'edit' => XenForo_Visitor::getInstance()->hasAdminPermission('node'), 'delete' => XenForo_Visitor::getInstance()->hasAdminPermission('node'), 'create_thread' => $this->canPostThreadInForum($forum), 'upload_attachment' => $this->canUploadAndManageAttachment($forum));
     if (XenForo_Application::$versionId >= 1020000) {
         $data['forum_is_followed'] = !empty($forum['forum_is_watched']);
         $data['links']['followers'] = bdApi_Data_Helper_Core::safeBuildApiLink('forums/followers', $forum);
         $data['permissions']['follow'] = $this->canWatchForum($forum);
     }
     return $data;
 }
Пример #7
0
 public function prepareApiDataForField(array $field, $fieldValue = null)
 {
     $field = $this->prepareUserField($field, true, $fieldValue);
     $data = array();
     $publicKeys = array('title' => 'title', 'description' => 'description', 'display_group' => 'display_group');
     if (!empty($field['isChoice'])) {
         $publicKeys['fieldChoices'] = 'choices';
         $data['is_multi_choice'] = !empty($field['isMultiChoice']);
     }
     $data += bdApi_Data_Helper_Core::filter($field, $publicKeys);
     $data['is_required'] = !empty($field['required']);
     if (!empty($data['choices'])) {
         $choices = array();
         foreach ($data['choices'] as $key => $value) {
             $choices[] = array('key' => strval($key), 'value' => strval($value));
         }
         $data['choices'] = $choices;
     }
     if ($fieldValue !== null) {
         if (!empty($data['choices'])) {
             // choices
             if (is_array($field['field_value'])) {
                 // array
                 $fieldValueIds = array_keys($field['field_value']);
             } else {
                 // single
                 $fieldValueIds = array($field['field_value']);
             }
             $data['values'] = array();
             foreach ($fieldValueIds as $fieldValueId) {
                 $choiceValue = null;
                 foreach ($data['choices'] as $choice) {
                     if ($choice['key'] == $fieldValueId) {
                         $choiceValue = $choice['value'];
                     }
                 }
                 if ($choiceValue !== null) {
                     $data['values'][] = array('key' => strval($fieldValueId), 'value' => $choiceValue);
                 }
             }
         } else {
             // text
             $data['value'] = $field['field_value'];
         }
     }
     return $data;
 }
Пример #8
0
 public function prepareApiDataForThread(array $thread, array $forum, array $firstPost)
 {
     /* @var $postModel bdApi_XenForo_Model_Post */
     $postModel = $this->_getPostModel();
     $thread = $this->prepareThread($thread, $forum);
     $publicKeys = array('thread_id' => 'thread_id', 'node_id' => 'forum_id', 'title' => 'thread_title', 'view_count' => 'thread_view_count', 'user_id' => 'creator_user_id', 'username' => 'creator_username', 'post_date' => 'thread_create_date', 'last_post_date' => 'thread_update_date');
     $data = bdApi_Data_Helper_Core::filter($thread, $publicKeys);
     if (isset($thread['reply_count'])) {
         $data['thread_post_count'] = $thread['reply_count'] + 1;
     }
     if (isset($thread['sticky']) and isset($thread['discussion_state'])) {
         switch ($thread['discussion_state']) {
             case 'visible':
                 $data['thread_is_published'] = true;
                 $data['thread_is_deleted'] = false;
                 $data['thread_is_sticky'] = empty($thread['sticky']) ? false : true;
                 break;
             case 'moderated':
                 $data['thread_is_published'] = false;
                 $data['thread_is_deleted'] = false;
                 $data['thread_is_sticky'] = false;
                 break;
             case 'deleted':
                 $data['thread_is_published'] = false;
                 $data['thread_is_deleted'] = true;
                 $data['thread_is_sticky'] = false;
                 break;
         }
     }
     $data['thread_is_followed'] = !empty($thread['thread_is_watched']);
     if (!empty($firstPost)) {
         $data['first_post'] = $postModel->prepareApiDataForPost($firstPost, $thread, $forum);
     }
     $data['links'] = array('permalink' => XenForo_Link::buildPublicLink('threads', $thread), 'detail' => bdApi_Data_Helper_Core::safeBuildApiLink('threads', $thread), 'followers' => bdApi_Data_Helper_Core::safeBuildApiLink('threads/followers', $thread), 'forum' => bdApi_Data_Helper_Core::safeBuildApiLink('forums', $thread), 'posts' => bdApi_Data_Helper_Core::safeBuildApiLink('posts', array(), array('thread_id' => $thread['thread_id'])), 'first_poster' => bdApi_Data_Helper_Core::safeBuildApiLink('users', $thread), 'first_post' => bdApi_Data_Helper_Core::safeBuildApiLink('posts', array('post_id' => $thread['first_post_id'])));
     if ($thread['last_post_user_id'] != $thread['user_id']) {
         $data['links']['last_poster'] = bdApi_Data_Helper_Core::safeBuildApiLink('users', array('user_id' => $thread['last_post_user_id'], 'username' => $thread['last_post_username']));
     }
     if ($thread['last_post_id'] != $thread['first_post_id']) {
         $data['links']['last_post'] = bdApi_Data_Helper_Core::safeBuildApiLink('posts', array('post_id' => $thread['last_post_id']));
     }
     $data['permissions'] = array('view' => $this->canViewThread($thread, $forum), 'edit' => $this->canEditThread($thread, $forum), 'delete' => $this->canDeleteThread($thread, $forum), 'follow' => $this->canWatchThread($thread, $forum), 'post' => $this->canReplyToThread($thread, $forum), 'upload_attachment' => $this->_getForumModel()->canUploadAndManageAttachment($forum));
     return $data;
 }
Пример #9
0
 public function prepareApiDataForThread(array $thread, array $forum, array $firstPost)
 {
     $thread = $this->prepareThread($thread, $forum);
     $publicKeys = array('thread_id' => 'thread_id', 'node_id' => 'forum_id', 'title' => 'thread_title', 'view_count' => 'thread_view_count', 'user_id' => 'creator_user_id', 'username' => 'creator_username', 'post_date' => 'thread_create_date', 'last_post_date' => 'thread_update_date');
     $data = bdApi_Data_Helper_Core::filter($thread, $publicKeys);
     $data['user_is_ignored'] = XenForo_Visitor::getInstance()->isIgnoring($thread['user_id']);
     if (isset($thread['reply_count'])) {
         $data['thread_post_count'] = $thread['reply_count'] + 1;
     }
     if (isset($thread['sticky']) and isset($thread['discussion_state'])) {
         switch ($thread['discussion_state']) {
             case 'visible':
                 $data['thread_is_published'] = true;
                 $data['thread_is_deleted'] = false;
                 $data['thread_is_sticky'] = empty($thread['sticky']) ? false : true;
                 break;
             case 'moderated':
                 $data['thread_is_published'] = false;
                 $data['thread_is_deleted'] = false;
                 $data['thread_is_sticky'] = false;
                 break;
             case 'deleted':
                 $data['thread_is_published'] = false;
                 $data['thread_is_deleted'] = true;
                 $data['thread_is_sticky'] = false;
                 break;
         }
     }
     $data['thread_is_followed'] = !empty($thread['thread_is_watched']);
     if (!empty($firstPost)) {
         /* @var $postModel bdApi_Extend_Model_Post */
         $postModel = $this->_getPostModel();
         $data['first_post'] = $postModel->prepareApiDataForPost($firstPost, $thread, $forum);
     }
     if ($thread['discussion_type'] === 'poll' && isset($this->_bdApi_polls[$thread['thread_id']])) {
         $poll = $this->_bdApi_polls[$thread['thread_id']];
         /** @var bdApi_Extend_Model_Poll $pollModel */
         $pollModel = $this->getModelFromCache('XenForo_Model_Poll');
         $data['poll'] = $pollModel->prepareApiDataForPoll($poll, $this->canVoteOnPoll($poll, $thread, $forum));
         $data['poll']['links']['vote'] = bdApi_Data_Helper_Core::safeBuildApiLink('threads/poll/votes', $thread);
         $data['poll']['links']['results'] = bdApi_Data_Helper_Core::safeBuildApiLink('threads/poll/results', $thread);
     }
     if (XenForo_Application::$versionId > 1050000 && isset($thread['tags'])) {
         $tags = @unserialize($thread['tags']);
         if (is_array($tags)) {
             /** @var bdApi_Extend_Model_Tag $tagModel */
             $tagModel = $this->getModelFromCache('XenForo_Model_Tag');
             $data['thread_tags'] = $tagModel->prepareApiDataForTags($tags);
         }
     }
     $data['links'] = array('permalink' => XenForo_Link::buildPublicLink('threads', $thread), 'detail' => bdApi_Data_Helper_Core::safeBuildApiLink('threads', $thread), 'followers' => bdApi_Data_Helper_Core::safeBuildApiLink('threads/followers', $thread), 'forum' => bdApi_Data_Helper_Core::safeBuildApiLink('forums', $thread), 'posts' => bdApi_Data_Helper_Core::safeBuildApiLink('posts', array(), array('thread_id' => $thread['thread_id'])), 'first_poster' => bdApi_Data_Helper_Core::safeBuildApiLink('users', $thread), 'first_post' => bdApi_Data_Helper_Core::safeBuildApiLink('posts', array('post_id' => $thread['first_post_id'])));
     if ($thread['last_post_user_id'] != $thread['user_id']) {
         $data['links']['last_poster'] = bdApi_Data_Helper_Core::safeBuildApiLink('users', array('user_id' => $thread['last_post_user_id'], 'username' => $thread['last_post_username']));
     }
     if ($thread['last_post_id'] != $thread['first_post_id']) {
         $data['links']['last_post'] = bdApi_Data_Helper_Core::safeBuildApiLink('posts', array('post_id' => $thread['last_post_id']));
     }
     $data['permissions'] = array('view' => $this->canViewThread($thread, $forum), 'delete' => $this->canDeleteThread($thread, $forum), 'follow' => $this->canWatchThread($thread, $forum), 'post' => $this->canReplyToThread($thread, $forum), 'upload_attachment' => $this->_getForumModel()->canUploadAndManageAttachment($forum));
     if (!empty($firstPost)) {
         $data['permissions']['edit'] = $this->_getPostModel()->canEditPost($firstPost, $thread, $forum);
         if (!empty($data['permissions']['edit'])) {
             $data['permissions']['edit_title'] = $this->canEditThread($thread, $forum);
             if (XenForo_Application::$versionId > 1050000) {
                 $data['permissions']['edit_tags'] = $this->canEditTags($thread, $forum);
             }
         }
     }
     return $data;
 }
Пример #10
0
 public function prepareApiDataForAttachment(array $attachment, array $post, array $thread, array $forum, $tempHash = '')
 {
     /* @var $attachmentModel XenForo_Model_Attachment */
     $attachmentModel = $this->getModelFromCache('XenForo_Model_Attachment');
     $attachment = $attachmentModel->prepareAttachment($attachment);
     $publicKeys = array('attachment_id' => 'attachment_id', 'content_id' => 'post_id', 'view_count' => 'attachment_download_count', 'filename' => 'filename');
     $data = bdApi_Data_Helper_Core::filter($attachment, $publicKeys);
     $paths = XenForo_Application::get('requestPaths');
     $paths['fullBasePath'] = XenForo_Application::getOptions()->get('boardUrl') . '/';
     $data['links'] = array('permalink' => XenForo_Link::buildPublicLink('attachments', $attachment));
     if (!empty($attachment['thumbnailUrl'])) {
         $data['links']['thumbnail'] = XenForo_Link::convertUriToAbsoluteUri($attachment['thumbnailUrl'], true, $paths);
     }
     if (!empty($post['post_id'])) {
         $data['links'] += array('data' => bdApi_Data_Helper_Core::safeBuildApiLink('posts/attachments', $post, array('attachment_id' => $attachment['attachment_id'])), 'post' => bdApi_Data_Helper_Core::safeBuildApiLink('posts', $post));
     }
     $data['permissions'] = array('view' => !empty($tempHash) ? $attachmentModel->canViewAttachment($attachment, $tempHash) : $this->canViewAttachmentOnPost($post, $thread, $forum), 'delete' => !empty($tempHash) ? $attachmentModel->canDeleteAttachment($attachment, $tempHash) : $this->canEditPost($post, $thread, $forum));
     if (isset($post['messageHtml'])) {
         $data['attachment_is_inserted'] = empty($post['attachments'][$attachment['attachment_id']]);
     }
     return $data;
 }
Пример #11
0
 public function prepareApiDataForUser(array $user)
 {
     $visitor = XenForo_Visitor::getInstance();
     $session = bdApi_Data_Helper_Core::safeGetSession();
     /* @var $userGroupModel bdApi_XenForo_Model_UserGroup */
     $userGroupModel = $this->getModelFromCache('XenForo_Model_UserGroup');
     /* @var $conversationModel XenForo_Model_Conversation */
     $conversationModel = $this->getModelFromCache('XenForo_Model_Conversation');
     $hasAdminScope = !empty($session) && $session->checkScope(bdApi_Model_OAuth2::SCOPE_MANAGE_SYSTEM);
     $isAdminRequest = $hasAdminScope && $visitor->hasAdminPermission('user');
     $prepareProtectedData = $user['user_id'] == $visitor->get('user_id') || $isAdminRequest;
     $publicKeys = array('user_id' => 'user_id', 'username' => 'username', 'message_count' => 'user_message_count', 'register_date' => 'user_register_date', 'like_count' => 'user_like_count');
     if ($prepareProtectedData) {
         $publicKeys = array_merge($publicKeys, array('email' => 'user_email', 'alerts_unread' => 'user_unread_notification_count', 'dob_day' => 'user_dob_day', 'dob_month' => 'user_dob_month', 'dob_year' => 'user_dob_year'));
         if (!empty($session) and $session->checkScope(bdApi_Model_OAuth2::SCOPE_PARTICIPATE_IN_CONVERSATIONS)) {
             // xf_user
             $publicKeys['conversations_unread'] = 'user_unread_conversation_count';
         }
     }
     $data = bdApi_Data_Helper_Core::filter($user, $publicKeys);
     $data['user_title'] = XenForo_Template_Helper_Core::helperUserTitle($user);
     if (isset($user['user_state']) and isset($user['is_banned'])) {
         if (!empty($user['is_banned'])) {
             $data['user_is_valid'] = false;
             $data['user_is_verified'] = true;
         } else {
             switch ($user['user_state']) {
                 case 'valid':
                     $data['user_is_valid'] = true;
                     $data['user_is_verified'] = true;
                     break;
                 case 'email_confirm':
                 case 'email_confirm_edit':
                     $data['user_is_valid'] = true;
                     $data['user_is_verified'] = false;
                     break;
                 case 'moderated':
                     $data['user_is_valid'] = false;
                     $data['user_is_verified'] = false;
                     break;
             }
         }
     }
     $data['user_is_followed'] = !empty($user['bdapi_user_is_followed']);
     if ($this->canViewUserCurrentActivity($user)) {
         $data['user_last_seen_date'] = $user['last_activity'];
     } else {
         // user hides his/her activity, use the register date value instead
         // (IMHO using 0 will make it too obvious that activity is hidden)
         $data['user_last_seen_date'] = $user['register_date'];
     }
     $data['links'] = array('permalink' => XenForo_Link::buildPublicLink('members', $user), 'detail' => bdApi_Data_Helper_Core::safeBuildApiLink('users', $user), 'avatar' => XenForo_Template_Helper_Core::callHelper('avatar', array($user, 'm', false, true)), 'avatar_big' => XenForo_Template_Helper_Core::callHelper('avatar', array($user, 'l', false, true)), 'avatar_small' => XenForo_Template_Helper_Core::callHelper('avatar', array($user, 's', false, true)), 'followers' => bdApi_Data_Helper_Core::safeBuildApiLink('users/followers', $user), 'followings' => bdApi_Data_Helper_Core::safeBuildApiLink('users/followings', $user), 'ignore' => bdApi_Data_Helper_Core::safeBuildApiLink('users/ignore', $user));
     $data['permissions'] = array('edit' => $prepareProtectedData, 'follow' => $user['user_id'] != $visitor->get('user_id') && $visitor->canFollow());
     /** @var XenForo_Model_UserIgnore $ignoreModel */
     $ignoreModel = $this->getModelFromCache('XenForo_Model_UserIgnore');
     $data['permissions']['ignore'] = $ignoreModel->canIgnoreUser($visitor->get('user_id'), $user);
     $data['user_is_ignored'] = $visitor->isIgnoring($user['user_id']);
     $data['user_is_visitor'] = $user['user_id'] == $visitor->get('user_id');
     if ($prepareProtectedData) {
         if (isset($user['timezone'])) {
             $dtz = new DateTimeZone($user['timezone']);
             $dt = new DateTime('now', $dtz);
             $data['user_timezone_offset'] = $dtz->getOffset($dt);
         }
         $auth = $this->getUserAuthenticationObjectByUserId($user['user_id']);
         $data['user_has_password'] = $auth->hasPassword();
         $data['user_fields'] = $this->prepareApiDataForUserFields($user);
         $thisUserGroups = array();
         $userGroups = $userGroupModel->bdApi_getAllUserGroupsCached();
         foreach ($userGroups as $userGroup) {
             if ($this->isMemberOfUserGroup($user, $userGroup['user_group_id'])) {
                 $thisUserGroups[] = $userGroup;
             }
         }
         $data['user_groups'] = $userGroupModel->prepareApiDataForUserGroups($thisUserGroups);
         foreach ($data['user_groups'] as &$userGroupRef) {
             if ($userGroupRef['user_group_id'] == $user['user_group_id']) {
                 $userGroupRef['is_primary_group'] = true;
             } else {
                 $userGroupRef['is_primary_group'] = false;
             }
         }
         $data['self_permissions'] = array('create_conversation' => $conversationModel->canStartConversations(), 'upload_attachment_conversation' => $conversationModel->canUploadAndManageAttachment());
         $data['edit_permissions'] = array('password' => true, 'user_email' => true, 'username' => false, 'user_title' => false, 'primary_group_id' => false, 'secondary_group_ids' => false, 'user_dob_day' => false, 'user_dob_month' => false, 'user_dob_year' => false, 'user_fields' => true);
         if ($isAdminRequest) {
             $data['edit_permissions'] = array_merge($data['edit_permissions'], array('username' => true, 'user_title' => true, 'primary_group_id' => true, 'secondary_group_ids' => true));
         }
         if (empty($data['user_dob_day']) && empty($data['user_dob_month']) && empty($data['user_dob_year']) || $isAdminRequest) {
             $data['edit_permissions'] = array_merge($data['edit_permissions'], array('user_dob_day' => true, 'user_dob_month' => true, 'user_dob_year' => true));
         }
     }
     /** @var XenForo_Model_UserProfile $userProfileModel */
     $userProfileModel = $this->getModelFromCache('XenForo_Model_UserProfile');
     if ($userProfileModel->canViewProfilePosts($user)) {
         $data['links']['timeline'] = bdApi_Data_Helper_Core::safeBuildApiLink('users/timeline', $user);
         if ($user['user_id'] == $visitor->get('user_id')) {
             $data['permissions']['profile_post'] = $visitor->canUpdateStatus();
         } else {
             $data['permissions']['profile_post'] = $userProfileModel->canPostOnProfile($user);
         }
     }
     return $data;
 }
Пример #12
0
 public function prepareApiDataForAlert(array $alert)
 {
     $publicKeys = array('alert_id' => 'notification_id', 'event_date' => 'notification_create_date', 'user_id' => 'creator_user_id', 'username' => 'creator_username', 'unviewed' => 'notification_is_unread');
     $data = bdApi_Data_Helper_Core::filter($alert, $publicKeys);
     if (!empty($alert['user'])) {
         $data['creator_user_id'] = $alert['user']['user_id'];
         $data['creator_username'] = $alert['user']['username'];
     }
     if (!empty($alert['content_type']) and !empty($alert['content_id']) and !empty($alert['action'])) {
         $data['notification_type'] = sprintf('%s_%d_%s', $alert['content_type'], $alert['content_id'], $alert['action']);
     }
     $data['links'] = array('content' => bdApi_Data_Helper_Core::safeBuildApiLink('notifications/content', null, array('notification_id' => $alert['alert_id'])));
     if (!empty($alert['user'])) {
         $data['links']['creator_avatar'] = XenForo_Template_Helper_Core::callHelper('avatar', array($alert['user'], 'm', false, true));
     }
     return $data;
 }
Пример #13
0
 public function prepareApiDataForUserGroup(array $userGroup)
 {
     $publicKeys = array('user_group_id' => 'user_group_id', 'title' => 'user_group_title');
     $data = bdApi_Data_Helper_Core::filter($userGroup, $publicKeys);
     return $data;
 }