/** * @return bool */ public function htmlBuildResult() { parent::htmlBuildResult(); $applicationIds = CountryApplicationLibrary::fetchAuthorizedApplicationIds(); foreach( $applicationIds as $k => $v ) { if(!$v) unset($applicationIds[$k]); } $applicationIds = array_values($applicationIds); $applications = ApplicationLocalized::fetchApplicationList( array('id' => array($applicationIds)) ); $applicationWebtrendsIdentifiers = array(); foreach( $applications as $k => $app ) { /* @var $app ApplicationObject */ $applicationWebtrendsParams = $app->applicationLocalized()->webtrendsParams(); if( trim($applicationWebtrendsParams['cg_n']) != '' ) $applicationWebtrendsIdentifiers[strval($app->attribute('id'))] = $applicationWebtrendsParams['cg_n']; } $this->tpl()->setVariable( 'apps_wb_labels', $applicationWebtrendsIdentifiers ); /* @var $app ApplicationLocalized */ foreach( CacheApplicationTool::clusterApplications() as $app ) { if( $app->applicationObject->identifier == 'merck-connect' ) { $this->tpl()->setVariable( 'merck_connect_results', true ); break; } } return true; }
/** * @return array */ public static function getApplicationLists() { $userAppList = AppBarControl::instance()->applicationIds(); $orderedAppList = $userAppList; $apps = array(); sort($orderedAppList); $rawApps = ApplicationLocalized::fetchApplicationList(array('id' => array($orderedAppList))); foreach ( $rawApps as $k => $app ) { $force = false; if(SolrSafeOperatorHelper::featureIsActive('LearningNeedsAssessment') && $app->identifier == 'learning-needs-assessment') { $force = true; } if ( $app->attribute('application_library') || $force ) { /* @var $app ApplicationLocalized */ $apps['#' . $app->attribute('id')] = $app; } else { unset($userAppList[array_search($app->attribute('id'), $userAppList)]); $userAppList = array_values($userAppList); unset($orderedAppList[array_search($app->attribute('id'), $orderedAppList)]); $orderedAppList = array_values($orderedAppList); } } // we check if some apps were deleted in the meantime if ( self::user() ) { $applistToUpdate = false; foreach ( $userAppList as $k => $id ) { if ( !isset($apps['#' . $id]) ) { // we remove the application from the app bar only if it is not available for the anonymous // display rights are handled at application level if ( !in_array($id, CountryApplicationLibrary::fetchAuthorizedApplicationIds(true)) ) { unset($userAppList[$k]); $applistToUpdate = true; } else { $apps['#' . $id] = CacheApplicationTool::buildLocalizedApplicationByApplication($id); } } } if ( $applistToUpdate ) { $userAppList = array_values($userAppList); $user = MMUsers::getCurrentUserObject(); $orderedAppList = $userAppList; sort($orderedAppList); $user->setApplicationList($userAppList); } } return array( 'app_list' => self::user() ? $orderedAppList : $userAppList, 'apps' => $apps ); }
/** * @param int $parent * @param int $id * @return ApplicationObject */ public static function fetchByParent($parent, $id = null) { $cond = array('parent_id' => $parent); $isLoggedUser = MMUsers::getCurrentUserObject(); if( !$isLoggedUser ) { $restricted = array( 'restriction_level' => array( array( self::RESTRICTION_LEVEL_PUBLIC, self::RESTRICTION_LEVEL_RESTRICTED ) ) ); } else { $restricted = array( 'id' => array( CountryApplicationLibrary::fetchAuthorizedApplicationIds() ) ); } $cond = array_merge($cond, $restricted); $relatedApps = ApplicationLocalized::fetchApplicationList ( $cond ); if( $id ) { for( $i=0; $i<count($relatedApps); $i++ ) { if( $relatedApps[$i]->id == $id ) { unset($relatedApps[$i]); break; } } } $wantedChildApps = array(); $i = 0; foreach ($relatedApps as $relatedApp) { $passAppToView = true; $appLocalized = $relatedApp->applicationLocalized(); if ( $appLocalized instanceof ApplicationLocalized && !$isLoggedUser) { if ( !in_array( $appLocalized->restrictionLevel(), $restricted['restriction_level'][0] ) ) { $passAppToView = false; } } if ( $passAppToView ) { $wantedChildApps[$i] = $relatedApp; $i++; } } return $wantedChildApps; }