Beispiel #1
0
 /** constructor needs to check for valid data and set the arguments.
  *
  *	@param	mixed
  * 	@param	mixed
  * 	@param	string
  **/
 public function __construct($routeInfo, $matches, $queryString = '', $anchor = '')
 {
     parent::__construct($routeInfo, $matches, $queryString = '', $anchor);
     if (!empty($matches)) {
         foreach ($matches as $key => $match) {
             //if we were passed routeInfo, skip it.
             if ($key == 'nodeid') {
                 $this->arguments['nodeid'] = $routeInfo['arguments']['nodeid'] = $match;
             } else {
                 if ($key == self::$actionKey) {
                     $action = explode('/', $match);
                     $this->arguments[self::$actionKey] = $routeInfo['arguments'][self::$actionKey] = $action[0];
                     if (count($action) > 1) {
                         $this->arguments['action2'] = $routeInfo['arguments']['action2'] = $action[1];
                     }
                 } else {
                     if ($key == 'action2') {
                         $this->arguments['action2'] = $routeInfo['arguments']['action2'] = $match;
                     }
                 }
             }
         }
     }
     //check for valid input.
     if (!self::validInput($routeInfo['arguments'])) {
         throw new vB_Exception_404('upload_invalid_url');
     }
 }
Beispiel #2
0
 public function __construct($routeInfo = array(), $matches = array(), $queryString = '')
 {
     if (!empty($routeInfo)) {
         parent::__construct($routeInfo, $matches, $queryString);
     } else {
         // We are not parsing the route
         $this->arguments = array();
     }
 }
Beispiel #3
0
 public function __construct($routeInfo, $matches, $queryString = '', $anchor = '')
 {
     parent::__construct($routeInfo, $matches, $queryString, $anchor);
     $this->setPageKey('pageid', 'userid');
     //this is a bad place for this... since it will get called whenever a route class is loaded and not just when the
     //user goes to the profile page.
     if (!empty($this->arguments['username'])) {
         $this->setUserAction('viewing_user_profile', $this->arguments['username'], $this->getFullUrl('fullurl'));
     }
 }
Beispiel #4
0
 public function __construct($routeInfo, $matches, $queryString = '', $anchor = '')
 {
     parent::__construct($routeInfo, $matches, $queryString, $anchor);
     if (isset($this->arguments['pageid']) and !empty($this->arguments['pageid'])) {
         $this->setPageKey('pageid');
         $page = $this->getPage();
         if ($page) {
             switch ($page['guid']) {
                 case vB_Page::PAGE_SOCIALGROUP:
                     $this->checkStyle(vB_Channel::DEFAULT_SOCIALGROUP_PARENT);
                     break;
                 case vB_Page::PAGE_BLOG:
                     $this->setUserAction('viewing_blog_home');
                     $this->checkStyle(vB_Channel::DEFAULT_BLOG_PARENT);
                     break;
                 case vB_Page::PAGE_ONLINE:
                 case vB_Page::PAGE_MEMBERLIST:
                     $this->setUserAction('viewing_whos_online');
                     break;
                 case vB_Page::PAGE_SEARCH:
                 case vB_Page::PAGE_SEARCHRESULT:
                     $this->setUserAction('searching_forums');
                     break;
                 case vB_Page::PAGE_HOME:
                 default:
                     // TODO: should pages have a link by default?
                     $this->setUserAction('viewing_x', $page['title'], $this->getFullUrl('fullurl'));
             }
         }
     }
     // RSS for channel pages (blog, group). Assuming that if a channelid argument is set, it's a channel
     // and the RSS xml exporter can create one for this. This should also set head links
     if (isset($this->arguments['channelid'])) {
         $channel = vB_Library::instance('Content_Channel')->getBareContent($this->arguments['channelid']);
         if (is_array($channel)) {
             $channel = array_pop($channel);
         }
         if ($channel['rss_enabled']) {
             $this->arguments['rss_enabled'] = $channel['rss_enabled'];
             $this->arguments['rss_route'] = $channel['rss_route'];
             $this->arguments['rss_title'] = $channel['title'];
             // because conversation routes also add their parent channel's rss info into the arguments,
             // this flag helps us tell channels apart from conversations when we're adding the RSS icon next to the page title
             $this->arguments['rss_show_icon_on_pagetitle'] = true;
         }
     }
 }
