From 89d188dac85fb02711d44ead92f888db0a99a3cc Mon Sep 17 00:00:00 2001 From: prasad <prasad@vtiger.com> Date: Sun, 2 Jul 2023 00:35:51 +0530 Subject: [PATCH] Added compatability changes in code to use composer dependency --- include/database/PearDatabase.php | 6 +++-- include/utils/ExportRecords.php | 43 ------------------------------- include/utils/VtlibUtils.php | 2 -- includes/runtime/Viewer.php | 9 ++++--- modules/Rss/actions/Save.php | 1 - modules/Rss/models/Record.php | 18 ++++++++----- 6 files changed, 21 insertions(+), 58 deletions(-) delete mode 100644 include/utils/ExportRecords.php diff --git a/include/database/PearDatabase.php b/include/database/PearDatabase.php index 10c4d5fab..755a14386 100644 --- a/include/database/PearDatabase.php +++ b/include/database/PearDatabase.php @@ -14,8 +14,7 @@ ********************************************************************************/ require_once 'include/logging.php'; -include_once 'libraries/adodb/adodb.inc.php'; -require_once 'libraries/adodb/adodb-xmlschema.inc.php'; +require_once 'libraries/adodb_vtigerfix/adodb.inc.php'; $log = Logger::getLogger('VT'); $logsqltm = Logger::getLogger('SQLTIME'); @@ -935,7 +934,10 @@ class PearDatabase{ $this->checkConnection(); $db = $this->database; + + require_once 'libraries/adodb_vtigerfix/adodb-xmlschema.inc.php'; $schema = new adoSchema( $db ); + //Debug Adodb XML Schema $schema->XMLS_DEBUG = TRUE; //Debug Adodb diff --git a/include/utils/ExportRecords.php b/include/utils/ExportRecords.php deleted file mode 100644 index bf785dcf2..000000000 --- a/include/utils/ExportRecords.php +++ /dev/null @@ -1,43 +0,0 @@ -<?php -/********************************************************************************* - -** The contents of this file are subject to the vtiger CRM Public License Version 1.0 - * ("License"); You may not use this file except in compliance with the License - * The Original Code is: vtiger CRM Open Source - * The Initial Developer of the Original Code is vtiger. - * Portions created by vtiger are Copyright (C) vtiger. - * All Rights Reserved. - ********************************************************************************/ -require_once('include/database/PearDatabase.php'); -require_once('Smarty_setup.php'); -require_once('include/utils/utils.php'); -global $app_strings,$mod_strings, $list_max_entries_per_page, $currentModule, $theme, $current_language, $current_user; - -$smarty = new vtigerCRM_Smarty(); -$category = getParentTab(); - -$theme_path="themes/".$theme."/"; -$image_path=$theme_path."images/"; -require_once('modules/Vtiger/layout_utils.php'); - -$smarty->assign("SESSION_WHERE",$_SESSION['export_where']); - -$smarty->assign('APP',$app_strings); -$smarty->assign('MOD',$mod_strings); -$smarty->assign("THEME", $theme_path); -$smarty->assign("IMAGE_PATH", $image_path); -$smarty->assign("CATEGORY",$category); -$smarty->assign("MODULE",$currentModule); -$smarty->assign("MODULELABEL",getTranslatedString($currentModule)); -$smarty->assign("IDSTRING",vtlib_purify($_REQUEST['idstring'])); -$smarty->assign("EXCLUDED_RECORDS",vtlib_purify($_REQUEST['excludedRecords'])); -$smarty->assign("PERPAGE",$list_max_entries_per_page); - -if(!is_admin($current_user) && (isPermitted($currentModule, 'Export') != 'yes')) { - $smarty->display(vtlib_getModuleTemplate('Vtiger','OperationNotPermitted.tpl')); -} else { - $smarty->display('ExportRecords.tpl'); -} - - -?> diff --git a/include/utils/VtlibUtils.php b/include/utils/VtlibUtils.php index cd1b44b1f..df65533d6 100644 --- a/include/utils/VtlibUtils.php +++ b/include/utils/VtlibUtils.php @@ -696,8 +696,6 @@ function vtlib_purify($input, $ignore = false) { 'data' => true ); - include_once __DIR__ . '/../../libraries/htmlpurifier410/library/HTMLPurifier.auto.php'; - $config = HTMLPurifier_Config::createDefault(); $config->set('Core.Encoding', $use_charset); $config->set('Cache.SerializerPath', "$use_root_directory/test/vtlib"); diff --git a/includes/runtime/Viewer.php b/includes/runtime/Viewer.php index 9e0fb9d1d..987a4de2d 100644 --- a/includes/runtime/Viewer.php +++ b/includes/runtime/Viewer.php @@ -8,9 +8,7 @@ * All Rights Reserved. ************************************************************************************/ -vimport ('~/libraries/Smarty/libs/SmartyBC.class.php'); - -class Vtiger_Viewer extends SmartyBC { +class Vtiger_Viewer extends Smarty { const DEFAULTLAYOUT = 'v7'; const DEFAULTTHEME = 'softed'; @@ -79,6 +77,11 @@ class Vtiger_Viewer extends SmartyBC { $this->log("URI: $debugViewerURI, TYPE: " . $_SERVER['REQUEST_METHOD']); } } + + // Backward compatible to SmartyBC + function get_template_vars($name = NULL) { + return $this->getTemplateVars($name); + } function safeHtmlFilter($content, $smarty) { //return htmlspecialchars($content,ENT_QUOTES,UTF-8); diff --git a/modules/Rss/actions/Save.php b/modules/Rss/actions/Save.php index a5c4defe6..3edede3a6 100644 --- a/modules/Rss/actions/Save.php +++ b/modules/Rss/actions/Save.php @@ -7,7 +7,6 @@ * Portions created by vtiger are Copyright (C) vtiger. * All Rights Reserved. *************************************************************************************/ -require_once('libraries/magpierss/rss_fetch.inc'); class Rss_Save_Action extends Vtiger_Save_Action { diff --git a/modules/Rss/models/Record.php b/modules/Rss/models/Record.php index 92a116387..753818bb9 100644 --- a/modules/Rss/models/Record.php +++ b/modules/Rss/models/Record.php @@ -7,13 +7,17 @@ * Portions created by vtiger are Copyright (C) vtiger. * All Rights Reserved. *************************************************************************************/ -require_once('libraries/magpierss/rss_fetch.inc'); -require_once('include/simplehtmldom/simple_html_dom.php'); -// for rss caching -define('MAGPIE_CACHE_DIR', '/tmp/magpie_cache'); -define('MAGPIE_CACHE_ON', 1); -define('MAGPIE_CACHE_AGE', 1800); +function fetch_feed_and_transform($url) { + $reader = \Feed::load($url); + $return = []; + $return["channel"] = ["title" => (string)$reader->title, "link" => (string)$reader->link]; + $return["items"] = []; + foreach ($reader->item as $item) { + $return["items"][] = $reader->toArray($item); + } + return (object) $return; +} class Rss_Record_Model extends Vtiger_Record_Model { @@ -212,4 +216,4 @@ class Rss_Record_Model extends Vtiger_Record_Model { $html = file_get_html($url); return $html->innertext; } -} \ No newline at end of file +} -- GitLab