Adds dropdown for subscription options to menu

- Modifies menu to include email subscription in addition to Telegram
  subscription
This commit is contained in:
Thomas Nilsen 2018-11-25 18:50:31 +01:00
parent a74ce9ad33
commit 39e53ab1f4

View File

@ -1,6 +1,7 @@
<?php
<?php
//This should later be translatable, maybe find a better solution?
//This is here for better generation of POT files :)
$statuses = array(_("Major outage"), _("Minor outage"), _("Planned maintenance"), _("Operational") );
$classes = array("danger", "warning", "primary", "success" );
$icons = array("fa fa-times", "fa fa-exclamation", "fa fa-info", "fa fa-check" );
@ -8,7 +9,7 @@ $some = array(_("Some systems are experiencing major outages"), _("Some systems
$all = array(_("Our systems are experiencing major outages."), _("Our systems are experiencing minor outages"), _("Our systems are under maintenance"), _("All systems operational"));
$permissions = array(_("Super admin"), _("Admin"), _("Editor"));
require_once("telegram.php");
require_once("classes/telegram.php");
/**
* Class that encapsulates methods to render header and footer
@ -22,6 +23,43 @@ class Template{
public static function render_header($page_name, $admin = false){
if (!$admin)
{
$telegram = new Telegram();
$tg_user = $telegram->getTelegramUserData(); // TODO Is this needed any longer?
// Create subscriber menu sections for later inclusion
// Check if we are on admin menu, if so do not display
$arr_url = explode("/", $_SERVER['PHP_SELF']);
$str_url = strtolower($arr_url[count($arr_url)-2]);
if ( 'admin' == $str_url ) {
$strSubsMenu = '';
} else {
// Subscriber menu is to be shown...
$strSubsMenu = '<ul class="nav navbar-nav mr-auto">';
// If subscriber is not logged on, display subscriber menus
if ( (!isset($_SESSION['subscriber_valid'])) || false == $_SESSION['subscriber_valid'] ) {
$strSubsMenu .= '<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" role="button" href="#"><span class="glyphicon glyphicon-th"></span>&nbsp;'. _('Subscribe').'</a>
<ul class="dropdown-menu ">';
if ( SUBSCRIBE_EMAIL ) {
$strSubsMenu .= '<li><a href="?do=email_subscription&amp;new=1"><span class="glyphicon glyphicon-envelope"></span>&nbsp;'._('Subscribe via email').'</a></li>';
}
if ( SUBSCRIBE_TELEGRAM ) {
$strSubsMenu .= '<li><a href="#"><script async src="https://telegram.org/js/telegram-widget.js?4" data-telegram-login="'.TG_BOT_USERNAME.'" data-size="small" data-userpic="false" data-auth-url="'.WEB_URL.'/telegram_check.php" data-request-access="write"></script></a></li>';
}
$strSubsMenu .= '</ul>';
}
// If subscriber is logged on, display unsub and logoff menu points
if ( (isset($_SESSION['subscriber_valid'])) && $_SESSION['subscriber_valid'] ) {
$strSubsMenu .= '<li><a href="?do=subscriptions">'._('Subscriptions').'</a></li>';
$strSubsMenu .= '<li><a href="'.WEB_URL.'/index.php?subscriber_logout=1">'._('Logout').'</a></li>';
}
$strSubsMenu .= '</ul>';
}
?>
<!doctype html>
<html lang="en">
@ -57,36 +95,27 @@ class Template{
<div class="navbar navbar-default" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only"><?php echo _("Toggle navigation");?></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only"><?php echo _("Toggle navigation");?></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="<?php echo WEB_URL;?>"><img src="<?php echo WEB_URL;?>/img/logo_white.png" alt="logo" class="menu-logo" width="50" height="50"></a>
</div>
<div class="navbar-left hidden-xs">
<ul class="nav navbar-nav">
<li><a href="<?php echo WEB_URL;?>/"><h1><?php echo _((defined('TITLE')?TITLE:"Service Status"));?></h1></a></li>
</ul>
</div>
<div class="navbar-collapse collapse navbar-right navbar-admin">
<ul class="nav navbar-nav mr-auto">
<?php
$tg_user = getTelegramUserData();
if($tg_user !== false){
echo'<li><a href="?do=subscriptions">Subscriptions</a></li>';
echo '<li><a href="'.WEB_URL.'/index.php?subscriber_logout=1">Logout</a></li>';
} else {
echo '<li><a href="#"><script async src="https://telegram.org/js/telegram-widget.js?4" data-telegram-login="'.TG_BOT_USERNAME.'" data-size="small" data-userpic="false" data-auth-url="'.WEB_URL.'/check.php" data-request-access="write"></script></a></li>';
}?>
</ul>
</div><!--/.nav-collapse -->
</div>
<div class="navbar-left hidden-xs">
<ul class="nav navbar-nav">
<li><a href="<?php echo WEB_URL;?>/"><h1><?php echo _((defined('TITLE')?TITLE:"Service Status"));?></h1></a></li>
</ul>
</div>
<div class="navbar-collapse collapse navbar-right navbar-admin">
<?php echo $strSubsMenu; ?>
</div><!--/.nav-collapse -->
</div>
<div id="wrapper" class="center admin">
</div>
</div>
<div id="wrapper" class="center admin">
<?php
}else{
global $user;
@ -197,6 +226,9 @@ class Template{
<?php }?>
<script src="<?php echo WEB_URL;?>/js/vendor/bootstrap.min.js"></script>
<script src="<?php echo WEB_URL;?>/js/main.js"></script>
<?php if ( GOOGLE_RECAPTCHA ) { ?>
<script src='https://www.google.com/recaptcha/api.js'></script>
<?php }?>
</body>
</html>
<?php