diff --git a/module/common/model.php b/module/common/model.php
index 8a7bf0a4df..4c7b5514c4 100644
--- a/module/common/model.php
+++ b/module/common/model.php
@@ -294,7 +294,7 @@ class commonModel extends model
if($app->company->website) echo html::a($app->company->website, $lang->company->website, '_blank');
if($app->company->backyard) echo html::a($app->company->backyard, $lang->company->backyard, '_blank');
- echo html::a(helper::createLink('tutorial', 'start'), $lang->tutorial, '', "class='iframe' data-width='800' data-headerless='true'");
+ if(!commonModel::isTutorialMode()) echo html::a(helper::createLink('tutorial', 'start'), $lang->tutorial, '', "class='iframe' data-width='800' data-headerless='true'");
echo html::a(helper::createLink('misc', 'feature'), $lang->feature, '', "class='iframe' data-width='1200' data-headerless='true'");
echo html::a('javascript:;', $lang->help, '', "class='open-help-tab'");
echo html::a(helper::createLink('misc', 'about'), $lang->aboutZenTao, '', "class='about iframe' data-width='900' data-headerless='true' data-class='modal-about'");
@@ -343,6 +343,32 @@ class commonModel extends model
$this->lang->menu = $menu;
}
+ /**
+ * Create menu item link
+ *
+ * @param object $menuItemLink
+ * @param boolean $isTutorialMode
+ * @access public
+ * @return string
+ */
+ public static function createMenuLink($menuItem)
+ {
+ $link = $menuItem->link;
+ if(is_array($menuItem->link))
+ {
+ $vars = isset($menuItem->link['vars']) ? $menuItem->link['vars'] : '';
+ if(isset($menuItem->tutorial) && $menuItem->tutorial)
+ {
+ $link = helper::createLink('tutorial', 'wizard', "module={$menuItem->link['module']}&method={$menuItem->link['method']}¶ms=$vars");
+ }
+ else
+ {
+ $link = helper::createLink($menuItem->link['module'], $menuItem->link['method'], $vars);
+ }
+ }
+ return $link;
+ }
+
/**
* Print the main menu.
*
@@ -368,19 +394,19 @@ class commonModel extends model
}
/* Print all main menus. */
- $menu = customModel::getMainMenu();
- $activeName = $app->getViewType() == 'mhtml' ? 'ui-btn-active' : 'active';
+ $menu = customModel::getMainMenu();
+ $activeName = $app->getViewType() == 'mhtml' ? 'ui-btn-active' : 'active';
echo "
\n";
foreach($menu as $menuItem)
{
if(isset($menuItem->hidden) && $menuItem->hidden) continue;
$active = $menuItem->name == $mainMenu ? "class='$activeName'" : '';
- $link = is_array($menuItem->link) ? helper::createLink($menuItem->link['module'], $menuItem->link['method'], isset($menuItem->link['vars']) ? $menuItem->link['vars'] : null) : $menuItem->link;
+ $link = commonModel::createMenuLink($menuItem);
echo "- $menuItem->text
\n";
}
$customLink = helper::createLink('custom', 'menu', "module={$app->getModuleName()}&method={$app->getMethodName()}", '', true);
- echo " ";
+ if(!commonModel::isTutorialMode()) echo " ";
echo "
\n";
}
@@ -446,9 +472,9 @@ class commonModel extends model
}
/* get current module and method. */
- $currentModule = $app->getModuleName();
- $currentMethod = $app->getMethodName();
- $menu = customModel::getModuleMenu($moduleName);
+ $currentModule = $app->getModuleName();
+ $currentMethod = $app->getMethodName();
+ $menu = customModel::getModuleMenu($moduleName);
/* The beginning of the menu. */
echo "\n";
@@ -467,7 +493,7 @@ class commonModel extends model
$target = '';
$module = '';
$method = '';
- $link = is_array($menuItem->link) ? helper::createLink($menuItem->link['module'], $menuItem->link['method'], isset($menuItem->link['vars']) ? $menuItem->link['vars'] : '') : $menuItem->link;
+ $link = commonModel::createMenuLink($menuItem);
if(is_array($menuItem->link))
{
if(isset($menuItem->link['subModule']))
@@ -1256,6 +1282,16 @@ class commonModel extends model
$httpHost = $_SERVER['HTTP_HOST'];
return "$httpType://$httpHost";
}
+
+ /**
+ * Check whether view type is tutorial
+ * @access public
+ * @return boolean
+ */
+ public static function isTutorialMode()
+ {
+ return $_SESSION['tutorialMode'];
+ }
}
class common extends commonModel
diff --git a/module/custom/model.php b/module/custom/model.php
index a838a0f1ba..75cdaa0b77 100644
--- a/module/custom/model.php
+++ b/module/custom/model.php
@@ -134,9 +134,10 @@ class customModel extends model
{
global $app, $lang, $config;
$isSetMenuConfig = isset($menuConfig);
- $menu = array();
- $order = 1;
- $menuConfigMap = array();
+ $menu = array();
+ $order = 1;
+ $menuConfigMap = array();
+ $isTutorialMode = commonModel::isTutorialMode();
if($isSetMenuConfig)
{
@@ -151,6 +152,17 @@ class customModel extends model
$item->hidden = false;
$menuConfigMap[$item->name] = $item;
}
+ foreach($allMenu as $name => $item)
+ {
+ if(!isset($menuConfigMap[$name]))
+ {
+ $item = new stdclass();
+ $item->name = $name;
+ $item->hidden = true;
+ $item->order = $order++;
+ $menuConfigMap[$name] = $item;
+ }
+ }
}
else if(is_array($menuConfig))
{
@@ -185,7 +197,8 @@ class customModel extends model
$label = $link;
}
- if(commonModel::hasPriv($module, $method))
+ $hasPriv = commonModel::hasPriv($module, $method);
+ if($isTutorialMode || $hasPriv)
{
$itemLink = '';
if($module && $method)
@@ -217,6 +230,7 @@ class customModel extends model
if($float) $menuItem->float = $float;
if($fixed) $menuItem->fixed = $fixed;
if($hidden) $menuItem->hidden = $hidden;
+ if($isTutorialMode) $menuItem->tutorial = true;
while(isset($menu[$menuItem->order])) { $menuItem->order++; }
$menu[$menuItem->order] = $menuItem;
@@ -242,8 +256,8 @@ class customModel extends model
if(empty($app->customMenu)) $app->customMenu = array();
if(!$rebuild && !empty($app->customMenu[$module])) return $app->customMenu[$module];
- $menuConfig = isset($config->menucustom->$module) ? $config->menucustom->$module : array();
- if(!empty($menuConfig)) $menuConfig = json_decode($menuConfig);
+ $menuConfig = commonModel::isTutorialMode() && $module === 'main' ? 'my,product,project,qa,company' : (isset($config->menucustom->$module) ? $config->menucustom->$module : array());
+ if(!empty($menuConfig) && is_string($menuConfig) && substr($menuConfig, 0, 1) === '[') $menuConfig = json_decode($menuConfig);
$allMenu = $module == 'main' ? $lang->menu : (isset($lang->$module->menu) ? $lang->$module->menu : $lang->my->menu);
if($module == 'product' and isset($allMenu->branch)) $allMenu->branch = str_replace('@branch@', $lang->custom->branch, $allMenu->branch);
@@ -279,8 +293,8 @@ class customModel extends model
$configKey = 'feature_' . $module . '_' . $method;
$allMenu = isset($lang->$module->featurebar[$method]) ? $lang->$module->featurebar[$method] : null;
$menuConfig = '';
- if(isset($config->menucustom->$configKey)) $menuConfig = $config->menucustom->$configKey;
- if(!empty($menuConfig)) $menuConfig = json_decode($menuConfig);
+ if(!commonModel::isTutorialMode() && isset($config->menucustom->$configKey)) $menuConfig = $config->menucustom->$configKey;
+ if(!empty($menuConfig) && is_string($menuConfig)) $menuConfig = json_decode($menuConfig);
return $allMenu ? self::buildMenuConfig($allMenu, $menuConfig) : null;
}