public function prepareParams() { if (!empty($this->_params['_user']['user_id'])) { call_user_func_array(array('bdApi_ViewApi_Helper_Subscription', 'prepareDiscoveryParams'), array(&$this->_params, $this->_response, bdApi_Model_Subscription::TYPE_USER, $this->_params['_user']['user_id'], XenForo_Link::buildApiLink('users', $this->_params['_user'], array('oauth_token' => '')), isset($this->_params['_user']['bdapi_user']) ? $this->_params['_user']['bdapi_user'] : '')); } parent::prepareParams(); }
public function prepareParams() { if (!empty($this->_params['_thread']['thread_id'])) { call_user_func_array(array('bdApi_ViewApi_Helper_Subscription', 'prepareDiscoveryParams'), array(&$this->_params, $this->_response, bdApi_Model_Subscription::TYPE_THREAD_POST, $this->_params['_thread']['thread_id'], XenForo_Link::buildApiLink('posts', null, array('thread_id' => $this->_params['_thread']['thread_id'], 'oauth_token' => '')), isset($this->_params['_thread']['bdapi_thread_post']) ? $this->_params['_thread']['bdapi_thread_post'] : '')); } parent::prepareParams(); }
public static function prepareDiscoveryParams(array &$params, Zend_Controller_Response_Http $response, $topicType, $topicId, $selfLink, $subscriptionOption) { if (!bdApi_Option::getSubscription($topicType)) { // subscription for this topic type has been disabled return false; } // subscription discovery $hubLink = XenForo_Link::buildApiLink('subscriptions', null, array('hub.topic' => bdApi_Model_Subscription::getTopic($topicType, $topicId), 'oauth_token' => '')); $response->setHeader('Link', sprintf('<%s>; rel=hub', $hubLink)); $response->setHeader('Link', sprintf('<%s>; rel=self', $selfLink)); // subscription info if (!empty($subscriptionOption)) { $subscriptionOption = @unserialize($subscriptionOption); if (!empty($subscriptionOption['subscriptions'])) { /* @var $session bdApi_Session */ $session = XenForo_Application::getSession(); $clientId = $session->getOAuthClientId(); foreach ($subscriptionOption['subscriptions'] as $subscription) { if ($subscription['client_id'] == $clientId) { $params['subscription_callback'] = $subscription['callback']; } } } } return true; }
public function prepareParams() { // render notification html $notifications =& $this->_params['notifications']; $templates = bdApi_ViewApi_Helper_Alert::getTemplates($this, $this->_params['_alerts'], $this->_params['_alertHandlers']); foreach ($notifications as $key => &$notification) { $notification['notification_html'] = $templates[$notification['notification_id']]['template']; } call_user_func_array(array('bdApi_ViewApi_Helper_Subscription', 'prepareDiscoveryParams'), array(&$this->_params, $this->_response, bdApi_Model_Subscription::TYPE_NOTIFICATION, XenForo_Visitor::getUserId(), XenForo_Link::buildApiLink('notifications', null, array('oauth_token' => '')), XenForo_Visitor::getInstance()->get('bdapi_user_notification'))); parent::prepareParams(); }
public function actionGetIndex() { /* @var $session bdApi_Session */ $session = XenForo_Application::getSession(); $systemInfo = array(); if ($session->checkScope(bdApi_Model_OAuth2::SCOPE_POST)) { $systemInfo = array('api_revision' => 2014030701, 'api_modules' => $this->_getModules()); } $data = array('links' => array('conversations' => XenForo_Link::buildApiLink('conversations'), 'conversation-messages' => XenForo_Link::buildApiLink('conversation-messages'), 'notifications' => XenForo_Link::buildApiLink('notifications'), 'search' => XenForo_Link::buildApiLink('search'), 'navigation' => XenForo_Link::buildApiLink('navigation', array(), array('parent' => 0)), 'threads' => XenForo_Link::buildApiLink('threads'), 'threads/recent' => XenForo_Link::buildApiLink('threads/recent'), 'threads/new' => XenForo_Link::buildApiLink('threads/new'), 'posts' => XenForo_Link::buildApiLink('posts'), 'users' => XenForo_Link::buildApiLink('users'), 'batch' => XenForo_Link::buildApiLink('batch'), 'subscriptions' => XenForo_Link::buildApiLink('subscriptions'), 'oauth_authorize' => XenForo_Link::buildApiLink('oauth/authorize', array(), array('oauth_token' => '')), 'oauth_token' => XenForo_Link::buildApiLink('oauth/token', array(), array('oauth_token' => ''))), 'system_info' => $systemInfo); return $this->responseData('bdApi_ViewApi_Index', $data); }
public function actionGetSdk() { $prefix = $this->_input->filterSingle('prefix', XenForo_Input::STRING); $prefix = preg_replace('/[^a-zA-Z0-9]/', '', $prefix); $sdkPath = XenForo_Autoloader::getInstance()->getRootDir() . '/../js/bdApi/full/sdk.js'; $sdk = file_get_contents($sdkPath); $sdk = str_replace('{prefix}', $prefix, $sdk); $sdk = str_replace('{data_uri}', XenForo_Link::buildPublicLink('canonical:misc/api-data'), $sdk); $sdk = str_replace('{request_uri}', XenForo_Link::buildApiLink('index'), $sdk); header('Content-Type: application/x-javascript; charset=utf-8'); header('Cache-Control: public, max-age=31536000'); header(sprintf('Last-Modified: %s', gmstrftime("%a, %d %b %Y %T %Z", filemtime($sdkPath)))); die($sdk); }
protected function _arrangeElements(array &$elements, array &$nodesGrouped, $parentNodeId, array &$options = array()) { foreach ($nodesGrouped as $_parentNodeId => $nodes) { if ($parentNodeId != $_parentNodeId) { continue; } foreach ($nodes as $node) { $element = false; switch ($node['node_type_id']) { case 'Category': $element = $this->_getCategoryModel()->prepareApiDataForCategory($node); break; case 'Forum': if (!empty($options['forums'][$node['node_id']])) { $element = $this->_getForumModel()->prepareApiDataForForum($options['forums'][$node['node_id']]); } break; case 'LinkForum': $element = $this->_getLinkForumModel()->prepareApiDataForLinkForum($node); break; } if (!empty($element)) { $element['navigation_type'] = strtolower($node['node_type_id']); $element['navigation_id'] = $node['node_id']; $element['navigation_parent_id'] = $node['parent_node_id']; $element['has_sub_elements'] = !empty($nodesGrouped[$node['node_id']]); if ($element['has_sub_elements']) { if (empty($element['links'])) { $element['links'] = array(); } $element['links']['sub-elements'] = XenForo_Link::buildApiLink('navigation', '', array('parent' => $element['navigation_id'])); } $elements[] = $element; if ($element['has_sub_elements'] && !is_int($options['expectedParentNodeId'])) { $this->_arrangeElements($elements, $nodesGrouped, intval($node['node_id']), $options); } } } } }
/** * Builds and adds the navigation for api data * * @param XenForo_Input $input * @param array $data * @param int $perPage * @param int $totalItems * @param int $page * @param string $linkType * @param mixed $linkData * @param array $linkParams * @param array $options */ public static function addPageLinks(XenForo_Input $input, array &$data, $perPage, $totalItems, $page, $linkType, $linkData = null, array $linkParams = array(), array $options = array()) { if (empty($perPage)) { return; } $pageNav = array(); $inputData = $input->filter(array('fields_include' => XenForo_Input::STRING, 'fields_exclude' => XenForo_Input::STRING)); if (!empty($inputData['fields_include'])) { $linkParams['fields_include'] = $inputData['fields_include']; } elseif (!empty($inputData['fields_exclude'])) { $linkParams['fields_exclude'] = $inputData['fields_exclude']; } if (empty($page)) { $page = 1; } $pageNav['pages'] = ceil($totalItems / $perPage); if ($pageNav['pages'] <= 1) { // do not do anything if there is only 1 page (or no pages) return; } $pageNav['page'] = $page; if ($page > 1) { // a previous link should only be added if we are not at page 1 $pageNav['prev'] = XenForo_Link::buildApiLink($linkType, $linkData, array_merge($linkParams, array('page' => $page - 1))); } if ($page < $pageNav['pages']) { // a next link should only be added if we are not at the last page $pageNav['next'] = XenForo_Link::buildApiLink($linkType, $linkData, array_merge($linkParams, array('page' => $page + 1))); } // add the page navigation into `links` // the data may have existing links or not // we simply don't care if (empty($data['links'])) { $data['links'] = array(); } $data['links'] = array_merge($data['links'], $pageNav); }
public function actionGetIndex() { $data = array('links' => array('posts' => XenForo_Link::buildApiLink('search/posts'), 'threads' => XenForo_Link::buildApiLink('search/threads'), 'profile-posts' => XenForo_Link::buildApiLink('search/profile-posts'))); return $this->responseData('bdApi_ViewApi_Index', $data); }
public function actionPostPassword() { $link = XenForo_Link::buildApiLink('users', array('user_id' => $this->_input->filterSingle('user_id', XenForo_Input::UINT))); $this->_setDeprecatedHeaders('PUT', $link); return $this->responseReroute(__CLASS__, 'put-index'); }