/** * Displays user subscription and link to invoice HTML (if allowed) * * @param UserTable $user * @param string $htmlTabDescription * @return string */ public function displaySubscriptionsAndInvoicesLink( $user, $htmlTabDescription = null ) { global $_CB_framework; $return = ''; $params = $this->params; $itsmyself = ( $_CB_framework->myId() == $user->id ); $displayToMe = $itsmyself; if ( ! $itsmyself ) { $displayToMe = cbpaidApp::authoriseAction( 'cbsubs.usersubscriptionview' ); if ( $displayToMe ) { $itsmyself = cbpaidApp::authoriseAction( 'cbsubs.usersubscriptionmanage' ); } } if ( $user->id && $displayToMe ) { $basketsMgr =& cbpaidOrdersMgr::getInstance(); $basketsMgr->timeoutUnusedBaskets( $user->id ); $subscriptionsGUI = new cbpaidControllerUI(); $htmlSubscriptionsAndUpgrades = $subscriptionsGUI->getShowSubscriptionUpgrades( $user, $itsmyself ); $htmlInvoicesLink = null; $showInvoices = $params->get( 'show_invoices', 1 ); $invoicesShowPeriod = $params->get( 'invoices_show_period', '0000-06-00 00:00:00' ); if ( $showInvoices ) { $invoicesNumber = $this->_getInvoices( $user, $invoicesShowPeriod, true ); if ( $invoicesNumber > 0 ) { $invoicesListUrl = $this->getInvoicesListUrl( $user ); if ( $invoicesShowPeriod && ( $invoicesShowPeriod != '0000-00-00 00:00:00' ) ) { $cbpaidTimes =& cbpaidTimes::getInstance(); $periodText = $cbpaidTimes->renderPeriod( $invoicesShowPeriod, 1, false ); } else { $periodText = ''; } $htmlInvoicesLink = $subscriptionsGUI->showInvoicesListLink( $invoicesNumber, $invoicesListUrl, $user, $itsmyself, $periodText ); } } $tabTitleText = $params->get( 'profileTitle', "Your subscriptions" ); /** @var $viewer cbpaiduserprofilesubstabView */ $viewer = cbpaidTemplateHandler::getViewer( null, 'userprofilesubstab' ); $viewer->setModel( $user ); $return .= $viewer->drawTab( $htmlSubscriptionsAndUpgrades, $htmlInvoicesLink, $tabTitleText, $htmlTabDescription ); } return $return; }