Beispiel #5
0
 public function __construct($routeInfo, $matches, $queryString = '', $anchor = '')
 {
     if (empty($matches['tab'])) {
         $matches['tab'] = 'profile';
     }
     parent::__construct($routeInfo, $matches, $queryString, $anchor);
     if (empty($this->arguments['userid'])) {
         $userInfo = vB::getCurrentSession()->fetch_userinfo();
         $this->arguments['userid'] = $userInfo['userid'];
         $this->arguments['username'] = $userInfo['username'];
     } else {
         if (empty($this->arguments['username'])) {
             $userInfo = vB_User::fetchUserinfo($this->arguments['userid']);
             $this->arguments['username'] = $userInfo['username'];
         }
     }
     $this->breadcrumbs = array(0 => array('title' => $this->arguments['username'], 'url' => vB5_Route::buildUrl('profile', array('userid' => $this->arguments['userid'], 'username' => vB_String::getUrlIdent($this->arguments['username'])))), 1 => array('phrase' => 'user_settings', 'url' => ''));
 }
Beispiel #6
0
 public function __construct($routeInfo, $matches, $queryString = '', $anchor = '')
 {
     parent::__construct($routeInfo, $matches, $queryString);
     if (isset($this->arguments['channelid'])) {
         if (!vB::getUserContext()->getChannelPermission('forumpermissions', 'canview', $this->arguments['channelid'])) {
             throw new vB_Exception_NodePermission($this->arguments['channelid']);
         }
         // check if we need to force a styleid
         $channel = vB_Library::instance('Content_Channel')->getBareContent($this->arguments['channelid']);
         if (is_array($channel)) {
             $channel = array_pop($channel);
         }
         if (!empty($channel['styleid'])) {
             $forumOptions = vB::getDatastore()->getValue('bf_misc_forumoptions');
             if ($channel['options']['styleoverride']) {
                 // the channel must force the style
                 $this->arguments['forceStyleId'] = $channel['styleid'];
             } else {
                 // the channel suggests to use this style
                 $this->arguments['routeStyleId'] = $channel['styleid'];
             }
         }
         if (!empty($this->queryParameters)) {
             $this->arguments['noindex'] = 1;
         }
         if (!empty($channel['description'])) {
             $this->arguments['nodedescription'] = $channel['description'];
         }
         // rss info
         $this->arguments['rss_enabled'] = $channel['rss_enabled'];
         $this->arguments['rss_route'] = $channel['rss_route'];
         $this->arguments['rss_title'] = $channel['title'];
         // because conversation routes also add their parent channel's rss info into the arguments,
         // this flag helps us tell channels apart from conversations when we're adding the RSS icon next to the page title
         $this->arguments['rss_show_icon_on_pagetitle'] = $channel['rss_enabled'];
         // styleid for channels are not final at this point, so let's not include them in the key
         $this->setPageKey('pageid', 'channelid');
         // set user action
         $this->setUserAction('viewing_forum_x', $channel['title'], $this->getFullUrl('fullurl'));
         // remove link from last crumb
         $this->breadcrumbs[count($this->breadcrumbs) - 1]['url'] = '';
     }
 }
 public function __construct($routeInfo, $matches, $queryString = '', $anchor = '')
 {
     parent::__construct($routeInfo, $matches, $queryString, $anchor);
     $this->arguments['userid'] = intval($this->arguments['userid']);
     $userInfo = vB_Api::instanceInternal('user')->fetchProfileInfo($this->arguments['userid']);
     if (empty($this->arguments['userid'])) {
         $this->arguments['userid'] = $userInfo['userid'];
         $this->arguments['username'] = $userInfo['username'];
     } else {
         if (empty($this->arguments['username'])) {
             $this->arguments['username'] = $userInfo['username'];
         }
     }
     if ($this->arguments['tab'] == 'subscriptions' and !$userInfo['showSubscriptions']) {
         throw new vB_Exception_NodePermission('subscriptions');
     } else {
         if ($this->arguments['tab'] == 'subscribers' and !$userInfo['showSubscribers']) {
             throw new vB_Exception_NodePermission('subscribers');
         }
     }
     $this->breadcrumbs = array(0 => array('title' => $this->arguments['username'], 'url' => vB5_Route::buildUrl('profile', array('userid' => $this->arguments['userid'], 'username' => vB_String::getUrlIdent($this->arguments['username'])))), 1 => array('phrase' => $this->arguments['tab'], 'url' => ''));
 }
