LSaddon / view : permit to hide a LSaddon view in menu
authorBenjamin Renard <brenard@easter-eggs.com>
Mon, 24 Aug 2015 10:24:33 +0000 (12:24 +0200)
committerBenjamin Renard <brenard@easter-eggs.com>
Mon, 24 Aug 2015 10:24:33 +0000 (12:24 +0200)
public_html/includes/class/class.LSsession.php
public_html/templates/default/top.tpl

index b6becb0..16bcee3 100644 (file)
@@ -1782,7 +1782,8 @@ class LSsession {
           $LSaddonsViewsAccess[]=array (
             'LSaddon' => $addon,
             'id' => $viewId,
-            'label' => $viewConf['label']
+            'label' => $viewConf['label'],
+            'showInMenu' => $viewConf['showInMenu']
           );
         }
       }
@@ -2501,9 +2502,11 @@ class LSsession {
    * @param[in] $allowedLSprofiles array|null Array listing allowed profiles.
    *                                          If null, no access control will
    *                                          be done for this view.
+   * @param[in] $showInMenu boolean Show (or not) this view in menu
+   *
    * @retval bool True is the view have been registred, false otherwise
    **/
-  public static function registerLSaddonView($LSaddon,$viewId,$label,$viewFunction,$allowedLSprofiles=null) {
+  public static function registerLSaddonView($LSaddon,$viewId,$label,$viewFunction,$allowedLSprofiles=null,$showInMenu=True) {
     if (function_exists($viewFunction)) {
       $func = new ReflectionFunction($viewFunction);
       if (basename($func->getFileName())=="LSaddons.$LSaddon.php") {
@@ -2511,7 +2514,8 @@ class LSsession {
           'LSaddon' => $LSaddon,
           'label' => $label,
           'function' => $viewFunction,
-          'allowedLSprofiles' => $allowedLSprofiles
+          'allowedLSprofiles' => $allowedLSprofiles,
+          'showInMenu' => (bool)$showInMenu
         );
         return True;
       }
index 15f8d8e..9f6d057 100644 (file)
@@ -34,7 +34,9 @@
         <li class='menu'><a href='view.php?LSobject={$LSobject_type}' class='menu'>{tr msg=$label}</a></li>
       {/foreach}
       {foreach from=$LSaddonsViewsAccess item=access}
+        {if $access.showInMenu}
         <li class='menu'><a href='addon_view.php?LSaddon={$access.LSaddon}&view={$access.id}' class='menu'>{tr msg=$access.label}</a></li>
+        {/if}
       {/foreach}
       </ul>
     </td>