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
//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">
@ -71,22 +109,13 @@ class Template{
</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>
<?php echo $strSubsMenu; ?>
</div><!--/.nav-collapse -->
</div>
</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