From e130faf0121e517b0c24c40d895b309bb5f756af Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Mon, 13 Apr 2020 10:36:24 +0200 Subject: [PATCH 1/3] Show active box state of a RSS feed --- htdocs/admin/external_rss.php | 40 ++++++++++++++++++++++++++++++++--- htdocs/langs/en_US/admin.lang | 2 ++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php index f2412175880..ec77cb32184 100644 --- a/htdocs/admin/external_rss.php +++ b/htdocs/admin/external_rss.php @@ -6,6 +6,7 @@ * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2020 Tobias Sekan * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,6 +31,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/rssparser.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; // Load translation files required by the page $langs->load("admin"); @@ -222,10 +224,14 @@ print '
'; print ''; print ''; print ''; -print '


'; +print ''; print ''; +print '
'.$langs->trans('RssNote'); +print '
'.$langs->trans('JumpToBoxes').''; + +print '

'; $sql = "SELECT rowid, file, note FROM ".MAIN_DB_PREFIX."boxes_def"; $sql .= " WHERE file = 'box_external_rss.php'"; @@ -235,8 +241,9 @@ dol_syslog("select rss boxes", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; + $boxlist = InfoBox::listBoxes($db, 'activated', -1, null); + $num = $db->num_rows($resql); + $i = 0; while ($i < $num) { @@ -312,6 +319,13 @@ if ($resql) print ""; } + // Active + $active = _isInBoxList($idrss, $boxlist) ? 'yes' : 'no'; + print ''; + print ''.$langs->trans('Active').''; + print ''.$langs->trans($active).''; + print ""; + print ''; print ""; @@ -327,3 +341,23 @@ else // End of page llxFooter(); $db->close(); + +/** + * Check if the given RSS feed if inside the list of boxes/widgets + * + * @param int $idrss The id of the RSS feed + * @param array $boxlist A list with boxes/widgets + * @return bool true if the rss feed is inside the box/widget list, otherwise false + */ +function _isInBoxList($idrss, array $boxlist) +{ + foreach($boxlist as $box) + { + if($box->boxcode === "lastrssinfos" && strpos($box->note, $idrss) !== FALSE) + { + return true; + } + } + + return false; +} diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 62a7c82437d..8776c673a8b 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1990,3 +1990,5 @@ EmailTemplate=Template for email EMailsWillHaveMessageID=Emails will have a tag 'References' matching this syntax PDF_USE_ALSO_LANGUAGE_CODE=If you want to have some texts in your PDF duplicated in 2 different languages in the same generated PDF, you must set here this second language so generated PDF will contains 2 different languages in same page, the one chosen when generating PDF and this one (only few PDF templates support this). Keep empty for 1 language per PDF. FafaIconSocialNetworksDesc=Enter here the code of a FontAwesome icon. If you don't know what is FontAwesome, you can use the generic value fa-address-book. +RssNote=Note: Each RSS feed must be separate activate as a widget to show it for a user. +JumpToBoxes=Jump to Setup -> Widgets From cfbb4e9ef6ba30a60172b78352a06c281efe466e Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 13 Apr 2020 08:55:33 +0000 Subject: [PATCH 2/3] Fixing style errors. --- htdocs/admin/external_rss.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php index ec77cb32184..7f8007ca22d 100644 --- a/htdocs/admin/external_rss.php +++ b/htdocs/admin/external_rss.php @@ -353,7 +353,7 @@ function _isInBoxList($idrss, array $boxlist) { foreach($boxlist as $box) { - if($box->boxcode === "lastrssinfos" && strpos($box->note, $idrss) !== FALSE) + if($box->boxcode === "lastrssinfos" && strpos($box->note, $idrss) !== false) { return true; } From 36669739f39f5ad5f12bb086ad903b2e19aa4a0f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Apr 2020 13:29:23 +0200 Subject: [PATCH 3/3] Update external_rss.php --- htdocs/admin/external_rss.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php index 7f8007ca22d..fdfbdf1f1dd 100644 --- a/htdocs/admin/external_rss.php +++ b/htdocs/admin/external_rss.php @@ -322,8 +322,8 @@ if ($resql) // Active $active = _isInBoxList($idrss, $boxlist) ? 'yes' : 'no'; print ''; - print ''.$langs->trans('Active').''; - print ''.$langs->trans($active).''; + print ''.$langs->trans('WidgetEnabled').''; + print ''.yesno($active).''; print ""; print '';