/**
  * Parses a specified page ID and redirects to another ID if required.
  * 
  * @param WebSoccer $websoccer Website context.
  * @param I18n $i18n messages provider.
  * @param string $requestedPageId unfiltered Page ID that has been requested.
  * @return string target page ID to display.
  */
 public static function getTargetPageId(WebSoccer $websoccer, I18n $i18n, $requestedPageId)
 {
     $pageId = $requestedPageId;
     // set default page ID
     if ($pageId == NULL) {
         $pageId = DEFAULT_PAGE_ID;
     }
     // redirect to log-in form if website is generally protected
     $user = $websoccer->getUser();
     if ($websoccer->getConfig('password_protected') && $user->getRole() == ROLE_GUEST) {
         // list of page IDs that needs to be excluded.
         $freePageIds = array(LOGIN_PAGE_ID, 'register', 'register-success', 'activate-user', 'forgot-password', 'imprint', 'logout', 'termsandconditions');
         if (!$websoccer->getConfig('password_protected_startpage')) {
             $freePageIds[] = DEFAULT_PAGE_ID;
         }
         if (!in_array($pageId, $freePageIds)) {
             // create warning message
             $websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_WARNING, $i18n->getMessage('requireslogin_box_title'), $i18n->getMessage('requireslogin_box_message')));
             $pageId = LOGIN_PAGE_ID;
         }
     }
     // exception rule: If user clicks at breadcrumb navigation on team details, there will be no ID given, so redirect to leagues
     if ($pageId == 'team' && $websoccer->getRequestParameter('id') == null) {
         $pageId = 'leagues';
     }
     // prompt user to enter user name, after he has been created without user name (e.g. by a custom LoginMethod).
     if ($user->getRole() == ROLE_USER && !strlen($user->username)) {
         $pageId = ENTERUSERNAME_PAGE_ID;
     }
     return $pageId;
 }
 public function __construct(I18n $i18n, WebSoccer $websoccer, DbConnection $db)
 {
     $this->_i18n = $i18n;
     $this->_websoccer = $websoccer;
     $this->_db = $db;
     $this->_addedPlayers = array();
     $this->_isNationalTeam = $websoccer->getRequestParameter('nationalteam') ? TRUE : FALSE;
 }
 /**
  * @param int $hits number of total hits.
  * @param int $eps number of maximum entries per page.
  * @param WebSoccer $websoccer environment.
  */
 public function __construct($hits, $eps, $websoccer)
 {
     $this->eps = $eps;
     $this->pageNo = max(1, (int) $websoccer->getRequestParameter(PARAM_PAGENUMBER));
     if ($hits % $eps) {
         $this->pages = floor($hits / $eps) + 1;
     } else {
         $this->pages = $hits / $eps;
     }
 }
 private static function _handlePremiumAction(WebSoccer $website, DbConnection $db, I18n $i18n, $actionId, $creditsRequired, $validatedParams, $controllerName)
 {
     // check if user has enough credit
     if ($creditsRequired > $website->getUser()->premiumBalance) {
         $targetPage = $website->getConfig('premium_infopage');
         // redirect to external info page
         if (filter_var($targetPage, FILTER_VALIDATE_URL)) {
             header('location: ' . $targetPage);
             exit;
             // render info page
         } else {
             $website->addContextParameter('premium_balance_required', $creditsRequired);
             return $targetPage;
         }
     }
     // debit amount and execute action
     if ($website->getRequestParameter('premiumconfirmed')) {
         PremiumDataService::debitAmount($website, $db, $website->getUser()->id, $creditsRequired, $actionId);
         return self::_executeAction($website, $db, $i18n, $actionId, $controllerName, $validatedParams);
     }
     // redirect to confirmation page
     $website->addContextParameter('premium_balance_required', $creditsRequired);
     $website->addContextParameter('actionparameters', $validatedParams);
     $website->addContextParameter('actionid', $actionId);
     $website->addContextParameter('srcpage', $website->getPageId());
     return 'premium-confirm-action';
 }