From 7df4f33c2509402c63804ed21a572c154537fe33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20=C5=9Amigielski?= Date: Thu, 15 Dec 2022 14:47:30 +0100 Subject: [PATCH] Remove deprecated function calls --- CRM/Admin/Form/Setting/BankingSettings.php | 44 +++++++++++----------- CRM/Banking/BAO/BankAccount.php | 2 +- CRM/Banking/Config.php | 4 +- CRM/Banking/Form/AccountsTab.php | 32 ++++++++-------- CRM/Banking/Form/Configure.php | 2 +- CRM/Banking/Helpers/Logger.php | 4 +- CRM/Banking/Matcher/Context.php | 2 +- CRM/Banking/Page/Import.php | 12 +++--- CRM/Banking/Page/Review.php | 4 +- CRM/Banking/PluginModel/Matcher.php | 2 +- CRM/Banking/Upgrader.php | 6 +-- banking.php | 6 +-- 12 files changed, 60 insertions(+), 60 deletions(-) diff --git a/CRM/Admin/Form/Setting/BankingSettings.php b/CRM/Admin/Form/Setting/BankingSettings.php index 30eb4f5b..5786a42d 100644 --- a/CRM/Admin/Form/Setting/BankingSettings.php +++ b/CRM/Admin/Form/Setting/BankingSettings.php @@ -140,19 +140,19 @@ function buildQuickForm() { function setDefaultValues() { $defaults = array(); - $defaults['new_ui'] = CRM_Core_BAO_Setting::getItem('CiviBanking', 'new_ui'); - $defaults['menu_position'] = CRM_Core_BAO_Setting::getItem('CiviBanking', 'menu_position'); - $defaults['json_editor_mode'] = CRM_Core_BAO_Setting::getItem('CiviBanking', 'json_editor_mode'); - $defaults['banking_log_level'] = CRM_Core_BAO_Setting::getItem('CiviBanking', 'banking_log_level'); - $defaults['banking_log_file'] = CRM_Core_BAO_Setting::getItem('CiviBanking', 'banking_log_file'); - $defaults['reference_store_disabled'] = CRM_Core_BAO_Setting::getItem('CiviBanking', 'reference_store_disabled'); - $defaults['reference_normalisation'] = CRM_Core_BAO_Setting::getItem('CiviBanking', 'reference_normalisation'); - $defaults['reference_matching_probability'] = CRM_Core_BAO_Setting::getItem('CiviBanking', 'reference_matching_probability'); + $defaults['new_ui'] = Civi::settings()->get('new_ui'); + $defaults['menu_position'] = Civi::settings()->get('menu_position'); + $defaults['json_editor_mode'] = Civi::settings()->get('json_editor_mode'); + $defaults['banking_log_level'] = Civi::settings()->get('banking_log_level'); + $defaults['banking_log_file'] = Civi::settings()->get('banking_log_file'); + $defaults['reference_store_disabled'] = Civi::settings()->get('reference_store_disabled'); + $defaults['reference_normalisation'] = Civi::settings()->get('reference_normalisation'); + $defaults['reference_matching_probability'] = Civi::settings()->get('reference_matching_probability'); if ($defaults['reference_matching_probability'] === null) { $defaults['reference_matching_probability'] = '1.0'; } - $defaults['reference_validation'] = CRM_Core_BAO_Setting::getItem('CiviBanking', 'reference_validation'); - $defaults['lenient_dedupe'] = CRM_Core_BAO_Setting::getItem('CiviBanking', 'lenient_dedupe'); + $defaults['reference_validation'] = Civi::settings()->get('reference_validation'); + $defaults['lenient_dedupe'] = Civi::settings()->get('lenient_dedupe'); return $defaults; } @@ -165,31 +165,31 @@ function postProcess() { $values = $this->exportValues(); // process menu relevant entries - $old_menu_position = (int) CRM_Core_BAO_Setting::getItem('CiviBanking', 'menu_position'); + $old_menu_position = (int) Civi::settings()->get('menu_position'); $new_menu_position = (int) $values['menu_position']; - $old_ui_style = (int) CRM_Core_BAO_Setting::getItem('CiviBanking', 'new_ui'); + $old_ui_style = (int) Civi::settings()->get('new_ui'); $new_ui_style = (int) $values['new_ui']; if ($old_menu_position != $new_menu_position || $old_ui_style != $new_ui_style) { - CRM_Core_BAO_Setting::setItem($new_ui_style, 'CiviBanking', 'new_ui'); - CRM_Core_BAO_Setting::setItem($new_menu_position, 'CiviBanking', 'menu_position'); + Civi::settings()->set('new_ui', $new_ui_style); + Civi::settings()->set('menu_position', $new_menu_position); CRM_Core_BAO_Navigation::resetNavigation(); } // process menu entry - CRM_Core_BAO_Setting::setItem($values['json_editor_mode'], 'CiviBanking', 'json_editor_mode'); + Civi::settings()->set('json_editor_mode', $values['json_editor_mode']); // log levels - CRM_Core_BAO_Setting::setItem($values['banking_log_level'], 'CiviBanking', 'banking_log_level'); - CRM_Core_BAO_Setting::setItem($values['banking_log_file'], 'CiviBanking', 'banking_log_file'); + Civi::settings()->set('banking_log_level', $values['banking_log_level']); + Civi::settings()->set('banking_log_file', $values['banking_log_file']); // process reference normalisation / validation - CRM_Core_BAO_Setting::setItem(!empty($values['reference_store_disabled']),'CiviBanking', 'reference_store_disabled'); - CRM_Core_BAO_Setting::setItem(!empty($values['reference_normalisation']), 'CiviBanking', 'reference_normalisation'); - CRM_Core_BAO_Setting::setItem($values['reference_matching_probability'], 'CiviBanking', 'reference_matching_probability'); - CRM_Core_BAO_Setting::setItem(!empty($values['reference_validation']), 'CiviBanking', 'reference_validation'); - CRM_Core_BAO_Setting::setItem(!empty($values['lenient_dedupe']), 'CiviBanking', 'lenient_dedupe'); + Civi::settings()->set('reference_store_disabled', !empty($values['reference_store_disabled'])); + Civi::settings()->set('reference_normalisation', !empty($values['reference_normalisation'])); + Civi::settings()->set('reference_matching_probability', $values['reference_matching_probability']); + Civi::settings()->set('reference_validation', !empty($values['reference_validation']),); + Civi::settings()->set('lenient_dedupe', !empty($values['lenient_dedupe']), ); // log results $logger = CRM_Banking_Helpers_Logger::getLogger(); diff --git a/CRM/Banking/BAO/BankAccount.php b/CRM/Banking/BAO/BankAccount.php index 141f8f2c..4e123b82 100755 --- a/CRM/Banking/BAO/BankAccount.php +++ b/CRM/Banking/BAO/BankAccount.php @@ -88,7 +88,7 @@ public function setDataParsed($data) { * ordered by the reference types' order in the option group */ public function getReferences() { - $bank_account_reference_matching_probability = CRM_Core_BAO_Setting::getItem('CiviBanking', 'reference_matching_probability'); + $bank_account_reference_matching_probability = Civi::settings()->get('reference_matching_probability'); if ($bank_account_reference_matching_probability === null) { $bank_account_reference_matching_probability = 1.0; } diff --git a/CRM/Banking/Config.php b/CRM/Banking/Config.php index 45a588af..2088513b 100644 --- a/CRM/Banking/Config.php +++ b/CRM/Banking/Config.php @@ -23,11 +23,11 @@ class CRM_Banking_Config { * Should the bank account dedupe be done in a lenient way? */ public static function lenientDedupe() { - $value = CRM_Core_BAO_Setting::getItem('CiviBanking', 'lenient_dedupe'); + $value = Civi::settings()->get('lenient_dedupe'); if (empty($value)) { return FALSE; } else { return TRUE; } } -} \ No newline at end of file +} diff --git a/CRM/Banking/Form/AccountsTab.php b/CRM/Banking/Form/AccountsTab.php index 66694c52..4157893f 100644 --- a/CRM/Banking/Form/AccountsTab.php +++ b/CRM/Banking/Form/AccountsTab.php @@ -70,11 +70,11 @@ function buildQuickForm() { } // load settings - $this->assign('reference_normalisation', (int) CRM_Core_BAO_Setting::getItem('CiviBanking', 'reference_normalisation')); - $this->assign('reference_validation', (int) CRM_Core_BAO_Setting::getItem('CiviBanking', 'reference_validation')); + $this->assign('reference_normalisation', (int) Civi::settings()->get('reference_normalisation')); + $this->assign('reference_validation', (int) Civi::settings()->get('reference_validation')); // ACCOUNT REFRENCE ITEMS - $this->add('hidden', 'contact_id', $contact_id, true); + $this->add('hidden', 'contact_id', $contact_id, []); $this->add('hidden', 'reference_id'); $reference_type = $this->add( @@ -85,7 +85,7 @@ function buildQuickForm() { true // is required ); // set last value - $reference_type->setSelected(CRM_Core_BAO_Setting::getItem('CiviBanking', 'account.default_reference_id')); + $reference_type->setSelected(Civi::settings()->get('account.default_reference_id')); $reference_type = $this->add( 'text', @@ -95,7 +95,7 @@ function buildQuickForm() { true ); - + // BANK ITEMS $this->add('hidden', 'ba_id'); @@ -123,7 +123,7 @@ function buildQuickForm() { false ); // set last value - $country->setSelected(CRM_Core_BAO_Setting::getItem('CiviBanking', 'account.default_country')); + $country->setSelected(Civi::settings()->get('account.default_country')); $this->addButtons(array( @@ -148,8 +148,8 @@ function buildQuickForm() { public function validate() { $error = parent::validate(); $values = $this->exportValues(); - $normalise = CRM_Core_BAO_Setting::getItem('CiviBanking', 'reference_normalisation'); - $validate = CRM_Core_BAO_Setting::getItem('CiviBanking', 'reference_validation'); + $normalise = Civi::settings()->get('reference_normalisation'); + $validate = Civi::settings()->get('reference_validation'); if (!empty($values['reference_type']) && !empty($values['reference'])) { if ($validate || $normalise) { @@ -164,10 +164,10 @@ public function validate() { } elseif ($normalise && $result['normalised'] ) { $values['reference'] = $result['reference']; $this->set('reference', $result['reference']); - } + } } } - + if (0 == count($this->_errors)) { return TRUE; } else { @@ -182,15 +182,15 @@ public function validate() { function postProcess() { $values = $this->exportValues(); $was_created = FALSE; - + // save presets if (!empty($values['reference_type'])) { - CRM_Core_BAO_Setting::setItem($values['reference_type'], 'CiviBanking', 'account.default_reference_id'); + Civi::settings()->set('account.default_reference_id', $values['reference_type']); } if (!empty($values['country'])) { - CRM_Core_BAO_Setting::setItem($values['country'], 'CiviBanking', 'account.default_country'); + Civi::settings()->set('account.default_country', $values['country']); } - + // create bank account $ba_id = $values['ba_id']; if (empty($ba_id)) { @@ -226,7 +226,7 @@ function postProcess() { if (!empty($values['reference_id'])) { $reference_update['id'] = $values['reference_id']; } - + civicrm_api3('BankingAccountReference', 'create', $reference_update); if ($was_created) { @@ -237,7 +237,7 @@ function postProcess() { // return to accounts tab if (!empty($values['contact_id'])) { - CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$values['contact_id']}&selectedChild=bank_accounts")); + CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$values['contact_id']}&selectedChild=bank_accounts")); } parent::postProcess(); } diff --git a/CRM/Banking/Form/Configure.php b/CRM/Banking/Form/Configure.php index d8068db3..f4531d56 100644 --- a/CRM/Banking/Form/Configure.php +++ b/CRM/Banking/Form/Configure.php @@ -42,7 +42,7 @@ public function buildQuickForm() { } // set default editor mode - $json_editor_mode = CRM_Core_BAO_Setting::getItem('CiviBanking', 'json_editor_mode'); + $json_editor_mode = Civi::settings()->get('json_editor_mode'); if (empty($json_editor_mode)) { $json_editor_mode = 'text'; } diff --git a/CRM/Banking/Helpers/Logger.php b/CRM/Banking/Helpers/Logger.php index 7a6cc5d3..93cfd240 100644 --- a/CRM/Banking/Helpers/Logger.php +++ b/CRM/Banking/Helpers/Logger.php @@ -48,7 +48,7 @@ public static function getLogger() { protected function __construct() { // read log level $all_levels = self::getLoglevels(); - $this->log_level = CRM_Core_BAO_Setting::getItem('CiviBanking', 'banking_log_level'); + $this->log_level = Civi::settings()->get('banking_log_level'); if (!isset($all_levels[$this->log_level])) { // invalid log level -> fall back to 'off' $this->log_level = 'off'; @@ -58,7 +58,7 @@ protected function __construct() { $this->timers = array(); // create log file - $log_file = CRM_Core_BAO_Setting::getItem('CiviBanking', 'banking_log_file'); + $log_file = Civi::settings()->get('banking_log_file'); if (!empty($log_file)) { // log to file: if (substr($log_file, 0, 1) != '/') { diff --git a/CRM/Banking/Matcher/Context.php b/CRM/Banking/Matcher/Context.php index f0e432a0..b880035a 100755 --- a/CRM/Banking/Matcher/Context.php +++ b/CRM/Banking/Matcher/Context.php @@ -34,7 +34,7 @@ public function __construct( CRM_Banking_BAO_BankTransaction $btx ) { $this->btx = $btx; $btx->context = $this; - $this->bank_account_reference_matching_probability = CRM_Core_BAO_Setting::getItem('CiviBanking', 'reference_matching_probability'); + $this->bank_account_reference_matching_probability = Civi::settings()->get('reference_matching_probability'); if ($this->bank_account_reference_matching_probability === null) { $this->bank_account_reference_matching_probability = 1.0; } diff --git a/CRM/Banking/Page/Import.php b/CRM/Banking/Page/Import.php index 5948c2ba..bd586367 100755 --- a/CRM/Banking/Page/Import.php +++ b/CRM/Banking/Page/Import.php @@ -40,7 +40,7 @@ function run() { if ($plugin->id == $plugin_id) { $this->assign('plugin_list', array($plugin)); break; - } + } } // RUN the importer @@ -70,7 +70,7 @@ function run() { } else { CRM_Core_Session::setStatus(E::ts('Importer needs a file to proceed.'), E::ts('No input file'), 'alert'); } - + // TODO: RUN the processor if (isset($_REQUEST['process']) && $_REQUEST['process']=="on") { CRM_Core_Session::setStatus(E::ts('Automated running not yet implemented'), E::ts('Not implemented'), 'alert'); @@ -98,17 +98,17 @@ function run() { foreach ($plugin_list as $plugin) { $class = $plugin->getClass(); if ($class::does_import_files()) { - $has_file_source[$plugin->id] = 'true'; + $has_file_source[$plugin->id] = 'true'; } else { - $has_file_source[$plugin->id] = 'false'; + $has_file_source[$plugin->id] = 'false'; } - + } $this->assign('has_file_source', $has_file_source); } // URLs - $new_ui_enabled = CRM_Core_BAO_Setting::getItem('CiviBanking', 'new_ui'); + $new_ui_enabled = Civi::settings()->get('new_ui'); if ($new_ui_enabled) { $this->assign('url_payments', CRM_Utils_System::url('civicrm/banking/statements')); } else { diff --git a/CRM/Banking/Page/Review.php b/CRM/Banking/Page/Review.php index fa121841..b2d4376e 100755 --- a/CRM/Banking/Page/Review.php +++ b/CRM/Banking/Page/Review.php @@ -30,7 +30,7 @@ class CRM_Banking_Page_Review extends CRM_Core_Page { function run() { CRM_Core_Resources::singleton()->addStyleFile(E::LONG_NAME, 'css/banking.css'); - $new_ui_enabled = CRM_Core_BAO_Setting::getItem('CiviBanking', 'new_ui'); + $new_ui_enabled = Civi::settings()->get('new_ui'); // set this variable to request a redirect $url_redirect = NULL; @@ -297,7 +297,7 @@ function run() { // tell the page if popups are available $popups_allowed = (int) version_compare(CRM_Utils_System::version(), '4.6', '>='); if ($popups_allowed) { // take the popup switch into account (thanks @VangelisP) - $popups_allowed = (int) CRM_Core_BAO_Setting::getItem('CiviCRM Preferences', 'ajaxPopupsEnabled'); + $popups_allowed = (int) Civi::settings()->get('ajaxPopupsEnabled'); } $this->assign('popups_allowed', $popups_allowed); diff --git a/CRM/Banking/PluginModel/Matcher.php b/CRM/Banking/PluginModel/Matcher.php index 75976f86..15dda0b5 100755 --- a/CRM/Banking/PluginModel/Matcher.php +++ b/CRM/Banking/PluginModel/Matcher.php @@ -234,7 +234,7 @@ function getPenalty($btx) { */ function storeAccountWithContact($btx, $contact_id) { // check if this has been turned off - if (CRM_Core_BAO_Setting::getItem('CiviBanking', 'reference_store_disabled')) { + if (Civi::settings()->get('reference_store_disabled')) { return; } diff --git a/CRM/Banking/Upgrader.php b/CRM/Banking/Upgrader.php index 20949092..ed0b96fc 100644 --- a/CRM/Banking/Upgrader.php +++ b/CRM/Banking/Upgrader.php @@ -48,7 +48,7 @@ public function upgrade_0610() { * @return TRUE on success */ public function upgrade_0611() { - CRM_Core_BAO_Setting::setItem(false, 'org.project60.banking', 'new_ui'); + Civi::settings()->set(false, 'org.project60.banking', 'new_ui'); // Update order of the option group banking_tx_status. $statusApi = civicrm_api3('OptionValue', 'get', array('option_group_id' => 'civicrm_banking.bank_tx_status', 'options' => array('limit' => 0))); @@ -175,7 +175,7 @@ public function upgrade_0703() { public function upgrade_0704() { // rebuild menu, in particular for the UI CRM_Core_Invoke::rebuildMenuAndCaches(); - CRM_Core_BAO_Setting::setItem($values['reference_matching_probability'], 'CiviBanking', 'reference_matching_probability'); + Civi::settings()->set('reference_matching_probability', $values['reference_matching_probability']); return true; } @@ -186,7 +186,7 @@ public function upgrade_0704() { */ public function upgrade_0800() { // Set the bank account reference probability to 100%. - CRM_Core_BAO_Setting::setItem('1.0', 'CiviBanking', 'reference_matching_probability'); + Civi::settings()->set('reference_matching_probability', '1.0'); return true; } diff --git a/banking.php b/banking.php index 16851f18..89060660 100755 --- a/banking.php +++ b/banking.php @@ -50,7 +50,7 @@ function banking_civicrm_install() { banking_civicrm_install_options(_banking_options()); // Set the bank account reference probability to 100%. - CRM_Core_BAO_Setting::setItem('1.0', 'CiviBanking', 'reference_matching_probability'); + Civi::settings()->set('reference_matching_probability', '1.0'); return _banking_civix_civicrm_install(); } @@ -216,7 +216,7 @@ function banking_civicrm_entityTypes(&$entityTypes) { */ function banking_civicrm_navigationMenu(&$menu) { // check if we want the menu to be built at all - $menu_position = (int) CRM_Core_BAO_Setting::getItem('CiviBanking', 'menu_position'); + $menu_position = (int) Civi::settings()->get('menu_position'); switch ($menu_position) { case 2: // menu is off, see CRM_Admin_Form_Setting_BankingSettings @@ -239,7 +239,7 @@ function banking_civicrm_navigationMenu(&$menu) { // Determine the url for the statements/payments (new ui or old ui). $statementUrl = 'civicrm/banking/statements'; - if (!CRM_Core_BAO_Setting::getItem('CiviBanking', 'new_ui')) { + if (!Civi::settings()->get('new_ui')) { $statementUrl = 'civicrm/banking/payments'; }