/** * Finds the Number of Notifications that should be displayed to an Admin. Both for proposed APIs and CBS. * @return int */ public function getAdminNotifNum() { // Count and add the APIs that are under review $apis = Apis::find()->where(['cbs' => 0, 'status' => 'Under Review']); $notifNum = $apis->count(); // Count and add the CBS that are still pending review $cbs = Apis::find()->where(['cbs' => 1, 'status' => 'pending']); $notifNum += $cbs->count(); // Add the usual following notification count $notifNum += ProfileController::getFollowingAPIsUsersNotifNum(); return $notifNum; }
<?php $this->beginBody(); ?> <div class="wrap"> <?php NavBar::begin(['brandLabel' => '<img src="' . Yii::getAlias('@web') . '/images/OPENi_logo.png">', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar navbar-default navbar-fixed-top']]); $menuItems = [['label' => 'Home', 'url' => ['/']], ['label' => 'Categories', 'url' => ['/categories/']], ['label' => 'APIs', 'url' => ['/apis/']], ['label' => 'Objects', 'url' => ['/objects/']], ['label' => 'CBS', 'url' => ['/cbs/']], ['label' => 'Swagger', 'url' => ['/swagger']], ['label' => 'About', 'url' => ['/site/about']]]; if (Yii::$app->user->isGuest) { $menuItems[] = ['label' => 'Signup', 'url' => ['/site/signup']]; $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']]; } else { $menuItems[] = ['label' => 'Profile', 'url' => ['/profile/']]; if (array_key_exists('admin', Yii::$app->authManager->getRolesByUser(Yii::$app->user->id))) { $menuItems[] = '<li role="presentation"><a href="' . Yii::getAlias('@web') . '/profile/adminnotifications" class="navbar-badge-link"><span class="badge navbar-badge" data-toggle="tooltip" data-placement="bottom" title="New Notifications">' . ProfileController::getAdminNotifNum() . '</span></a></li>'; } else { $menuItems[] = '<li role="presentation"><a href="' . Yii::getAlias('@web') . '/profile/notifications" class="navbar-badge-link"><span class="badge navbar-badge" data-toggle="tooltip" data-placement="bottom" title="New Notifications">' . ProfileController::getFollowingAPIsUsersNotifNum() . '</span></a></li>'; } $menuItems[] = ['label' => 'Logout (' . Yii::$app->user->identity->username . ')', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post']]; } echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => $menuItems]); NavBar::end(); ?> <div class="container"> <?php echo Breadcrumbs::widget(['links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]); ?> <?php echo Alert::widget(); ?> <?php