diff --git a/lib/zin/wg/mainnavbar/v1.php b/lib/zin/wg/mainnavbar/v1.php
index d83d3df87a..9321bd1db6 100644
--- a/lib/zin/wg/mainnavbar/v1.php
+++ b/lib/zin/wg/mainnavbar/v1.php
@@ -42,7 +42,8 @@ class mainNavbar extends nav
$currentMethod = $app->getMethodName();
commonModel::setMainMenu();
- $items = \customModel::getModuleMenu($app->rawMethod);
+ $activeMenu = commonModel::printMainMenu(false);
+ $items = \customModel::getModuleMenu($activeMenu);
if($items)
{
$items = json_decode(json_encode($items), true);
diff --git a/module/common/model.php b/module/common/model.php
index a0fdde3ede..1a7371ebee 100644
--- a/module/common/model.php
+++ b/module/common/model.php
@@ -1131,11 +1131,12 @@ class commonModel extends model
/**
* Print the main menu.
*
+ * @param bool $printHtml
* @static
* @access public
* @return string
*/
- public static function printMainMenu()
+ public static function printMainMenu(bool $printHtml = true): string
{
global $app, $lang, $config;
@@ -1157,12 +1158,12 @@ class commonModel extends model
/* Print all main menus. */
$menu = customModel::getMainMenu();
- echo "
\n";
+ $menuHtml = "\n";
foreach($menu as $menuItem)
{
if(isset($menuItem->hidden) and $menuItem->hidden and (!isset($menuItem->tutorial) or !$menuItem->tutorial)) continue;
if(empty($menuItem->link)) continue;
- if($menuItem->divider) echo "";
+ if($menuItem->divider) $menuHtml .= "";
/* Init the these vars. */
$alias = isset($menuItem->alias) ? $menuItem->alias : '';
@@ -1185,11 +1186,11 @@ class commonModel extends model
if($menuItem->link['module'] == 'execution' and $menuItem->link['method'] == 'more')
{
$executionID = $menuItem->link['vars'];
- commonModel::buildMoreButton($executionID);
+ commonModel::buildMoreButton($executionID, $printHtml);
}
elseif($menuItem->link['module'] == 'app' and $menuItem->link['method'] == 'serverlink')
{
- commonModel::buildAppButton();
+ commonModel::buildAppButton($printHtml);
}
else
{
@@ -1262,22 +1263,23 @@ class commonModel extends model
$label .= "";
$dropMenu = "";
- echo "- " . html::a($link, $label, $target, $misc) . $dropMenu . "
\n";
+ $menuHtml .= "- " . html::a($link, $label, $target, $misc) . $dropMenu . "
\n";
}
else
{
- echo "- " . html::a($link, $label, $target, $misc) . "
\n";
+ $menuHtml .= "- " . html::a($link, $label, $target, $misc) . "
\n";
}
}
else
{
- echo "- $menuItem->text
\n";
+ $menuHtml .= "- $menuItem->text
\n";
}
}
}
- echo "
\n";
+ $menuHtml .= "
\n";
+ if($printHtml) echo $menuHtml;
return $activeMenu;
}
@@ -1798,18 +1800,19 @@ EOF;
* Build more executions button.
*
* @param int $executionID
+ * @param bool $printHtml
* @static
* @access public
- * @return void
+ * @return bool
*/
- public static function buildMoreButton($executionID)
+ public static function buildMoreButton(int $executionID, bool $printHtml = true): bool
{
- if(defined('TUTORIAL')) return;
+ if(defined('TUTORIAL')) return false;
global $lang, $app;
$object = $app->dbh->query('SELECT project,`type` FROM ' . TABLE_EXECUTION . " WHERE `id` = '$executionID'")->fetch();
- if(empty($object)) return;
+ if(empty($object)) return false;
$executionPairs = array();
$userCondition = !$app->user->admin ? " AND `id` " . helper::dbIN($app->user->view->sprints) : '';
@@ -1827,7 +1830,7 @@ EOF;
$executionPairs[$execution->id] = $execution->name;
}
- if(empty($executionPairs)) return;
+ if(empty($executionPairs)) return false;
$html = "{$lang->more}";
$html .= "\n";
- echo $html;
+ if($printHtml) echo $html;
+ return true;
}
/**
* Build devops app button.
*
+ * @param bool $printHtml
* @static
* @access public
- * @return void
+ * @return bool
*/
- public static function buildAppButton()
+ public static function buildAppButton(bool $printHtml = true): bool
{
- if(defined('TUTORIAL')) return;
+ if(defined('TUTORIAL')) return false;
global $app, $config, $lang;
$condition = '';
@@ -1868,11 +1873,11 @@ EOF;
{
if(commonModel::hasPriv($pipelineType, 'browse')) $types .= "'$pipelineType',";
}
- if(empty($types)) return;
+ if(empty($types)) return false;
$condition .= ' AND `type` in (' . trim($types, ',') . ')';
}
$pipelineList = $app->dbh->query("SELECT `type`,name,url FROM " . TABLE_PIPELINE . " WHERE `deleted` = '0' $condition order by type")->fetchAll();
- if(empty($pipelineList)) return;
+ if(empty($pipelineList)) return false;
$appCommon = isset($lang->db->custom['devopsMenu']['menu']['app']) ? $lang->db->custom['devopsMenu']['menu']['app'] : $lang->app->common;
$html = "{$appCommon}";
@@ -1884,7 +1889,8 @@ EOF;
}
$html .= "\n";
- echo $html;
+ if($printHtml) echo $html;
+ return true;
}
/**