diff --git a/application/itopwebpage.class.inc.php b/application/itopwebpage.class.inc.php index f2f19e24a..8f1f324be 100644 --- a/application/itopwebpage.class.inc.php +++ b/application/itopwebpage.class.inc.php @@ -910,67 +910,6 @@ JS return $aNewEntry; } - /** - * Handles the "newsroom" menu at the top-right of the screen - */ - protected function InitNewsroom() - { - $sNewsroomInitialImage = ''; - $aProviderParams = array(); - - if (MetaModel::GetConfig()->Get('newsroom_enabled') !== false) - { - $oUser = UserRights::GetUserObject(); - /** - * @var iNewsroomProvider[] $aProviders - */ - $aProviders = MetaModel::EnumPlugins('iNewsroomProvider'); - foreach($aProviders as $oProvider) - { - $oProvider->SetConfig(MetaModel::GetConfig()); - $bProviderEnabled = appUserPreferences::GetPref('newsroom_provider_'.get_class($oProvider),true); - if ($bProviderEnabled && $oProvider->IsApplicable($oUser)) - { - $aProviderParams[] = array( - 'label' => $oProvider->GetLabel(), - 'fetch_url' => $oProvider->GetFetchURL(), - 'view_all_url' => $oProvider->GetViewAllURL(), - 'mark_all_as_read_url' => $oProvider->GetMarkAllAsReadURL(), - 'placeholders' => $oProvider->GetPlaceholders(), - 'ttl' => $oProvider->GetTTL(), - ); - } - } - } - // Show newsroom only if there are some providers - if (count($aProviderParams) > 0) - { - $sImageUrl= 'fas fa-comment-dots'; - $sPlaceholderImageUrl= 'far fa-envelope'; - $aParams = array( - 'image_icon' => $sImageUrl, - 'placeholder_image_icon' => $sPlaceholderImageUrl, - 'cache_uuid' => 'itop-newsroom-'.UserRights::GetUserId().'-'.md5(APPROOT), - 'providers' => $aProviderParams, - 'display_limit' => (int)appUserPreferences::GetPref('newsroom_display_size', 7), - 'labels' => array( - 'no_message' => Dict::S('UI:Newsroom:NoNewMessage'), - 'mark_all_as_read' => Dict::S('UI:Newsroom:MarkAllAsRead'), - 'view_all' => Dict::S('UI:Newsroom:ViewAllMessages'), - ), - ); - $sParams = json_encode($aParams); - $this->add_ready_script( -<<'; } + // TODO: Don't forget this! + if (utils::IsArchiveMode()) + { + $sIcon = ''; + $this->AddApplicationMessage(Dict::S('UI:ArchiveMode:Banner'), $sIcon, Dict::S('UI:ArchiveMode:Banner+')); + } + + // TODO: Move this in the Header method + $sRestrictions = ''; + if (!MetaModel::DBHasAccess(ACCESS_ADMIN_WRITE)) + { + if (!MetaModel::DBHasAccess(ACCESS_ADMIN_WRITE)) + { + $sRestrictions = Dict::S('UI:AccessRO-All'); + } + } + elseif (!MetaModel::DBHasAccess(ACCESS_USER_WRITE)) + { + $sRestrictions = Dict::S('UI:AccessRO-Users'); + } + if (strlen($sRestrictions) > 0) + { + $sIcon = + << + + + +EOF; + + $sAdminMessage = trim(MetaModel::GetConfig()->Get('access_message')); + if (strlen($sAdminMessage) > 0) + { + $sRestrictions .= ' '.$sAdminMessage; + } + $this->AddApplicationMessage($sRestrictions, $sIcon); + } + + // TODO: Move this in the header method + $sApplicationMessages = ''; + foreach ($this->m_aMessages as $aMessage) + { + $sHtmlIcon = $aMessage['icon'] ? $aMessage['icon'] : ''; + $sHtmlMessage = $aMessage['message']; + $sTitleAttr = $aMessage['tip'] ? 'title="'.htmlentities($aMessage['tip'], ENT_QUOTES, self::PAGES_CHARSET).'"' : ''; + $sApplicationMessages .= '
'.$sHtmlIcon.''.$sHtmlMessage.'
'; + } + // Call the extensions to add content to the page, warning they can also add styles or scripts through as they have access to the \iTopWebPage foreach (MetaModel::EnumPlugins('iPageUIExtension') as $oExtensionInstance) { @@ -1195,9 +1184,6 @@ EOF EOF ); - // TODO: Extract in a dedicated component and call it in the nav menu - $sNewsRoomInitialImage = $this->InitNewsroom(); - $this->outputCollapsibleSectionInit(); // TODO: Is this for the "Debug" popup? We should do a helper to display a popup in various cases (welcome message for example) @@ -1252,11 +1238,6 @@ EOF } - -// $sHtml .= "\n"; - - - $sHtml .= "\n"; $sBodyClass = ""; if ($this->IsPrintableVersion()) { @@ -1298,6 +1279,7 @@ EOF; $sHtml .= "
"; } + // TODO // // Render the text of the global search form // $sText = htmlentities(utils::ReadParam('text', '', false, 'raw_data'), ENT_QUOTES, self::PAGES_CHARSET); // $sOnClick = " onclick=\"if ($('#global-search-input').val() != '') { $('#global-search form').submit(); } \""; @@ -1311,218 +1293,6 @@ EOF; } elseif ($this->GetOutputFormat() == 'html') { - $oAppContext = new ApplicationContext(); - - $sUserName = UserRights::GetUser(); - // TODO: BEGIN USER MENU - $sIsAdmin = UserRights::IsAdministrator() ? '(Administrator)' : ''; - if (UserRights::IsAdministrator()) - { - $sLogonMessage = Dict::Format('UI:LoggedAsMessage+Admin', $sUserName); - } - else - { - $sLogonMessage = Dict::Format('UI:LoggedAsMessage', $sUserName); - } - $sLogOffMenu = "
    • "; - $sLogOffMenu .= "
    • $sLogonMessage
    • \n"; - $aActions = array(); - -// $aAllowedPortals = UserRights::GetAllowedPortals(); -// if (count($aAllowedPortals) > 1) -// { -// // Adding portals -// foreach ($aAllowedPortals as $aAllowedPortal) -// { -// if ($aAllowedPortal['id'] !== 'backoffice') -// { -// $oPortalMenuItem = new URLPopupMenuItem('portal:'.$aAllowedPortal['id'], Dict::S($aAllowedPortal['label']), -// $aAllowedPortal['url'], '_blank'); -// $aActions[$oPortalMenuItem->GetUID()] = $oPortalMenuItem->GetMenuItem(); -// } -// } -// // Adding a separator -// $oPortalSeparatorMenuItem = new SeparatorPopupMenuItem(); -// $aActions[$oPortalSeparatorMenuItem->GetUID()] = $oPortalSeparatorMenuItem->GetMenuItem(); -// } - -// $oPrefs = new URLPopupMenuItem('UI:Preferences', Dict::S('UI:Preferences'), -// utils::GetAbsoluteUrlAppRoot()."pages/preferences.php?".$oAppContext->GetForLink()); -// $aActions[$oPrefs->GetUID()] = $oPrefs->GetMenuItem(); - - if (utils::IsArchiveMode()) - { -// $oExitArchive = new JSPopupMenuItem('UI:ArchiveModeOff', Dict::S('UI:ArchiveModeOff'), 'return ArchiveMode(false);'); -// $aActions[$oExitArchive->GetUID()] = $oExitArchive->GetMenuItem(); - - $sIcon = ''; - $this->AddApplicationMessage(Dict::S('UI:ArchiveMode:Banner'), $sIcon, Dict::S('UI:ArchiveMode:Banner+')); - } -// elseif (UserRights::CanBrowseArchive()) -// { -// $oBrowseArchive = new JSPopupMenuItem('UI:ArchiveModeOn', Dict::S('UI:ArchiveModeOn'), 'return ArchiveMode(true);'); -// $aActions[$oBrowseArchive->GetUID()] = $oBrowseArchive->GetMenuItem(); -// } -// if (utils::CanLogOff()) -// { -// $oLogOff = new URLPopupMenuItem('UI:LogOffMenu', Dict::S('UI:LogOffMenu'), -// utils::GetAbsoluteUrlAppRoot().'pages/logoff.php?operation=do_logoff'); -// $aActions[$oLogOff->GetUID()] = $oLogOff->GetMenuItem(); -// } -// if (UserRights::CanChangePassword()) -// { -// $oChangePwd = new URLPopupMenuItem('UI:ChangePwdMenu', Dict::S('UI:ChangePwdMenu'), -// utils::GetAbsoluteUrlAppRoot().'pages/UI.php?loginop=change_pwd'); -// $aActions[$oChangePwd->GetUID()] = $oChangePwd->GetMenuItem(); -// } - utils::GetPopupMenuItems($this, iPopupMenuExtension::MENU_USER_ACTIONS, null, $aActions); - -// $oAbout = new JSPopupMenuItem('UI:AboutBox', Dict::S('UI:AboutBox'), 'return ShowAboutBox();'); -// $aActions[$oAbout->GetUID()] = $oAbout->GetMenuItem(); - - $sLogOffMenu .= $this->RenderPopupMenuItems($aActions); - // TODO: END USER MENU - - // TODO: Move this in the Header method - $sRestrictions = ''; - if (!MetaModel::DBHasAccess(ACCESS_ADMIN_WRITE)) - { - if (!MetaModel::DBHasAccess(ACCESS_ADMIN_WRITE)) - { - $sRestrictions = Dict::S('UI:AccessRO-All'); - } - } - elseif (!MetaModel::DBHasAccess(ACCESS_USER_WRITE)) - { - $sRestrictions = Dict::S('UI:AccessRO-Users'); - } - - if (strlen($sRestrictions) > 0) - { - $sIcon = - << - - - -EOF; - - $sAdminMessage = trim(MetaModel::GetConfig()->Get('access_message')); - if (strlen($sAdminMessage) > 0) - { - $sRestrictions .= ' '.$sAdminMessage; - } - $this->AddApplicationMessage($sRestrictions, $sIcon); - } - - // TODO: Move this in the header method - $sApplicationMessages = ''; - foreach ($this->m_aMessages as $aMessage) - { - $sHtmlIcon = $aMessage['icon'] ? $aMessage['icon'] : ''; - $sHtmlMessage = $aMessage['message']; - $sTitleAttr = $aMessage['tip'] ? 'title="'.htmlentities($aMessage['tip'], ENT_QUOTES, self::PAGES_CHARSET).'"' : ''; - $sApplicationMessages .= '
      '.$sHtmlIcon.''.$sHtmlMessage.'
      '; - } - - $sApplicationBanner = "
      $sApplicationMessages$sBannerExtraHtml
      "; - - if (!empty($sNorthPane)) - { - $sNorthPane = '
      '.$sNorthPane.'
      '; - } - - if (!empty($sSouthPane)) - { - $sSouthPane = '
      '.$sSouthPane.'
      '; - } - - // TODO: What do we do with this? -// $sOnlineHelpUrl = MetaModel::GetConfig()->Get('online_help'); - //$sLogOffMenu = ""; - -// $sDisplayIcon = utils::GetAbsoluteUrlAppRoot().'images/itop-logo.png?t='.utils::GetCacheBusterTimestamp(); -// if (file_exists(MODULESROOT.'branding/main-logo.png')) -// { -// $sDisplayIcon = utils::GetAbsoluteUrlModulesRoot().'branding/main-logo.png?t='.utils::GetCacheBusterTimestamp(); -// } - - $sHtml .= $sNorthPane; - $sHtml .= '
      '; - $sHtml .= ''; - $sHtml .= '
      '; -// $sHtml .= ' '; - $sHtml .= '
      '; -// if (!MetaModel::GetConfig()->Get('demo_mode')) -// { -// $sHtml .= '
      pin
      '; -// } - $sHtml .= '
      '.self::FilterXSS($sForm).'
      '; - $sHtml .= '
      '; - $sHtml .= '
      '; -// $sHtml .= ' '; - $sHtml .= ' '; - $sHtml .= ''; - $sHtml .= '
      '; - - $sHtml .= '
      '; - $sHtml .= '
      '; - $sHtml .= self::FilterXSS($sApplicationBanner); - -// $GoHomeInitialStyle = $this->IsMenuPaneVisible() ? 'display: none;' : ''; - -// $sHtml .= ' '; -// $sHtml .= ' '; -// $sHtml .= ' '; -// $sHtml .= ' '; -// $sHtml .= ' '; -// $sHtml .= ' '; - $sHtml .= ' '; -// $sHtml .= ' '; -// $sHtml .= '
      '; -// $sHtml .= '
      '; -// $sHtml .= '
      '; - -// $sHtml .= ' '; -// $sHtml .= '
      '; - - $sHtml .= '
      '; - $sHtml .= '
      '; - $sHtml .= ' '; - $sHtml .= self::FilterXSS($this->s_content); - $sHtml .= ' '; - $sHtml .= '
      '; - $sHtml .= '
      '; - $sHtml .= $sSouthPane; // Add the captured output if (trim($s_captured_output) != "") @@ -1544,8 +1314,6 @@ EOF; $sHtml .= '
'; } - $sHtml .= "\n"; - $sHtml .= "\n"; if ($this->GetOutputFormat() == 'html') { @@ -1555,6 +1323,7 @@ EOF; } else { + // TODO: Check with ITOMIG if we can remove this if ($this->GetOutputFormat() == 'pdf' && $this->IsOutputFormatAvailable('pdf')) { // Note: Apparently this was a demand from ITOMIG a while back, so it's not "dead code" per say. @@ -1585,8 +1354,6 @@ EOF; } } } -// DBSearch::RecordQueryTrace(); -// ExecutionKPI::ReportStats(); } /** diff --git a/sources/application/UI/Component/PopoverMenu/PopoverMenuFactory.php b/sources/application/UI/Component/PopoverMenu/PopoverMenuFactory.php index ec1173fe6..cda8df57e 100644 --- a/sources/application/UI/Component/PopoverMenu/PopoverMenuFactory.php +++ b/sources/application/UI/Component/PopoverMenu/PopoverMenuFactory.php @@ -163,6 +163,7 @@ class PopoverMenuFactory } // TODO: iPopupMenuExtension::MENU_USER_ACTIONS + // Legacy code: utils::GetPopupMenuItems($this, iPopupMenuExtension::MENU_USER_ACTIONS, null, $aActions); return $aItems; }