Beispiel #8
0
 public function __construct($routeInfo, $matches, $queryString = '', $anchor = '')
 {
     parent::__construct($routeInfo, $matches, $queryString, $anchor);
     if (empty($matches['nodeid'])) {
         throw new vB_Exception_Router('invalid_request');
     } else {
         $routeInfo['nodeid'] = $matches['nodeid'];
         $this->nodeid = $matches['nodeid'];
         $this->arguments['nodeid'] = $matches['nodeid'];
         $this->arguments['contentid'] = $matches['nodeid'];
     }
     if (!empty($matches['title'])) {
         //It should start with a dash, which we can ignore
         $routeInfo['title'] = substr($matches['title'], 1);
         $this->arguments['title'] = substr($matches['title'], 1);
     }
     if (!empty($routeInfo['title'])) {
         $this->title = $routeInfo['title'];
     }
     $this->setPageKey('nodeid');
     $this->setUserAction('viewing_album');
 }
 public function __construct($routeInfo, $matches, $queryString = '', $anchor)
 {
     // if no action is defined, use index
     if (!isset($matches['action']) || empty($matches['action'])) {
         $matches['action'] = 'index';
     }
     // set action class
     $actionClassName = 'vB5_Route_PrivateMessage_' . ucfirst($matches['action']);
     $this->actionClass = new $actionClassName($routeInfo, $matches, $queryString);
     // Add action to arguments (required for rebuilding the URL for this action)
     $routeInfo['arguments']['action'] = $matches['action'];
     $this->actionInternal = $matches['action'];
     parent::__construct($routeInfo, $matches, $queryString, $anchor);
     // add action parameters to route arguments
     $actionParameters = $this->actionClass->getParameters();
     $this->arguments = empty($this->arguments) ? $actionParameters : array_merge($this->arguments, $actionParameters);
     // This might need to be changed into switch statement with cases that can be applied for different locations in the message center
     if (!empty($this->arguments['messageid'])) {
         $msgInfo = vB_Library::instance('node')->getNodeBare($actionParameters['messageid']);
         $senderUrl = vB5_Route::buildUrl('profile', $msgInfo);
         $this->setUserAction('viewing_private_message', $msgInfo['authorname'], $senderUrl);
     } else {
         $this->setUserAction('viewing_private_message');
     }
     // set breadcrumbs
     $this->breadcrumbs = $this->actionClass->getBreadcrumbs();
     // add querystring parameters for permalink (similar to vB5_Route_Conversation)
     if (!empty($matches['nodeid']) and $nodeId = intval($matches['nodeid']) and !empty($matches['innerPost']) and $innerPost = intval($matches['innerPost'])) {
         if ($innerPost != $nodeId) {
             // it's not the starter, either a reply or a comment
             $this->queryParameters['p'] = intval($matches['innerPost']);
             if (isset($matches['innerPostParent']) and $innerPostParent = intval($matches['innerPostParent']) and $nodeId != $innerPostParent) {
                 // it's a comment
                 $this->queryParameters['pp'] = $innerPostParent;
             }
         }
     }
 }
 public function __construct($routeInfo, $matches, $queryString = '', $anchor = '')
 {
     parent::__construct($routeInfo, $matches, $queryString, $anchor);
     if (empty($matches['nodeid'])) {
         throw new vB_Exception_Router('invalid_request');
     } else {
         $vmchannel = vB_Library::instance('node')->fetchVMChannel();
         if (!empty($vmchannel)) {
             $this->arguments['channelid'] = $vmchannel;
         }
         $routeInfo['nodeid'] = $matches['nodeid'];
         $this->arguments['nodeid'] = $matches['nodeid'];
         $this->arguments['contentid'] = $matches['nodeid'];
     }
     if (!empty($matches['title'])) {
         $routeInfo['title'] = $matches['title'];
         $this->arguments['title'] = $matches['title'];
     }
     $node = vB_Library::instance('node')->getNodeBare($this->arguments['nodeid']);
     if (!empty($routeInfo['title'])) {
         $this->arguments['title'] = vB_String::getUrlIdent($routeInfo['title']);
         // @TODO handle this in another way.
         $phrases = vB_Api::instanceInternal("phrase")->fetch(array('visitor_message_from_x'));
         $this->arguments['title'] = sprintf($phrases['visitor_message_from_x'], $node['authorname']);
     }
     // get userid and username
     if (empty($this->arguments['userid'])) {
         //get userInfo
         if ($node['setfor']) {
             $user = vB_Api::instanceInternal('user')->fetchUsernames(array($node['setfor']));
             $user = $user[$node['setfor']];
             $this->arguments['userid'] = $node['setfor'];
             $this->arguments['username'] = $user['username'];
         }
     }
     $this->breadcrumbs = array(0 => array('title' => $this->arguments['username'], 'url' => vB5_Route::buildUrl('profile', array('userid' => $this->arguments['userid'], 'username' => vB_String::getUrlIdent($this->arguments['username'])))), 1 => array('phrase' => 'visitor_message', 'url' => ''));
 }
 public function __construct($routeInfo, $matches, $queryString = '', $anchor = '')
 {
     parent::__construct($routeInfo, $matches, $queryString, $anchor);
     if (isset($this->arguments['channelid'])) {
         $cache = vB_Cache::instance(vB_Cache::CACHE_FAST);
         $hashKey = 'vbRouteChannelInfo_' . $this->arguments['channelid'];
         $channelInfo = $cache->read($hashKey);
         if (empty($channelInfo)) {
             // check if we need to force a styleid
             $channel = vB_Library::instance('Content_Channel')->getBareContent($this->arguments['channelid']);
             $channel = array_pop($channel);
             $channelInfo['styleid'] = $channel['styleid'];
             $channelInfo['options'] = $channel['options'];
             $channelInfo['routeid'] = $channel['routeid'];
             $channelInfo['rss_enabled'] = $channel['rss_enabled'];
             $channelInfo['rss_route'] = $channel['rss_route'];
             $channelInfo['title'] = $channel['title'];
             $cache->write($hashKey, $channelInfo, 1440, array('routeChg_' . $channelInfo['routeid'], 'nodeChg_' . $channelInfo['routeid']));
         }
         if (!empty($channelInfo['styleid'])) {
             if ($channelInfo['options']['styleoverride']) {
                 // the channel must force the style
                 $this->arguments['forceStyleId'] = $channelInfo['styleid'];
             } else {
                 // the channel suggests to use this style
                 $this->arguments['routeStyleId'] = $channelInfo['styleid'];
             }
         }
         // rss info
         $this->arguments['rss_enabled'] = $channelInfo['rss_enabled'];
         $this->arguments['rss_route'] = $channelInfo['rss_route'];
         $this->arguments['rss_title'] = $channelInfo['title'];
         $this->setPageKey('pageid', 'channelid', 'nodeid');
     }
     if (isset($this->arguments['nodeid'])) {
         if (!empty($this->arguments['userid']) && !empty($this->arguments['contenttypeid']) && !empty($this->arguments['title']) && !empty($this->arguments['parentid'])) {
             $node['userid'] = $this->arguments['userid'];
             $node['contenttypeid'] = $this->arguments['contenttypeid'];
             $node['title'] = $this->arguments['title'];
             $node['parentid'] = $this->arguments['parentid'];
         } else {
             try {
                 $node = vB_Library::instance('node')->getNodeBare($this->arguments['nodeid']);
             } catch (vB_Exception_Api $e) {
                 if ($e->has_error('invalid_node_id')) {
                     // the node does not exist, send a 404
                     throw new vB_Exception_404('invalid_page_url');
                 } else {
                     // rethrow exception
                     throw $e;
                 }
             }
         }
         // privacy check
         $albumChannel = vB_Api::instance('node')->fetchAlbumChannel($node['nodeid']);
         if ($node['parentid'] == $albumChannel) {
             $userInfo = vB_Api::instance('user')->fetchProfileInfo($node['userid']);
             if ($node['contenttypeid'] == vB_Types::instance()->getContentTypeID('vBForum_Video') and !$userInfo['showVideos'] or $node['contenttypeid'] == vB_Types::instance()->getContentTypeID('vBForum_Gallery') and (!$userInfo['showPhotos'] or !vB::getUserContext()->hasPermission('albumpermissions', 'canviewalbum'))) {
                 throw new vB_Exception_NodePermission($node['nodeid']);
             }
         }
         $contentApi = vB_Api_Content::getContentApi($node['contenttypeid']);
         if (!$contentApi->validate($node, vB_Api_Content::ACTION_VIEW, $node['nodeid'], array($node['nodeid'] => $node)) and empty($node['public_preview'])) {
             throw new vB_Exception_NodePermission($node['nodeid']);
         }
         if (!empty($this->queryParameters)) {
             $this->arguments['noindex'] = 1;
         }
         if (!empty($node['description'])) {
             $this->arguments['metadescription'] = $node['description'];
         }
         // set user action
         $this->setUserAction('viewing_topic_x', $node['title'], $this->getFullUrl('fullurl'));
         // set last crumb
         $this->breadcrumbs[] = array('title' => $node['title'], 'url' => '');
     }
     $this->arguments['pageSchema'] = 'http://schema.org/ItemPage';
 }