Last active
September 9, 2020 10:32
-
-
Save cgi-caesar/62ecac2e6561320622ea6d3f1a0f5285 to your computer and use it in GitHub Desktop.
aMember (site.php): Different Menu for member and affiliate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//replace standard menu with affiliate specific if currently logged in user is affiliate | |
$di = Am_Di::getInstance(); | |
if ($di->auth->getUserId() && $di->auth->getUser()->is_affiliate) { | |
$n = new Am_Navigation_User(); | |
$n->addMenuPages('_aff'); | |
$di->setService('navigationUser', $n); | |
} | |
//add menu item to admin interface (edit affiliate menu) | |
Am_Di::getInstance()->hook->add(Am_Event::ADMIN_MENU, function(Am_Event $e){ | |
if ($page = $e->getMenu()->findOneById('configuration')) { | |
$page->addPage([ | |
'id' => 'menu-aff', | |
'label' => 'Affiliate Menu', | |
'uri' => $e->getDi()->url('admin-menu', ['menu_id' => '_aff']) | |
]); | |
} | |
}); | |
//add icon for admin menu item | |
Am_View_Helper_Icon::$src['menu-aff'] = | |
'data:image/png;base64,' . | |
'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAACoSURBVCjPY/jPAIMMCgxmYKiAEAOKwhmMDGZ//v/5/+M/qhI0BW/+gxQBlTDiUPDl/3v8Cn7//4VfwR/cVkB8kfI27S0WR+7rm/ui70X7i9YX88O7whtflANh7ouUPqgCBsbZLyBGAq1hRLBiX4BZiODBxgIpgAWPOYM/BgukGCl4En9jsswYkIIHKIzBgiiABg9QGINlxoAUPEBhDJYZwhdmDDZYWAoAtTEEdnXdy7IAAAAASUVORK5CYII='; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment