/** * IEM_Menu * This builds both the nav menu (with the dropdown items) and the text menu links at the top * It gets the main nav items from SendStudio_Functions::GenerateMenuLinks * It gets the text menu items from SendStudio_Functions::GenerateTextMenuLinks * * It will also see if test-mode is enabled (and display an appropriate message) * and also generate the right headers at the top (user is logged in as 'X', the current time is 'Y' etc). * * <b>Do *not* put any "ParseTemplate" calls inside IEM_Menu as you will cause an infinite loop.</b> * "ParseTemplate" calls "IEM_Menu" via IEM_DefaultVariables * Since the header menu has not yet finished building (ie the $menu variable is still null), * calling IEM_Menu at this stage will then call ParseTemplate (which then calls IEM_Menu). * * It returns an array: * - the first item is the main nav menu (contact lists, contacts, email campaigns etc) * - the second item is the text menu links at the top of the page (templates, users/manage account, logout etc) * * @uses SendStudio_Functions::GenerateMenuLinks * @uses SendStudio_Functions::GenerateTextMenuLinks * * @return Array Returns an array containing the main nav menu (the first item of the array) and the text menu items (the second item of the array). */ private function IEM_Menu() { static $menu = null; // we've already built the menu? just return it. if ($menu !== null) { return $menu; } // see if there is an upgrade required or problem with the lk. if (!isset($_GET['Page']) || strtolower($_GET['Page']) != 'upgradenx') { if (IEM::sessionGet('LicenseError')) { if (!isset($_GET['Page']) || strtolower($_GET['Page']) != 'settings') { header('Location: index.php?Page=Settings'); exit; } } } $user = IEM::getCurrentUser(); // we're not logged in? we don't have a menu so just return empty items. if (!$user) { $menu = array('', ''); return $menu; } $textlinks = SendStudio_Functions::GenerateTextMenuLinks(); $nav_menus = ''; if (!IEM::sessionGet('LicenseError')) { $nav_menus = SendStudio_Functions::GenerateMenuLinks(); } $GLOBALS['UsingWYSIWYG'] = '0'; if ($user->Get('usewysiwyg') == 1) { $GLOBALS['UsingWYSIWYG'] = '1'; } $adjustedtime = AdjustTime(); $GLOBALS['SystemDateTime'] = sprintf(GetLang('UserDateHeader'), AdjustTime($adjustedtime, false, GetLang('UserDateFormat'), true), $user->Get('usertimezone')); $name = $user->Get('username'); $fullname = $user->Get('fullname'); if ($fullname != '') { $name = $fullname; } $GLOBALS['UserLoggedInAs'] = sprintf(GetLang('LoggedInAs'), htmlentities($name, ENT_QUOTES, SENDSTUDIO_CHARSET)); $unlimited_total_emails = $user->hasUnlimitedTotalCredit(); if (!$unlimited_total_emails) { $creditUsed = API_USERS::getRecordById($user->userid)->getUsedCredit(); $creditLeft = (int) $user->group->limit_totalemailslimit - (int) $creditUsed; $GLOBALS['TotalEmailCredits'] = sprintf(GetLang('User_Total_CreditsLeft'), SendStudio_Functions::FormatNumber($creditLeft)); } $GLOBALS['MonthlyEmailCredits'] = ''; $unlimited_monthly_emails = $user->hasUnlimitedMonthlyCredit(); if (!$unlimited_monthly_emails) { $creditUsed = API_USERS::getRecordById($user->userid)->getUsedMonthlyCredit(); $creditLeft = (int) $user->group->limit_emailspermonth - (int) $creditUsed; $GLOBALS['MonthlyEmailCredits'] = sprintf(GetLang('User_Monthly_CreditsLeft'), SendStudio_Functions::FormatNumber($creditLeft), SendStudio_Functions::FormatNumber($user->group->limit_emailspermonth)); if (!$unlimited_total_emails) { $GLOBALS['MonthlyEmailCredits'] .= ' |'; } } $menu = array($nav_menus, $textlinks); return $menu; }