Skip to content

Commit

Permalink
Merge pull request #1102 from claroline/improve-user-menu
Browse files Browse the repository at this point in the history
Permanent link first and don't show delimiter if not needed in top right user menu
  • Loading branch information
ngodfraind committed Apr 1, 2015
2 parents b45cba1 + c146f2c commit a7ac2ae
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
9 changes: 6 additions & 3 deletions Manager/ToolManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,10 @@ public function addWorkspaceTool(
/**
* @param \Claroline\CoreBundle\Entity\User $user
*
* @return \Claroline\CoreBundle\Entity\Tool\Tool
* @param int $type
* @param array $excludedTools
*
* @return \Claroline\CoreBundle\Entity\Tool\Tool[]
*/
public function getDisplayedDesktopOrderedTools(
User $user,
Expand All @@ -177,9 +180,9 @@ public function getDisplayedDesktopOrderedTools(
}

/**
* @param \Claroline\CoreBundle\Entity\User $user
* @param integer $type
*
* @return \Claroline\CoreBundle\Entity\Tool\Tool
* @return \Claroline\CoreBundle\Entity\Tool\OrderedTool[]
*/
public function getOrderedToolsLockedByAdmin($type = 0)
{
Expand Down
20 changes: 14 additions & 6 deletions Menu/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function topBarRightMenu(FactoryInterface $factory, array $options)
$hasRoleExtension = $this->container->get('claroline.core_bundle.twig.has_role_extension');
$router = $this->container->get('router');
$dispatcher = $this->container->get('event_dispatcher');
/** @var \Claroline\CoreBundle\Manager\ToolManager $toolManager */
$toolManager = $this->container->get('claroline.manager.tool_manager');

$menu = $factory->createItem('root')
Expand All @@ -40,6 +41,12 @@ public function topBarRightMenu(FactoryInterface $factory, array $options)
->setAttribute('role', 'presentation')
->setExtra('icon', 'fa fa-cog');

//allowing the menu to be extended
$this->container->get('event_dispatcher')->dispatch(
'claroline_top_bar_right_menu_configure',
new ConfigureMenuEvent($factory, $menu)
);

$this->addDivider($menu, '1');

$menu->addChild(
Expand Down Expand Up @@ -69,8 +76,11 @@ public function topBarRightMenu(FactoryInterface $factory, array $options)
1,
$excludedTools
);
/** @var \Claroline\CoreBundle\Entity\Tool\Tool[] $tools */
$tools = array_merge($adminTools, $desktopTools);

$countPermanentMenuLinks = $menu->count();

foreach ($tools as $tool) {
$toolName = $tool->getName();

Expand All @@ -92,13 +102,11 @@ public function topBarRightMenu(FactoryInterface $factory, array $options)
}
}

//allowing the menu to be extended
$this->container->get('event_dispatcher')->dispatch(
'claroline_top_bar_right_menu_configure',
new ConfigureMenuEvent($factory, $menu)
);
$countAddedToolMenuLinks = $menu->count();

$this->addDivider($menu, '2');
if ($countPermanentMenuLinks < $countAddedToolMenuLinks) {
$this->addDivider($menu, '2');
}

//logout
if ($hasRoleExtension->isImpersonated()) {
Expand Down

0 comments on commit a7ac2ae

Please sign in to comment.